Skip to content

linter: double-comparisons applies an unsafe fix - changes logic #22967

@michal-kurz

Description

@michal-kurz

What version of Oxlint are you using?

1.67.0

What command did you run?

oxlint --fix linttest.ts

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
  "categories": {
    "correctness": "allow"
  },
  "rules": {
    "oxc/double-comparisons": "error"
  }
}

What happened?

Autofix rewrites x > 0 || x < 0 to x != 0 - but those two conditions are certainly not equivalent. They seem to be equivalent for non-NaN numbers, numeral strings and true, but are not equivalent for undefined and null as well as many other values (objects, arrays, etc)

The docs say that --fix should only apply safe fixes - this does not seem like something that should be regarded as a safe fix

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions