Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/rules/jsx-no-undef.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ module.exports = Hello;

## When Not To Use It

If you are not using JSX then you can disable this rule.
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@karlhorky karlhorky Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the TS playground goes back to version 3.3.3333, and it seems like it's present there:

Screenshot 2025-08-13 at 19 38 55

https://www.typescriptlang.org/play/?ts=3.3.3#code/JYWwDg9gTgLgBAJQKYEMDG8BmUIjgcilQ3wG4AoSygHgAkkAbBiOAOxRCQF4AiAKQgALVjzgB6AHykgA

3. uses [`typescript-eslint` with `no-undef`](https://typescript-eslint.io/play/#ts=5.7.2&fileType=.tsx&code=DwCQpgNhD2AEB2BDAtmAvAIgFLQBbw1gHoA%2BAbgCgg&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQHYHsBaWXAE0QDN0pFpp9pJwwBfEFoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false)
Loading