question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Indent rule false positive violation for VariableDeclarator on named export

See original GitHub issue

What 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
ilyavolodincommented, Jun 23, 2016

I actually agree with @BYK we should deprecate var, let and const options and add align option instead. We don’t need to remove schema, but just make it either or schema like we did for couple of other rules.

0reactions
not-an-aardvarkcommented, Apr 22, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

indent and multiline parameters. · Issue #6052 · eslint ... - GitHub
JSCS has the rule to align parameters vertically. ... Indent rule false positive violation for VariableDeclarator on named export #6296.
Read more >
Working with Rules - ESLint - Pluggable JavaScript Linter
Returns true if a variable with the given name was found and marked as used, otherwise false . report(descriptor) - reports a problem...
Read more >
VS Code not indenting to 4 spaces but only for a single file
However, I have one file in particular that refuses to auto-format to 4-space tab and insists on using 2-space tabs. app.controller.ts @ ...
Read more >
Diff - 402e1b6e55e9041dfd1a93580e45e5c5dba1db55^!
-0,0 +1,15 @@ +Name: DevTools Node Modules +Short Name: ... 113c1a8 Fix: `max-statements-per-line` false positive at exports (fixes #6264) ...
Read more >
eslint/CHANGELOG.md - UNPKG
304, * 47ac478 Update: add named imports and exports for ... 383, * 43d4ba8 Fix: false positive on rule`lines-between-class-members` (fixes #9665) (#9680) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found