Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-plugin): add checks for unnecessary optional chains
This adds type checking around the the new optional-chaining feature. With this, it becomes invalid to start an optional chain when the base value is known to be not-nullish. ```js // Good declare const foo: string | null; declare const bar: null : (() => {}); foo?.length; foo?.slice(); bar?.(); // Bad declare const baz: string; declare const qux: (() => {}); baz?.length; baz?.slice(); baz.slice?.(); qux?.(); ```
- Loading branch information
1 parent
348d2f6
commit 07ad7a9
Showing
4 changed files
with
273 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters