Releases: jscs-dev/node-jscs
v2.10.0
Version 2.10.0 (2016-02-15):
Happy Presidents Day!
In this release, it's just some additional rules to update to the airbnb preset, new rules, and fixes.
Preset Changes
- Add
maximumLineLength
to theairbnb
preset (reference) (Oleg Gaidarenko) - Add
disallowSpacesInsideTemplateStringPlaceholders
to theairbnb
preset (not explicit but used in examples) (Oleg Gaidarenko) - Add
disallowNewlineBeforeBlockStatements
rule to themdcs
preset (reference) (Mauricio Massaia)
New Rules
disallowSpacesInsideTemplateStringPlaceholders
(ikokostya)
Disallows spaces before and after curly brace inside template string placeholders.
// usage in config
"disallowSpacesInsideTemplateStringPlaceholders": true
// Valid
`Hello ${name}!`
// Invalid
`Hello ${ name}!`
`Hello ${name }!`
`Hello ${ name }!`
requireImportsAlphabetized
(Ray Hammond)
Requires imports to be alphabetized
// usage in config
"requireImportAlphabetized": true
// Valid
import a from 'a';
import c from 'c';
import z from 'z';
// Invalid
import a from 'a';
import z from 'z';
import c from 'c';
Rule Updates
requireSpaceBeforeKeywords
: skipfunction
by default (gpiress)
Bug Fixes
requireNumericLiterals
: miss if first argument is an Identifier (Robert Jackson)disallowSpacesInsideTemplateStringPlaceholders
: skip the edge case (Oleg Gaidarenko)requirePaddingNewLinesBeforeExport
: exclude if only statement in block (Brian Schemp)maximumLineLength
: some nodes might contain null values (Oleg Gaidarenko)
Docs
- Correct date in the changelog (Oleg Gaidarenko)
- Various rule corrections (Christopher Cook)
v2.9.0
Version 2.9.0 (2015-01-23):
Changed the changelog date format to be YYYY-MM-DD.
Whoo a release during this blizzard! Hopefully, this will be our last release before we start pushing out pre-release versions of 3.0. (If necessary, we can push bug fixes to 2.x)
The plan:
- Push the
2.9.0
release - Create a
2.x
branch off ofmaster
- Switch
master
to be the3.0
branch - Merge in 2.x changes + cleanup stuff for a 3.0 alpha release.
- Do what we can in our 3.0 milestone. We would really appreciate any help!
- Especially for deprecating rules/options, rule merging, renames/inconsistencies that we don't catch.
New Rules
requireCapitalizedConstructorsNew
(Alexander O'Mara)
// Description: Requires capitalized constructors to to use the `new` keyword
// Usage
"requireCapitalizedConstructors": {
"allExcept": ["somethingNative"]
}
// Valid
var x = new Y();
var x = new somethingNative(); // exception
// Invalid
var x = Y();
Rule Updates
validateNewlineAfterArrayElements
: add autofix support for this rule (Joeri de Gooijer)
// can turn
var a = [0,
1,
2];
// into
var a = [
0,
1,
2
];
This was @joerideg's first PR, so congrats and hope to see more contributions (not necessarily here)!
I think we would need a seperate rule to both check/fix alignment properly.
requireSemicolons
: account for stage-2ClassProperty
(Henry Zhu)
class A {
prop; // will add a semicolon here
prop2 = 1; // and here
}
requireCamelCaseOrUpperCaseIdentifiers
: add extra optionsallowedPrefixes, allowedSuffixes, allExcept
- This lets you specify a permitted array of String, RegExp, or ESTree RegExpLiteral values
For options: { allowedSuffixes: ["_dCel", {regex:{pattern:"_[kMG]?Hz"}}] }
// Extra valid options
var camelCase_dCel = 5;
var _camelCase_MHz = 6;
// Invalid
var camelCase_cCel = 4;
var CamelCase_THz = 5;
requireNewlineBeforeBlockStatements
,disallowNewlineBeforeBlockStatements
: account forSwitchStatement
// Valid for requireNewlineBeforeBlockStatements
switch (a)
{
case 1: break;
}
// Valid for disallowNewlineBeforeBlockStatements
switch (a) {
case 1: break;
}
Presets
airbnb
: Enforce rule 25.1 (Joe Bartlett)- This adds
requireDollarBeforejQueryAssignment
- This adds
airbnb
: Enforce rule 7.11 (Joe Bartlett)- This fixes up function spacing issues (autofixable)
google
: Enforce naming rules- This adds
"requireCamelCaseOrUpperCaseIdentifiers": { "allowedPrefixes": ["opt_"], "allExcept": ["var_args"] }
- This adds
Bug Fixes
requireEnhancedObjectLiterals
: Don't error for computed properties (Henry Zhu)requireTemplateStrings
: should not report string to binary (Oleg Gaidarenko)requireVarDeclFirst
: be aware of the comments (Kushan Joshi)
Misc
OVERVIEW.md
: add the Visual Studio Code extension to list of "Friendly Packages" (Tyler Hughes)
2.8.0
Version 2.8.0
Happy new year! Small changes this time, small, but important fixes which still warrants the minor bump.
Aside from bug fixes, this update includes improvement for the airbnb
preset and allExcept
option for the disallowNewlineBeforeBlockStatements
v2.7.0
Version 2.7.0 (12-08-2015):
It's this time of the year again, 2.7 is here!
One new rule, cool amount of fixes and massive jsdoc rule set update.
New Rules
Although there's only one new rule in this release, it's pretty powerful! Say thanks to @ficristo!
requireEarlyReturn
// This is cool
function test() {
if (x) {
return x;
}
return y;
}
// This is not
function test() {
if (x) {
return x;
} else {
return y;
}
}
This is one of the most popular patterns out there, such as in idiomatic and node-style-guide.
Presets
- The
idiomatic
andnode-style-guide
presets now have therequireEarlyReturn
rule. - Whereas the
airbnb
preset is better in treating JSX.
Bug Fixes
disallowTrailingWhitespace
changes for autofix (thanks @lukeapage!)requirePaddingNewlinesBeforeKeywords
: allow function return on the same linedisallowMixedSpacesAndTabs
: fix issue with erroring on block commentsauto-configure
: setmaxErrors
toInfinity
Notable Changes in jsDoc
- Improves ES6 support for
enforceExistence
: add exceptions for arrow functions and ES6 modules exports - Many fixes related to
requireDescriptionCompleteSentence
- Fixes for incorrecly sticked docblocks to IIFE
- Docblocks without tags now parsing correctly
- Adds
@override
tojsdoc3
preset - Arrow functions now treats as usual functions
See the full list in jscs-jsdoc changelog.
v2.6.0
Version 2.6.0 (11-18-2015):
Thanks to @seanpdoyle, we're able to move some of the ES6 rules from the ember-suave preset to JSCS!
New Rules
disallowVar
(Sean Doyle)
Disallows declaring variables with var
.
"disallowVar": true
// Valid
let foo;
const bar = 1;
// Invalid
var baz;
You can also use "disallowKeywords": ["var"]
requireArrayDestructuring
(Sean Doyle)
Requires that variable assignment from array values are destructured.
"requireArrayDestructuring": true
// Valid
var colors = ['red', 'green', 'blue'];
var [ red ] = colors;
// Invalid
var colors = ['red', 'green', 'blue'];
var red = colors[0];
requireEnhancedObjectLiterals
(Sean Doyle)
Requires declaring objects via ES6 enhanced object literals (shorthand versions of properties)
"requireEnhancedObjectLiterals": true
var obj = {
foo() { },
bar
};
var obj = {
foo: function() { },
bar: bar
};
requireObjectDestructuring
(Sean Doyle)
Requires variable declarations from objects via destructuring
"requireObjectDestructuring": true
// Valid
var { foo } = SomeThing;
var { bar } = SomeThing.foo;
// Invalid
var foo = SomeThing.foo;
var bar = SomeThing.foo.bar;
disallowSpacesInGenerator
(Francisc Romano)
Checks the spacing around the *
in a generator function.
"disallowSpacesInGenerator": {
"beforeStar": true,
"afterStar": true
}
var x = function*() {};
function*a() {};
var x = async function*() {};
New Rule Options
requireCamelCaseOrUpperCaseIdentifiers
: addstrict
option (Jan-Pieter Zoutewelle)
Also forces the first character to not be capitalized.
"requireCamelCaseOrUpperCaseIdentifiers": {
"strict": true
}
// Valid
var camelCase = 0;
var UPPER_CASE = 4;
// Invalid
var Mixed_case = 2;
var Snake_case = { snake_case: 6 };
var snake_case = { SnakeCase: 6 };
disallowSpace(After|Before)Comma
: addallExcept: ['sparseArrays']
(Brian Dixon)validateQuoteMarks
: add "ignoreJSX" value (Oleg Gaidarenko)requireMatchingFunctionName
: addincludeModuleExports
option (George Chung)
Fixes
- Account for sparse arrays in rules with spacing and commas (Brian Dixon)
requireSpaceBeforeBinaryOperators
: report "operator =" correctly when erroring (Rob Wu)requireAlignedMultilineParams
: do not throw on function without body (Oleg Gaidarenko)
Preset Changes
WordPress
: addrequireBlocksOnNewLines
(Gary Jones)
v2.5.1
Version 2.5.1 (11-06-2015):
Just some bug fixes and an internal change before we integrate CST.
Fixes
disallowUnusedParams
: ignore eval exressions (Oleg Gaidarenko)Configuration
: do not try to load presets with function values (Oleg Gaidarenko)requirePaddingNewLinesAfterBlocks
- don't throw on empty block (Oleg Gaidarenko)requireSpacesInGenerator
- account for named functions (Henry Zhu)
Internal changes
- Add
Whitespace
token in preparation for using CST (Marat Dulin)
2.5.0
Version 2.5.0 (10-28-2015):
Preset Updates
Thanks to markelog and Krinkle, the built-in wikimedia preset will be hosted at https://github.com/wikimedia/jscs-preset-wikimedia.
The purpose of this change is so that organizations can update their preset as needed without waiting for JSCS to update to another minor version (even though we are releasing more often anyway). The plan is to not update our preset dependencies until a new minor version of JSCS.
Example:
// JSCS package.json
"jscs-preset-wikimedia": "~1.0.0",
- Wikimedia updates their preset to to
1.1.0
- A new user runs
npm install
with jscs and will get version1.0.0
of the wikimedia preset - If the user wants to update the preset themselves, they can add a direct dependency in their package.json
- Otherwise they can wait for JSCS to have a minor version update (
2.4.0
to2.5.0
) which will update all presets.
If you would like to maintain one of the default supported presets, please let us know.
New Rules
requireSpacesInGenerator
(stefania11)
Checks the spacing around the *
in a generator function.
"requireSpacesInGenerator": {
"beforeStar": true,
"afterStar": true
}
// allowed
var x = function * () {};
function * a() {};
var x = async function * () {};
Thanks to Stefania and Christopher for working on this rule this past Sunday during the JS Open Source workshop at the NY Javascript meetup!
New Rule Options
requireCurlyBraces
(Henry Zhu)
"requireCurlyBraces": {
"allExcept": ["return", "continue", "break", ...],
"keywords": ["if", "else", "for", "while", ... ]
}
// allowed
if (x) return;
if (x) return 1;
if (x) continue;
if (x) break;
// still not allowed
if (x) i++;
requireSpaceAfterComma
add option { allExcept: ['trailing'] }
(Brian Dixon)
// allows
var a = [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
}];
Fixes
Account for sparse arrays in comma spacing rules (Brian Dixon)
disallowSpaceBeforeComma
,disallowSpaceAfterComma
disallowSpaceBeforeBinaryOperators
,disallowSpaceAfterBinaryOperators
// allowed
var x = [1, , ,2];
Configuration: correct config dir detection (Oleg Gaidarenko)
Fixes a regression with loading additional rules in a .jscsrc
2.4.0
Version 2.4.0 (10-22-2015):
We're releasing pretty often now, right? :-)
Fix
option
- The
--fix
CLI flag can now be used programatically and through a.jscsrc
config.
This is be useful for plugin authors (not only for jscs plugins but also for
grunt
/gulp
/etc...
)
Preset updates
- The
jquery
preset (and dependant ones likewordpress
andwikimedia
) is less strict, whereasidiomatic
is now more meticulous.
Couple new rules
disallowSpaceAfterComma
- to have an opposite rule todisallowSpaceBeforeComma
:
[1,2,3] // valid
[1, 2, 3] // invalid
requireAlignedMultilineParams
- a nice addition to our indentation rules:
var test = function(one, two,
/*indent!*/ three) {
...
};
Some new rule options
requireDotNotation
now supports fancy letters likeπ
-
obj["ಠ_ಠ"] // This is wrong!
obj.ಠ_ಠ // Now you get it :-)
maxNumberOfLines
can now ignore comments with the{"allExcept": ["comments"]}
optionrequireObjectKeysOnNewLine
can ignore object properties on the same line with{"allExcept": ["sameLine"]}
option -
var whatDoesAnimalsSay = {
cat: 'meow', dog: 'woof', fox: 'What does it say?' // this is cool now
};
Fixes
- Account for bare blocks in both
disallowNewlineBeforeBlockStatements
anddisallowSpaceBeforeBlockStatements
// allows
var a = 1;
{
let b = 1;
}
v2.3.5
Version 2.3.5 (10-19-2015):
Why not fix some more bugs!
Bug Fixes
- Fix:
requireSpacesInForStatement
account for parenthesizedExpression (Henry Zhu)
// allows ()
for (var i = 0; (!reachEnd && (i < elementsToMove)); i++) {
- Fix:
disallowCommaBeforeLineBreak
: fix for function params (Henry Zhu)
// allows
function a(b, c) {
console.log('');
}
- Fix:
requirePaddingNewLineAfterVariableDeclaration
- allow exported declarations (Henry Zhu)
// allows
export var a = 1;
export let a = 1;
export const a = 1;
- Fix:
disallowSpaceAfterKeywords
- fix issue with using default keyword list (Henry Zhu)
// fixes autofix from `return obj` to `returnobj`
- Fix:
disallowTrailingComma
,requireTrailingComma
- support ObjectPattern and ArrayPattern (Henry Zhu)
// disallow
const { foo, bar } = baz;
const [ foo, bar ] = baz;
// require
const { foo, bar, } = baz;
const [ foo, bar, ] = baz;