no-undef should apply on assigning a property to an undefined variable
See original GitHub issueWhat rule do you want to change? no-undef
Does this change cause the rule to produce more or fewer warnings? more
How will the change be implemented? (New option, new default behavior, etc.)? maybe a new option
Please provide some example code that this change will affect:
The following assignment should not be allowed if the rule is active, assuming Text
is an undefined variable.
Text.propTypes = { a: 'b' }
What does the rule currently do for this code? It does not apply on this case and can potentially break builds.
What will the rule do after it’s changed? It will warn or error if there is an property-assignment to an undefined variable.
Are you willing to submit a pull request to implement this change? Yes
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
ESLint's "no-undef" rule is calling my use of Underscore an ...
Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment, or specified ...
Read more >no-undef - ESLint - Pluggable JavaScript Linter
no-undef. Disallow the use of undeclared variables unless mentioned in /*global */ ... The "extends": "eslint:recommended" property in a configuration file ...
Read more >undefined - JavaScript - MDN Web Docs - Mozilla
The global undefined property represents the primitive value ... A variable that has not been assigned a value is of type undefined ....
Read more >List of available rules - ESLint - Pluggable JavaScript linter
The "extends": "eslint:recommended" property in a configuration file enables rules that ... enforce the use of variables within the scope they are defined....
Read more >7 Tips to Handle undefined in JavaScript - Dmitri Pavlutin
JavaScript doesn't initialize variables or object properties with null . ... Ideally, you would assign a value right away after declaration ...
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
seems it was true: https://github.com/sindresorhus/globals/blob/8f022be1112cc0964ca77947a4db5417056188c8/globals.json#L874
so it was working as expected. 😃
I can’t reproduce: https://eslint.org/demo/#eyJ0ZXh0IjoiVGV4dC5wcm9wVHlwZXMgPSB7IGE6ICdiJyB9Iiwib3B0aW9ucyI6eyJwYXJzZXJPcHRpb25zIjp7ImVjbWFWZXJzaW9uIjo5LCJzb3VyY2VUeXBlIjoibW9kdWxlIiwiZWNtYUZlYXR1cmVzIjp7fX0sInJ1bGVzIjp7Im5vLXVuZGVmIjoyfSwiZW52Ijp7fX19