Skip to content

[no-unused-vars] throws "Node must be provided when reporting error if location is not provided" on string enum #2486

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

Closed
3 tasks done
Samox opened this issue Sep 4, 2020 · 2 comments
Labels
fix: user error issue was fixed by correcting the configuration / correcting the code package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@Samox
Copy link

Samox commented Sep 4, 2020

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro
I have added a failing test to my fork, you can check out the code Samox#1 and run cd packages/eslint-plugin && yarn test ./tests/eslint-rules/no-unused-vars.test.ts.

I'd be glad to fix the issue myself but have no idea how to do it.

I thought it would be easier with a failing test on your repo than a copy of package.json, tsconfig, etc.

Expected Result

String enum are properly parsed and the rule no-unused-vars does not throw "Node must be provided when reporting error if location is not provided" so we can easily find where the issue is.

Actual Result
I upgraded to typescript 4 and latest version of typescript-eslint. Eslint started throwing a "Node must be provided when reporting error if location is not provided". I had to add logs to eslint-plugin to understand where the issue was, it was an enum and I fixed the issue by removing the strings.

@Samox Samox added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Sep 4, 2020
@tadhgmister
Copy link
Contributor

tadhgmister commented Sep 4, 2020

You are testing the default eslint rule, not the typescript-eslint one, if you disable the eslint rule and enable ours it works correctly. see this and documentation

@bradzacher bradzacher added fix: user error issue was fixed by correcting the configuration / correcting the code and removed triage Waiting for team members to take a look labels Sep 4, 2020
@bradzacher
Copy link
Member

You ticked the box saying you have read the FAQ, but I don't think you did.
The first FAQ question explains what you should do if a base rule doesn't work.

https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-am-using-a-rule-from-eslint-core-and-it-doesnt-work-correctly-with-typescript-code

As @tadhgmister pointed out, there is an extension rule to use. Please reconfigure appropriately.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fix: user error issue was fixed by correcting the configuration / correcting the code package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants