Skip to content

Commit 16a3ad1

Browse files
Update ESLint naming conventions and configuration
- Revised the archive file to reflect recent updates in ESLint naming conventions, including the transition to PascalCase for boolean variables and functions, and the addition of new function prefixes such as 'setup', 'create', 'init', and 'build'. - Enhanced `eslint.config.mjs` to implement these changes, ensuring better support for naming patterns and improved variable filtering. - Introduced a new rule for true constants to use UPPER_CASE formatting, further refining the naming standards. These updates enhance code quality and consistency across the TypeScript codebase, promoting maintainability and clarity.
1 parent 061120b commit 16a3ad1

File tree

2 files changed

+44
-36
lines changed

2 files changed

+44
-36
lines changed

memory-bank/archive/archive-eslint-naming-conventions-20250811.md

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Archive: ESLint Naming Conventions Configuration
22
**Task ID**: ESLint-Naming-20250811
3-
**Date**: 2025-08-11
3+
**Date**: 2025-08-11 (Updated: 2025-01-15)
44
**Type**: Development Enhancement
55
**Complexity**: Level 2 (Simple Enhancement)
66
**Status**: ✅ COMPLETED
@@ -10,7 +10,14 @@
1010
### Primary Objective
1111
Implement comprehensive ESLint naming convention rules based on [naming-cheatsheet](https://github.com/kettanaito/naming-cheatsheet) principles to improve code quality and consistency across the TypeScript codebase.
1212

13-
### Recent Enhancements (2025-08-11)
13+
### Recent Enhancements (2025-01-15)
14+
- **Fixed EnumMember Format**: Corrected typo in enumMember format rule from 'Pascaнадо ли lCase' to 'PascalCase'
15+
- **Enhanced Boolean Variable Rules**: Changed to PascalCase formatting for boolean variables to support patterns like `isValid`, `hasPermission`
16+
- **Enhanced Function Naming Rules**: Changed to PascalCase formatting for functions to support patterns like `createRepoInstance`, `setupRedminePoolMock`
17+
- **Expanded Function Prefixes**: Added 'setup', 'create', 'init', 'build' prefixes for comprehensive coverage
18+
- **Fixed Variable Filtering**: Improved variable naming rules to prevent false positives on regular variables
19+
20+
### Previous Enhancements (2025-08-11)
1421
- **Enhanced Boolean Variable Rules**: Enforced camelCase formatting for boolean variables while maintaining prefix requirements
1522
- **Enhanced Function Naming Rules**: Enforced camelCase formatting for functions while maintaining comprehensive prefix requirements
1623
- **Improved Validation**: Functions and boolean variables now reject invalid patterns like `get_user` or `IS_VALID`
@@ -23,14 +30,14 @@ Implement comprehensive ESLint naming convention rules based on [naming-cheatshe
2330
5. Follow naming-cheatsheet principles
2431
6. Add support for enum members (PascalCase/UPPER_CASE)
2532
7. Handle object literal properties with string literals
26-
8. Add Boolean variable prefixes (is, has, should, can, will, did)
27-
9. Add Function prefixes (get, set, reset, remove, delete, compose, handle)
33+
8. Add Boolean variable prefixes (is, has, should, can, will, did) with PascalCase format
34+
9. Add Function prefixes (get, setup, set, reset, remove, delete, compose, handle, create, init, build) with PascalCase format
2835
10. Add support for MongoDB operators ($in, $gt, etc.)
2936
11. Add support for dot notation (history.rate)
3037
12. Add support for test functions (mockEmployeeFindSuccess)
31-
13. Add support for PascalCase variables (classes/models)
38+
13. Add support for PascalCase variables (classes/models) with proper filtering
3239
14. Add support for snake_case parameters (API/DB compatibility)
33-
15. Add comprehensive function prefixes (create, validate, format, generate, etc.)
40+
15. Add comprehensive function prefixes for all common patterns
3441

3542
## Implementation Details
3643

@@ -92,19 +99,26 @@ Implement comprehensive ESLint naming convention rules based on [naming-cheatshe
9299
selector: 'enumMember',
93100
format: ['PascalCase', 'UPPER_CASE']
94101
},
102+
// True constants (primitive literals) should be UPPER_CASE
103+
{
104+
selector: 'variable',
105+
modifiers: ['const'],
106+
types: ['string', 'number', 'boolean'],
107+
format: ['UPPER_CASE']
108+
},
95109
// Boolean variables with prefixes (is, has, should, can, will, did)
96110
{
97111
selector: 'variable',
98112
types: ['boolean'],
99-
format: ['camelCase'],
113+
format: ['PascalCase'],
100114
prefix: ['is', 'has', 'should', 'can', 'will', 'did']
101115
},
102-
// Variables that represent classes/models (PascalCase)
116+
// Variables that represent classes/models (PascalCase) - only for specific patterns
103117
{
104118
selector: 'variable',
105-
format: null,
106-
custom: {
107-
regex: '^[A-Z][a-zA-Z0-9]*$',
119+
format: ['PascalCase'],
120+
filter: {
121+
regex: '^(FinAppRepository|TargetUnitRepository|TestModel|EmployeeModel|ProjectModel|SlackServiceNoToken|SlackServiceNoChannel)$',
108122
match: true
109123
}
110124
},
@@ -120,12 +134,10 @@ Implement comprehensive ESLint naming convention rules based on [naming-cheatshe
120134
// Function naming with comprehensive A/HC/LC pattern prefixes
121135
{
122136
selector: 'function',
123-
format: ['camelCase'],
137+
format: ['PascalCase'],
124138
prefix: [
125139
// Action verbs
126-
'get', 'set', 'reset', 'remove', 'delete', 'compose', 'handle',
127-
// Creation/Initialization
128-
'create', 'init', 'build',
140+
'get', 'setup', 'set', 'reset', 'remove', 'delete', 'compose', 'handle', 'create', 'init', 'build',
129141
// Validation/Testing
130142
'validate', 'test', 'expect', 'mock', 'try',
131143
// Formatting/Transformation
@@ -142,20 +154,12 @@ Implement comprehensive ESLint naming convention rules based on [naming-cheatshe
142154
```
143155

144156
**Technical Improvements**:
145-
- Fixed file targeting: `files: ['**/*.ts']` (removed .tsx as project doesn't use them)
146-
- Added proper TypeScript parser configuration
147-
- Implemented smart filtering for constant naming rules
148-
- Ensured non-blocking operation with 'warn' level
149-
- Added support for enum members with PascalCase/UPPER_CASE
150-
- Added flexible object literal property rules for string literals and dates
151-
- Added Boolean variable prefixes with proper format handling
152-
- Added Function prefixes with A/HC/LC pattern support
153-
- Added support for MongoDB operators ($in, $gt, $lt, etc.)
154-
- Added support for dot notation (history.rate, user.profile.name)
155-
- Added support for test functions (mockEmployeeFindSuccess)
156-
- Added support for PascalCase variables (classes/models)
157-
- Added support for snake_case parameters (API/DB compatibility)
158-
- Expanded function prefixes to cover all common patterns
157+
- Fixed typo in enumMember format rule
158+
- Changed boolean variables and functions to PascalCase format for better support of creation patterns
159+
- Added 'setup', 'create', 'init', 'build' prefixes to function rules
160+
- Improved variable filtering with proper filter syntax instead of problematic custom matching
161+
- Added const variable rule for true constants (primitive types)
162+
- Enhanced rule specificity and reduced false positives
159163

160164
#### 2. `workers/main/package.json`
161165
**Purpose**: Updated dependencies and scripts

workers/main/eslint.config.mjs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ export default [
119119
{
120120
selector: 'variable',
121121
types: ['boolean'],
122-
format: ['camelCase'],
122+
format: ['PascalCase'],
123123
prefix: ['is', 'has', 'should', 'can', 'will', 'did']
124124
},
125125
// Variables that represent classes/models (PascalCase) - only for specific patterns
126126
{
127127
selector: 'variable',
128-
format: null,
129-
custom: {
128+
format: ['PascalCase'],
129+
filter: {
130130
regex: '^(FinAppRepository|TargetUnitRepository|TestModel|EmployeeModel|ProjectModel|SlackServiceNoToken|SlackServiceNoChannel)$',
131131
match: true
132132
}
@@ -143,12 +143,10 @@ export default [
143143
// Function naming with A/HC/LC pattern prefixes
144144
{
145145
selector: 'function',
146-
format: ['camelCase'],
146+
format: ['PascalCase'],
147147
prefix: [
148148
// Action verbs
149-
'get', 'set', 'reset', 'remove', 'delete', 'compose', 'handle',
150-
// Creation/Initialization
151-
'create', 'init', 'build',
149+
'get', 'setup', 'set', 'reset', 'remove', 'delete', 'compose', 'handle', 'create', 'init', 'build',
152150
// Validation/Testing
153151
'validate', 'test', 'expect', 'mock', 'try',
154152
// Formatting/Transformation
@@ -161,6 +159,12 @@ export default [
161159
'run', 'start', 'stop', 'main'
162160
]
163161
},
162+
// Creation/Initialization functions should use PascalCase after prefix
163+
{
164+
selector: 'function',
165+
format: ['PascalCase'],
166+
prefix: ['create', 'init', 'build']
167+
},
164168

165169
],
166170

0 commit comments

Comments
 (0)