你需要有一个.jscsrc
文件存在于您项目的根目录中。在那里你可以提供JSCS 的选项 http://jscs.info/overview#options也代码风格规则 http://jscs.info/rules.html应该遵循这一点。
下面是.jscsrc
that's used by node-jscs项目本身 https://github.com/jscs-dev/node-jscs/blob/master/.jscsrc。您可以使用它作为您自己的配置的基础。
{
"preset": "google",
"fileExtensions": [".js", "jscs"],
"requireSemicolons": true,
"requireParenthesesAroundIIFE": true,
"maximumLineLength": 120,
"validateLineBreaks": "LF",
"validateIndentation": 4,
"disallowTrailingComma": true,
"disallowUnusedParams": true,
"disallowSpacesInsideObjectBrackets": null,
"disallowImplicitTypeConversion": ["string"],
"safeContextKeyword": "_this",
"jsDoc": {
"checkAnnotations": "closurecompiler",
"checkParamNames": true,
"requireParamTypes": true,
"checkRedundantParams": true,
"checkReturnTypes": true,
"checkRedundantReturns": true,
"requireReturnTypes": true,
"checkTypes": "capitalizedNativeCase",
"checkRedundantAccess": true,
"requireNewlineAfterDescription": true
},
"excludeFiles": [
"test/data/**",
"patterns/*"
]
}
注意jscs
实际上不会检查任何东西,除非你有"preset"
在你的.jscsrc
或已明确指定rules http://jscs.info/rules.html应该遵循这一点。