From a770674ad5695ba861ae44c18106aacd368ec0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=89=E1=85=A1=E1=86=BC?= =?UTF-8?q?=E1=84=83=E1=85=AE?= Date: Mon, 5 May 2025 00:16:37 +0900 Subject: [PATCH 1/2] feat: naming-convention add enumMember PascalCase default option --- packages/eslint-plugin/src/rules/naming-convention.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/eslint-plugin/src/rules/naming-convention.ts b/packages/eslint-plugin/src/rules/naming-convention.ts index 03500d825163..20d80048f545 100644 --- a/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/packages/eslint-plugin/src/rules/naming-convention.ts @@ -60,6 +60,11 @@ const defaultCamelCaseAllTheThingsConfig: Options = [ format: ['PascalCase'], selector: 'typeLike', }, + + { + format: ['PascalCase'], + selector: 'enumMember', + }, ]; export default createRule({ From 4277e2afb373794285a24b243ba269c044d217fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=89=E1=85=A1=E1=86=BC?= =?UTF-8?q?=E1=84=83=E1=85=AE?= Date: Tue, 6 May 2025 15:43:38 +0900 Subject: [PATCH 2/2] test: add valid and invaild enum Member case --- .../naming-convention.test.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts b/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts index c43b293c686e..8ca4dc6014ad 100644 --- a/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts +++ b/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts @@ -1301,6 +1301,32 @@ ruleTester.run('naming-convention', rule, { }, ], }, + { + code: ` + const enum SearchIndexType { + title = 1, + heading = 2, + } + `, + errors: [ + { + data: { + formats: 'PascalCase', + name: 'title', + type: 'Enum Member', + }, + messageId: 'doesNotMatchFormat', + }, + { + data: { + formats: 'PascalCase', + name: 'heading', + type: 'Enum Member', + }, + messageId: 'doesNotMatchFormat', + }, + ], + }, ], valid: [ { @@ -2291,5 +2317,13 @@ ruleTester.run('naming-convention', rule, { }, ], }, + { + code: ` + const enum SearchIndexType { + Title = 1, + Heading = 2, + } + `, + }, ], });