mm_sql 1.4.0 → 1.4.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 +6 -0
- package/admin_vs_direct_test.js +162 -0
- package/compatibility_test.js +320 -0
- package/comprehensive_test.js +304 -0
- package/db/mm.db +0 -0
- package/debug_error_test.js +127 -0
- package/debug_test.js +35 -0
- package/debug_test2.js +45 -0
- package/debug_test3.js +54 -0
- package/detailed_error_test.js +133 -0
- package/eslint.config.js +235 -0
- package/index.js +306 -297
- package/mysql_error_test.js +110 -0
- package/package.json +13 -5
- package/test.js +271 -222
- package/test2.js +53 -49
package/eslint.config.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const namingConventionPlugin = require('mm_eslint');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 基于个人规则的ESLint配置
|
|
7
|
+
* 符合最新ESLint Flat Config格式
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
module.exports = [
|
|
11
|
+
{
|
|
12
|
+
files: ['**/*.js'],
|
|
13
|
+
plugins: {
|
|
14
|
+
'naming-convention': namingConventionPlugin,
|
|
15
|
+
jsdoc: require('eslint-plugin-jsdoc'),
|
|
16
|
+
},
|
|
17
|
+
languageOptions: {
|
|
18
|
+
ecmaVersion: 'latest',
|
|
19
|
+
sourceType: 'module',
|
|
20
|
+
parserOptions: {
|
|
21
|
+
ecmaVersion: 'latest',
|
|
22
|
+
sourceType: 'module',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
// 命名规范规则 - 由自定义插件处理
|
|
27
|
+
rules: {
|
|
28
|
+
// 自定义命名规范插件规则(优先使用)
|
|
29
|
+
'naming-convention/class-name': 'error',
|
|
30
|
+
'naming-convention/function-name': 'error',
|
|
31
|
+
'naming-convention/method-name': 'error',
|
|
32
|
+
'naming-convention/variable-name': 'warn',
|
|
33
|
+
'naming-convention/constant-name': 'error',
|
|
34
|
+
'naming-convention/private-method-naming': 'warn',
|
|
35
|
+
'naming-convention/private-variable-naming': 'warn',
|
|
36
|
+
'naming-convention/param-name': 'warn',
|
|
37
|
+
'naming-convention/property-name': 'warn',
|
|
38
|
+
'naming-convention/instance-property': 'warn',
|
|
39
|
+
'naming-convention/prototype-method': 'error',
|
|
40
|
+
|
|
41
|
+
// 禁用与命名规范插件冲突的默认规则
|
|
42
|
+
camelcase: 'off',
|
|
43
|
+
'id-match': 'off',
|
|
44
|
+
'new-cap': 'off',
|
|
45
|
+
'id-length': 'off',
|
|
46
|
+
'id-denylist': 'off',
|
|
47
|
+
'id-blacklist': 'off',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
{
|
|
52
|
+
// 代码风格规则
|
|
53
|
+
rules: {
|
|
54
|
+
// 最大行长度100字符
|
|
55
|
+
'max-len': [
|
|
56
|
+
'error',
|
|
57
|
+
{
|
|
58
|
+
code: 100,
|
|
59
|
+
ignoreComments: true,
|
|
60
|
+
ignoreUrls: true,
|
|
61
|
+
ignoreStrings: true,
|
|
62
|
+
ignoreTemplateLiterals: true,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
|
|
66
|
+
// 缩进2空格
|
|
67
|
+
indent: [
|
|
68
|
+
'error',
|
|
69
|
+
2,
|
|
70
|
+
{
|
|
71
|
+
SwitchCase: 1,
|
|
72
|
+
VariableDeclarator: 1,
|
|
73
|
+
outerIIFEBody: 1,
|
|
74
|
+
MemberExpression: 1,
|
|
75
|
+
FunctionDeclaration: { parameters: 1, body: 1 },
|
|
76
|
+
FunctionExpression: { parameters: 1, body: 1 },
|
|
77
|
+
CallExpression: { arguments: 1 },
|
|
78
|
+
ArrayExpression: 1,
|
|
79
|
+
ObjectExpression: 1,
|
|
80
|
+
ImportDeclaration: 1,
|
|
81
|
+
flatTernaryExpressions: false,
|
|
82
|
+
ignoreComments: false,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
|
|
86
|
+
// 单引号
|
|
87
|
+
quotes: [
|
|
88
|
+
'error',
|
|
89
|
+
'single',
|
|
90
|
+
{
|
|
91
|
+
avoidEscape: true,
|
|
92
|
+
allowTemplateLiterals: true,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
|
|
96
|
+
// 禁止制表符
|
|
97
|
+
'no-tabs': 'error',
|
|
98
|
+
|
|
99
|
+
// 行尾分号
|
|
100
|
+
semi: ['error', 'always'],
|
|
101
|
+
|
|
102
|
+
// 逗号风格
|
|
103
|
+
'comma-style': ['error', 'last'],
|
|
104
|
+
|
|
105
|
+
// 逗号间距
|
|
106
|
+
'comma-spacing': [
|
|
107
|
+
'error',
|
|
108
|
+
{
|
|
109
|
+
before: false,
|
|
110
|
+
after: true,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
{
|
|
117
|
+
// 错误处理规则
|
|
118
|
+
rules: {
|
|
119
|
+
// 必须进行参数校验
|
|
120
|
+
'no-unused-vars': [
|
|
121
|
+
'error',
|
|
122
|
+
{
|
|
123
|
+
args: 'all',
|
|
124
|
+
caughtErrors: 'all',
|
|
125
|
+
ignoreRestSiblings: true,
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
|
|
129
|
+
// 建议使用try-catch
|
|
130
|
+
'no-unsafe-finally': 'warn',
|
|
131
|
+
|
|
132
|
+
// 禁止直接抛出字符串
|
|
133
|
+
'no-throw-literal': 'error',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
{
|
|
138
|
+
// 最佳实践规则
|
|
139
|
+
rules: {
|
|
140
|
+
// 优先使用async/await
|
|
141
|
+
'prefer-promise-reject-errors': 'error',
|
|
142
|
+
|
|
143
|
+
// 避免副作用
|
|
144
|
+
'no-param-reassign': [
|
|
145
|
+
'error',
|
|
146
|
+
{
|
|
147
|
+
props: true,
|
|
148
|
+
ignorePropertyModificationsFor: [
|
|
149
|
+
'acc', // for reduce accumulators
|
|
150
|
+
'accumulator', // for reduce accumulators
|
|
151
|
+
'e', // for e.returnvalue
|
|
152
|
+
'ctx', // for Koa routing
|
|
153
|
+
'context', // for Koa routing
|
|
154
|
+
'req', // for Express requests
|
|
155
|
+
'request', // for Express requests
|
|
156
|
+
'res', // for Express responses
|
|
157
|
+
'response', // for Express responses
|
|
158
|
+
'$scope', // for Angular 1 scopes
|
|
159
|
+
'staticContext', // for ReactRouter context
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
|
|
164
|
+
// 优先链式编程
|
|
165
|
+
'prefer-object-spread': 'error',
|
|
166
|
+
|
|
167
|
+
// 优先函数式编程
|
|
168
|
+
'prefer-arrow-callback': 'error',
|
|
169
|
+
|
|
170
|
+
// 方法长度限制
|
|
171
|
+
'max-lines-per-function': [
|
|
172
|
+
'warn',
|
|
173
|
+
{
|
|
174
|
+
max: 40,
|
|
175
|
+
skipBlankLines: true,
|
|
176
|
+
skipComments: true,
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
|
|
180
|
+
// 复杂度限制
|
|
181
|
+
complexity: ['warn', 10],
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
{
|
|
186
|
+
// JSDoc规则
|
|
187
|
+
rules: {
|
|
188
|
+
// 要求公开方法有JSDoc注释
|
|
189
|
+
'jsdoc/require-jsdoc': [
|
|
190
|
+
'warn',
|
|
191
|
+
{
|
|
192
|
+
publicOnly: true,
|
|
193
|
+
require: {
|
|
194
|
+
FunctionDeclaration: true,
|
|
195
|
+
MethodDefinition: true,
|
|
196
|
+
ClassDeclaration: true,
|
|
197
|
+
ArrowFunctionExpression: false,
|
|
198
|
+
FunctionExpression: false,
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
|
|
203
|
+
// 检查JSDoc语法
|
|
204
|
+
'jsdoc/check-alignment': 'warn',
|
|
205
|
+
'jsdoc/check-indentation': 'warn',
|
|
206
|
+
'jsdoc/check-param-names': 'warn',
|
|
207
|
+
'jsdoc/check-syntax': 'warn',
|
|
208
|
+
'jsdoc/check-tag-names': 'warn',
|
|
209
|
+
'jsdoc/check-types': 'warn',
|
|
210
|
+
'jsdoc/no-undefined-types': 'warn',
|
|
211
|
+
'jsdoc/require-description': 'warn',
|
|
212
|
+
'jsdoc/require-param': 'warn',
|
|
213
|
+
'jsdoc/require-param-description': 'warn',
|
|
214
|
+
'jsdoc/require-param-name': 'warn',
|
|
215
|
+
'jsdoc/require-param-type': 'warn',
|
|
216
|
+
'jsdoc/require-returns': 'warn',
|
|
217
|
+
'jsdoc/require-returns-check': 'warn',
|
|
218
|
+
'jsdoc/require-returns-description': 'warn',
|
|
219
|
+
'jsdoc/require-returns-type': 'warn',
|
|
220
|
+
'jsdoc/valid-types': 'warn',
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
{
|
|
225
|
+
// 忽略规则
|
|
226
|
+
ignores: [
|
|
227
|
+
'node_modules/**',
|
|
228
|
+
'dist/**',
|
|
229
|
+
'build/**',
|
|
230
|
+
'coverage/**',
|
|
231
|
+
'*.min.js',
|
|
232
|
+
'eslint.config.js'
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
];
|