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

args detected as import ? #100

Closed
jycouet opened this issue Sep 11, 2024 · 10 comments
Closed

args detected as import ? #100

jycouet opened this issue Sep 11, 2024 · 10 comments

Comments

@jycouet
Copy link

jycouet commented Sep 11, 2024

Hi,
I'm trying to go to ESLint v9, and started from scratch my config (not that easy bump).

I don't know why but with this config

rules: {
  'no-unused-vars': 'off',
  '@typescript-eslint/no-unused-vars': 'off',
  'unused-imports/no-unused-imports': 'error',
  'unused-imports/no-unused-vars': 'error',
}

I get this error:
image
image

I'm expecting to have unused-imports/no-unused-vars, but I don't get why I'm getting unused-imports/no-unused-imports (same position & variable)
event is not an import.

Do you have a default repro template for me to try reproducing it somewhere ?

Thank you for your help.

@antfu
Copy link
Collaborator

antfu commented Sep 12, 2024

Do you have a default repro template for me to try reproducing it somewhere ?

Sorry we don't. But I guess it shouldn't be hard to setup a basic node project to reproduce? I think we could not maintain repro template for every single plugin and keep them in sync.

From a glance I can't tell why it would happend. I'd appreciate a repro for us to investigate. Thanks

@jycouet
Copy link
Author

jycouet commented Sep 12, 2024

Thank you for the reply.

I did a repro https://github.com/jycouet/eslint-repro-unused-imports
But was not able to reproduce the issue! :(

I tried to go as close as my "big" repo (growing it step by step):

  • using decorator
  • using an external plugin @kitql/eslint-config that has eslint-plugin-unused-imports configured

On my side, it would be the variable titi that triggers unused-imports/no-unused-imports. But it's not an import, it's an arg of a function.

I also looked into ESLint Config Inspectorv0.5.4 (thx for this nice tool), and was able to explore rules & plugins & co... But didn't find where I'm screwing things.

Would you have an idea of where else should I explore ?
Is there a way to run the rule in debug mode so that I can trace what's the root cause ?

Let me know

@jycouet
Copy link
Author

jycouet commented Sep 12, 2024

I started to console.log to in the node_modules/ /index.mjs to see if I can find something.

And in the "wrong" report, parent is null. (In these lines https://github.com/sweepline/eslint-plugin-unused-imports/blob/master/src/rules/predicates.ts#L18-L26)

image

@antfu antfu closed this as completed in 7252cca Sep 12, 2024
@antfu
Copy link
Collaborator

antfu commented Sep 12, 2024

I don't know under what circumstances the parent would be null, but yeah, indeed, there was a bug on our side. Thanks.

@jycouet
Copy link
Author

jycouet commented Sep 13, 2024

Thank you, I'll test it ASAP 👍

jycouet added a commit to jycouet/kitql that referenced this issue Sep 13, 2024
@jycouet
Copy link
Author

jycouet commented Sep 13, 2024

Do you know when it will be released?

@antfu
Copy link
Collaborator

antfu commented Sep 13, 2024

It's released now. There was a release failure I didn't notice before going bed 😅

@jycouet
Copy link
Author

jycouet commented Sep 13, 2024

Haha, thx again ✌️

@mbrevda
Copy link

mbrevda commented Nov 4, 2024

Still seeing this on 4.1.4 with the error argument on catch blocks

@mbrevda
Copy link

mbrevda commented Nov 14, 2024

@antfu were you able to have a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants