Skip to content

[naming-convention] Precedence of property selector has been changed #2860

@susisu

Description

@susisu
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/naming-convention": [
      "error",
      {
        "selector": "memberLike",
        "format": ["camelCase"]
      },
      {
        "selector": "property",
        "format": ["camelCase", "PascalCase"]
      }
    ]
  }
}
const foo = { MyProperty: 42 };

Expected Result
Because typescript-eslint 4.8.2 doesn't report error for this, I expect typescript-eslint 4.9.x also doesn't report error.

Actual Result
The following error is reported.

  1:15  error  Object Literal Property name `MyProperty` must match one of the following formats: camelCase  @typescript-eslint/naming-convention

Previously property had a higher precedence than memberLike, but it is now a meta selector and the precedence seems to be lower (ref: #2807).

I know it works as expected if I use "selector": ["classProperty", "objectLiteralProperty", "typeProperty"] instead of "selector": "property", but I report this issue because it feels like a breaking change in a minor upgrade for me.

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 4.9.1
@typescript-eslint/parser 4.9.1
TypeScript 4.1.2
ESLint 7.15.0
node 14.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: 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