Skip to content

Bug: method-signature-style autofix is not always safe #11806

@andreww2012

Description

@andreww2012

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://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/f7546f9569aeefe997623a2e9620ebacca45d2ab/src/createRule.ts#L51

Repro Code

Changing method definition style is not purely stylistic and may cause TypeScript to report more or fewer errors after the change. Therefore, the autofix cannot be considered safe (I expect autofixes not to alter logic) and I believe it should be downgraded to a suggestion.

How to reproduce:
1. Clone https://github.com/JoshuaKGoldberg/eslint-plugin-package-json
2. Set up the repo, run `pnpm typecheck` and ensure there are no errors
3. Change the method definition style at `src/createRule.ts#L51`
4. Run `pnpm typecheck` and observe new errors

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/method-signature-style": ["error", "property"],
  },
};

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

Autofix is enabled.

Actual Result

Autofix is disabled.

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugintriageWaiting for team members to take a look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions