Detected not working optional chaining on global variables / optional DOM APIs
See original GitHub issuePlease describe what the rule should do:
eslint should warn me that a browser (without a secure context) can throw and the optional chaining will not save the day:
// Throws an exception in runtime with insecure origin
> caches?.has('anything');
VM262:1 Uncaught ReferenceError: caches is not defined
// Runs without exception in runtime (with secure and insecure origin)
window.caches?.has('anything');
What new ECMAScript feature does this rule relate to? Same for all new APIs which are on the global object.
What category of rule is this? (place an “X” next to just one item)
[x] Warns about a potential error (problem)
Why should this rule be included in ESLint (instead of a plugin)? I dont know. Are you willing to submit a pull request to implement this rule? No, sorry.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
The optional chaining ( ?. ) operator accesses an object's property or calls a function. If the object accessed or function called is ......
Read more >Optional chaining '?.' - The Modern JavaScript Tutorial
The optional chaining ?. is a safe way to access nested object properties, even if an intermediate property doesn't exist.
Read more >Documentation - TypeScript 3.7
Optional chaining is issue #16 on our issue tracker. For context, there have been over 23,000 issues on the TypeScript issue tracker since...
Read more >How To Enable Optional Chaining Within Your Javascript ...
The best way to describe optional chaining is to show a useful problem that it solves, dealing with JSON returned from an external...
Read more >Optional chaining, but for a variable? [duplicate] - Stack Overflow
Is it possible to do something where it prints undefined or something if the variable is not there instead of throwing an error?...
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
We aren’t moving forward with this, so closing.
Gotcha. I’m not sold on the need for this being a core rule, though. It doesn’t really seem to rise to the level of must-have for us.