Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Bug: [naming-convention] typeMethod selector doesn't support function expressions  #6617

Copy link
Copy link
Closed
@kozlovvski

Description

@kozlovvski
Issue body actions

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&sourceType=module&code=C4TwDgpgBACgTgezAZygXigbwFBSgenygGME44JjgoA7AQwFsJlcoEaAxBBACgEoAXFABuCAJYATANyt2AITpwh-dAD4R46dlaEoYmqXKVq9JizwALOjQkAbCF16CNkmZet2ICpVBVp1oq7YAL5SQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6JgQwFtmBzWsgHsmAN0QtKw9GADa4bDkTRog6JAA08hVgXZIyREjL5V0yEVIBZRPgAWggCYatuyMWiIAZpQAe0ubquUi4KALqagTieqlwc+P6QAMr4VMYAChzIZBzwAMKZiJChIWAAvi7FEOWlQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

type Props = {
  // correct names
  onFoo(): void;
  onBar: () => void;

  // incorrect names
  handleFoo(): void;
  handleBar: () => void;
};

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/naming-convention": [
      "error",
      {
        "selector": "typeMethod",
        "prefix": [
          "on"
        ],
        "format": ["StrictPascalCase"]
      }
    ]
  },
};

tsconfig

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

Expected Result

Both handleFoo and handleBar should be marked as errors.

Actual Result

Only handleFoo is marked as an error.

Additional Info

The typeMethod selector should pick up every possible method syntax similarly to the objectLiteralMethod selector. Right now only TSMethodSignature nodes are picked up by the typeMethod selector, whereas it should also pickup TSPropertySignature nodes with typeAnnotation of TSFunctionType.

If you confirm this is a bug, I would be more than happy to create a PR with the fix 😄

References in code:

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.