Skip to content

Bug: @typescript-eslint/no-extra-parens applying erroneously to class extensions #5899

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
4 tasks done
phm07 opened this issue Oct 28, 2022 · 0 comments · Fixed by #5901
Closed
4 tasks done

Bug: @typescript-eslint/no-extra-parens applying erroneously to class extensions #5899

phm07 opened this issue Oct 28, 2022 · 0 comments · Fixed by #5901
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working formatting Related to whitespace/bracket formatting. We strongly recommend you use a formatter instead. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@phm07
Copy link

phm07 commented Oct 28, 2022

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.8.4&sourceType=module&code=MYGwhgzhAECiBuBTAdgF1gWwJatYgTtAN7QC+AsAFBUD0N0AAqgJ4AOiEw+WrqAtBxBY0NZAHsBAD1T4wfVmHwoIALmgBVZMkTAOERc2gKlaABYcO0RWICuyACbREk1kqhYxyKqEgwA+gAqbIj2CCjo2LgETtIo9jAAFGFomDh4hJBWyMwAlMRkVLT0BPhihJ7QAGZiICBiAO7CAObQQtoqRdA+UNBB7KFIKZHpAEwxeA4wyRFp0Zlg2fkUlEA&eslintrc=N4KABGBECmAeAu0B2ATAzpAXGA2uCU0aANgJZLyYBO0AxgPYC2jyK0KkANPhJAA7EArgHNymAALwAnnyK0qpPvAC0RMhQD0aeAtrxI+ALrdefAIZU00KliiSZchUtUly8DecvWu+fkNFIGNh4BHbSsmjyiipqbgYQxr6eVlQA8kqk9IG2oKH8VPQAVnT62JAAdBrwkVkAZqTC5YVoWT551QxI9cIASvT08AAipDZllfFgAL4mUAUDt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RbeshlaKinXSqWUnd9zdVGNOyFQ8GJvderQMnepO1AFGtXhAfR-c7ydDe85NiqNvBR7eT51kLR7g9XKfu8LkXoBDDWEOaWW-XeyndFLXKGV6eQO8jDrBqfuQQP7ycbBF2QwrVs7HsAIMilRCS8ooFTTQl30HH8Hl-cO-WCi03qNAmbQGYZGRviud5BvXK7Yn9yI8jqiwG50UUKQWvyofWayaMDuIYaDaFwiTWi2d3ZAKTJDdeSMH7r1DmROen5YHkHtjQbI+9eCwIOPFOWKCQyQxODWFgEY5r4GFJMIAA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkeAhpgObp4VQCiAygEwAMPAIyQANOBqQSeTMmhtK0gK7oxNKPFgATRRnaQAwgg1EAUl1HjaG7RgBK6ErFSKCxPUS3oLayPVSpYAHcuAE8iPAALVlkAEXQAM3odPABJJFhMPDIFTGVVCUwHJwA3dBNHIgBZLR0vHLzLKAdqm3QU8KxYRHYlFUbJAGtkRAAZZAAjfSjoAZ7cvp9YFxjkTD1NZCkAem8JVAn2AG1G2m5+IUhGgF182mR0zIAJdFRELGywXtuoR0VMaHQlXo3Xq6HEAF98pBkERoM5NHUwMcfCR-lsAFTojGXCA3cSQdAADzhigRR36HgRAH1rLUyOIriBwUA

Repro Code

class EventEmitter { }

// @typescript-eslint/no-extra-parens: Unnecessary parentheses around expression
class _TypedEventEmitter extends (EventEmitter as any) { }

// error on following line:
class TypedEventEmitter2 extends EventEmitter as any { }

ESLint Config

{
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/strict"
  ],
  "parser": "@typescript-eslint/parser",
  "plugins": [
    "@typescript-eslint"
  ],
  "parserOptions": {
    "project": "./tsconfig.json",
    "tsconfigRootDir": "./"
  },
  "root": true,
  "rules": {
    "@typescript-eslint/no-extra-parens": "warn"
  }
}

tsconfig

{
  "compilerOptions": {
    "target": "ES2021",
    "strict": true,
    "module": "CommonJS",
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "outDir": "dist/",
    "lib": [
      "ES2021"
    ],
    "importHelpers": true,
    "sourceMap": true
  },
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "node_modules"
  ]
}

Expected Result

no-extra-parens should not occur on this line because the parentheses are needed.

Actual Result

After applying rule there is an error.

Additional Info

No response

Versions

package version
@typescript-eslint/eslint-plugin 5.36.2
@typescript-eslint/parser 5.36.2
TypeScript 4.8.3
ESLint 8.23.0
node 18.11.0
@phm07 phm07 added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Oct 28, 2022
@bradzacher bradzacher added accepting prs Go ahead, send a pull request that resolves this issue formatting Related to whitespace/bracket formatting. We strongly recommend you use a formatter instead. and removed triage Waiting for team members to take a look labels Oct 28, 2022
yeonjuan added a commit to yeonjuan/typescript-eslint that referenced this issue Oct 29, 2022
@JoshuaKGoldberg JoshuaKGoldberg changed the title Bug: @typescript-eslint/no-extra-parens Bug: @typescript-eslint/no-extra-parens not applying to class extensions Oct 30, 2022
@JoshuaKGoldberg JoshuaKGoldberg changed the title Bug: @typescript-eslint/no-extra-parens not applying to class extensions Bug: @typescript-eslint/no-extra-parens applying erroneously to class extensions Oct 30, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2022
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 formatting Related to whitespace/bracket formatting. We strongly recommend you use a formatter instead. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants