Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement Proposal: auto fixing of no-var #6639

Closed
mysticatea opened this issue Jul 9, 2016 · 4 comments
Closed

Enhancement Proposal: auto fixing of no-var #6639

mysticatea opened this issue Jul 9, 2016 · 4 comments
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules

Comments

@mysticatea
Copy link
Member

mysticatea commented Jul 9, 2016

This proposal is it makes no-var rule fixable:

  • It modifies most var declarations to let declarations.
  • It does not modify a var declaration if the declaration has redeclaration(s) in the same scope because let declarations are not allowed redeclaration.
  • (It does not modify any var declarations to const declarations. If it can become a const declaration, prefer-const rule will modify it in the next step.)
var a;            // => let a;
var b = 1;        // => let b = 1;
var {c, d} = obj; // => let {c, d} = obj;
var e = 1;        // not changed since this is redeclared.
var e = 1;        // 
var f = 1;        // not changed since this is redeclared.
if (a) {
    var f = 2;    // 
}

This would help us to apply this rule to our codebase.

@mysticatea mysticatea added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 9, 2016
@mysticatea mysticatea self-assigned this Jul 9, 2016
@mysticatea
Copy link
Member Author

  • It does not modify a var declaration if the variable is used from outside of the scope.
if (a) {
    var g = 1;
}
foo(g);

@ilyavolodin
Copy link
Member

👍

@nzakas
Copy link
Member

nzakas commented Jul 9, 2016

This would be awesome! 👍

@mysticatea mysticatea added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 10, 2016
@mysticatea
Copy link
Member Author

Thank you.
I will work on this.

mysticatea added a commit that referenced this issue Jul 10, 2016
mysticatea added a commit that referenced this issue Jul 11, 2016
nzakas pushed a commit that referenced this issue Jul 15, 2016
* Update: make `no-var` fixable (fixes #6639)

* Fix: modify `no-var` not fixing `var` on a case chunk.

* Chore: add the notes of not-fixable cases.
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

3 participants