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

Bug: [no-unused-vars] still false positive if name is type/value merged and exported #7336

Closed
4 tasks done
Dannymx opened this issue Jul 27, 2023 · 2 comments
Closed
4 tasks done
Labels
external This issue is with another package, not typescript-eslint itself fix: user error issue was fixed by correcting the configuration / correcting the code

Comments

@Dannymx
Copy link

Dannymx commented Jul 27, 2023

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

I know that previously this bug issue was submitted related to false positives with types merged and exported, today I still see the same error in my own repo.

I've tried:

  • Updating all packages
  • Removing packages that could have interfered, so to narrow the issue to typescript-eslint only.
  • Tried to create a basic snippet where I'm seeing the error locally (vscode) onto TS Playground, but I don't see the error there, here's the link Playground

Is this a me problem or the issue still persists with the no-unused-vars rule?

The basic snippet lives in the repo linked, in this file ./lib/test.ts (screenshot below), the original code (and more complex) that was causing me problems lives in ./lib/OpenGraph.ts

image

Reproduction Repository Link

https://github.com/Dannymx/shockinglemon.com/tree/bug/no-unused-vars

Repro Steps

  1. clone the repo
  2. pnpm install
  3. pnpm lint
  4. open ./lib/test.ts in vscode (this is what I use and where I see the error too)
  5. Alternatively also open ./lib/OpenGraph.ts for a real code example where I'm seeing the error too

Versions

package version
@typescript-eslint/eslint-plugin 6.2.0
@typescript-eslint/parser 6.2.0
@typescript-eslint/scope-manager X.Y.Z
@typescript-eslint/typescript-estree X.Y.Z
@typescript-eslint/type-utils X.Y.Z
@typescript-eslint/utils X.Y.Z
TypeScript 5.1.6
ESLint 8.45.0
node v18.17.0
@Dannymx Dannymx added bug Something isn't working triage Waiting for maintainers to take a look labels Jul 27, 2023
@JoshuaKGoldberg JoshuaKGoldberg added external This issue is with another package, not typescript-eslint itself fix: user error issue was fixed by correcting the configuration / correcting the code and removed bug Something isn't working triage Waiting for maintainers to take a look labels Jul 27, 2023
@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Jul 27, 2023

The error doesn't reproduce in the playground: https://typescript-eslint.io/play/#ts=5.1.6&fileType=.tsx&code=C4TwDgpgBAQghgZwJYGMDyAjAVhFwoC8UA3gFBRTAQLABcUNATkgHYDmA3KQL5ekQAPMAHtG%2BUJFiJUAFXDQiAJVyiAJgB5yDYM3YAaLQApiUFnAC2EPQwA2AVzZRu9E2cv0mrTrYcedXpwBKQgA%2BKWR0bFxgUhCuIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tidmUQAmtAG4BDaKgyRE0aB2iRwYAL4hlQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false. Which means your code is doing something funky.

Furthermore, running pnpm lint or npx eslint lib/test.ts locally, we get this:

$ npx eslint lib/test.ts
=============

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <5.1.0

YOUR TYPESCRIPT VERSION: 5.1.6

Please only submit bug reports when using the officially supported version.

=============

/Users/josh/repos/shockinglemon.com/lib/test.ts
  7:6   error  'name' is defined but never used  @typescript-eslint/no-unused-vars
  7:12  error  'slug' is defined but never used  @typescript-eslint/no-unused-vars

If you check the pnpm-lock.yaml file, you'll see that @typescript-eslint/typescript-estree@5.59.11 shows up.

Then, npm ls @typescript-eslint/typescript-estree shows (among other output lines):

├─┬ eslint-config-next@13.4.12 -> ./node_modules/.pnpm/eslint-config-next@13.4.12_eslint@8.45.0_typescript@5.1.6/node_modules/eslint-config-next
│ └─┬ @typescript-eslint/parser@5.59.11 -> ./node_modules/.pnpm/@typescript-eslint+parser@5.59.11_eslint@8.45.0_typescript@5.1.6/node_modules/@typescript-eslint/parser

eslint-config-next will be fixed in vercel/next.js#52848. So this is external. Fun!

For now, you can use https://pnpm.io/package_json#pnpmoverrides.

@Dannymx
Copy link
Author

Dannymx commented Jul 28, 2023

For anybody else facing the same issue, here's what I added to package.json:

...
"pnpm": {
    "overrides": {
      "@typescript-eslint/typescript-estree": "^6.2.0",
      "@typescript-eslint/parser": "^6.2.0"
    }
  },
...

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2023
@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
external This issue is with another package, not typescript-eslint itself fix: user error issue was fixed by correcting the configuration / correcting the code
Projects
None yet
Development

No branches or pull requests

2 participants