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.

Make no-case-declarations rule fixable

See original GitHub issue

When error is spotted, fix will be about wrapping case clauses with blocks. It’ll be great to have it.


What rule do you want to change?

no-case-declarations

Does this change cause the rule to produce more or fewer warnings?

No

How will the change be implemented? (New option, new default behavior, etc.)?

Fix functionality will be configured

Please provide some example code that this change will affect:

Code as:

switch (foo) {
case "bar":
  let bar;
}

Will be fixed to:

switch (foo) {
case "bar": {
  let bar;
}
}

What does the rule currently do for this code?

There’s no fix functionality configured

What will the rule do after it’s changed?

Fix functionality will be configured

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
medikoocommented, May 9, 2017

@ljharb Sure indentation should be maintained, this fix should be purely about adding block wrap nothing more (I’ve updated example)

0reactions
not-an-aardvarkcommented, Jul 11, 2017

Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn’t get enough support from the team and so I’m closing it. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach consensus after a long time tend to never do it, and as such, we close those issues. This doesn’t mean the idea isn’t interesting, just that it’s not something the team can commit to.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-case-declarations - ESLint - Pluggable JavaScript Linter
This rule aims to prevent access to uninitialized lexical bindings as well as accessing hoisted functions across case clauses. Examples of incorrect code...
Read more >
eslint - unexpected lexical declaration in case block
1. deleteInterests is still a reference to the array in state so you're still mutating. Clone the list before splicing. · 2. Use...
Read more >
Exclude eslint rule no-case-declarations [#2915263] | Drupal.org
Proposed resolution. Turn off no-case-declarations until the problem files are fixed.
Read more >
Enable "no-case-declarations" · ab48e08d61 - eslint-config ...
This rule disallows lexical declarations in case statements. http://eslint.org/docs/rules/no-case-declarations Change-Id: ...
Read more >
no-case-declarations - ESLint Config
This rule aims to prevent access to uninitialized lexical bindings as well as accessing hoisted functions across case clauses.
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