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: [switch-exhaustiveness-check] Some cases for member names are not being fixed properly #7768

Closed
4 tasks done
StyleShit opened this issue Oct 19, 2023 · 1 comment · Fixed by #7806
Closed
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@StyleShit
Copy link
Contributor

StyleShit commented Oct 19, 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.

Playground Link

https://typescript-eslint.io/play/#ts=4.9.3&showAST=es&fileType=.tsx&code=KYOwrgtgBAglDeAoKUBCUC8UCMAaZUA5AMIC0ATIZlOfigNoAGAIqQMyMC61bdUTAUVKIRKACxdqY-AF8RAE2ABjADYBDAE7AoSgPYgAzgBcoagFywRBgO4BLI0oAWUABRqAlAgJK1B7TAA6VAt4KCNHDV1rKBBgaIENSI0XQgA5XRNbCAAHFWAIUCNgeSgAT2AjC0D0Hz9CTzkZIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6ZAd0vzIAt6AHrwCGsZPkoA3RExTJafRGQDW6KImjQA9tEjgwAXxAGgA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Run the fixer and you'll notice the issue

Repro Code

enum A {
  B = 1,
  'C-2' = 2,
  [`D-3`] = 3,
  [`E-


  4`] = 4,
}

declare const a: A

switch (a) {
  case A.B: { throw new Error('Not implemented yet: A.B case') }
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/switch-exhaustiveness-check": ["error"],
  },
};

tsconfig

No response

Expected Result

Probably this?

switch (a) {
  case A.B: { throw new Error('Not implemented yet: A.B case') }
  case A['C-2']: { throw new Error('Not implemented yet: A[\'C-2\'] case') }
  case A['D-3']: { throw new Error('Not implemented yet: A[\'D-3\'] case') }
  case A[`E-


  4`]: { throw new Error('Not implemented yet: A[`E-


  4`] case') }
}

Actual Result

switch (a) {
  case A.B: { throw new Error('Not implemented yet: A.B case') }
  case A['C-2']: { throw new Error('Not implemented yet: A['C-2'] case') }
  case A['D-3']: { throw new Error('Not implemented yet: A['D-3'] case') }
  case A['E-


  4']: { throw new Error('Not implemented yet: A['E-


  4'] case') }
}

Additional Info

No response

@StyleShit StyleShit added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Oct 19, 2023
@JoshuaKGoldberg
Copy link
Member

Really, really amusing 😂. Nice spot. Thanks for investigating this thoroughly from #7691!

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Oct 19, 2023
@StyleShit StyleShit changed the title Bug: [switch-exhaustiveness-check] Some cases for member names are not covered Bug: [switch-exhaustiveness-check] Some cases for member names are not being fixed properly Oct 19, 2023
StyleShit added a commit to StyleShit/typescript-eslint that referenced this issue Oct 20, 2023
…ine or single quotes are not being fixed correctly

Closes typescript-eslint#7768
JoshuaKGoldberg pushed a commit that referenced this issue Nov 16, 2023
…ew line or single quotes are not being fixed correctly (#7806)

* feat(eslint-plugin): [switch-exhaustiveness-check] members with new line or single quotes are not being fixed correctly

Closes #7768

* cleanup

* oops

* wip wip

* maybe?

* idk why it was missing
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants