-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed as not planned
Closed as not planned
Copy link
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionenhancementThis change enhances an existing feature of ESLintThis change enhances an existing feature of ESLintruleRelates to ESLint's core rulesRelates to ESLint's core rules
Description
What rule do you want to change?
no-nested-ternary
What change do you want to make?
Generate more warnings
How do you think the change should be implemented?
A new default behavior
Example code
/* eslint no-nested-ternary: "error" */
// JavaScript code with nested ternary operators
const thing = foo ? bar : baz === qux ? quxx : foobar;
foo ? (baz === qux ? quxx() : foobar()) : bar();
// TypeScript code with nested ternary operators
type KindOf<T> = T extends string
? 'string'
: T extends number
? 'number'
: T extends boolean
? 'boolean'
: T extends any[]
? 'array'
: 'other';
What does the rule currently do for this code?
The no-nested-ternary
rule currently doesn’t understand TypeScript syntax, so it fails to flag errors when nested conditional types are used.
That’s because the TypeScript AST differs slightly from the JavaScript AST for ternary operations.
What will the rule do after it's changed?
For the reasons mentioned above, I’d like to request adding TypeScript syntax support to the no-nested-ternary
rule.
Participation
- I am willing to submit a pull request to implement this change.
Additional comments
This issue is follow-up to #19173
Metadata
Metadata
Assignees
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionenhancementThis change enhances an existing feature of ESLintThis change enhances an existing feature of ESLintruleRelates to ESLint's core rulesRelates to ESLint's core rules
Type
Projects
Status
Complete