Indent rule false positive violation for VariableDeclarator on named export
See original GitHub issueWhat version of ESLint are you using? 2.11.1
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
"indent" : ["error", 2, {
"SwitchCase": 0,
"VariableDeclarator": { "var": 2, "let": 2, "const": 3 }
}]
What did you do? Please include the actual source code causing the issue.
export const MAX_POSTS = 10,
MAX_PUBLISHED_POSTS = 5,
MAX_TEAM_MEMBERS = 9,
MAX_TEAM_PARTNERS = 5;
What did you expect to happen? No errors from the indent rule
What actually happened?
The indent rule reports violations as it doesn’t take the export
keyword into account.
A quick workaround I found for my usage is to add more spaces to the indent count in the checkIndentInVariableDeclarations
method from indent.js rule file:
// If variable declaration is exported, add 7 spaces to indent count for the "export " keyword
if (node.parent.type.indexOf("Export") === 0) {
elementsIndent += 7;
}
I’m brand new to ESLint so I didn’t had time to dig into its core concepts. This is a quick n dirty fix that only works for my particular setup, it may need some more knowledge to handle any possible cases.
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:14 (13 by maintainers)
Top GitHub Comments
I actually agree with @BYK we should deprecate
var
,let
andconst
options and addalign
option instead. We don’t need to remove schema, but just make it either or schema like we did for couple of other rules.Re-closing this, as it’s not handled by the indent rewrite and it looks like there’s insufficient interest for the team to pursue this.