-
-
Notifications
You must be signed in to change notification settings - Fork 923
Labels
A-linterArea - LinterArea - Linter
Description
What version of Oxlint are you using?
1.50.0
What command did you run?
oxlint --fix --config oxlint.config.ts repro.ts
What does your .oxlintrc.json (or oxlint.config.ts) config file look like?
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["oxc"],
rules: {
"oxc/double-comparisons": "error"
}
});What happened?
It appears the autofix is changing expression semantics by swapping comparator order.
Repro:
repro.tssmelly input:
export const check = (a: number, b: number) => {
if (a === b || b < a) {
return "invalid";
}
return "ok";
};- Run:
oxlint --fix --config oxlint.config.ts repro.ts - Actual output after fix:
if (a <= b) {
return "invalid";
}- Expected equivalent simplification:
if (b <= a) {
return "invalid";
}The autofix changed behavior:
- Original is true when b <= a
- Fixed output is true when a <= b
It is not a safe autofix for this type of code smell, my question is if it should either:
- be fixed to preserve operand order correctly, or
- be moved behind dangerous fixes (--fix-dangerously/fix-suggestions) ?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-linterArea - LinterArea - Linter
Type
Fields
Give feedbackPriority
None yet
Effort
None yet