Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
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.
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[...]]
jscs
is configured using .jscs.json
file, located in the project root.
Example configuration:
{
/*
Option: require_curly_braces
Requires curly braces after statements.
Valid example:
if (x) {
x++;
}
Invalid example:
if (x) x++;
*/
"require_curly_braces": ["if", "else", "for", "while", "do"],
/*
Option: require_space_after_keywords
Requires space after keyword.
Valid example:
return true;
Invalid example:
if(x) {
x++;
}
*/
"require_space_after_keywords": ["if", "else", "for", "while", "do", "switch", "return"],
/*
Option: disallow_space_after_keywords
Disallows space after keyword.
Valid example:
if(x > y) {
y++;
}
*/
"disallow_space_after_keywords": ["if", "else", "for", "while", "do", "switch"],
/*
Option: disallow_multiple_var_decl
Disallows multiple var declaration.
Valid example:
var x = 1;
var y = 2;
Invalid example:
var x = 1,
y = 2;
*/
"disallow_multiple_var_decl": true,
/*
Option: require_multiple_var_decl
Requires multiple var declaration.
Valid example:
var x = 1,
y = 2;
Invalid example:
var x = 1;
var y = 2;
*/
"require_multiple_var_decl": true,
/*
Option: disallow_left_sticked_operators
Disallows sticking operators to the left.
Valid example:
x = y ? 1 : 2;
Invalid example:
x = y? 1 : 2;
*/
"disallow_left_sticked_operators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
/*
Option: require_right_sticked_operators
Requires sticking operators to the left.
Valid example:
x = !y;
Invalid example:
x = ! y;
*/
"require_right_sticked_operators": ["!"],
/*
Option: disallow_right_sticked_operators
Disallows sticking operators to the right.
Valid example:
x = y + 1;
Invalid example:
x = y +1;
*/
"disallow_right_sticked_operators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
/*
Option: disallow_right_sticked_operators
Requires sticking operators to the right.
Valid example:
x = [1, 2];
Invalid example:
x = [1,2];
*/
"require_left_sticked_operators": [","],
/*
Option: disallow_implicit_type_conversion
Disallows implicit type conversion.
Valid example:
x = Boolean(y);
x = Number(y);
x = String(y);
x = s.indexOf('.') !== -1;
Invalid example:
x = !!y;
x = +y;
x = '' + y;
x = ~s.indexOf('.');
*/
"disallow_implicit_type_conversion": ["numeric", "boolean", "binary", "string"],
/*
Option: disallow_keywords
Disallows usage of specified keywords.
Invalid example:
with (x) {
prop++;
}
*/
"disallow_keywords": ["with"],
/*
Option: disallow_muliple_line_breaks
Disallows multiple blank lines in a row.
Invalid example:
var x = 1;
x++;
*/
"disallow_muliple_line_breaks": true,
/*
Option: disallow_keywords_on_new_line
Disallows placing keywords on a new line.
Valid example:
if (x < 0) {
x++;
} else {
x--;
}
Invalid example:
if (x < 0) {
x++;
}
else {
x--;
}
*/
"disallow_keywords_on_new_line": ["else"],
/*
Option: require_keywords_on_new_line
Requires placing keywords on a new line.
Valid example:
if (x < 0) {
x++;
}
else {
x--;
}
Invalid example:
if (x < 0) {
x++;
} else {
x--;
}
*/
"require_keywords_on_new_line": ["else"],
/*
Option: require_line_feed_at_file_end
Requires placing line feed at file end.
*/
"require_line_feed_at_file_end": true,
/*
Option: validate_jsdoc
Enables jsdoc validation.
Option: validate_jsdoc.check_param_names
Ensures param names in jsdoc and in function declaration are equal.
Option: validate_jsdoc.require_param_types
Ensures params in jsdoc contains type.
Option: validate_jsdoc.check_redundant_params
Reports redundant params in jsdoc.
*/
"validate_jsdoc": {
"check_param_names": true,
"check_redundant_params": true,
"require_param_types": true
},
/*
Option: exclude_files
Disables style checking for specified paths.
*/
"exclude_files": ["node_modules/**"]
}
Version 0.0.4:
disallowYodaConditions
.requireMultipleVarDecl
.FAQs
JavaScript Code Style
We found that jscs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.