node-jscs
JSCS — JavaScript Code Style.
jscs
is a code style checker. jscs
can check cases, which are not implemeted in jshint,
but it does not duplicate jshint
functionality, so you should use jscs
and jshint
together.
Friendly packages
Installation
jscs
can be installed using npm
:
npm install jscs
To run jscs
, you can use the following command from the project root:
./node_modules/.bin/jscs path[ path[...]]
Configuration
jscs
is configured using .jscs.json
file, located in the project root.
Example configuration:
{
"requireCurlyBraces": ["if", "else", "for", "while", "do"],
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return"],
"disallowSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch"],
,
"requireSpacesInFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },
,
"disallowSpacesInFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },
"disallowMultipleVarDecl": true,
"requireMultipleVarDecl": true,
"disallowSpacesInsideObjectBrackets": true,
"disallowSpacesInsideArrayBrackets": true,
"requireSpacesInsideObjectBrackets": "all",
"requireSpacesInsideArrayBrackets": "all",
"disallowQuotedKeysInObjects": true,
"disallowSpaceAfterObjectKeys": true,
"requireSpaceAfterObjectKeys": true,
"requireAlignedObjectValues": "all",
"disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"requireRightStickedOperators": ["!"],
"disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"requireLeftStickedOperators": [","],
"disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"],
"disallowKeywords": ["with"],
"disallowMultipleLineBreaks": true,
"disallowKeywordsOnNewLine": ["else"],
"requireKeywordsOnNewLine": ["else"],
"requireLineFeedAtFileEnd": true,
"validateJSDoc": {
"checkParamNames": true,
"checkRedundantParams": true,
"requireParamTypes": true
},
"excludeFiles": ["node_modules/**"]
}