Skip to content

[naming-convention] method selector limits ability to control format of properties (vs memberLike) #1477

@G-Rath

Description

@G-Rath

The titles a bit average, but this relates a bit to #1475.

Basically, because of the overlap of memberLike & method, it's not possible to have allow properties that are assigned functions to have the PascelCase format without allowing public methods on classes to have that format too.

Repro

{
  "rules": {
    "@typescript-eslint/naming-convention": ["error", 
       { "selector": "memberLike", "format": ["camelCase"] },
       { "selector": "property", "format": ["camelCase", "PascalCase"] }
    ]
  }
}
class MyClass {
  public MyMethod(): void {
    //
  }
}

const o = {
  Literal(node): void {
    //
  }
};

Expected Result
MyClass#MyMethod is flagged as not being camelcase, while o#Literal is fine.

Actual Result
Both MyMethod & Literal are flagged as not being in camelcase.

Additional Info

Versions

Also tried against canary.

package version
@typescript-eslint/eslint-plugin 2.16.0
@typescript-eslint/parser 2.16.0
TypeScript 3.7.5
ESLint 6.8.0
node 12.14.1
npm 6.13.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    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