mm_eslint 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -18
- package/README_EN.md +121 -14
- package/index.js +573 -96
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -10,16 +10,20 @@
|
|
|
10
10
|
- ✅ **变量名检测** - 小写蛇形命名法(snake_case)
|
|
11
11
|
- ✅ **常量名检测** - 大写蛇形命名法(UPPER_SNAKE_CASE)
|
|
12
12
|
- ✅ **私有成员检测** - 下划线开头的小写蛇形命名
|
|
13
|
+
- ✅ **入参名检测** - 小写蛇形命名法(snake_case)
|
|
14
|
+
- ✅ **属性名检测** - 基于值类型的多风格命名
|
|
13
15
|
- ✅ **长度限制** - 所有命名长度限制在1-20字符
|
|
14
16
|
- ✅ **单个单词优先** - 鼓励使用单个单词命名
|
|
17
|
+
- ✅ **单词长度限制** - 每个单词限制在最大8字符
|
|
15
18
|
- ✅ **禁止废话词** - 避免使用Manager、Handler等冗余词汇
|
|
19
|
+
- ✅ **JSDoc支持** - 集成JSDoc文档要求
|
|
16
20
|
|
|
17
21
|
## 安装
|
|
18
22
|
|
|
19
23
|
### npm安装
|
|
20
24
|
|
|
21
25
|
```bash
|
|
22
|
-
npm install
|
|
26
|
+
npm install mm_eslint --save-dev
|
|
23
27
|
```
|
|
24
28
|
|
|
25
29
|
### 本地安装
|
|
@@ -28,32 +32,100 @@ npm install mm-eslint-plugin --save-dev
|
|
|
28
32
|
|
|
29
33
|
```bash
|
|
30
34
|
# 复制插件文件到您的项目
|
|
31
|
-
cp
|
|
35
|
+
cp mm_eslint/index.js your-project/eslint-plugins/
|
|
32
36
|
```
|
|
33
37
|
|
|
34
38
|
## 快速开始
|
|
35
39
|
|
|
36
|
-
### 1.
|
|
40
|
+
### 1. 完整配置
|
|
37
41
|
|
|
38
42
|
在您的ESLint配置文件中引入插件:
|
|
39
43
|
|
|
40
44
|
```javascript
|
|
41
45
|
// eslint.config.js
|
|
42
|
-
const namingConventionPlugin = require('
|
|
46
|
+
const namingConventionPlugin = require('mm_eslint');
|
|
43
47
|
|
|
44
48
|
module.exports = [
|
|
45
49
|
{
|
|
46
50
|
files: ['**/*.js'],
|
|
47
51
|
plugins: {
|
|
48
|
-
'naming-convention': namingConventionPlugin
|
|
52
|
+
'naming-convention': namingConventionPlugin,
|
|
53
|
+
'jsdoc': require('eslint-plugin-jsdoc')
|
|
49
54
|
},
|
|
50
55
|
rules: {
|
|
56
|
+
// 自定义命名规范插件规则(优先使用)
|
|
51
57
|
'naming-convention/class-name': 'error',
|
|
52
58
|
'naming-convention/function-name': 'error',
|
|
53
59
|
'naming-convention/method-name': 'error',
|
|
54
60
|
'naming-convention/variable-name': 'warn',
|
|
55
61
|
'naming-convention/constant-name': 'error',
|
|
56
|
-
'naming-convention/private-naming': 'warn'
|
|
62
|
+
'naming-convention/private-naming': 'warn',
|
|
63
|
+
'naming-convention/param-name': 'warn',
|
|
64
|
+
'naming-convention/property-name': 'warn',
|
|
65
|
+
|
|
66
|
+
// 禁用与命名规范插件冲突的默认规则
|
|
67
|
+
'camelcase': 'off',
|
|
68
|
+
'id-match': 'off',
|
|
69
|
+
'new-cap': 'off',
|
|
70
|
+
'id-length': 'off',
|
|
71
|
+
'id-denylist': 'off',
|
|
72
|
+
'id-blacklist': 'off'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
{
|
|
77
|
+
// 代码风格规则
|
|
78
|
+
rules: {
|
|
79
|
+
'max-len': ['error', { code: 100 }],
|
|
80
|
+
'indent': ['error', 2],
|
|
81
|
+
'quotes': ['error', 'single'],
|
|
82
|
+
'no-tabs': 'error',
|
|
83
|
+
'semi': ['error', 'always']
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
{
|
|
88
|
+
// 错误处理规则
|
|
89
|
+
rules: {
|
|
90
|
+
'no-unused-vars': ['error', { args: 'all' }],
|
|
91
|
+
'no-unsafe-finally': 'warn',
|
|
92
|
+
'no-throw-literal': 'error'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
{
|
|
97
|
+
// 最佳实践规则
|
|
98
|
+
rules: {
|
|
99
|
+
'prefer-promise-reject-errors': 'error',
|
|
100
|
+
'no-param-reassign': 'error',
|
|
101
|
+
'prefer-object-spread': 'error',
|
|
102
|
+
'prefer-arrow-callback': 'error',
|
|
103
|
+
'max-lines-per-function': ['warn', { max: 40 }],
|
|
104
|
+
'complexity': ['warn', 10]
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
{
|
|
109
|
+
// JSDoc规则
|
|
110
|
+
rules: {
|
|
111
|
+
'jsdoc/require-jsdoc': ['warn', { publicOnly: true }],
|
|
112
|
+
'jsdoc/check-alignment': 'warn',
|
|
113
|
+
'jsdoc/check-indentation': 'warn',
|
|
114
|
+
'jsdoc/check-param-names': 'warn',
|
|
115
|
+
'jsdoc/check-syntax': 'warn',
|
|
116
|
+
'jsdoc/check-tag-names': 'warn',
|
|
117
|
+
'jsdoc/check-types': 'warn',
|
|
118
|
+
'jsdoc/no-undefined-types': 'warn',
|
|
119
|
+
'jsdoc/require-description': 'warn',
|
|
120
|
+
'jsdoc/require-param': 'warn',
|
|
121
|
+
'jsdoc/require-param-description': 'warn',
|
|
122
|
+
'jsdoc/require-param-name': 'warn',
|
|
123
|
+
'jsdoc/require-param-type': 'warn',
|
|
124
|
+
'jsdoc/require-returns': 'warn',
|
|
125
|
+
'jsdoc/require-returns-check': 'warn',
|
|
126
|
+
'jsdoc/require-returns-description': 'warn',
|
|
127
|
+
'jsdoc/require-returns-type': 'warn',
|
|
128
|
+
'jsdoc/valid-types': 'warn'
|
|
57
129
|
}
|
|
58
130
|
}
|
|
59
131
|
];
|
|
@@ -78,30 +150,32 @@ npx eslint --fix your-file.js
|
|
|
78
150
|
- **级别**: error
|
|
79
151
|
- **要求**: 大驼峰命名法(PascalCase)
|
|
80
152
|
- **长度**: 1-20字符
|
|
81
|
-
-
|
|
82
|
-
-
|
|
153
|
+
- **单词长度**: 每个单词≤8字符
|
|
154
|
+
- **示例**: `User`, `Product`
|
|
155
|
+
- **错误示例**: `UserConfiguration`, `ProductManagement`
|
|
83
156
|
|
|
84
157
|
### 函数名规则(function-name)
|
|
85
158
|
- **级别**: error
|
|
86
159
|
- **要求**: 小驼峰命名法(camelCase)
|
|
87
160
|
- **长度**: 1-20字符
|
|
161
|
+
- **单词长度**: 每个单词≤8字符
|
|
88
162
|
- **优先**: 单个单词
|
|
89
|
-
- **示例**: `
|
|
90
|
-
- **错误示例**: `
|
|
163
|
+
- **示例**: `get`, `getName`, `process`
|
|
164
|
+
- **错误示例**: `getConfiguration`, `processInformation`
|
|
91
165
|
|
|
92
166
|
### 方法名规则(method-name)
|
|
93
167
|
- **级别**: error
|
|
94
168
|
- **要求**: 小驼峰命名法(camelCase)
|
|
95
169
|
- **长度**: 1-20字符
|
|
170
|
+
- **单词长度**: 每个单词≤8字符
|
|
96
171
|
- **优先**: 单个单词
|
|
97
|
-
- **示例**: `
|
|
98
|
-
- **错误示例**: `
|
|
172
|
+
- **示例**: `add`, `setName`, `isValid`
|
|
173
|
+
- **错误示例**: `addConfiguration`, `validateAuthentication`
|
|
99
174
|
|
|
100
175
|
### 变量名规则(variable-name)
|
|
101
176
|
- **级别**: warn
|
|
102
177
|
- **要求**: 小写蛇形命名法(snake_case)
|
|
103
178
|
- **长度**: 1-20字符
|
|
104
|
-
- **优先**: 单个单词
|
|
105
179
|
- **示例**: `user_count`, `max_retry`
|
|
106
180
|
- **错误示例**: `userCount`, `MAX_RETRY`
|
|
107
181
|
|
|
@@ -119,22 +193,39 @@ npx eslint --fix your-file.js
|
|
|
119
193
|
- **示例**: `_user_count`, `_internal_data`
|
|
120
194
|
- **错误示例**: `userCount`, `_UserCount`
|
|
121
195
|
|
|
196
|
+
### 入参名规则(param-name)
|
|
197
|
+
- **级别**: warn
|
|
198
|
+
- **要求**: 小写蛇形命名法(snake_case)
|
|
199
|
+
- **长度**: 1-20字符
|
|
200
|
+
- **示例**: `user_name`, `max_count`
|
|
201
|
+
- **错误示例**: `userName`, `maxCount`
|
|
202
|
+
|
|
203
|
+
### 属性名规则(property-name)
|
|
204
|
+
- **级别**: warn
|
|
205
|
+
- **要求**: 基于值类型的多风格命名
|
|
206
|
+
- **长度**: 1-20字符
|
|
207
|
+
- **示例**: `user_name`(字符串), `getUser`(函数), `User`(类)
|
|
208
|
+
|
|
122
209
|
## 错误示例
|
|
123
210
|
|
|
124
211
|
```javascript
|
|
125
212
|
// ❌ 错误的命名示例
|
|
126
|
-
class
|
|
127
|
-
const
|
|
213
|
+
class UserConfiguration { // "Configuration"超过8字符
|
|
214
|
+
const getConfiguration = function() {}; // "Configuration"超过8字符
|
|
128
215
|
let maxRetryCount = 5; // 变量名应该小写蛇形
|
|
129
216
|
const userCount = 10; // 常量名应该大写蛇形
|
|
130
217
|
|
|
131
218
|
// ✅ 正确的命名示例
|
|
132
|
-
class
|
|
219
|
+
class User {
|
|
133
220
|
constructor() {
|
|
134
221
|
this._user_count = 0; // 私有属性正确
|
|
135
222
|
}
|
|
136
223
|
|
|
137
|
-
|
|
224
|
+
/**
|
|
225
|
+
* 获取用户数量
|
|
226
|
+
* @returns {number} 用户数量
|
|
227
|
+
*/
|
|
228
|
+
get() { // 方法名正确(单个单词≤8字符)
|
|
138
229
|
return this._user_count;
|
|
139
230
|
}
|
|
140
231
|
}
|
|
@@ -143,6 +234,15 @@ const MAX_RETRY = 5; // 常量名正确
|
|
|
143
234
|
let user_count = 10; // 变量名正确
|
|
144
235
|
```
|
|
145
236
|
|
|
237
|
+
## 单词长度验证
|
|
238
|
+
|
|
239
|
+
插件验证复合名称中的每个单词不超过8个字符:
|
|
240
|
+
|
|
241
|
+
- **有效**: `UserService`("User"=4, "Service"=7)
|
|
242
|
+
- **无效**: `UserConfiguration`("Configuration"=13 > 8)
|
|
243
|
+
- **有效**: `getUser`("get"=3, "User"=4)
|
|
244
|
+
- **无效**: `getConfiguration`("Configuration"=13 > 8)
|
|
245
|
+
|
|
146
246
|
## 配置选项
|
|
147
247
|
|
|
148
248
|
您可以通过配置自定义规则参数:
|
|
@@ -154,6 +254,7 @@ const customConfig = {
|
|
|
154
254
|
regex: /^[A-Z][a-zA-Z]*$/,
|
|
155
255
|
min: 1,
|
|
156
256
|
max: 25, // 扩展最大长度
|
|
257
|
+
single_word_len: 10, // 扩展单词长度限制
|
|
157
258
|
message: '类名{name}必须使用大驼峰命名法'
|
|
158
259
|
}
|
|
159
260
|
};
|
|
@@ -166,7 +267,7 @@ const detector = new NamingDetector(customConfig);
|
|
|
166
267
|
### 项目结构
|
|
167
268
|
|
|
168
269
|
```
|
|
169
|
-
|
|
270
|
+
mm_eslint/
|
|
170
271
|
├── index.js # 主插件文件
|
|
171
272
|
├── package.json # npm配置
|
|
172
273
|
├── eslint.config.js # ESLint配置
|
|
@@ -195,6 +296,12 @@ ISC License
|
|
|
195
296
|
|
|
196
297
|
## 更新日志
|
|
197
298
|
|
|
299
|
+
### v1.1.0
|
|
300
|
+
- 添加单词长度验证(每个单词最大8字符)
|
|
301
|
+
- 添加入参名和属性名检测
|
|
302
|
+
- 集成JSDoc文档要求
|
|
303
|
+
- 增强配置,包含完整的ESLint规则
|
|
304
|
+
|
|
198
305
|
### v1.0.0
|
|
199
306
|
- 初始版本发布
|
|
200
307
|
- 支持类名、函数名、方法名、变量名、常量名、私有成员命名规范检测
|
package/README_EN.md
CHANGED
|
@@ -10,9 +10,13 @@ An ESLint plugin based on personal naming conventions, supporting naming convent
|
|
|
10
10
|
- ✅ **Variable Name Detection** - snake_case naming convention
|
|
11
11
|
- ✅ **Constant Name Detection** - UPPER_SNAKE_CASE naming convention
|
|
12
12
|
- ✅ **Private Member Detection** - underscore-prefixed snake_case naming
|
|
13
|
+
- ✅ **Parameter Name Detection** - snake_case naming convention
|
|
14
|
+
- ✅ **Property Name Detection** - Multi-style naming based on value type
|
|
13
15
|
- ✅ **Length Restrictions** - All names limited to 1-20 characters
|
|
14
16
|
- ✅ **Single Word Preferred** - Encourages single word naming
|
|
17
|
+
- ✅ **Word Length Limit** - Each word limited to maximum 8 characters
|
|
15
18
|
- ✅ **Forbidden Words** - Avoids redundant words like Manager, Handler, etc.
|
|
19
|
+
- ✅ **JSDoc Support** - Integrated JSDoc documentation requirements
|
|
16
20
|
|
|
17
21
|
## Installation
|
|
18
22
|
|
|
@@ -33,7 +37,7 @@ cp mm-eslint-plugin/index.js your-project/eslint-plugins/
|
|
|
33
37
|
|
|
34
38
|
## Quick Start
|
|
35
39
|
|
|
36
|
-
### 1.
|
|
40
|
+
### 1. Complete Configuration
|
|
37
41
|
|
|
38
42
|
Import the plugin in your ESLint configuration file:
|
|
39
43
|
|
|
@@ -45,15 +49,83 @@ module.exports = [
|
|
|
45
49
|
{
|
|
46
50
|
files: ['**/*.js'],
|
|
47
51
|
plugins: {
|
|
48
|
-
'naming-convention': namingConventionPlugin
|
|
52
|
+
'naming-convention': namingConventionPlugin,
|
|
53
|
+
'jsdoc': require('eslint-plugin-jsdoc')
|
|
49
54
|
},
|
|
50
55
|
rules: {
|
|
56
|
+
// Custom naming convention rules (priority)
|
|
51
57
|
'naming-convention/class-name': 'error',
|
|
52
58
|
'naming-convention/function-name': 'error',
|
|
53
59
|
'naming-convention/method-name': 'error',
|
|
54
60
|
'naming-convention/variable-name': 'warn',
|
|
55
61
|
'naming-convention/constant-name': 'error',
|
|
56
|
-
'naming-convention/private-naming': 'warn'
|
|
62
|
+
'naming-convention/private-naming': 'warn',
|
|
63
|
+
'naming-convention/param-name': 'warn',
|
|
64
|
+
'naming-convention/property-name': 'warn',
|
|
65
|
+
|
|
66
|
+
// Disable conflicting default rules
|
|
67
|
+
'camelcase': 'off',
|
|
68
|
+
'id-match': 'off',
|
|
69
|
+
'new-cap': 'off',
|
|
70
|
+
'id-length': 'off',
|
|
71
|
+
'id-denylist': 'off',
|
|
72
|
+
'id-blacklist': 'off'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
{
|
|
77
|
+
// Code style rules
|
|
78
|
+
rules: {
|
|
79
|
+
'max-len': ['error', { code: 100 }],
|
|
80
|
+
'indent': ['error', 2],
|
|
81
|
+
'quotes': ['error', 'single'],
|
|
82
|
+
'no-tabs': 'error',
|
|
83
|
+
'semi': ['error', 'always']
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
{
|
|
88
|
+
// Error handling rules
|
|
89
|
+
rules: {
|
|
90
|
+
'no-unused-vars': ['error', { args: 'all' }],
|
|
91
|
+
'no-unsafe-finally': 'warn',
|
|
92
|
+
'no-throw-literal': 'error'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
{
|
|
97
|
+
// Best practices
|
|
98
|
+
rules: {
|
|
99
|
+
'prefer-promise-reject-errors': 'error',
|
|
100
|
+
'no-param-reassign': 'error',
|
|
101
|
+
'prefer-object-spread': 'error',
|
|
102
|
+
'prefer-arrow-callback': 'error',
|
|
103
|
+
'max-lines-per-function': ['warn', { max: 40 }],
|
|
104
|
+
'complexity': ['warn', 10]
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
{
|
|
109
|
+
// JSDoc rules
|
|
110
|
+
rules: {
|
|
111
|
+
'jsdoc/require-jsdoc': ['warn', { publicOnly: true }],
|
|
112
|
+
'jsdoc/check-alignment': 'warn',
|
|
113
|
+
'jsdoc/check-indentation': 'warn',
|
|
114
|
+
'jsdoc/check-param-names': 'warn',
|
|
115
|
+
'jsdoc/check-syntax': 'warn',
|
|
116
|
+
'jsdoc/check-tag-names': 'warn',
|
|
117
|
+
'jsdoc/check-types': 'warn',
|
|
118
|
+
'jsdoc/no-undefined-types': 'warn',
|
|
119
|
+
'jsdoc/require-description': 'warn',
|
|
120
|
+
'jsdoc/require-param': 'warn',
|
|
121
|
+
'jsdoc/require-param-description': 'warn',
|
|
122
|
+
'jsdoc/require-param-name': 'warn',
|
|
123
|
+
'jsdoc/require-param-type': 'warn',
|
|
124
|
+
'jsdoc/require-returns': 'warn',
|
|
125
|
+
'jsdoc/require-returns-check': 'warn',
|
|
126
|
+
'jsdoc/require-returns-description': 'warn',
|
|
127
|
+
'jsdoc/require-returns-type': 'warn',
|
|
128
|
+
'jsdoc/valid-types': 'warn'
|
|
57
129
|
}
|
|
58
130
|
}
|
|
59
131
|
];
|
|
@@ -78,30 +150,32 @@ npx eslint --fix your-file.js
|
|
|
78
150
|
- **Level**: error
|
|
79
151
|
- **Requirement**: PascalCase naming convention
|
|
80
152
|
- **Length**: 1-20 characters
|
|
81
|
-
- **
|
|
82
|
-
- **
|
|
153
|
+
- **Word Length**: Each word ≤8 characters
|
|
154
|
+
- **Examples**: `User`, `Product`
|
|
155
|
+
- **Invalid Examples**: `UserConfiguration`, `ProductManagement`
|
|
83
156
|
|
|
84
157
|
### Function Name Rule (function-name)
|
|
85
158
|
- **Level**: error
|
|
86
159
|
- **Requirement**: camelCase naming convention
|
|
87
160
|
- **Length**: 1-20 characters
|
|
161
|
+
- **Word Length**: Each word ≤8 characters
|
|
88
162
|
- **Preference**: Single word
|
|
89
|
-
- **Examples**: `
|
|
90
|
-
- **Invalid Examples**: `
|
|
163
|
+
- **Examples**: `get`, `getName`, `process`
|
|
164
|
+
- **Invalid Examples**: `getConfiguration`, `processInformation`
|
|
91
165
|
|
|
92
166
|
### Method Name Rule (method-name)
|
|
93
167
|
- **Level**: error
|
|
94
168
|
- **Requirement**: camelCase naming convention
|
|
95
169
|
- **Length**: 1-20 characters
|
|
170
|
+
- **Word Length**: Each word ≤8 characters
|
|
96
171
|
- **Preference**: Single word
|
|
97
|
-
- **Examples**: `
|
|
98
|
-
- **Invalid Examples**: `
|
|
172
|
+
- **Examples**: `add`, `setName`, `isValid`
|
|
173
|
+
- **Invalid Examples**: `addConfiguration`, `validateAuthentication`
|
|
99
174
|
|
|
100
175
|
### Variable Name Rule (variable-name)
|
|
101
176
|
- **Level**: warn
|
|
102
177
|
- **Requirement**: snake_case naming convention
|
|
103
178
|
- **Length**: 1-20 characters
|
|
104
|
-
- **Preference**: Single word
|
|
105
179
|
- **Examples**: `user_count`, `max_retry`
|
|
106
180
|
- **Invalid Examples**: `userCount`, `MAX_RETRY`
|
|
107
181
|
|
|
@@ -119,22 +193,39 @@ npx eslint --fix your-file.js
|
|
|
119
193
|
- **Examples**: `_user_count`, `_internal_data`
|
|
120
194
|
- **Invalid Examples**: `userCount`, `_UserCount`
|
|
121
195
|
|
|
196
|
+
### Parameter Name Rule (param-name)
|
|
197
|
+
- **Level**: warn
|
|
198
|
+
- **Requirement**: snake_case naming convention
|
|
199
|
+
- **Length**: 1-20 characters
|
|
200
|
+
- **Examples**: `user_name`, `max_count`
|
|
201
|
+
- **Invalid Examples**: `userName`, `maxCount`
|
|
202
|
+
|
|
203
|
+
### Property Name Rule (property-name)
|
|
204
|
+
- **Level**: warn
|
|
205
|
+
- **Requirement**: Multi-style naming based on value type
|
|
206
|
+
- **Length**: 1-20 characters
|
|
207
|
+
- **Examples**: `user_name` (string), `getUser` (function), `User` (class)
|
|
208
|
+
|
|
122
209
|
## Error Examples
|
|
123
210
|
|
|
124
211
|
```javascript
|
|
125
212
|
// ❌ Invalid naming examples
|
|
126
|
-
class
|
|
127
|
-
const
|
|
213
|
+
class UserConfiguration { // "Configuration" exceeds 8 characters
|
|
214
|
+
const getConfiguration = function() {}; // "Configuration" exceeds 8 characters
|
|
128
215
|
let maxRetryCount = 5; // Variable name should be snake_case
|
|
129
216
|
const userCount = 10; // Constant name should be UPPER_SNAKE_CASE
|
|
130
217
|
|
|
131
218
|
// ✅ Correct naming examples
|
|
132
|
-
class
|
|
219
|
+
class User {
|
|
133
220
|
constructor() {
|
|
134
221
|
this._user_count = 0; // Private property correct
|
|
135
222
|
}
|
|
136
223
|
|
|
137
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Get user count
|
|
226
|
+
* @returns {number} User count
|
|
227
|
+
*/
|
|
228
|
+
get() { // Method name correct (single word ≤8 chars)
|
|
138
229
|
return this._user_count;
|
|
139
230
|
}
|
|
140
231
|
}
|
|
@@ -143,6 +234,15 @@ const MAX_RETRY = 5; // Constant name correct
|
|
|
143
234
|
let user_count = 10; // Variable name correct
|
|
144
235
|
```
|
|
145
236
|
|
|
237
|
+
## Word Length Validation
|
|
238
|
+
|
|
239
|
+
The plugin validates that each word in compound names does not exceed 8 characters:
|
|
240
|
+
|
|
241
|
+
- **Valid**: `UserService` ("User"=4, "Service"=7)
|
|
242
|
+
- **Invalid**: `UserConfiguration` ("Configuration"=13 > 8)
|
|
243
|
+
- **Valid**: `getUser` ("get"=3, "User"=4)
|
|
244
|
+
- **Invalid**: `getConfiguration` ("Configuration"=13 > 8)
|
|
245
|
+
|
|
146
246
|
## Configuration Options
|
|
147
247
|
|
|
148
248
|
You can customize rule parameters through configuration:
|
|
@@ -154,6 +254,7 @@ const customConfig = {
|
|
|
154
254
|
regex: /^[A-Z][a-zA-Z]*$/,
|
|
155
255
|
min: 1,
|
|
156
256
|
max: 25, // Extend maximum length
|
|
257
|
+
single_word_len: 10, // Extend word length limit
|
|
157
258
|
message: 'Class name {name} must use PascalCase naming convention'
|
|
158
259
|
}
|
|
159
260
|
};
|
|
@@ -195,6 +296,12 @@ Welcome to submit Issues and Pull Requests to improve this plugin.
|
|
|
195
296
|
|
|
196
297
|
## Changelog
|
|
197
298
|
|
|
299
|
+
### v1.1.0
|
|
300
|
+
- Added word length validation (max 8 characters per word)
|
|
301
|
+
- Added parameter name and property name detection
|
|
302
|
+
- Integrated JSDoc documentation requirements
|
|
303
|
+
- Enhanced configuration with complete ESLint rules
|
|
304
|
+
|
|
198
305
|
### v1.0.0
|
|
199
306
|
- Initial version release
|
|
200
307
|
- Support for class name, function name, method name, variable name, constant name, and private member naming convention detection
|