JSCS v2.0.0 Release Notes

  • Overview

    πŸš€ Gosh! We haven’t released a new version in more than two months! What have we done all this time? Well, we were working hard on the next big step - 2.0!

    And we’re finally ready to show it to you. We’ve improved JSCS all over the place!

    esnext

    πŸ“œ It was a big pain to check ES6/JSX code with JSCS, since you had to install special extensions or different parsers. Well, no more of that! Thanks to all the hard work of the @hzoo, now you can just write "esnext": true in your config or execute JSCS from the CLI with the --esnext flag. πŸ“œ Now all that new fancy code will be examined without any hassle, as decorators, function bind (::) operator, and all valid babel code can be checked by JSCS.

    πŸ‘€ We also added seven ES6-only rules; see below for more information.

    Autofixing

    πŸ‘ We really want to support autofixing for as many rules as possible. But as it turns out, we are at forefront of this problem; it’s really hard to change the code without affecting unrelated instructions.

    What we need is a Concrete Syntax Tree, instead of the AST + tokens structures that we use now. Unfortunately, there is no CST standard for JavaScript at the moment – this is why we decided to step up and come up with our vision of a CST - https://github.com/mdevils/cst. Currently, we are working with the estree team on this proposal – hoping the development of this crucial part of JavaScript parsing will move faster.

    β†ͺ Meanwhile, using some workarounds and hacks, we managed to support autofixing for 4 more rules:

    πŸ†• New rules

    There are 31 new rules, including 16 rules for JSDoc validation, and 7 ES6-only rules:

    πŸ†• New ES6-only rules

    πŸ‘€ There are also a lot of new rule values (see the "Changelog" section) which makes a lot of rules more flexible.

    We also added new rules and values to some presets. If you feel that we’ve missed something, don't be quiet! Send us a PR and we will surely add the needed rules to your favorite preset.

    πŸ”Œ Simplified inclusion of plugins, presets, and custom rules

    Since every possible JSCS extension can now be loaded without defining its full path, it is enough to just specify the needed dependency to your project so it can be found by JSCS.

    {
      "plugins": ["./your-local-package"], // Same with `additionalRules` and `preset` options
      "plugins": ["jscs-your-npm-package"],
      "plugins": ["your-npm-package"], // can omit β€œjscs-” prefix if you want
    }
    

    Other

    • πŸ‘Œ Support for disabling rules on a single line -

      if (x) y(); // jscs:ignore requireCurlyBraces
      if (z) a(); // will show the error with `requireCurlyBraces`
      
    • Two new reporters - summary (could be very helpful to acquire full overview of all possible errors in your project) and unix. You could enable them by providing --reporter=<reporter name> flag.

    • 0️⃣ node_modules path is included by default to excludeFiles

    • πŸ”Œ For every possible error, like missing or corrupted config, JSCS now provides different exit-codes. We believe it might be useful for piping, editors plugins, etc.

    • JSCS (like any good unix program) now obeys the rule of silence.

    πŸ›  And of course, a lot of bug-fixes, improved ES6 support of existing rules, docs, infrastructure changes, etc.

    πŸ”¨ Although this is major version, we didn't remove deprecated rule values or changed config format, we expecting to do this in the 3.0 version while switching to CST and fully refactor JSCS code-base.

    πŸ”„ Changelog

    Backward incompatible changes

    • 🚚 Utils: remove comma from list of binary operators (Oleg Gaidarenko)
    • 🚚 Checker: remove deprecated constructor options (Oleg Gaidarenko)
    • Obey the Rule of Silence (Feross Aboukhadijeh)
    • πŸ”§ Configuration: add ability to load external presets (Oleg Gaidarenko)
    • πŸ”§ Configuration: small corrections to JSDoc of "node-configuration" module (Oleg Gaidarenko)
    • πŸ”¨ Configuration: small refactoring of the configuration module (Oleg Gaidarenko)
    • πŸ”§ Configuration: allow "getReporter" method to require node modules (Oleg Gaidarenko)
    • πŸ”§ Configuration: initial pass on the polymorphic require (Oleg Gaidarenko)
    • Checker: more API changes for 2.0 (Oleg Gaidarenko)
    • CLI: Differentiate exit codes (Oleg Gaidarenko)
    • 0️⃣ Misc: set default value of maxErrors option to 50 (Oleg Gaidarenko)
    • 🚚 yodaConditions: remove comparison operators from default set (Oleg Gaidarenko)
    • 🚚 Misc: remove all deprecated rules/tests (Henry Zhu)
    • API: allow external entities to be defined without "jscs" prefix (Oleg Gaidarenko)
    • πŸ”§ Configuration: exclude node_modules/ by default (Louis Pilfold)
    • CLI: set "maxErrors" to Infinity with enabled "fix" option (Oleg Gaidarenko)
    • 0️⃣ Misc: change default dialect to es5 and make appropriate changes (Alexej Yaroshevich)

    Autofix

    • πŸ”€ Autofix: remove merge artefact (Oleg Gaidarenko)
    • πŸ‘ Autofix: support disallowTrailingComma rule (Oleg Gaidarenko)
    • πŸ‘ Autofix: support trailing whitespaces and missing commas (Andrzej Wamicz)
    • validateQuoteMarks: try out "fix" field (Oleg Gaidarenko)

    Preset

    • Preset: requireSemicolons = true for google preset (BigBlueHat)
    • Preset: add jsDoc rules to relevant presets (Oleg Gaidarenko)
    • Preset: add disallowTrailingWhitespace to MDCS (Joshua Koo)
    • Preset: add requireVarDeclFirst rule to the relevant presets (Oleg Gaidarenko)
    • ⚑️ Preset: update Wordpress preset (Ivo Julca)
    • Preset: add requireCapitalizedComments to jquery and wordpress presets (Oleg Gaidarenko)
    • ⚑️ Preset: update mdcs (Joshua Koo)
    • Preset: require trailing comma in airbnb preset (Christophe Hurpeau)
    • Preset: add missing rules to google preset (Christophe Hurpeau)
    • ⚑️ Preset: update airbnb preset (Craig Jennings)
    • ⚑️ Preset: update jquery and dependant presets (Oleg Gaidarenko)
    • πŸ’… Preset: require spaces in anonymous FE for crockford style (Oleg Gaidarenko)
    • Preset: fix requireDotNotation rule value according to es3 changes (Alexej Yaroshevich)
    • 🚚 Preset: remove jsdoc rules from yandex preset (Oleg Gaidarenko)

    πŸ†• New rules

    • πŸ†• New rules: add SpaceBeforeComma rules (shashanka)
    • πŸ†• New Rule: requireVarDeclFirst (oredi)
    • πŸ†• New Rule: add JSDoc rules (Oleg Gaidarenko)
    • πŸ†• New Rule: (disallow|require)SpaceBeforeSemicolon (Richard Munroe)
    • πŸ†• New Rule: requireMatchingFunctionName (Pavel Strashkin)
    • πŸ†• New Rule: requireTemplateStrings (Henry Zhu)
    • πŸ†• New Rule: (require|disallow)ParenthesesAroundArrowParam (Henry Zhu)
    • πŸ†• New Rule: requireSpread (Henry Zhu)
    • πŸ†• New Rule: requireShorthandArrowFunctions (Henry Zhu)
    • πŸ†• New Rule: requireArrowFunctions (Henry Zhu)
    • πŸ†• New Rule: disallowNodeTypes (Henry Zhu)
    • πŸ†• New Rule: requireNumericLiterals (Henry Zhu)
    • πŸ†• New Rule: (disallow|require)ObjectKeysOnNewLine (Eli White)

    πŸ†• New rule values

    • πŸ‘ requireYodaConditions: support an array of operators (Ivo Julca)
    • πŸ‘ disallowYodaConditions: support an array of operators (Ivo Julca)
    • (require|disallow)AnonymousFunctionExpression: account for shorthand methods (Henry Zhu)
    • πŸ‘» disallowMultipleVarDecl: add exception for require statements (Stefano Sala)
    • disallowSpaceAfterObjectKeys: added ignoreAligned option (Andrey Ermakov)
    • maximumLineLength: allow function delcarations to exceed limit (Clay Reimann)
    • requirePaddingNewLinesAfterBlocks: add "inNewExpressions" to exceptions (Mato Ilic)
    • disallowCommaBeforeLineBreak: added allExcept function (Andrey Ermakov)
    • πŸ”§ requirePaddingNewlinesInBlocks: Add object option to configuration (oredi)
    • πŸ‘» maximumLineLength: Add exception for long require expressions (Philip Hayes)
    • πŸ†• NewlineBeforeBlockStatement: allow settings per block statement type (Dave Hilton)
    • validateIndentation: add option to ignore comments (Danny Shternberg)

    ✨ Enhancements for ES6 support

    • πŸ‘ requireSemicolons: Add support for import and export declarations (Roman Dvornov)
    • ⬆️ Esprima: Upgrade to 2.4.0 (Joel Kemp)
    • requireArrowFunctions: don't check AssignmentExpression or Property (Henry Zhu)
    • 0️⃣ SpacesInFunctionDeclaration: check export default function (Henry Zhu)
    • πŸ‘ AlignedObjectValues: support computed property names (Henry Zhu)
    • (disallow|require)SpaceAfterObjectKeys: check object method shorthand (Henry Zhu)
    • πŸ‘ (require|disallow)SpaceAfterObjectKeys: support computed properties (Henry Zhu)
    • SpacesInsideObjectBrackets: Add Check for destructive assignments (Oleg Gaidarenko)
    • Misc: use babel-jscs for the esnext option (Henry Zhu)
    • requireSemicolons: Don't warn on class and function exports (Roman Dvornov)

    Inline control

    • Errors: Ability to suppress a single line (Louis Pilfold)
    • 🚚 StringChecker: Remove grit processing includes (Tony Ganch)

    πŸ†• New reporters

    • πŸ’… Reporters: add new machine readable unix-style reporter (Andreas Tolfsen)
    • Reporters: add new summary reporter (oredi)

    πŸ› Bug fixes

    • βͺ Revert "New Rule: (disallow|require)SpaceBeforeSemicolon" (Oleg Gaidarenko)
    • πŸ‘» requireMultipleVarDecl: add exception for require statements (Stefano Sala)
    • πŸ”§ requirePaddingNewlinesAfterBlocks: initialize exceptions in configure (Eli White)
    • disallowSpaceAfterKeywords: fix "else if" case (Henry Zhu)
    • String-checker: do not check empty strings (Oleg Gaidarenko)
    • requirePaddingNewLinesAfterBlocks: fixing blocks that end with semicolons (Eli White)
    • disallowPaddingNewLinesAfterBlocks: fix blocks which end with semicolon (Oleg Gaidarenko)
    • πŸ‘ disallowSpaceAfterObjectKeys: support for legacy options (Andrey Ermakov)
    • requireAlignedObjectValues: do not assert exact amount of spaces before colons (Andrey Ermakov)
    • disallowImplicitTypeConversion: Don't report concat for same string literals (Oleg Gaidarenko)
    • disallowSpacesInCallExpression: Extend rule to validate NewExpression (Inian Parameshwaran)
    • Iterator: correct "TryStatement" path (Oleg Gaidarenko)
    • requirePaddingNewLinesAfterBlocks: consider IIFE case (Oleg Gaidarenko)
    • disallowKeywordsOnNewLine: Allow comments before keywords (oredi)

    πŸ“„ Docs

    • πŸ“„ Docs: last minutes updates for 2.0 (Oleg Gaidarenko)
    • πŸ“„ Docs: update rules sum (Oleg Gaidarenko)
    • πŸ“„ Docs: add es3 option to OVERVIEW.md (Oleg Gaidarenko)
    • πŸ“„ Docs: reflect some of the 2.0 changes (Oleg Gaidarenko)
    • πŸ“„ Docs: clarify space brackets rules description (Oleg Gaidarenko)
    • πŸ“„ Docs: Remove needless semicolon (yong woo jeon)
    • πŸ“„ Docs: fix diff range link for 1.13.1 version (Alexej Yaroshevich)
    • πŸ“„ Docs: add link to commits between minor releases in CHANGELOG (Henry Zhu)
    • πŸ“„ Docs: Document how to programmatically invoke jscs (K. Adam White)
    • πŸ“„ Docs: Add and improve docs for inline comments (oredi)
    • πŸ“„ Docs: add message about demo not working, fix link to team (Henry Zhu)
    • πŸ“„ Docs: Change label to beginner-friendly (oredi)
    • πŸ“„ Docs: Mention which tickets are beginner-friendly (Joel Kemp)
    • πŸ“„ Docs: add "allowEOLComments" option info for disallowMultipleSpaces rule (bigmonkeyboy)
    • πŸ“„ Docs: correct syntax error for disallowFunctionDeclarations rule (Christophe Hurpeau)
    • βœ… Misc: Docs: add docs and test for "esprima" config option (Oleg Gaidarenko)
    • πŸ“„ Docs: correct true value description (Adrian Heine nΓ© Lang)
    • πŸ“„ Docs: add quotes to the "wordpress" preset (raimon)
    • πŸ“„ Docs: align gitter badge with others (Oleg Gaidarenko)
    • πŸ“„ Docs: Add gitter room to readme (Joel Kemp)
    • πŸ“„ Docs: fix table of contents anchor links in contributing.md (Henry Zhu)
    • πŸ“„ Docs: add protocol to homepage address (Oleg Gaidarenko)
    • πŸ“„ Docs: update outdated info & fix small issue in jscs config (Oleg Gaidarenko)
    • πŸ“„ Docs: correct validateAlignedFunctionParameters values (Adrian Heine nΓ© Lang)
    • πŸ“„ Docs: various corrections for the rules page (Oleg Gaidarenko)
    • πŸ“š disallowPaddingNewlinesInObjects: Clarify documentation (Ángel Sanz)
    • πŸ“„ requireSpacesInAnonymousFunctionExpression: fix syntax error in docs (Christophe Hurpeau)

    Misc

    • Misc: add disallowTrailingComma rule to jscs config (Oleg Gaidarenko)
    • βœ… Tests: correct preset examples (Oleg Gaidarenko)
    • 🚚 Misc: use babel-jscs 2.0.0, move jscs-jsdoc to dependencies (Henry Zhu)
    • πŸ”€ Misc: remove merge artefact (Oleg Gaidarenko)
    • String-checker: make "fix" field private (Oleg Gaidarenko)
    • πŸ”§ Configuration: improve JSDoc notes (Oleg Gaidarenko)
    • String-checker: use "fix" field in rule declaration if it exist (Oleg Gaidarenko)
    • Errors: add "cast" method (Oleg Gaidarenko)
    • πŸ”§ Configuration: add "getConfiguredRule" method (Oleg Gaidarenko)
    • πŸ”§ Configuration: simplify and modulize configuration module (Oleg Gaidarenko)
    • βœ… Tests: do not define anything if test should not run (Oleg Gaidarenko)
    • ⚑️ Iterator: update to latest estraverse and don't monkeypatch (Oleg Gaidarenko)
    • Misc: Add node .12 and io.js to the travis (Oleg Gaidarenko)
    • πŸ‘ Misc: add support for babel-jscs (Henry Zhu)
    • Misc: bump estraverse to 2.x (Oleg Gaidarenko)
    • requireArrowFunctions: only error for callbacks (Henry Zhu)
    • 🚚 Tests: Move require-matching-function-name to spec folder (Joel Kemp)
    • πŸ”¨ requirePaddingNewlinesInBlocks: Refactor unit tests (oredi)
    • requirePaddingNewlinesBeforeKeywords: Modify special scenarios (oredi)
    • βœ… Tests: ES2015 Airbnb Preset (Christophe Hurpeau)
    • πŸ”¨ requireTemplateStrings: refactor, check if either node is a string (Henry Zhu)
    • ⚑️ Deps: Update JSHint and Lodash.assign (paladox)
    • πŸ‘Œ Improve JsFile constructor for better encapsulation (Marat Dulin)
    • πŸ”¨ Refactor integration tests (Marat Dulin)
    • 🚚 Misc: remove extraneous file (Henry Zhu)
    • Misc: increase coverage of remaining rules (Henry Zhu)
    • 0️⃣ disallowParenthesesAroundArrowParam: make exception when using a default parameter (Henry Zhu)
    • βœ… requireTemplateStrings: improve logic (Oleg Gaidarenko)
    • ⚑️ Misc: update dependencies (Henry Zhu)
    • πŸ‘ Misc: support class methods for various function rules (Henry Zhu)
    • βœ… Misc: fix test filename for disallowSpaceBeforeObjectValues (Henry Zhu)
    • βœ… Misc: add intergration tests for "autofix" feature (Oleg Gaidarenko)
    • βœ… Tests: correct couple assertions (Oleg Gaidarenko)
    • Misc: fix jsdoc types with non-standard Promise-star declaration (Alexej Yaroshevich)
    • πŸ‘• Lint: Add jscs-jsdoc plugin (Alexej Yaroshevich)
    • ⚑️ Misc: update dependencies & temporary remove coverage badge (Oleg Gaidarenko)
    • πŸ’… Misc: code style fixes (Alexej Yaroshevich)
    • Misc: introduce reservedWords instead of utils.isES3 (Alexej Yaroshevich)
    • βœ… Intergration: correct integration tests for big amount of results (Oleg Gaidarenko)
    • πŸ—„ validateIndentation: deprecate includeEmptyLines in favour of allExcept (Oleg Gaidarenko)