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

validateIndentation ignores disallowMixedSpacesAndTabs setting #2263

Closed JonathanGawrych closed 8 years ago

JonathanGawrych commented 8 years ago

Take for example the following config:

{
    "validateIndentation": "\t",
    "disallowMixedSpacesAndTabs": false
}

(or if disallowMixedSpacesAndTabs is "smart")

And the following test file:

if (true) {
\t  console.log(true &&
\t  ············false);
}

where \t`` ``is a tab, and· is a space, validateIndentation ignores disallowMixedSpacesAndTabs and throws an error "Invalid indentation character:". Turning on disallowMixedSpacesAndTabs throws 2 errors (one for each).

Correct me if I'm wrong, but isn't validateIndentation throwing false positives? Prior to https://github.com/jscs-dev/node-jscs/commit/d0c70f1c5763c923186945f4b2c10b1aab54e95e (which looks like a complete rewrite of validateIndentation) it wouldn't. Removing validate-indentation.js#L500-L506 seems to fix these problems and passes a npm test (however those mixed tab-spaces lines are not validated for indentation anymore, I believe). Thanks

markelog commented 8 years ago

false is indented, but with spaces, when you want tabs. There is and there were many issues with indentation rules, but this is not one of them