-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[no-restricted-globals] False positive with optional chaining #1090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thinking about it - this is happening for the same reason that #1104 is happening. They both rely upon scope analysis to determine variables in the program. |
Still happens to me on |
That would be because |
@bradzacher ok I get that. The weird thins is that it's happening to me when I reference it from a JSON object that has some data I imported. Example: import banks from './data/banks.json'
const getBankNameByCode = code => {
const selectedBank = banks.find(bank => bank.code === code);
return selectedBank?.name ?? ''; // error happens here.
} |
I am unable to repro this against master. typescript-eslint/packages/eslint-plugin/tests/eslint-rules/no-restricted-globals.test.ts Lines 33 to 42 in 10d86b1
|
@bradzacher thanks for checking. I'll dig in more on my side and report back here if anything. Maybe it's related to my specific project config for some reason. |
Uh oh!
There was an error while loading. Please reload this page.
I wasn't quite sure which should sub-project was appropriate for this issue. I am aware that strictly ts 3.7.0-beta isn't supported while TS 3.7 syntax is, but out of caution I thought to raise the issue as I couldn't see any other reports.
What code were you trying to parse?
What did you expect to happen?
That eslint would not emit any warnings nor errors
What actually happened?
Eslint emitted the following error:
Unexpected use of 'name' no-restricted-globals
This does not happen for all properties, but so far I've only been able to reproduce with properties called
name
.Versions
@typescript-eslint/parser
2.4.0
TypeScript
3.7.0-beta
(15 Oct 2019)ESLint
6.5.1
node
12.11.1
npm
6.11.3
yarn
1.19.1
The text was updated successfully, but these errors were encountered: