6

使用 .jsrc 文件,我的服务器/前端文件出现以下错误。它在我的文件顶部引发错误。我怎么能压制这个?

Unsupported rule: fix at js/server.js :
 1 |'use strict';

Unsupported rule: fix at js/example.js :
 1 |(function() {

这是我的.jscsrc文件

  // http://jscs.info/rules.html
  {
    "requireOperatorBeforeLineBreak": true,
    "requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
    "maximumLineLength": {
      "value": 100,
      "allowComments": true,
      "allowRegex": true
    },
    "validateIndentation": 2,
    "validateQuoteMarks": { "mark": "'", "escape": true },

    "disallowMultipleLineStrings": true,
    "disallowMixedSpacesAndTabs": true,
    "disallowTrailingWhitespace": true,
    "disallowSpaceAfterPrefixUnaryOperators": true,
    "disallowKeywordsOnNewLine": ["else"],

    "requireSpaceAfterKeywords": [
      "if",
      "else",
      "for",
      "while",
      "do",
      "switch",
      "return",
      "try",
      "catch"
    ],
    "requireSpaceBeforeBinaryOperators": [
        "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
        "&=", "|=", "^=", "+=",

        "+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
        "|", "^", "&&", "||", "===", "==", ">=",
        "<=", "<", ">", "!=", "!=="
    ],
    "requireSpaceAfterBinaryOperators": true,
    "requireSpacesInConditionalExpression": true,
    "requireSpaceBeforeBlockStatements": true,
    "requireSpacesInForStatement": true,
    "requireLineFeedAtFileEnd": true,
    "requireSpacesInFunctionExpression": {
        "beforeOpeningCurlyBrace": true
    },
    "disallowSpacesInAnonymousFunctionExpression": {
        "beforeOpeningRoundBrace": true
    },
    "disallowSpacesInsideArrayBrackets": "all",
    "disallowSpacesInsideParentheses": true,
    "disallowMultipleLineBreaks": true,
    "disallowNewlineBeforeBlockStatements": true
  }
4

2 回答 2

8

在 .jscsrc 中添加以下检查将删除您的错误:

"jsDoc": {
    "checkParamNames": true,
    "requireParamTypes": true
}

“validateJSDoc”被贬低;请参阅以下网址访问

访问以获取更多信息http://jscs.info/rule/jsDoc.html

拉取请求https://github.com/roots/sage/pull/1522

提交 SHA https://github.com/chrisk2020/sage/commit/bcefb5908fdb457d2126833198cd760378ffe949

于 2015-09-16T08:49:53.573 回答
0

我的所有文件上都显示了相同的错误消息。我的 .jscsrc 文件中有一条“fix: true”规则;不记得我从哪里得到的。它应该自动修复间距错误等问题。也许这在 JSCS 的早期版本中有效,但现在不起作用。我正在使用 grunt,我必须修改 grunt 任务以获得所需的结果。我以前在哪里

grunt.config.set('jscs', {
  js: {
    src: [ /* path to my files */ ]
  }
});

我在之后添加了以下内容src

options: {
  config: ".jscsrc",
  fix: true
}
于 2015-11-17T20:32:03.890 回答