jscs-dev / node-jscs

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

requireSpaceBeforeDestructuredValues does not work in vanilla JS #2281

Closed pixelpax closed 8 years ago

pixelpax commented 8 years ago

requireSpaceBeforeDestructuredValues does not seem to parse to a proper JSCS option, documentation says that it's constrained to ES6. I see no reason this shouldn't work in non-ES6 JS.

markelog commented 8 years ago

ES6/ES2015 is mostly compatible with previous versions, "ES6" tag in rules docs means it works with new js constructions

pixelpax commented 8 years ago

OK, well I suppose it isn't a problem with the JavaScript dialect, but the issue remains that when using "requireSpaceBeforeDestructuredValues": true on jscs 3.0.5, I get the warning: Unknown JSCS option name and the following code

var foo = {
  bar:'bar'
};

Is treated as valid when it should be invalid.

Did you try to reproduce this? If not, would you mind trying it and possibly reopening?

Here is my entire .jscs.json for reference:

{
  "requireCamelCaseOrUpperCaseIdentifiers": true,
  "requireSpacesInFunctionExpression": {
    "beforeOpeningCurlyBrace": true
  },
  "requireSpaceAfterBinaryOperators": [
    "=", ",", "+", "-", "/", "*", "+=", "-=",
    "*=", "/=", "<", ">", "===", "!==", "<=", ">="
  ],
  "requireSpaceBeforeBinaryOperators": [
    "=", "+", "-", "/", "*", "+=", "-=", "*=",
    "/=", "<", ">", "===", "!==", "<=", ">="
  ],
  "validateIndentation": 2,
  "disallowTrailingComma": true,
  "disallowTrailingWhitespace": true,
  "requireSemicolons": true,
  "disallowMultipleSpaces": true,
  "requireSpaceBeforeBlockStatements": 1,
  "validateQuoteMarks": "'",
  "requireSpaceBeforeDestructuredValues": true,
  "requireLineFeedAtFileEnd": true,
  "jsDoc": {
    "checkAnnotations": "closurecompiler",
    "checkParamNames": true,
    "requireParamTypes": true,
    "checkRedundantParams": true,
    "checkReturnTypes": true,
    "checkRedundantReturns": true,
    "requireReturnTypes": true,
    "checkTypes": true,
    "checkRedundantAccess": true,
    "requireNewlineAfterDescription": true
  },
  "maximumLineLength": 120,
  "disallowMultipleLineBreaks": true
}
markelog commented 8 years ago

You say you use latest version of jscs, but this error could only happen when requireSpaceBeforeDestructuredValues on older versions of jscs in which such rule wasn't introduced