v2.2.0
Version 2.2.0 (09-28-2015):
Again, it's been way too long since the last version; we're going to be releasing more often in the future!
In this release, we have a nicer homepage, 5 new rules, 4 more autofixable rules, many new rule options/bug fixes, and a jscs-jsdoc@1.2.0 update.
We also added support for using YAML in config files, checking JS style in HTML files, and are trying out some non-stylistic rules (like disallowUnusedParams
)!
Be on the look out for https://github.com/cst/cst (just finished ES6 support this weekend) if you haven't already.
Autofixing: Support for 4 more rules!
Thanks to @markelog, we also have autofix support for the following rules:
We will also be labeling which rules don't support autofixing (only a few).
Configuration: YAML support, and linting JS in HTML files
We weren't even thinking about different config formats, but @ronkorving stepped in and added support for using YAML as a config format!
So now you can use a .jscsrc / jscs.json
(JSON) file or a .jscs.yaml
(YAML) file.
@lahmatiy has landed support for linting javascript in HTML files with the extract option! Thanks so much for sticking with us for that PR.
Example usage:
jscs ./hello.html --extract *.html
New Rules
disallowMultiLineTernary
(Brian Dixon)
// Valid for "disallowMultiLineTernary": true
var foo = (a === b) ? 1 : 2;
requireMultiLineTernary
(Brian Dixon)
// Valid for "requireMultiLineTernary": true
var foo = (a === b)
? 1
: 2;
disallowTabs
(Mike Ottum)
It disallows tab characters everywhere!
disallowUnusedParams
(Oleg Gaidarenko)
Another cool rule @markelog added is actually a non-stylistic rule with autofixing support! It checks to make sure you use the parameters in function declarations and function expressions!
// Invalid since test is unused
function x(test) {
}
var x = function(test) {
}
validateCommentPosition
(Brian Dixon)
Comments that start with keywords like eslint, jscs, jshint
are ignored by default.
/* Valid for "validateCommentPosition": { position: `above`, allExcept: [`pragma`] } */
// This is a valid comment
1 + 1; // pragma (this comment is fine)
/* Valid for "validateCommentPosition": { position: `beside` } */
1 + 1; // This is a valid comment
Just as a reminder, you can disable certain AST node types with the disallowNodeTypes
rule which takes in an array of node types.
For example: if you want to disable arrow functions for some reason, you could do
"disallowNodeTypes": ['ArrowFunctionExpression']
.
Presets: Idiomatic.js and other updates
We finally added support for Idiomatic.js! There are a few more rules we still need to add, so leave a comment in the issue or create a new one.
Google
: removecapitalizedNativeCase
option in the JSDoccheckTypes
rule (Sam Thorogood)Idiomatic
: add initial preset (Henry Zhu)jQuery
: adddisallowSpacesInCallExpression
rule to (Oleg Gaidarenko)jQuery
: useignoreIfInTheMiddle
value forrequireCapitalizedComments
rule (Oleg Gaidarenko)jQuery
: addvalidateIndentation
rule (Oleg Gaidarenko)Wikimedia
: enablees3
(James Forrester)
Rule Options/Changes
requireSpacesInsideParentheses
:ignoreParenthesizedExpression
option (Oleg Gaidarenko)disallowSpaceAfterObjectKeys
: addmethod
exception option (Alexander Zeilmann)disallowSpaceBeforeSemicolon
: addallExcept
option (Oleg Gaidarenko)requireCapitalizedComments
: addignoreIfInTheMiddle
option (Oleg Gaidarenko)disallowSpacesInsideParentheses
: add quotes option (Oleg Gaidarenko)requireSpacesInsideParentheses
: add quotes option (Oleg Gaidarenko)requireCapitalizedComments
: add default exceptions (alawatthe)requireArrowFunctions
: create an error on function bind (Henry Zhu)- Misc: Bucket all rules into groups, test case to ensure new rules have a group (indexzero)
Bug Fixes
We fixed a bug with exit codes not matching the wiki (Oleg Gaidarenko).
disallowParenthesesAroundArrowParam
: fix check for params (Henry Zhu)spacesInsideBrackets
: account for block comments (Oleg Gaidarenko)disallowSemicolons
: ignore needed exceptions (Oleg Gaidarenko)spacesInFunctionExpression
: account for async functions (MikeMac)disallowSpaceBeforeSemicolon
: do not trigger error if it's first token (Oleg Gaidarenko)requireCapitalizedComments
: consider edge cases (Oleg Gaidarenko)requireSemicolons
: handle phantom cases (Oleg Gaidarenko)spaceAfterObjectKeys
: fix for computed properties with more than one token (Henry Zhu)- Exclude
.git
folder by default (Vladimir Starkov)
JSDoc updates
- New Rule:
checkParamExistence
- New Rule:
requireReturnDescription
enforceExistence
addparamless-procedures
exception
What's JSCS?
The homepage now showcases what JSCS actually does. We were missing a 🐱 picture as well so ...
If you have any feedback on the site, leave a comment at our website repo.
༼ つ ◕_◕ ༽つ GIVE CST!
We've also been busy working on https://github.com/cst/cst.
CST stands for Concrete Syntax Tree
, as opposed to AST which stands for Abstract Syntax Tree
. CST uses a regular AST but adds support for information that you normally don't care about but is vital for a style checker, e.g. spaces, newlines, comments, semicolons, etc. Using a CST will allow us to support more complex autofixing such as adding curly braces while retaining other formatting or much larger transformations.
We just finished supporting all of ES6 this past weekend. ES6+ and JSX support is also in progress! We'll be integrating CST into JSCS in the 3.0 branch, so look out for that soon (CST uses babel as its AST parser).
If you're interested, there was a lot of discussion on CSTs at the ESTree repo.
Hopefully we can get more community help for JSCS! (check out CONTRIBUTING.md if you're interested)
We have a beginner-friendly
tag for people to get started on issues.
Small personal sidenote
Thanks to everyone who has been submitting issues/PRs!
It's been almost a year since I (hzoo) really started contributing to open source. It's still crazy to me that my first pull request was just adding the table of contents. I was so excited to contribute that day!
Little did I know I would slowly do more and more - typo fixes, docs changes, bugfixes, rules, and then eventually become part of the team! I've become a better communicator and become more confident to give and take constructive feedback. I'm currently still figuring out how to review PRs, label issues, do changelogs (like right now), release, etc.
So much has happened after starting that one simple contribution! Even though I know a lot more about ASTs, javascript/node, and programming style, it all adds up to much more than that technical knowledge.
Contributing here helped me make PRs to a lot of other projects (in my case babel, eslint, and others). I understand more that it doesn't take a special person to start helping out. I really hope to encourage others to join our awesome open source community at large!
Other Awesome Changes!
- CLI: correct
describe
description (Roman Dvornov) - ClI: move
handleMaxErrors
helper to the more appropriate place (Oleg Gaidarenko) - CLI: set
maxErrors
toInfinity
for autoconfigure (Henry Zhu) - disallowSemicolons: simplify
disallowSemicolons
rule (Oleg Gaidarenko) - Docs: another portion of changelog fixes (Oleg Gaidarenko)
- Docs: Correct documentation for
requireCapitalizedComments
(Alexander Zeilmann) - Docs:
disallowParenthesesAroundArrowParam
(Samuel Lindblom) - Docs: fix markdown for
disallowMultipleSpaces
(Marián Rusnák) - Docs: fix markdown in
requireBlocksOnNewline
(Marián Rusnák) - Docs: fix markdown in
requireCapitalizedComments
(Marián Rusnák) - Docs: fixup broken links (Henry Zhu)
- Docs: improve documentation for various rules (oredi)
- Docs: improve documentation for various rules (oredi)
- Docs: remove unnecessary paragraph, use js syntax highlighting (Dennis Wissel)
- Docs: small changelog corrections (Oleg Gaidarenko)
- Docs: small correction for the
disallowEmptyBlocks
rule (Oleg Gaidarenko) - js-file: add
getScope
method (Oleg Gaidarenko) - js-file: add
removeToken
method (Oleg Gaidarenko) - js-file: all return values should be consistent (Oleg Gaidarenko)
- js-file: check argument of the
file#getNodeRange
(Oleg Gaidarenko) - js-file: do not interpret html as grit instructions (Oleg Gaidarenko)
- js-file: make grit regexp case-insensitive (Oleg Gaidarenko)
- Misc: add
only
property toreportAndFix
assert helper (Oleg Gaidarenko) - Misc: make jslint happy (Oleg Gaidarenko)
- Misc: make lint happy (Oleg Gaidarenko)
- Misc: use node "4" instead of node "4.0" in travis (Henry Zhu)
- Misc: correct code style violations (Oleg Gaidarenko)
- Misc: add node 4.0 to travis (Henry Zhu)
- Misc: autofix tests for rules that are not supported by default presets (Oleg Gaidarenko)
- Misc: change default mocha reporter (Oleg Gaidarenko)
- Misc: disable duplicative jshint check for semicolons (Oleg Gaidarenko)
- Misc: do not show console.error at the test run (Oleg Gaidarenko)
- Misc: increase coverage and use console.error for maxError output (Oleg Gaidarenko)
- Misc: increase rules coverage (Oleg Gaidarenko)
- Misc: use full lodash package (Oleg Gaidarenko)
- Misc: add
requireSemicolons
rule to our jscsrc (Oleg Gaidarenko) requireCapitalizedComments
: remove merge artefacts (Oleg Gaidarenko)*Semicolons
: increase coverage (Oleg Gaidarenko)- String-checker: pass
file
instance to_fix
method (Oleg Gaidarenko) - Strip
BOM
from config files (Jonathan Wilsson) - Support
null
and-1
values formaxErrors
option (Daniel Anechitoaie) - Tests: improve
reportAndFix
assertion helper (Oleg Gaidarenko) - Utils: add
isPragma
method (Brian Dixon)