-
-
Notifications
You must be signed in to change notification settings - Fork 925
Closed
Copy link
Labels
A-linterArea - LinterArea - Linter
Description
What version of Oxlint are you using?
1.51.0
What command did you run?
npx oxlint
What does your .oxlintrc.json (or oxlint.config.ts) config file look like?
What happened?
Ran oxlint on the following with prefer-const set to "prefer-const": ["error", { "destructuring": "all" }]
let someOuterScopeVariable : string;
async function generatorFunction() {
return {
inner: 'foo',
outer: 'bar',
};
}
async function myFunction() {
let innerScope: string;
// destructure assignment to existing variables
({inner: innerScope, outer: someOuterScopeVariable} = await generatorFunction());
console.info(`${innerScope}, ${someOuterScopeVariable}`);
}
myFunction();And got the false positive report:
× eslint(prefer-const): `innerScope` is never reassigned.
╭─[index.ts:11:7]
10 │ async function myFunction() {
11 │ let innerScope: string;
· ──────────
12 │ // destructure assignment to existing variables
╰────
help: Use `const` instead.
ESLint does not flag on the same configuration.
Reproduction: https://github.com/MichaelGoff/oxlint-prefer-const/tree/prefer-const-destructure-assignment
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-linterArea - LinterArea - Linter
Type
Fields
Give feedbackPriority
None yet
Effort
None yet
{ "env": { "browser": true, "node": true, "jest": true }, "categories": { "correctness": "error" }, "plugins": ["import", "unicorn", "typescript", "oxc", "vue"], "rules": { "prefer-const": ["error", { "destructuring": "all" }], } }