Skip to content

Bug: no-var autofix is not working #16610

@mvorisek

Description

@mvorisek

How to reproduce?

config:

'no-var': ['error']

code:

var fx = function (i = 0) {
  if (i < 5) {
    return fx(i + 1);
  }
  console.log(i);
};

fx();

What did you expect to happen?

var fx autofixed to let fx

I tried the code in a sandpit and it behaves the same.

What actually happened?

not autofixed, Unexpected var, use let or const instead no-var error is generated

(autofix of var -> let works in other cases, the problem is present only when the variable is referred in anonymous function in the same declaration)

Metadata

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionautofixThis change is related to ESLint's autofixing capabilitiesbugESLint is working incorrectlyrepro:yesIssues with a reproducible exampleruleRelates to ESLint's core rules

Type

No type

Projects

Status

Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions