[bug] undefined variable `name` does not trigger errors or warnings in JSX.
See original GitHub issueI’m not sure which rule is failing, but if I had a component which had prop name and used it in JSX, while refactoring and renaming prop to title
, the leftovers of name prop iN JSX slept unnoticed, and caused errors in production, even with typescript.
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (10 by maintainers)
Top Results From Across the Web
[bug] undefined variable `name` does not trigger errors or ...
I'm not sure which rule is failing, but if I had a component which had prop name and used it in JSX, while...
Read more >ReactJS using undefined variable even after checking for it ...
The main problem is that my if statements do not check properly if the variables are not empty arrays or null or undefined,...
Read more >Error Messages | Cypress Documentation
We found an error preparing your test file. This message means that Cypress encountered an error when compiling and/or bundling your test file....
Read more >Google TypeScript Style Guide
var foo = someValue; // Don't use - var scoping is complex and causes bugs. Variables must not be used before their declaration....
Read more >A Definitive Guide to Handling Errors in JavaScript - Kinsta
Getting tripped up by errors in your JavaScript? We'll show you how to tame those errors so you can get back to developing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There is a
no-restricted-globals
rule for that. create-react-app is maintaining aconfusing-browser-globals
package, which is a list of globals you usually want to restrict, includingname
andevent
.You can set
env: { browser: false }
(instead oftrue
) in your config and use/* globals ...*/
comments to enable only browser globals you want to use in that file.Or, as @webOS101 recommended in this comment, enable just
window
/document
and access browser globals only through those, in which case you should also setenv: { browser: false }
.Either of these solutions would lead to no-undef rule warnings on the
name
reference.A problem with this might be if
@typescript-eslint/eslint-recommended
config turnsno-undef
off, in which case the solution withno-restricted-globals
as recommended by @ark120202 in this comment looks like the best approach for a typescript project.