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-extraneous-class triggered on abstract class that does not contain any static methods #9359

Closed
4 tasks done
cowwoc opened this issue Jun 14, 2024 · 1 comment · Fixed by #9367
Closed
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@cowwoc
Copy link

cowwoc commented Jun 14, 2024

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=5.4.5&fileType=.ts&code=LAKA9AVBoAQTAVAFgUxgYwPYDsBmBLAcwFcAnAQwBd8cYBnJc0lAExgCMBPGcgG15gA3PvhZVMpOgDoYAYUbZCKOjwAOq3t0qYYKAB7461RTAkxsKAO5CRY7ZKmwIYUOXZGK6Shl7k6KgHFeTHY%2BWRwCEgpqWgBvWBhIaBAYVPgAJRRKMmwVSlRdbCwWfBM6YnUJSlYOLQLq0gBbUr5HFLSEuBgAAWZs0lyYfLQUIswSsorVKpquIfqUJpbeTucE1WJ2Xnx0HndKT28lSgBlKZmWBEXm7D4AUTGJwjoACgBKAC4YE6yAHmxiI12IsAHwAblACSSqxgmX6g2GGDIzGw3gaNz4hWKpUIbVScBhvSyOTyBXQyNGaOuyyx4xxMBeLBQuHIxF4lDyOkRrO0AFomdUvDVRtjFG9Vi52hstjs9h5yF4YMcrktbrwHqLCO8vgCgYsISAoVAYT8OfM0OiaSK6SZMLhzaZiJQNpQ8WkYL9VCCYchDBhyNgOGhiHQatoYLgJOgLQUQ2g7TAAIIAOROAEkMJhgpIYJZUIHhvhSPRzqRvH7sJhvAKUEKWG6Ce0ut1VExyI1aU8YLyHZROKp4-brV38lRe9S1SXKmW6IS%2BiT5oZCflSJhLCoEP2UHdSKvi-h7b9iigQcOcb8wMeQTA-cRsEyCBY2GYAfwJetNttdm55YrQ5QVQxdVHhxF4z0UHVAWBUhPhgIIQjCCIiDIKgaGwA0AF9IRAfRpjLGBYjg4JQl4cI8GQ6I0JgDCwSAA&eslintrc=N4KABGBEAOA2CuBzAlgOwM6QFzjAbVwkgAEAXAT2gFN0BjAJ2WlIFobY1SB6U9D1UpFwBdADS5I9eLBrYwoCETKUaDJq3acuqAPZsAHqXoBDVFR3x0LWrGPpMWKFXr0d9IRAC%2BIT0A&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

/**
 * The configuration shared by all validators. Changes apply to existing or new validators.
 */
abstract class GlobalConfiguration {
  /**
   * Returns the encoding supported by the terminal.
   *
   * @returns the encoding supported by the terminal
   */
  public abstract getSupportedTerminalEncodings(): Set<number>;

  /**
   * Returns the current terminal encoding.
   *
   * @returns the current terminal encoding (defaults to the auto-detected encoding)
   */
  public abstract getTerminalEncoding(): number;

  /**
   * Sets the terminal encoding of the output.
   * <p>
   * This can be used to force the use of ANSI colors when their support is not detected.
   *
   * @param encoding - the type of encoding that the terminal supports
   * @returns this
   * @throws TypeError if <code>encoding</code> is undefined or null
   */
  public abstract setTerminalEncoding(encoding: number): GlobalConfiguration;
}

export { GlobalConfiguration };

ESLint Config

{
  "plugins":
  [
    "@typescript-eslint/tslint"
  ],
  "rules": {
    "@typescript-eslint/no-extraneous-class": "error"
  }
}

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

No error

Actual Result

Error claiming that the class only contains static properties, when in fact it does not contain even a single static property.

Additional Info

"@eslint/js": "^9.4.0",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"eslint": "^9.4.0",
"typescript-eslint": "^7.13.0",

@cowwoc cowwoc 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 Jun 14, 2024
@bradzacher bradzacher added accepting prs Go ahead, send a pull request that resolves this issue good first issue Good for newcomers and removed triage Waiting for team members to take a look labels Jun 15, 2024
@kirkwaiblinger
Copy link
Member

@cowwoc Thanks for the report!

For anyone that wants to take this on - I think the oversight in the rule implementation is simply that abstract fields/methods, which have different AST Nodes from their concrete counterparts, are not counted as instance properties. So, the fix would probably be just to address that. We'd still want an abstract class to flag if it actually only has static properties.

@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Jul 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 1, 2024
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 good first issue Good for newcomers locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants