Skip to content

Linter: Consider adjacent fixes as overlapping #19160

@overlookmotel

Description

@overlookmotel

Oxlint and ESLint differ in their treatment of fixes which alter sections of source which are directly adjacent:

e.g. If source is x==1 and fix 1 replaces x with _x, and fix 2 replaces == with === then:

  • ESLint considers the 2 fixes to be overlapping, and only applies the first.
  • Oxlint does not consider them to be overlapping, and applies both fixes.

#19094 added logic to RuleTester to emulate ESLint's behavior when the eslintCompat option is set, in order to pass all conformance tests.

However, I think we should consider following ESLint's behavior by default in Oxlint proper.

ESLint previously did what Oxlint does, but they changed it due to this issue:

Issue: eslint/eslint#4321
PR: eslint/eslint#4329

We changed Oxlint's behavior in the opposite direction in #4217.

Given how bad the consequences are when fixes malfunction, personally I think it's better to err on the conservative side, and go back to following ESLint.

Making this change breaks a few tests for no_unused_vars and no_useless_escape rules.

Metadata

Metadata

Assignees

Labels

A-linterArea - LinterC-bugCategory - Bug

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions