Skip to content

[no-empty-function] Allow empty functions for overridden class functions #4919

@anton-johansson

Description

@anton-johansson
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages. (as far as xo goes)
  • I have read the FAQ and my problem is not listed.

Repro

I'm not exactly sure how my rule is configured, it comes from the XO package.

abstract class AbstractThing {
    protected reportStuff(): void {
        console.log("This reports a lot of stuff...");
    }
}

class MyThing {
    protected override reportStuff() {};
}

Here is my tsconfig:

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "jsx": "preserve",
    "lib": [
      "dom",
      "es2020"
    ],
    "baseUrl": "./",
    "moduleResolution": "node",
    "strict": true,
    "allowJs": true,
    "noEmit": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "isolatedModules": true,
    "removeComments": false,
    "preserveConstEnums": true,
    "sourceMap": true,
    "forceConsistentCasingInFileNames": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "resolveJsonModule": true,
    "noImplicitOverride": true,
    "incremental": true
  },
  "include": [
    "src/**/*",
    "test/**/*"
  ],
  "exclude": [
    "node_modules"
  ]
}

Expected Result

I expect the rule to not give me a warning, because it can be an actual use case to "disable" base-class functionality.

Actual Result

I get the classic warning "Unexpected empty method 'reportStuff'. (@typescript-eslint/no-empty-function)XO(@typescript-eslint/no-empty-function)" because the function is obviously empty, but the rule does not consider the (relatively new) override keyword.

Additional Info

None.

Versions

package version
@typescript-eslint/eslint-plugin 5.11.0
@typescript-eslint/parser 5.11.0
TypeScript 4.5.5
ESLint 8.14.0
node 16.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulegood first issueGood for newcomerspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy