mm_eslint 1.4.5 → 1.4.6
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 +26 -0
- package/README_EN.md +27 -1
- package/index.js +153 -297
- package/{config.js → lib/config.js} +59 -32
- package/lib/detector/class_instance_name.js +246 -0
- package/lib/detector/class_name.js +261 -0
- package/lib/detector/const_name.js +519 -0
- package/lib/detector/function_name.js +318 -0
- package/lib/detector/index.js +18 -0
- package/lib/detector/name.js +626 -0
- package/lib/detector/object_name.js +245 -0
- package/lib/detector/param_name.js +247 -0
- package/lib/detector/variable_name.js +286 -0
- package/lib/fix/class_fix.js +83 -0
- package/lib/fix/export_fix.js +169 -0
- package/lib/fix/function_fix.js +85 -0
- package/lib/fix/index.js +21 -0
- package/lib/fix/method_fix.js +82 -0
- package/lib/fix/param_fix.js +63 -0
- package/lib/fix/property_fix.js +93 -0
- package/lib/fix/variable_fix.js +134 -0
- package/lib/fix.js +160 -0
- package/{util.js → lib/util.js} +8 -0
- package/{validator.js → lib/validator.js} +3 -3
- package/package.json +10 -13
- package/detector.js +0 -1291
- package/eslint.config.js +0 -25
- package/fix.js +0 -441
- package/handler.js +0 -993
- /package/{corrector.js → lib/corrector.js} +0 -0
- /package/{tip.js → lib/tip.js} +0 -0
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/mm_eslint)
|
|
6
6
|
[](https://opensource.org/licenses/ISC)
|
|
7
7
|
[](https://nodejs.org/)
|
|
8
|
+
[](https://www.npmjs.com/package/mm_eslint)
|
|
9
|
+
[](https://gitee.com/qiuwenwu91/mm_eslint/stargazers)
|
|
8
10
|
|
|
9
11
|
## 功能特性
|
|
10
12
|
|
|
@@ -298,6 +300,30 @@ npm test
|
|
|
298
300
|
npm run lint
|
|
299
301
|
```
|
|
300
302
|
|
|
303
|
+
## 发布说明
|
|
304
|
+
|
|
305
|
+
### npm发布
|
|
306
|
+
|
|
307
|
+
插件已发布到npm,可以通过以下命令安装:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
npm install mm_eslint --save-dev
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### 版本管理
|
|
314
|
+
|
|
315
|
+
项目使用语义化版本控制(Semantic Versioning):
|
|
316
|
+
- **主版本号**:不兼容的API修改
|
|
317
|
+
- **次版本号**:向下兼容的功能性新增
|
|
318
|
+
- **修订号**:向下兼容的问题修正
|
|
319
|
+
|
|
320
|
+
### 发布流程
|
|
321
|
+
|
|
322
|
+
1. 更新版本号:`npm version patch|minor|major`
|
|
323
|
+
2. 运行测试:`npm test`
|
|
324
|
+
3. 代码检查:`npm run lint`
|
|
325
|
+
4. 发布到npm:`npm publish`
|
|
326
|
+
|
|
301
327
|
## 许可证
|
|
302
328
|
|
|
303
329
|
ISC License
|
package/README_EN.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# MM ESLint Plugin
|
|
2
2
|
|
|
3
|
-
ESLint plugin for personal naming conventions - supports PascalCase, camelCase, snake_case, and UPPER_SNAKE_CASE naming rules.
|
|
3
|
+
ESLint plugin for personal naming conventions - supports PascalCase, camelCase, snake_case, and UPPER_SNAKE_CASE naming rules with intelligent recommendations.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/mm_eslint)
|
|
6
6
|
[](https://opensource.org/licenses/ISC)
|
|
7
7
|
[](https://nodejs.org/)
|
|
8
|
+
[](https://www.npmjs.com/package/mm_eslint)
|
|
9
|
+
[](https://gitee.com/qiuwenwu91/mm_eslint/stargazers)
|
|
8
10
|
|
|
9
11
|
## Features
|
|
10
12
|
|
|
@@ -298,6 +300,30 @@ npm test
|
|
|
298
300
|
npm run lint
|
|
299
301
|
```
|
|
300
302
|
|
|
303
|
+
## Publishing Information
|
|
304
|
+
|
|
305
|
+
### npm Publishing
|
|
306
|
+
|
|
307
|
+
The plugin is published to npm and can be installed via:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
npm install mm_eslint --save-dev
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Version Management
|
|
314
|
+
|
|
315
|
+
Project uses Semantic Versioning:
|
|
316
|
+
- **Major version**: Incompatible API changes
|
|
317
|
+
- **Minor version**: Backward-compatible functionality additions
|
|
318
|
+
- **Patch version**: Backward-compatible bug fixes
|
|
319
|
+
|
|
320
|
+
### Publishing Process
|
|
321
|
+
|
|
322
|
+
1. Update version: `npm version patch|minor|major`
|
|
323
|
+
2. Run tests: `npm test`
|
|
324
|
+
3. Code linting: `npm run lint`
|
|
325
|
+
4. Publish to npm: `npm publish`
|
|
326
|
+
|
|
301
327
|
## License
|
|
302
328
|
|
|
303
329
|
ISC License
|
package/index.js
CHANGED
|
@@ -2,343 +2,199 @@
|
|
|
2
2
|
* ESLint命名规范检测插件
|
|
3
3
|
* 版本: 2.0.0 - 模块化重构版,职责分离
|
|
4
4
|
*/
|
|
5
|
-
const {
|
|
5
|
+
const { ClassName, ClassInstanceName, FunctionName, VariableName, ObjectName, ConstName, ParamName } = require('./lib/detector');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* 规则定义类
|
|
9
9
|
* 负责定义ESLint规则配置
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 构造函数
|
|
14
|
-
*/
|
|
15
|
-
constructor() {
|
|
16
|
-
this.handler = new Handler();
|
|
17
|
-
}
|
|
18
|
-
|
|
11
|
+
module.exports = {
|
|
19
12
|
/**
|
|
20
13
|
* 创建类名规则
|
|
21
14
|
* @returns {object} 类名规则配置
|
|
22
15
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
description: '检测类名是否符合命名规范',
|
|
31
|
-
category: 'Stylistic Issues',
|
|
32
|
-
recommended: true,
|
|
33
|
-
},
|
|
34
|
-
fixable: 'code',
|
|
35
|
-
schema: [],
|
|
16
|
+
'class-name': {
|
|
17
|
+
meta: {
|
|
18
|
+
type: 'suggestion',
|
|
19
|
+
docs: {
|
|
20
|
+
description: '检测类名是否符合命名规范',
|
|
21
|
+
category: 'Stylistic Issues',
|
|
22
|
+
recommended: true,
|
|
36
23
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
ExportDefaultDeclaration: function (node) {
|
|
52
|
-
handler.handleExportDefaultDeclaration(context, node, node, 'class');
|
|
53
|
-
},
|
|
54
|
-
ExportNamedDeclaration: function (node) {
|
|
55
|
-
handler.handleExportNamedDeclaration(context, node, node, 'class');
|
|
56
|
-
},
|
|
57
|
-
ClassExpression: function (node) {
|
|
58
|
-
handler.handleClassExpression(context, node, node, 'class');
|
|
59
|
-
},
|
|
60
|
-
ImportDeclaration: function (node) {
|
|
61
|
-
handler.handleImportDeclaration(context, node, node, 'class');
|
|
62
|
-
},
|
|
63
|
-
Identifier: function (node) {
|
|
64
|
-
handler.handleIdentifier(context, node, node, 'class');
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
}
|
|
24
|
+
fixable: 'code',
|
|
25
|
+
schema: [],
|
|
26
|
+
},
|
|
27
|
+
create: function (context) {
|
|
28
|
+
var cs = new ClassName(context);
|
|
29
|
+
let obj = {};
|
|
30
|
+
for (let key in cs) {
|
|
31
|
+
if (typeof cs[key] === 'function' && !key.startsWith('_')) {
|
|
32
|
+
obj[key] = cs[key].bind(cs);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return obj
|
|
36
|
+
}
|
|
37
|
+
},
|
|
70
38
|
|
|
71
39
|
/**
|
|
72
40
|
* 创建类实例名规则
|
|
73
41
|
* @returns {object} 类实例名规则配置
|
|
74
42
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
description: '检测类实例名是否符合命名规范',
|
|
83
|
-
category: 'Stylistic Issues',
|
|
84
|
-
recommended: true,
|
|
85
|
-
},
|
|
86
|
-
fixable: 'code',
|
|
87
|
-
schema: [],
|
|
43
|
+
'class-instance-name': {
|
|
44
|
+
meta: {
|
|
45
|
+
type: 'suggestion',
|
|
46
|
+
docs: {
|
|
47
|
+
description: '检测类实例名是否符合命名规范',
|
|
48
|
+
category: 'Stylistic Issues',
|
|
49
|
+
recommended: true,
|
|
88
50
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
51
|
+
fixable: 'code',
|
|
52
|
+
schema: [],
|
|
53
|
+
},
|
|
54
|
+
create: function (context) {
|
|
55
|
+
var cs = new ClassInstanceName(context);
|
|
56
|
+
let obj = {};
|
|
57
|
+
for (let key in cs) {
|
|
58
|
+
if (typeof cs[key] === 'function' && !key.startsWith('_')) {
|
|
59
|
+
obj[key] = cs[key].bind(cs);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return obj
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 创建对象名规则
|
|
68
|
+
* @returns {object} 对象名规则配置
|
|
69
|
+
*/
|
|
70
|
+
'object-name': {
|
|
71
|
+
meta: {
|
|
72
|
+
type: 'suggestion',
|
|
73
|
+
docs: {
|
|
74
|
+
description: '检测对象名是否符合命名规范',
|
|
75
|
+
category: 'Stylistic Issues',
|
|
76
|
+
recommended: true,
|
|
104
77
|
},
|
|
105
|
-
|
|
106
|
-
|
|
78
|
+
fixable: 'code',
|
|
79
|
+
schema: [],
|
|
80
|
+
},
|
|
81
|
+
create: function (context) {
|
|
82
|
+
var cs = new ObjectName(context);
|
|
83
|
+
let obj = {};
|
|
84
|
+
for (let key in cs) {
|
|
85
|
+
if (typeof cs[key] === 'function' && !key.startsWith('_')) {
|
|
86
|
+
obj[key] = cs[key].bind(cs);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return obj
|
|
90
|
+
}
|
|
91
|
+
},
|
|
107
92
|
|
|
108
93
|
/**
|
|
109
94
|
* 创建函数名规则
|
|
110
95
|
* @returns {object} 函数名规则配置
|
|
111
96
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
description: '检测函数名是否符合命名规范',
|
|
120
|
-
category: 'Stylistic Issues',
|
|
121
|
-
recommended: true,
|
|
122
|
-
},
|
|
123
|
-
fixable: 'code',
|
|
124
|
-
schema: [],
|
|
97
|
+
'function-name': {
|
|
98
|
+
meta: {
|
|
99
|
+
type: 'suggestion',
|
|
100
|
+
docs: {
|
|
101
|
+
description: '检测函数名是否符合命名规范',
|
|
102
|
+
category: 'Stylistic Issues',
|
|
103
|
+
recommended: true,
|
|
125
104
|
},
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
MethodDefinition: function (node) {
|
|
141
|
-
handler.handleMethodDefinition(context, node, node, 'function');
|
|
142
|
-
},
|
|
143
|
-
Property: function (node) {
|
|
144
|
-
handler.handleProperty(context, node, node, 'function');
|
|
145
|
-
},
|
|
146
|
-
PropertyDefinition: function (node) {
|
|
147
|
-
handler.handlePropertyDefinition(context, node, node, 'function');
|
|
148
|
-
},
|
|
149
|
-
AssignmentExpression: function (node) {
|
|
150
|
-
handler.handleAssignmentExpression(context, node, node, 'function');
|
|
151
|
-
},
|
|
152
|
-
VariableDeclaration: function (node) {
|
|
153
|
-
handler.handleVariableDeclaration(context, node, node, 'function');
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
}
|
|
105
|
+
fixable: 'code',
|
|
106
|
+
schema: [],
|
|
107
|
+
},
|
|
108
|
+
create: function (context) {
|
|
109
|
+
var cs = new FunctionName(context);
|
|
110
|
+
let obj = {};
|
|
111
|
+
for (let key in cs) {
|
|
112
|
+
if (typeof cs[key] === 'function' && !key.startsWith('_')) {
|
|
113
|
+
obj[key] = cs[key].bind(cs);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return obj
|
|
117
|
+
}
|
|
118
|
+
},
|
|
159
119
|
|
|
160
120
|
/**
|
|
161
121
|
* 创建变量名规则
|
|
162
122
|
* @returns {object} 变量名规则配置
|
|
163
123
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
description: '检测变量名是否符合命名规范',
|
|
172
|
-
category: 'Stylistic Issues',
|
|
173
|
-
recommended: true,
|
|
174
|
-
},
|
|
175
|
-
fixable: 'code',
|
|
176
|
-
schema: [],
|
|
177
|
-
},
|
|
178
|
-
create: function (context) {
|
|
179
|
-
return {
|
|
180
|
-
VariableDeclaration: function (node) {
|
|
181
|
-
handler.handleVariableDeclaration(context, node, node, 'variable');
|
|
182
|
-
},
|
|
183
|
-
ForStatement: function (node) {
|
|
184
|
-
if (node.init && node.init.type === 'VariableDeclaration') {
|
|
185
|
-
handler.handleVariableDeclaration(context, node, node.init, 'variable');
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
ForInStatement: function (node) {
|
|
189
|
-
if (node.left && node.left.type === 'VariableDeclaration') {
|
|
190
|
-
handler.handleVariableDeclaration(context, node, node.left, 'variable');
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
ForOfStatement: function (node) {
|
|
194
|
-
if (node.left && node.left.type === 'VariableDeclaration') {
|
|
195
|
-
handler.handleVariableDeclaration(context, node, node.left, 'variable');
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
Property: function (node) {
|
|
199
|
-
handler.handleProperty(context, node, node, 'variable');
|
|
200
|
-
},
|
|
201
|
-
PropertyDefinition: function (node) {
|
|
202
|
-
handler.handlePropertyDefinition(context, node, node, 'variable');
|
|
203
|
-
},
|
|
204
|
-
AssignmentExpression: function (node) {
|
|
205
|
-
handler.handleAssignmentExpression(context, node, node, 'variable');
|
|
206
|
-
}
|
|
207
|
-
};
|
|
124
|
+
'variable-name': {
|
|
125
|
+
meta: {
|
|
126
|
+
type: 'suggestion',
|
|
127
|
+
docs: {
|
|
128
|
+
description: '检测变量名是否符合命名规范',
|
|
129
|
+
category: 'Stylistic Issues',
|
|
130
|
+
recommended: true,
|
|
208
131
|
},
|
|
209
|
-
|
|
210
|
-
|
|
132
|
+
fixable: 'code',
|
|
133
|
+
schema: [],
|
|
134
|
+
},
|
|
135
|
+
create: function (context) {
|
|
136
|
+
var cs = new VariableName(context);
|
|
137
|
+
let obj = {};
|
|
138
|
+
for (let key in cs) {
|
|
139
|
+
if (typeof cs[key] === 'function' && !key.startsWith('_')) {
|
|
140
|
+
obj[key] = cs[key].bind(cs);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return obj
|
|
144
|
+
}
|
|
145
|
+
},
|
|
211
146
|
|
|
212
147
|
/**
|
|
213
148
|
* 创建常量名规则
|
|
214
149
|
* @returns {object} 常量名规则配置
|
|
215
150
|
*/
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
description: '检测常量名是否符合命名规范',
|
|
224
|
-
category: 'Stylistic Issues',
|
|
225
|
-
recommended: true,
|
|
226
|
-
},
|
|
227
|
-
fixable: 'code',
|
|
228
|
-
schema: [],
|
|
229
|
-
},
|
|
230
|
-
create: function (context) {
|
|
231
|
-
return {
|
|
232
|
-
VariableDeclaration: function (node) {
|
|
233
|
-
handler.handleVariableDeclaration(context, node, node, 'constant');
|
|
234
|
-
},
|
|
235
|
-
Property: function (node) {
|
|
236
|
-
handler.handleProperty(context, node, node, 'constant');
|
|
237
|
-
},
|
|
238
|
-
PropertyDefinition: function (node) {
|
|
239
|
-
handler.handlePropertyDefinition(context, node, node, 'constant');
|
|
240
|
-
},
|
|
241
|
-
AssignmentExpression: function (node) {
|
|
242
|
-
handler.handleAssignmentExpression(context, node, node, 'constant');
|
|
243
|
-
}
|
|
244
|
-
};
|
|
151
|
+
'constant-name': {
|
|
152
|
+
meta: {
|
|
153
|
+
type: 'suggestion',
|
|
154
|
+
docs: {
|
|
155
|
+
description: '检测常量名是否符合命名规范',
|
|
156
|
+
category: 'Stylistic Issues',
|
|
157
|
+
recommended: true,
|
|
245
158
|
},
|
|
246
|
-
|
|
247
|
-
|
|
159
|
+
fixable: 'code',
|
|
160
|
+
schema: [],
|
|
161
|
+
},
|
|
162
|
+
create: function (context) {
|
|
163
|
+
var cs = new ConstName(context);
|
|
164
|
+
let obj = {};
|
|
165
|
+
for (let key in cs) {
|
|
166
|
+
if (typeof cs[key] === 'function' && !key.startsWith('_')) {
|
|
167
|
+
obj[key] = cs[key].bind(cs);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return obj
|
|
171
|
+
}
|
|
172
|
+
},
|
|
248
173
|
|
|
249
174
|
/**
|
|
250
175
|
* 创建参数名规则
|
|
251
176
|
* @returns {object} 参数名规则配置
|
|
252
177
|
*/
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
description: '检测参数名是否符合命名规范',
|
|
261
|
-
category: 'Stylistic Issues',
|
|
262
|
-
recommended: true,
|
|
263
|
-
},
|
|
264
|
-
fixable: 'code',
|
|
265
|
-
schema: [],
|
|
266
|
-
},
|
|
267
|
-
create: function (context) {
|
|
268
|
-
return {
|
|
269
|
-
FunctionDeclaration: function (node) {
|
|
270
|
-
if (node.params && node.params.length > 0) {
|
|
271
|
-
for (var i = 0; i < node.params.length; i++) {
|
|
272
|
-
var param = node.params[i];
|
|
273
|
-
if (param.type === 'Identifier') {
|
|
274
|
-
var result = handler.detector.detect(param, param.name);
|
|
275
|
-
if (result) {
|
|
276
|
-
result.node = param;
|
|
277
|
-
result.fix = handler.fix.createParamFixFunction(context, param, result);
|
|
278
|
-
context.report(result);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
FunctionExpression: function (node) {
|
|
285
|
-
if (node.params && node.params.length > 0) {
|
|
286
|
-
for (var i = 0; i < node.params.length; i++) {
|
|
287
|
-
var param = node.params[i];
|
|
288
|
-
if (param.type === 'Identifier') {
|
|
289
|
-
var result = handler.detector.detect(param, param.name);
|
|
290
|
-
if (result) {
|
|
291
|
-
result.node = param;
|
|
292
|
-
result.fix = handler.fix.createParamFixFunction(context, param, result);
|
|
293
|
-
context.report(result);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
ArrowFunctionExpression: function (node) {
|
|
300
|
-
if (node.params && node.params.length > 0) {
|
|
301
|
-
for (var i = 0; i < node.params.length; i++) {
|
|
302
|
-
var param = node.params[i];
|
|
303
|
-
if (param.type === 'Identifier') {
|
|
304
|
-
var result = handler.detector.detect(param, param.name);
|
|
305
|
-
if (result) {
|
|
306
|
-
result.node = param;
|
|
307
|
-
result.fix = handler.fix.createParamFixFunction(context, param, result);
|
|
308
|
-
context.report(result);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
};
|
|
178
|
+
'param-name': {
|
|
179
|
+
meta: {
|
|
180
|
+
type: 'suggestion',
|
|
181
|
+
docs: {
|
|
182
|
+
description: '检测参数名是否符合命名规范',
|
|
183
|
+
category: 'Stylistic Issues',
|
|
184
|
+
recommended: true,
|
|
315
185
|
},
|
|
316
|
-
|
|
186
|
+
fixable: 'code',
|
|
187
|
+
schema: [],
|
|
188
|
+
},
|
|
189
|
+
create: function (context) {
|
|
190
|
+
var cs = new ParamName(context);
|
|
191
|
+
let obj = {};
|
|
192
|
+
for (let key in cs) {
|
|
193
|
+
if (typeof cs[key] === 'function' && !key.startsWith('_')) {
|
|
194
|
+
obj[key] = cs[key].bind(cs);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return obj
|
|
198
|
+
}
|
|
317
199
|
}
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* 获取所有规则
|
|
321
|
-
* @returns {object} 所有规则配置
|
|
322
|
-
*/
|
|
323
|
-
getAllRules() {
|
|
324
|
-
return {
|
|
325
|
-
'class-name': this.createClassNameRule(),
|
|
326
|
-
'class-instance-name': this.createClassInstanceNameRule(),
|
|
327
|
-
'function-name': this.createFunctionNameRule(),
|
|
328
|
-
'variable-name': this.createVariableNameRule(),
|
|
329
|
-
'constant-name': this.createConstantNameRule(),
|
|
330
|
-
'param-name': this.createParamNameRule()
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* 创建ESLint规则配置
|
|
337
|
-
* @returns {object} ESLint规则配置对象
|
|
338
|
-
*/
|
|
339
|
-
function createNamingRules() {
|
|
340
|
-
var rules = new Rules();
|
|
341
|
-
return rules.getAllRules();
|
|
342
200
|
}
|
|
343
|
-
|
|
344
|
-
module.exports = createNamingRules();
|