Skip to content

[naming-convention] enumMembers should be default PascalCase #7879

@Mister-Hope

Description

@Mister-Hope

Before You File a Proposal Please Confirm You Have Done The Following...

Description

Code like this fails with the default option:

const enum SearchItemType {
  Page = 0,
  ID = 1,
}

const enum SearchIndexType {
  Title = 1,
  Heading = 2,
  Text = 3,
  Image = 4,
  Card = 5,
  Doc = 6,
}

However, I think using PascalCase for enum member should be the default option, as this is the default syntax in TypeScript official docs, blogs and examples.

E.g.:


Other things to report and could be a feature request

The problem is affecting me because we are not providing a keyword to enable the default naming convention and "make some tweaks over it". I.E.: In this case, I can not simply add the green line below, instead I have to redeclare the whole "option". That is not convinient for me accross projects.

Impacted Configurations

// the default config is similar to ESLint's camelcase rule but more strict
const defaultOptions: Options = [
  {
    selector: 'default',
    format: ['camelCase'],
    leadingUnderscore: 'allow',
    trailingUnderscore: 'allow',
  },

  {
    selector: 'import',
    format: ['camelCase', 'PascalCase'],
  },

  {
    selector: 'variable',
    format: ['camelCase', 'UPPER_CASE'],
    leadingUnderscore: 'allow',
    trailingUnderscore: 'allow',
  },

  {
    selector: 'typeLike',
    format: ['PascalCase'],
  },

+  {
+    selector: 'enumMember',
+    format: ['PascalCase'],
+  },
];

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginpreset config changeProposal for an addition, removal, or general change to a preset config

    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