eslint-plugin-power-esrules 0.1.4 → 0.1.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/index.js
CHANGED
|
@@ -16,8 +16,8 @@ module.exports = {
|
|
|
16
16
|
"power-esrules/formatting-blank-lines": "error",
|
|
17
17
|
"power-esrules/no-default-props": "error",
|
|
18
18
|
"power-esrules/no-inline-callbacks-in-jsx": "error",
|
|
19
|
-
"power-esrules/id-naming-convention": "
|
|
20
|
-
"power-esrules/use-state-naming": "
|
|
19
|
+
"power-esrules/id-naming-convention": "warn",
|
|
20
|
+
"power-esrules/use-state-naming": "warn",
|
|
21
21
|
"power-esrules/class-to-functional": "error",
|
|
22
22
|
"power-esrules/import-sorting": "error",
|
|
23
23
|
"power-esrules/require-data-testid": "error",
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
const path = require("path");
|
|
13
13
|
|
|
14
|
+
const packetName = "power-linter";
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* Проверяет, является ли класс React компонентом
|
|
16
18
|
*/
|
|
@@ -182,7 +184,7 @@ module.exports = {
|
|
|
182
184
|
messages: {
|
|
183
185
|
shouldConvertToFunctional:
|
|
184
186
|
'Классовый компонент "{{componentName}}" подходит для конвертации в функциональный. ' +
|
|
185
|
-
|
|
187
|
+
`Запустите:node node_modules/${packetName}/scripts/classToFC/run-codemod.js {{filePath}}`,
|
|
186
188
|
},
|
|
187
189
|
},
|
|
188
190
|
|
|
@@ -127,9 +127,21 @@ function checkDestructuredProperties(node, context) {
|
|
|
127
127
|
variableName: name,
|
|
128
128
|
suggestedName,
|
|
129
129
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
/*
|
|
131
|
+
* OLD auto-fix:
|
|
132
|
+
* fix(fixer) {
|
|
133
|
+
* return fixer.replaceText(key, suggestedName);
|
|
134
|
+
* },
|
|
135
|
+
*/
|
|
136
|
+
suggest: [
|
|
137
|
+
{
|
|
138
|
+
messageId: 'suggestRenameTo',
|
|
139
|
+
data: { suggestedName },
|
|
140
|
+
fix(fixer) {
|
|
141
|
+
return fixer.replaceText(key, suggestedName);
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
133
145
|
});
|
|
134
146
|
}
|
|
135
147
|
}
|
|
@@ -145,12 +157,14 @@ module.exports = {
|
|
|
145
157
|
category: 'Stylistic Issues',
|
|
146
158
|
recommended: false,
|
|
147
159
|
},
|
|
148
|
-
fixable: 'code',
|
|
160
|
+
// fixable: 'code', // OLD: auto-fixable (eslint --fix)
|
|
161
|
+
hasSuggestions: true, // NEW: quick-fix suggestions (not applied by eslint --fix)
|
|
149
162
|
schema: [],
|
|
150
163
|
messages: {
|
|
151
164
|
idMustBeUppercase:
|
|
152
165
|
'Идентификаторы должны использовать "ID" в капсе. ' +
|
|
153
166
|
'Вместо "{{variableName}}" используйте "{{suggestedName}}"',
|
|
167
|
+
suggestRenameTo: 'Переименовать в "{{suggestedName}}"',
|
|
154
168
|
},
|
|
155
169
|
},
|
|
156
170
|
|
|
@@ -167,9 +181,21 @@ module.exports = {
|
|
|
167
181
|
variableName,
|
|
168
182
|
suggestedName,
|
|
169
183
|
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
184
|
+
/*
|
|
185
|
+
* OLD auto-fix:
|
|
186
|
+
* fix(fixer) {
|
|
187
|
+
* return fixer.replaceText(node.id, suggestedName);
|
|
188
|
+
* },
|
|
189
|
+
*/
|
|
190
|
+
suggest: [
|
|
191
|
+
{
|
|
192
|
+
messageId: 'suggestRenameTo',
|
|
193
|
+
data: { suggestedName },
|
|
194
|
+
fix(fixer) {
|
|
195
|
+
return fixer.replaceText(node.id, suggestedName);
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
],
|
|
173
199
|
});
|
|
174
200
|
}
|
|
175
201
|
if (node.id && node.id.type === 'ObjectPattern') {
|
|
@@ -193,9 +219,21 @@ module.exports = {
|
|
|
193
219
|
variableName: name,
|
|
194
220
|
suggestedName,
|
|
195
221
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
222
|
+
/*
|
|
223
|
+
* OLD auto-fix:
|
|
224
|
+
* fix(fixer) {
|
|
225
|
+
* return fixer.replaceText(param, suggestedName);
|
|
226
|
+
* },
|
|
227
|
+
*/
|
|
228
|
+
suggest: [
|
|
229
|
+
{
|
|
230
|
+
messageId: 'suggestRenameTo',
|
|
231
|
+
data: { suggestedName },
|
|
232
|
+
fix(fixer) {
|
|
233
|
+
return fixer.replaceText(param, suggestedName);
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
],
|
|
199
237
|
});
|
|
200
238
|
}
|
|
201
239
|
} else if (param.type === 'ObjectPattern') {
|
|
@@ -220,9 +258,21 @@ module.exports = {
|
|
|
220
258
|
variableName: name,
|
|
221
259
|
suggestedName,
|
|
222
260
|
},
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
261
|
+
/*
|
|
262
|
+
* OLD auto-fix:
|
|
263
|
+
* fix(fixer) {
|
|
264
|
+
* return fixer.replaceText(param, suggestedName);
|
|
265
|
+
* },
|
|
266
|
+
*/
|
|
267
|
+
suggest: [
|
|
268
|
+
{
|
|
269
|
+
messageId: 'suggestRenameTo',
|
|
270
|
+
data: { suggestedName },
|
|
271
|
+
fix(fixer) {
|
|
272
|
+
return fixer.replaceText(param, suggestedName);
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
],
|
|
226
276
|
});
|
|
227
277
|
}
|
|
228
278
|
} else if (param.type === 'ObjectPattern') {
|
|
@@ -243,9 +293,21 @@ module.exports = {
|
|
|
243
293
|
variableName: name,
|
|
244
294
|
suggestedName,
|
|
245
295
|
},
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
296
|
+
/*
|
|
297
|
+
* OLD auto-fix:
|
|
298
|
+
* fix(fixer) {
|
|
299
|
+
* return fixer.replaceText(node.key, suggestedName);
|
|
300
|
+
* },
|
|
301
|
+
*/
|
|
302
|
+
suggest: [
|
|
303
|
+
{
|
|
304
|
+
messageId: 'suggestRenameTo',
|
|
305
|
+
data: { suggestedName },
|
|
306
|
+
fix(fixer) {
|
|
307
|
+
return fixer.replaceText(node.key, suggestedName);
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
],
|
|
249
311
|
});
|
|
250
312
|
}
|
|
251
313
|
}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
const path = require("path");
|
|
9
9
|
|
|
10
|
+
const packetName = "power-linter";
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* Получает имя JSX элемента
|
|
12
14
|
*/
|
|
@@ -131,8 +133,8 @@ module.exports = {
|
|
|
131
133
|
messages: {
|
|
132
134
|
missingDataTestId:
|
|
133
135
|
"Корневой контейнер JSX не содержит атрибут data-testid. " +
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
`Запустите: node node_modules/${packetName}/scripts/addDataTestId/run-codemod.js {{filePath}}` +
|
|
137
|
+
` или node node_modules/${packetName}/scripts/addDataTestId/run-codemod.js src для всего проекта`,
|
|
136
138
|
},
|
|
137
139
|
},
|
|
138
140
|
|
|
@@ -60,12 +60,14 @@ module.exports = {
|
|
|
60
60
|
category: 'Stylistic Issues',
|
|
61
61
|
recommended: false,
|
|
62
62
|
},
|
|
63
|
-
fixable: 'code',
|
|
63
|
+
// fixable: 'code', // OLD: auto-fixable (eslint --fix)
|
|
64
|
+
hasSuggestions: true, // NEW: quick-fix suggestions (not applied by eslint --fix)
|
|
64
65
|
schema: [],
|
|
65
66
|
messages: {
|
|
66
67
|
useStateShouldEndWithState:
|
|
67
68
|
'Переменные useState должны иметь окончание "State". ' +
|
|
68
69
|
'Вместо "{{variableName}}" используйте "{{suggestedName}}"',
|
|
70
|
+
suggestRenameTo: 'Переименовать в "{{suggestedName}}"',
|
|
69
71
|
},
|
|
70
72
|
},
|
|
71
73
|
|
|
@@ -96,9 +98,21 @@ module.exports = {
|
|
|
96
98
|
variableName: stateName,
|
|
97
99
|
suggestedName,
|
|
98
100
|
},
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
/*
|
|
102
|
+
* OLD auto-fix:
|
|
103
|
+
* fix(fixer) {
|
|
104
|
+
* return fixer.replaceText(stateElement, suggestedName);
|
|
105
|
+
* },
|
|
106
|
+
*/
|
|
107
|
+
suggest: [
|
|
108
|
+
{
|
|
109
|
+
messageId: 'suggestRenameTo',
|
|
110
|
+
data: { suggestedName },
|
|
111
|
+
fix(fixer) {
|
|
112
|
+
return fixer.replaceText(stateElement, suggestedName);
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
],
|
|
102
116
|
});
|
|
103
117
|
}
|
|
104
118
|
}
|
|
@@ -116,9 +130,21 @@ module.exports = {
|
|
|
116
130
|
variableName: setterName,
|
|
117
131
|
suggestedName: expectedSetterName,
|
|
118
132
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
/*
|
|
134
|
+
* OLD auto-fix:
|
|
135
|
+
* fix(fixer) {
|
|
136
|
+
* return fixer.replaceText(setterElement, expectedSetterName);
|
|
137
|
+
* },
|
|
138
|
+
*/
|
|
139
|
+
suggest: [
|
|
140
|
+
{
|
|
141
|
+
messageId: 'suggestRenameTo',
|
|
142
|
+
data: { suggestedName: expectedSetterName },
|
|
143
|
+
fix(fixer) {
|
|
144
|
+
return fixer.replaceText(setterElement, expectedSetterName);
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
],
|
|
122
148
|
});
|
|
123
149
|
}
|
|
124
150
|
}
|