-
-
Notifications
You must be signed in to change notification settings - Fork 943
linter: no-unused-expressions does not support satisfies expressions #14248
Copy link
Copy link
Labels
A-linterArea - LinterArea - Linter
Description
What version of Oxlint are you using?
1.16.0
What command did you run?
oxlint
What does your .oxlintrc.json config file look like?
What happened?
The satisfies statement below is reported as an unused expression. It is a valid type assertion which is handy to ensure switch statements are exhaustive (e.g. here Typescript reports Type '"baz"' does not satisfy the expected type 'never')
type FooBarBaz = 'foo' | 'bar' | 'baz';
export function satisfiesTest(c: FooBarBaz): string {
switch(c) {
case 'foo':
return 'foo';
case 'bar':
return 'bar';
default:
c satisfies never;
return '';
}
} × eslint(no-unused-expressions): Disallow unused expressions
╭─[src/satisfies.ts:10:13]
9 │ default:
10 │ c satisfies never;
· ──────────────────
11 │ return '';
╰────
help: Consider removing this expression
Note that even though the configuration uses typescript/no-unused-expressions, the error is reported under the no-unused-expressions rule. Even though they're documented under different names, both seem to be pointing to the same rule? Not sure if that's expected, but that is confusing
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-linterArea - LinterArea - Linter
Type
Fields
Give feedbackPriority
None yet
Effort
None yet
{ "rules": { "typescript/no-unused-expressions": "error" } }