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.
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:
{
"require_curly_braces": ["if", "else", "for", "while", "do"],
"require_space_after_keywords": ["if", "else", "for", "while", "do", "switch", "return"],
"disallow_space_after_keywords": ["if", "else", "for", "while", "do", "switch"],
"disallow_multiple_var_decl": true,
"require_multiple_var_decl": true,
"disallow_spaces_inside_object_brackets": true,
"disallow_spaces_inside_array_brackets": true,
"require_spaces_inside_object_brackets": "all",
"disallow_quoted_keys_in_objects": true,
"disallow_space_after_object_keys": true,
"disallow_left_sticked_operators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"require_right_sticked_operators": ["!"],
"disallow_right_sticked_operators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"require_left_sticked_operators": [","],
"disallow_implicit_type_conversion": ["numeric", "boolean", "binary", "string"],
"disallow_keywords": ["with"],
"disallow_muliple_line_breaks": true,
"disallow_keywords_on_new_line": ["else"],
"require_keywords_on_new_line": ["else"],
"require_line_feed_at_file_end": true,
"validate_jsdoc": {
"check_param_names": true,
"check_redundant_params": true,
"require_param_types": true
},
"exclude_files": ["node_modules/**"]
}