Add note about not needing jsx-no-undef with TS / typescript-eslint#3941
Add note about not needing jsx-no-undef with TS / typescript-eslint#3941karlhorky wants to merge 3 commits intojsx-eslint:masterfrom
Conversation
| It's recommended to avoid this rule if your project: | ||
|
|
||
| 1. does not use JSX | ||
| 2. uses TypeScript, which [automatically enables better checks than ESLint `no-undef` rules](https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors) |
There was a problem hiding this comment.
item 2 and 3 are basically the same - it would be a very bad idea to turn off this rule and NOT enable the typescript-eslint rule.
There was a problem hiding this comment.
Hmm, well following the advice from the typescript-eslint docs, actually the no-undef rule should be disabled in TypeScript files
So option 3 is for files where TS type checking is disabled, eg. JS files in a typescript-eslint project
If that doesn't make sense, I can try re-explaining
There was a problem hiding this comment.
ah, hmm, ok - which version of TS enabled these better checks? (because TS definitely did not used to do a better job than this rule)
There was a problem hiding this comment.
Good question, I'm thinking that this was like this from pretty early on... can't remember a time when TS didn't give me errors for undefined JSX element identifiers 🤔
|
IIUC, it sounds like maybe "JSX reference tracking" in ESLint v10 will be another reason to not need
|

Hi @ljharb, hope everything is going well! 👋
Quick PR to add an additional 2 cases of when to not use
react/jsx-no-undefwhen using TypeScript, since it has better checks than ESLint
no-undefrulesthe
@typescript-eslint/parserparser allows for usage of ESLint's built-inno-undefwithoutreact/jsx-no-undef:This applies to:
.tsxfiles (as demonstrated in the typescript-eslint Playground link).jsxor.jsfiles - also without"allowJs": trueor"checkJs": trueintsconfig.json.