eslint-plugin-react-naming-convention 1.47.1-next.1 → 1.47.2-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 +35 -8
- package/dist/index.mjs +36 -9
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ var rules = {
|
|
|
55
55
|
|
|
56
56
|
// package.json
|
|
57
57
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
58
|
-
var version = "1.47.
|
|
58
|
+
var version = "1.47.2-beta.0";
|
|
59
59
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("naming-convention"));
|
|
60
60
|
|
|
61
61
|
// src/rules/component-name.ts
|
|
@@ -417,25 +417,42 @@ var use_state_default = createRule({
|
|
|
417
417
|
defaultOptions: []
|
|
418
418
|
});
|
|
419
419
|
function create5(context) {
|
|
420
|
+
const alias = shared.getSettingsFromContext(context).additionalHooks.useState ?? [];
|
|
421
|
+
const isUseStateCall = ER2__namespace.isReactHookCallWithNameAlias(context, "useState", alias);
|
|
420
422
|
return {
|
|
421
|
-
|
|
423
|
+
CallExpression(node) {
|
|
424
|
+
if (!isUseStateCall(node)) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
422
427
|
if (node.parent.type !== types.AST_NODE_TYPES.VariableDeclarator) {
|
|
423
|
-
context.report({
|
|
428
|
+
context.report({
|
|
429
|
+
messageId: "missingDestructuring",
|
|
430
|
+
node
|
|
431
|
+
});
|
|
424
432
|
return;
|
|
425
433
|
}
|
|
426
434
|
const id = ER2__namespace.getInstanceId(node);
|
|
427
435
|
if (id?.type !== types.AST_NODE_TYPES.ArrayPattern) {
|
|
428
|
-
context.report({
|
|
436
|
+
context.report({
|
|
437
|
+
messageId: "missingDestructuring",
|
|
438
|
+
node: id ?? node
|
|
439
|
+
});
|
|
429
440
|
return;
|
|
430
441
|
}
|
|
431
442
|
const [value, setter] = id.elements;
|
|
432
443
|
if (value == null || setter == null) {
|
|
433
|
-
context.report({
|
|
444
|
+
context.report({
|
|
445
|
+
messageId: "missingDestructuring",
|
|
446
|
+
node: id
|
|
447
|
+
});
|
|
434
448
|
return;
|
|
435
449
|
}
|
|
436
450
|
const setterName = tsPattern.match(setter).with({ type: types.AST_NODE_TYPES.Identifier }, (id2) => id2.name).otherwise(() => null);
|
|
437
451
|
if (setterName == null || !setterName.startsWith("set")) {
|
|
438
|
-
context.report({
|
|
452
|
+
context.report({
|
|
453
|
+
messageId: "invalidSetterNaming",
|
|
454
|
+
node: setter
|
|
455
|
+
});
|
|
439
456
|
return;
|
|
440
457
|
}
|
|
441
458
|
const valueName = tsPattern.match(value).with({ type: types.AST_NODE_TYPES.Identifier }, ({ name: name3 }) => stringTs.snakeCase(name3)).with({ type: types.AST_NODE_TYPES.ObjectPattern }, ({ properties }) => {
|
|
@@ -447,8 +464,18 @@ function create5(context) {
|
|
|
447
464
|
}, []);
|
|
448
465
|
return values.join("_");
|
|
449
466
|
}).otherwise(() => null);
|
|
450
|
-
if (valueName == null
|
|
451
|
-
context.report({
|
|
467
|
+
if (valueName == null) {
|
|
468
|
+
context.report({
|
|
469
|
+
messageId: "invalidSetterNaming",
|
|
470
|
+
node: value
|
|
471
|
+
});
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (stringTs.snakeCase(setterName) !== `set_${valueName}`) {
|
|
475
|
+
context.report({
|
|
476
|
+
messageId: "invalidSetterNaming",
|
|
477
|
+
node: setter
|
|
478
|
+
});
|
|
452
479
|
return;
|
|
453
480
|
}
|
|
454
481
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as AST from '@eslint-react/ast';
|
|
2
2
|
import * as ER2 from '@eslint-react/core';
|
|
3
3
|
import { RE } from '@eslint-react/kit';
|
|
4
|
-
import { getDocsUrl } from '@eslint-react/shared';
|
|
4
|
+
import { getDocsUrl, getSettingsFromContext } from '@eslint-react/shared';
|
|
5
5
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
6
6
|
import { identity, isObject } from '@eslint-react/eff';
|
|
7
7
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
@@ -29,7 +29,7 @@ var rules = {
|
|
|
29
29
|
|
|
30
30
|
// package.json
|
|
31
31
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
32
|
-
var version = "1.47.
|
|
32
|
+
var version = "1.47.2-beta.0";
|
|
33
33
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("naming-convention"));
|
|
34
34
|
|
|
35
35
|
// src/rules/component-name.ts
|
|
@@ -391,25 +391,42 @@ var use_state_default = createRule({
|
|
|
391
391
|
defaultOptions: []
|
|
392
392
|
});
|
|
393
393
|
function create5(context) {
|
|
394
|
+
const alias = getSettingsFromContext(context).additionalHooks.useState ?? [];
|
|
395
|
+
const isUseStateCall = ER2.isReactHookCallWithNameAlias(context, "useState", alias);
|
|
394
396
|
return {
|
|
395
|
-
|
|
397
|
+
CallExpression(node) {
|
|
398
|
+
if (!isUseStateCall(node)) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
396
401
|
if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) {
|
|
397
|
-
context.report({
|
|
402
|
+
context.report({
|
|
403
|
+
messageId: "missingDestructuring",
|
|
404
|
+
node
|
|
405
|
+
});
|
|
398
406
|
return;
|
|
399
407
|
}
|
|
400
408
|
const id = ER2.getInstanceId(node);
|
|
401
409
|
if (id?.type !== AST_NODE_TYPES.ArrayPattern) {
|
|
402
|
-
context.report({
|
|
410
|
+
context.report({
|
|
411
|
+
messageId: "missingDestructuring",
|
|
412
|
+
node: id ?? node
|
|
413
|
+
});
|
|
403
414
|
return;
|
|
404
415
|
}
|
|
405
416
|
const [value, setter] = id.elements;
|
|
406
417
|
if (value == null || setter == null) {
|
|
407
|
-
context.report({
|
|
418
|
+
context.report({
|
|
419
|
+
messageId: "missingDestructuring",
|
|
420
|
+
node: id
|
|
421
|
+
});
|
|
408
422
|
return;
|
|
409
423
|
}
|
|
410
424
|
const setterName = match(setter).with({ type: AST_NODE_TYPES.Identifier }, (id2) => id2.name).otherwise(() => null);
|
|
411
425
|
if (setterName == null || !setterName.startsWith("set")) {
|
|
412
|
-
context.report({
|
|
426
|
+
context.report({
|
|
427
|
+
messageId: "invalidSetterNaming",
|
|
428
|
+
node: setter
|
|
429
|
+
});
|
|
413
430
|
return;
|
|
414
431
|
}
|
|
415
432
|
const valueName = match(value).with({ type: AST_NODE_TYPES.Identifier }, ({ name: name3 }) => snakeCase(name3)).with({ type: AST_NODE_TYPES.ObjectPattern }, ({ properties }) => {
|
|
@@ -421,8 +438,18 @@ function create5(context) {
|
|
|
421
438
|
}, []);
|
|
422
439
|
return values.join("_");
|
|
423
440
|
}).otherwise(() => null);
|
|
424
|
-
if (valueName == null
|
|
425
|
-
context.report({
|
|
441
|
+
if (valueName == null) {
|
|
442
|
+
context.report({
|
|
443
|
+
messageId: "invalidSetterNaming",
|
|
444
|
+
node: value
|
|
445
|
+
});
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
if (snakeCase(setterName) !== `set_${valueName}`) {
|
|
449
|
+
context.report({
|
|
450
|
+
messageId: "invalidSetterNaming",
|
|
451
|
+
node: setter
|
|
452
|
+
});
|
|
426
453
|
return;
|
|
427
454
|
}
|
|
428
455
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "1.47.
|
|
3
|
+
"version": "1.47.2-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.29.1",
|
|
50
50
|
"string-ts": "^2.2.1",
|
|
51
51
|
"ts-pattern": "^5.7.0",
|
|
52
|
-
"@eslint-react/ast": "1.47.
|
|
53
|
-
"@eslint-react/core": "1.47.
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
52
|
+
"@eslint-react/ast": "1.47.2-beta.0",
|
|
53
|
+
"@eslint-react/core": "1.47.2-beta.0",
|
|
54
|
+
"@eslint-react/eff": "1.47.2-beta.0",
|
|
55
|
+
"@eslint-react/shared": "1.47.2-beta.0",
|
|
56
|
+
"@eslint-react/kit": "1.47.2-beta.0",
|
|
57
|
+
"@eslint-react/var": "1.47.2-beta.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/react": "^19.1.1",
|