jscs-dev / node-jscs

:arrow_heading_up: JavaScript Code Style checker (unmaintained)
https://jscs-dev.github.io
MIT License
4.96k stars 510 forks source link

requireSpaceAfterKeywords:true rule conflict causes fix toggling #2067

Closed lancecaraccioli closed 8 years ago

lancecaraccioli commented 8 years ago

Intent: to force function definitions to have a space after the keyword "function"

.jscsrc

    "preset": "google",
    "requireSpaceAfterKeywords": true

example.js

(function() {
  console.log('foo');
}());

run auto fix

jscs --fix ./example.js

cat ./example.js results

(function () {
  console.log('foo');
}());

running auto fix again results in the fix being reverted

jscs --fix ./example.js

cat ./example.js results

(function() {
  console.log('foo');
}());

.jscsrc workaround gives the expected behaviour

{
    "preset": "google",
    "disallowSpacesInAnonymousFunctionExpression": null,
    "disallowSpacesInFunctionExpression": null,
    "disallowSpacesInFunctionDeclaration": null,
    "requireSpacesInFunctionExpression": null,
    "requireSpaceAfterKeywords": true
}
markelog commented 8 years ago

Well, yeah, requireSpaceAfterKeywords conflicts with pre-defined rules in google preset, so you need to disable them.

And since their conflict with each other, --fix will always give different output