eslint-plugin-react-naming-convention 1.53.0-next.0 → 1.53.1-beta.0
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/dist/index.js +22 -22
- package/dist/index.mjs +22 -22
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -50,7 +50,7 @@ const rules = { "react-naming-convention/context-name": "warn" };
|
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region package.json
|
|
52
52
|
var name = "eslint-plugin-react-naming-convention";
|
|
53
|
-
var version = "1.53.
|
|
53
|
+
var version = "1.53.1-beta.0";
|
|
54
54
|
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region src/utils/create-rule.ts
|
|
@@ -90,7 +90,7 @@ var component_name_default = createRule({
|
|
|
90
90
|
type: "problem",
|
|
91
91
|
defaultOptions: [...defaultOptions$2],
|
|
92
92
|
docs: { description: "Enforces naming conventions for components." },
|
|
93
|
-
messages: {
|
|
93
|
+
messages: { invalidComponentName: "A component name '{{name}}' does not match {{rule}}." },
|
|
94
94
|
schema: schema$2
|
|
95
95
|
},
|
|
96
96
|
name: RULE_NAME$4,
|
|
@@ -114,7 +114,7 @@ function create$4(context) {
|
|
|
114
114
|
const name$2 = id.name;
|
|
115
115
|
if (isValidName(name$2, options)) continue;
|
|
116
116
|
context.report({
|
|
117
|
-
messageId: "
|
|
117
|
+
messageId: "invalidComponentName",
|
|
118
118
|
node: id,
|
|
119
119
|
data: {
|
|
120
120
|
name: name$2,
|
|
@@ -128,7 +128,7 @@ function create$4(context) {
|
|
|
128
128
|
const name$2 = id.name;
|
|
129
129
|
if (isValidName(name$2, options)) continue;
|
|
130
130
|
context.report({
|
|
131
|
-
messageId: "
|
|
131
|
+
messageId: "invalidComponentName",
|
|
132
132
|
node: id,
|
|
133
133
|
data: {
|
|
134
134
|
name: name$2,
|
|
@@ -170,7 +170,7 @@ var context_name_default = createRule({
|
|
|
170
170
|
meta: {
|
|
171
171
|
type: "problem",
|
|
172
172
|
docs: { description: "Enforces context name to be a valid component name with the suffix `Context`." },
|
|
173
|
-
messages: {
|
|
173
|
+
messages: { invalidContextName: "A context name must be a valid component name with the suffix 'Context'." },
|
|
174
174
|
schema: []
|
|
175
175
|
},
|
|
176
176
|
name: RULE_NAME$3,
|
|
@@ -192,7 +192,7 @@ function create$3(context) {
|
|
|
192
192
|
}, __eslint_react_eff.identity).otherwise(() => null);
|
|
193
193
|
if (name$2 != null && __eslint_react_core.isComponentName(name$2) && name$2.endsWith("Context")) return;
|
|
194
194
|
context.report({
|
|
195
|
-
messageId: "
|
|
195
|
+
messageId: "invalidContextName",
|
|
196
196
|
node: id
|
|
197
197
|
});
|
|
198
198
|
} };
|
|
@@ -252,8 +252,8 @@ var filename_default = createRule({
|
|
|
252
252
|
defaultOptions: [...defaultOptions$1],
|
|
253
253
|
docs: { description: "Enforces consistent file naming conventions." },
|
|
254
254
|
messages: {
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
empty: "A file must have non-empty name.",
|
|
256
|
+
invalidCase: "A file with name '{{name}}' does not match {{rule}}. Rename it to '{{suggestion}}'."
|
|
257
257
|
},
|
|
258
258
|
schema: schema$1
|
|
259
259
|
},
|
|
@@ -278,14 +278,14 @@ function create$2(context) {
|
|
|
278
278
|
const [basename = "", ...rest] = node_path.default.basename(context.filename).split(".");
|
|
279
279
|
if (basename.length === 0) {
|
|
280
280
|
context.report({
|
|
281
|
-
messageId: "
|
|
281
|
+
messageId: "empty",
|
|
282
282
|
node
|
|
283
283
|
});
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
286
286
|
if (validate(basename)) return;
|
|
287
287
|
context.report({
|
|
288
|
-
messageId: "
|
|
288
|
+
messageId: "invalidCase",
|
|
289
289
|
node,
|
|
290
290
|
data: {
|
|
291
291
|
name: context.filename,
|
|
@@ -329,8 +329,8 @@ var filename_extension_default = createRule({
|
|
|
329
329
|
defaultOptions: [...defaultOptions],
|
|
330
330
|
docs: { description: "Enforces consistent file naming conventions." },
|
|
331
331
|
messages: {
|
|
332
|
-
|
|
333
|
-
|
|
332
|
+
missingJSXExtension: "Use {{extensions}} file extension for JSX files.",
|
|
333
|
+
unnecessaryJSXExtension: "Do not use {{extensions}} file extension for files without JSX."
|
|
334
334
|
},
|
|
335
335
|
schema
|
|
336
336
|
},
|
|
@@ -357,7 +357,7 @@ function create$1(context) {
|
|
|
357
357
|
const isJSXExt = extensions.includes(fileNameExt);
|
|
358
358
|
if (hasJSXNode && !isJSXExt) {
|
|
359
359
|
context.report({
|
|
360
|
-
messageId: "
|
|
360
|
+
messageId: "missingJSXExtension",
|
|
361
361
|
node: program,
|
|
362
362
|
data: { extensions: extensionsString }
|
|
363
363
|
});
|
|
@@ -367,7 +367,7 @@ function create$1(context) {
|
|
|
367
367
|
const ignoreFilesWithoutCode = (0, __eslint_react_eff.isObject)(options) && options.ignoreFilesWithoutCode === true;
|
|
368
368
|
if (!hasCode && ignoreFilesWithoutCode) return;
|
|
369
369
|
if (!hasJSXNode && isJSXExt && allow === "as-needed") context.report({
|
|
370
|
-
messageId: "
|
|
370
|
+
messageId: "unnecessaryJSXExtension",
|
|
371
371
|
node: program,
|
|
372
372
|
data: { extensions: extensionsString }
|
|
373
373
|
});
|
|
@@ -387,8 +387,8 @@ var use_state_default = createRule({
|
|
|
387
387
|
[Symbol.for("rule_features")]: RULE_FEATURES
|
|
388
388
|
},
|
|
389
389
|
messages: {
|
|
390
|
-
|
|
391
|
-
|
|
390
|
+
invalidAssignment: "useState should be destructured into a value and setter pair, e.g., const [state, setState] = useState(...).",
|
|
391
|
+
invalidSetterName: "The setter should be named 'set' followed by the capitalized state variable name, e.g., 'setState' for 'state'."
|
|
392
392
|
},
|
|
393
393
|
schema: []
|
|
394
394
|
},
|
|
@@ -403,7 +403,7 @@ function create(context) {
|
|
|
403
403
|
if (!isUseStateCall(node)) return;
|
|
404
404
|
if (node.parent.type !== __typescript_eslint_types.AST_NODE_TYPES.VariableDeclarator) {
|
|
405
405
|
context.report({
|
|
406
|
-
messageId: "
|
|
406
|
+
messageId: "invalidAssignment",
|
|
407
407
|
node
|
|
408
408
|
});
|
|
409
409
|
return;
|
|
@@ -411,7 +411,7 @@ function create(context) {
|
|
|
411
411
|
const id = __eslint_react_core.getInstanceId(node);
|
|
412
412
|
if (id?.type !== __typescript_eslint_types.AST_NODE_TYPES.ArrayPattern) {
|
|
413
413
|
context.report({
|
|
414
|
-
messageId: "
|
|
414
|
+
messageId: "invalidAssignment",
|
|
415
415
|
node: id ?? node
|
|
416
416
|
});
|
|
417
417
|
return;
|
|
@@ -419,7 +419,7 @@ function create(context) {
|
|
|
419
419
|
const [value, setter] = id.elements;
|
|
420
420
|
if (value == null || setter == null) {
|
|
421
421
|
context.report({
|
|
422
|
-
messageId: "
|
|
422
|
+
messageId: "invalidAssignment",
|
|
423
423
|
node: id
|
|
424
424
|
});
|
|
425
425
|
return;
|
|
@@ -427,7 +427,7 @@ function create(context) {
|
|
|
427
427
|
const setterName = (0, ts_pattern.match)(setter).with({ type: __typescript_eslint_types.AST_NODE_TYPES.Identifier }, (id$1) => id$1.name).otherwise(() => null);
|
|
428
428
|
if (setterName == null || !setterName.startsWith("set")) {
|
|
429
429
|
context.report({
|
|
430
|
-
messageId: "
|
|
430
|
+
messageId: "invalidSetterName",
|
|
431
431
|
node: setter
|
|
432
432
|
});
|
|
433
433
|
return;
|
|
@@ -441,14 +441,14 @@ function create(context) {
|
|
|
441
441
|
}).otherwise(() => null);
|
|
442
442
|
if (valueName == null) {
|
|
443
443
|
context.report({
|
|
444
|
-
messageId: "
|
|
444
|
+
messageId: "invalidSetterName",
|
|
445
445
|
node: value
|
|
446
446
|
});
|
|
447
447
|
return;
|
|
448
448
|
}
|
|
449
449
|
if ((0, string_ts.snakeCase)(setterName) !== `set_${valueName}`) {
|
|
450
450
|
context.report({
|
|
451
|
-
messageId: "
|
|
451
|
+
messageId: "invalidSetterName",
|
|
452
452
|
node: setter
|
|
453
453
|
});
|
|
454
454
|
return;
|
package/dist/index.mjs
CHANGED
|
@@ -31,7 +31,7 @@ const rules = { "react-naming-convention/context-name": "warn" };
|
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region package.json
|
|
33
33
|
var name = "eslint-plugin-react-naming-convention";
|
|
34
|
-
var version = "1.53.
|
|
34
|
+
var version = "1.53.1-beta.0";
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/utils/create-rule.ts
|
|
@@ -71,7 +71,7 @@ var component_name_default = createRule({
|
|
|
71
71
|
type: "problem",
|
|
72
72
|
defaultOptions: [...defaultOptions$2],
|
|
73
73
|
docs: { description: "Enforces naming conventions for components." },
|
|
74
|
-
messages: {
|
|
74
|
+
messages: { invalidComponentName: "A component name '{{name}}' does not match {{rule}}." },
|
|
75
75
|
schema: schema$2
|
|
76
76
|
},
|
|
77
77
|
name: RULE_NAME$4,
|
|
@@ -95,7 +95,7 @@ function create$4(context) {
|
|
|
95
95
|
const name$2 = id.name;
|
|
96
96
|
if (isValidName(name$2, options)) continue;
|
|
97
97
|
context.report({
|
|
98
|
-
messageId: "
|
|
98
|
+
messageId: "invalidComponentName",
|
|
99
99
|
node: id,
|
|
100
100
|
data: {
|
|
101
101
|
name: name$2,
|
|
@@ -109,7 +109,7 @@ function create$4(context) {
|
|
|
109
109
|
const name$2 = id.name;
|
|
110
110
|
if (isValidName(name$2, options)) continue;
|
|
111
111
|
context.report({
|
|
112
|
-
messageId: "
|
|
112
|
+
messageId: "invalidComponentName",
|
|
113
113
|
node: id,
|
|
114
114
|
data: {
|
|
115
115
|
name: name$2,
|
|
@@ -151,7 +151,7 @@ var context_name_default = createRule({
|
|
|
151
151
|
meta: {
|
|
152
152
|
type: "problem",
|
|
153
153
|
docs: { description: "Enforces context name to be a valid component name with the suffix `Context`." },
|
|
154
|
-
messages: {
|
|
154
|
+
messages: { invalidContextName: "A context name must be a valid component name with the suffix 'Context'." },
|
|
155
155
|
schema: []
|
|
156
156
|
},
|
|
157
157
|
name: RULE_NAME$3,
|
|
@@ -173,7 +173,7 @@ function create$3(context) {
|
|
|
173
173
|
}, identity).otherwise(() => null);
|
|
174
174
|
if (name$2 != null && ER.isComponentName(name$2) && name$2.endsWith("Context")) return;
|
|
175
175
|
context.report({
|
|
176
|
-
messageId: "
|
|
176
|
+
messageId: "invalidContextName",
|
|
177
177
|
node: id
|
|
178
178
|
});
|
|
179
179
|
} };
|
|
@@ -233,8 +233,8 @@ var filename_default = createRule({
|
|
|
233
233
|
defaultOptions: [...defaultOptions$1],
|
|
234
234
|
docs: { description: "Enforces consistent file naming conventions." },
|
|
235
235
|
messages: {
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
empty: "A file must have non-empty name.",
|
|
237
|
+
invalidCase: "A file with name '{{name}}' does not match {{rule}}. Rename it to '{{suggestion}}'."
|
|
238
238
|
},
|
|
239
239
|
schema: schema$1
|
|
240
240
|
},
|
|
@@ -259,14 +259,14 @@ function create$2(context) {
|
|
|
259
259
|
const [basename = "", ...rest] = path.basename(context.filename).split(".");
|
|
260
260
|
if (basename.length === 0) {
|
|
261
261
|
context.report({
|
|
262
|
-
messageId: "
|
|
262
|
+
messageId: "empty",
|
|
263
263
|
node
|
|
264
264
|
});
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
267
|
if (validate(basename)) return;
|
|
268
268
|
context.report({
|
|
269
|
-
messageId: "
|
|
269
|
+
messageId: "invalidCase",
|
|
270
270
|
node,
|
|
271
271
|
data: {
|
|
272
272
|
name: context.filename,
|
|
@@ -310,8 +310,8 @@ var filename_extension_default = createRule({
|
|
|
310
310
|
defaultOptions: [...defaultOptions],
|
|
311
311
|
docs: { description: "Enforces consistent file naming conventions." },
|
|
312
312
|
messages: {
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
missingJSXExtension: "Use {{extensions}} file extension for JSX files.",
|
|
314
|
+
unnecessaryJSXExtension: "Do not use {{extensions}} file extension for files without JSX."
|
|
315
315
|
},
|
|
316
316
|
schema
|
|
317
317
|
},
|
|
@@ -338,7 +338,7 @@ function create$1(context) {
|
|
|
338
338
|
const isJSXExt = extensions.includes(fileNameExt);
|
|
339
339
|
if (hasJSXNode && !isJSXExt) {
|
|
340
340
|
context.report({
|
|
341
|
-
messageId: "
|
|
341
|
+
messageId: "missingJSXExtension",
|
|
342
342
|
node: program,
|
|
343
343
|
data: { extensions: extensionsString }
|
|
344
344
|
});
|
|
@@ -348,7 +348,7 @@ function create$1(context) {
|
|
|
348
348
|
const ignoreFilesWithoutCode = isObject(options) && options.ignoreFilesWithoutCode === true;
|
|
349
349
|
if (!hasCode && ignoreFilesWithoutCode) return;
|
|
350
350
|
if (!hasJSXNode && isJSXExt && allow === "as-needed") context.report({
|
|
351
|
-
messageId: "
|
|
351
|
+
messageId: "unnecessaryJSXExtension",
|
|
352
352
|
node: program,
|
|
353
353
|
data: { extensions: extensionsString }
|
|
354
354
|
});
|
|
@@ -368,8 +368,8 @@ var use_state_default = createRule({
|
|
|
368
368
|
[Symbol.for("rule_features")]: RULE_FEATURES
|
|
369
369
|
},
|
|
370
370
|
messages: {
|
|
371
|
-
|
|
372
|
-
|
|
371
|
+
invalidAssignment: "useState should be destructured into a value and setter pair, e.g., const [state, setState] = useState(...).",
|
|
372
|
+
invalidSetterName: "The setter should be named 'set' followed by the capitalized state variable name, e.g., 'setState' for 'state'."
|
|
373
373
|
},
|
|
374
374
|
schema: []
|
|
375
375
|
},
|
|
@@ -384,7 +384,7 @@ function create(context) {
|
|
|
384
384
|
if (!isUseStateCall(node)) return;
|
|
385
385
|
if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) {
|
|
386
386
|
context.report({
|
|
387
|
-
messageId: "
|
|
387
|
+
messageId: "invalidAssignment",
|
|
388
388
|
node
|
|
389
389
|
});
|
|
390
390
|
return;
|
|
@@ -392,7 +392,7 @@ function create(context) {
|
|
|
392
392
|
const id = ER.getInstanceId(node);
|
|
393
393
|
if (id?.type !== AST_NODE_TYPES.ArrayPattern) {
|
|
394
394
|
context.report({
|
|
395
|
-
messageId: "
|
|
395
|
+
messageId: "invalidAssignment",
|
|
396
396
|
node: id ?? node
|
|
397
397
|
});
|
|
398
398
|
return;
|
|
@@ -400,7 +400,7 @@ function create(context) {
|
|
|
400
400
|
const [value, setter] = id.elements;
|
|
401
401
|
if (value == null || setter == null) {
|
|
402
402
|
context.report({
|
|
403
|
-
messageId: "
|
|
403
|
+
messageId: "invalidAssignment",
|
|
404
404
|
node: id
|
|
405
405
|
});
|
|
406
406
|
return;
|
|
@@ -408,7 +408,7 @@ function create(context) {
|
|
|
408
408
|
const setterName = match(setter).with({ type: AST_NODE_TYPES.Identifier }, (id$1) => id$1.name).otherwise(() => null);
|
|
409
409
|
if (setterName == null || !setterName.startsWith("set")) {
|
|
410
410
|
context.report({
|
|
411
|
-
messageId: "
|
|
411
|
+
messageId: "invalidSetterName",
|
|
412
412
|
node: setter
|
|
413
413
|
});
|
|
414
414
|
return;
|
|
@@ -422,14 +422,14 @@ function create(context) {
|
|
|
422
422
|
}).otherwise(() => null);
|
|
423
423
|
if (valueName == null) {
|
|
424
424
|
context.report({
|
|
425
|
-
messageId: "
|
|
425
|
+
messageId: "invalidSetterName",
|
|
426
426
|
node: value
|
|
427
427
|
});
|
|
428
428
|
return;
|
|
429
429
|
}
|
|
430
430
|
if (snakeCase(setterName) !== `set_${valueName}`) {
|
|
431
431
|
context.report({
|
|
432
|
-
messageId: "
|
|
432
|
+
messageId: "invalidSetterName",
|
|
433
433
|
node: setter
|
|
434
434
|
});
|
|
435
435
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "1.53.
|
|
3
|
+
"version": "1.53.1-beta.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"@typescript-eslint/utils": "^8.42.0",
|
|
50
50
|
"string-ts": "^2.2.1",
|
|
51
51
|
"ts-pattern": "^5.8.0",
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/eff": "1.53.
|
|
54
|
-
"@eslint-react/kit": "1.53.
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
52
|
+
"@eslint-react/core": "1.53.1-beta.0",
|
|
53
|
+
"@eslint-react/eff": "1.53.1-beta.0",
|
|
54
|
+
"@eslint-react/kit": "1.53.1-beta.0",
|
|
55
|
+
"@eslint-react/shared": "1.53.1-beta.0",
|
|
56
|
+
"@eslint-react/ast": "1.53.1-beta.0",
|
|
57
|
+
"@eslint-react/var": "1.53.1-beta.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/react": "^19.1.12",
|