Skip to content
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

eslint error 'NodeJS' is not defined no-undef #45

Open
huan opened this issue Feb 2, 2021 · 11 comments
Open

eslint error 'NodeJS' is not defined no-undef #45

huan opened this issue Feb 2, 2021 · 11 comments
Labels
bug Something isn't working

Comments

@huan
Copy link
Member

huan commented Feb 2, 2021

@typescript-eslint/parser@4 cause this problem. (related commit: 4d7265a)

Downgrade it to v3 @typescript-eslint/parser@3 to solve the problem.

See: https://stackoverflow.com/q/64089216/1123955

huan added a commit that referenced this issue Feb 2, 2021
@huan huan added the bug Something isn't working label Feb 2, 2021
@huan huan closed this as completed Feb 2, 2021
@huan huan reopened this Feb 9, 2021
@huan
Copy link
Member Author

huan commented Feb 9, 2021

Monitor this problem to see when the upstream will fix it. (or other solutions)

@leolivier
Copy link

Hi, still no solution for that bug?
I'm in 4.28.2 and still the issue is here... I'd rather not downgrade to v3

@huan
Copy link
Member Author

huan commented Jul 10, 2021

Unfortunately, I'm still working with v3 for all my projects...

Please let me know if you have any solutions, thanks and good luck!

@abarke
Copy link

abarke commented Jul 23, 2021

I also upgraded to @typescript-eslint/parser@4.28.4

Work around for me was just to add it as a global in .eslintrc.js:

"globals": {
  "NodeJS": true
},

@leolivier
Copy link

Thanks @abarke, I will try this.
Meanwhile I just added an eslint "no check" comment inside my code for this declaration and it worked.

@leolivier
Copy link

I confirm your trick is working for too @abarke, thanks!

@thany
Copy link

thany commented Sep 12, 2021

Workaround is working. But since .eslintrc doesn't allow comments, I cannot link this issue in there in a comment, allowing me to keep track of why that global is there.

I suppose my project will have that workaround years after the issue has been fixed, because I will not be remembering each and every workaround, and their corresponding issue number, by heart...

So I guess it's really important to get this problem fixed sooner rather than later, especially seeing how old it already is. Or release a fix that allows comments. But I prefer the former over the latter, tbh.

@ITenthusiasm
Copy link

@thany Strangely enough, if you name files under .eslintrc.json (instead of .eslintrc, you can add comments to the file.

@il3ven
Copy link

il3ven commented Jan 3, 2022

A proper solution will be to turn off no-undef rule for typescript files. We need this rule for js not ts. This makes sense as typescript handles undefined variables. The project will not build if there are undefined variables. Add the following to your config:

overrides: [
  {
    files: ['*.ts'],
    rules: {
      'no-undef': 'off'
    }
  }
]

This is the recommended method by TypeScript ESLint. See here: https://typescript-eslint.io/docs/linting/troubleshooting/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors

dayo09 added a commit to dayo09/ONE-vscode that referenced this issue Sep 2, 2022
This commit adds envs and globals to configurations to remove wrong errors.

NOTE

"node" in "env"  <-- Removes 'process' is undefined error
"mocha" in "env" <-- Removes 'test'/'suites' is undefined error
"Thenable" in "globals" <-- Removes 'Thenables' is undefined error. Thenable is defined in node_modules/@types/vscode
"NodeJS" in "gloabls" <-- Removes 'NodeJS' is undefined error. Ref Chatie/eslint-config#45

ONE-vscode-DCO-1.0-Signed-off-by: dayo09 <dayoung.lee@samsung.com>
llFreetimell pushed a commit to Samsung/ONE-vscode that referenced this issue Sep 6, 2022
This commit adds envs and globals to configurations to remove wrong errors.

NOTE

"node" in "env"  <-- Removes 'process' is undefined error
"mocha" in "env" <-- Removes 'test'/'suites' is undefined error
"Thenable" in "globals" <-- Removes 'Thenables' is undefined error. Thenable is defined in node_modules/@types/vscode
"NodeJS" in "gloabls" <-- Removes 'NodeJS' is undefined error. Ref Chatie/eslint-config#45

ONE-vscode-DCO-1.0-Signed-off-by: dayo09 <dayoung.lee@samsung.com>
@Sahillather002
Copy link

export const cryptoApi=createApi({
reducerPath:'cryptoApi',
baseQuery:fetchBaseQuery({baseUrl}),
endpoints:(builder)=({
getCrypto:builder.query({
query:()=>createRequest('/coins')
})
})
});

Error:
ERROR in [eslint]
src\services\cryptoApi.js
Line 17:16: 'builder' is not defined no-undef
Line 18:19: 'builder' is not defined no-undef

@miluoshi
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants