jscs-dev / node-jscs

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

requireSpaceAfterKeywords and generator functions #2168

Closed jsumners closed 8 years ago

jsumners commented 8 years ago
const JSCS = require("jscs");
const jscs = new JSCS();
jscs.registerDefaultRules();
jscs.configure({ requireSpaceAfterKeywords: true });

const results = jscs.checkString('function* generator() { yield true; }');
const errors = results.getErrorList();

console.log(errors[0].message); // "One space required after "function" keyword"

In my actual rule list I also have:

"requireSpacesInGenerator": {
    "afterStar": true
}

It'd be great if an exception could be made such that "function*" is recognized as a keyword (even though it isn't really).

markelog commented 8 years ago

This sounds like a custom rule to me, would be confusing otherwise

sebastien-mignot commented 8 years ago

@markelog You closed both the issues, but I'm not really sure why. In ES6, "function*" IS INDEED a keyword. This is not a "custom rule" or whatever, it's a basic syntaxe of the language, and it's supposed to be written like this. What is the advised way to configure jscs so generators are accepted ?

sebastien-mignot commented 8 years ago

(I meant : while still using requireSpaceAfterKeywords 'function' for all the other cases)