eslint-plugin-react-naming-convention 1.36.0-next.2 → 1.36.1-next.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.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +9 -7
- package/dist/index.mjs +9 -7
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
import { RulePreset } from '@eslint-react/shared';
|
|
3
3
|
|
|
4
|
+
type MessageID$2 = "missingDestructuring" | "invalidSetterNaming";
|
|
5
|
+
|
|
4
6
|
type MessageID$1 = "useJsxFileExtension" | "useNonJsxFileExtension";
|
|
5
7
|
|
|
6
8
|
type MessageID = "filenameEmpty" | "filenameInvalid";
|
|
@@ -33,7 +35,7 @@ declare const _default: {
|
|
|
33
35
|
extensions?: readonly string[];
|
|
34
36
|
ignoreFilesWithoutCode?: boolean;
|
|
35
37
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
36
|
-
readonly "use-state": _typescript_eslint_utils_ts_eslint.RuleModule<
|
|
38
|
+
readonly "use-state": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
37
39
|
};
|
|
38
40
|
};
|
|
39
41
|
};
|
|
@@ -68,7 +70,7 @@ declare const _default: {
|
|
|
68
70
|
extensions?: readonly string[];
|
|
69
71
|
ignoreFilesWithoutCode?: boolean;
|
|
70
72
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
71
|
-
readonly "use-state": _typescript_eslint_utils_ts_eslint.RuleModule<
|
|
73
|
+
readonly "use-state": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
72
74
|
};
|
|
73
75
|
};
|
|
74
76
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
import { RulePreset } from '@eslint-react/shared';
|
|
3
3
|
|
|
4
|
+
type MessageID$2 = "missingDestructuring" | "invalidSetterNaming";
|
|
5
|
+
|
|
4
6
|
type MessageID$1 = "useJsxFileExtension" | "useNonJsxFileExtension";
|
|
5
7
|
|
|
6
8
|
type MessageID = "filenameEmpty" | "filenameInvalid";
|
|
@@ -33,7 +35,7 @@ declare const _default: {
|
|
|
33
35
|
extensions?: readonly string[];
|
|
34
36
|
ignoreFilesWithoutCode?: boolean;
|
|
35
37
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
36
|
-
readonly "use-state": _typescript_eslint_utils_ts_eslint.RuleModule<
|
|
38
|
+
readonly "use-state": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
37
39
|
};
|
|
38
40
|
};
|
|
39
41
|
};
|
|
@@ -68,7 +70,7 @@ declare const _default: {
|
|
|
68
70
|
extensions?: readonly string[];
|
|
69
71
|
ignoreFilesWithoutCode?: boolean;
|
|
70
72
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
71
|
-
readonly "use-state": _typescript_eslint_utils_ts_eslint.RuleModule<
|
|
73
|
+
readonly "use-state": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
72
74
|
};
|
|
73
75
|
};
|
|
74
76
|
|
package/dist/index.js
CHANGED
|
@@ -49,7 +49,7 @@ var rules = {};
|
|
|
49
49
|
|
|
50
50
|
// package.json
|
|
51
51
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
52
|
-
var version = "1.36.
|
|
52
|
+
var version = "1.36.1-next.0";
|
|
53
53
|
var createRule = shared.createRuleForPlugin("naming-convention");
|
|
54
54
|
|
|
55
55
|
// src/utils/regexp.ts
|
|
@@ -411,7 +411,8 @@ var use_state_default = createRule({
|
|
|
411
411
|
[Symbol.for("rule_features")]: RULE_FEATURES
|
|
412
412
|
},
|
|
413
413
|
messages: {
|
|
414
|
-
|
|
414
|
+
invalidSetterNaming: "The setter should be named 'set' followed by the capitalized state variable name, e.g., 'setState' for 'state'.",
|
|
415
|
+
missingDestructuring: "useState should be destructured into a value and setter pair, e.g., const [state, setState] = useState(...)."
|
|
415
416
|
},
|
|
416
417
|
schema: []
|
|
417
418
|
},
|
|
@@ -423,21 +424,22 @@ function create5(context) {
|
|
|
423
424
|
return {
|
|
424
425
|
"CallExpression[callee.name='useState']"(node) {
|
|
425
426
|
if (node.parent.type !== types.AST_NODE_TYPES.VariableDeclarator) {
|
|
426
|
-
context.report({ messageId: "
|
|
427
|
+
context.report({ messageId: "missingDestructuring", node });
|
|
428
|
+
return;
|
|
427
429
|
}
|
|
428
430
|
const id = core.getInstanceId(node);
|
|
429
431
|
if (id?.type !== types.AST_NODE_TYPES.ArrayPattern) {
|
|
430
|
-
context.report({ messageId: "
|
|
432
|
+
context.report({ messageId: "missingDestructuring", node });
|
|
431
433
|
return;
|
|
432
434
|
}
|
|
433
435
|
const [value, setter] = id.elements;
|
|
434
436
|
if (value == null || setter == null) {
|
|
435
|
-
context.report({ messageId: "
|
|
437
|
+
context.report({ messageId: "missingDestructuring", node });
|
|
436
438
|
return;
|
|
437
439
|
}
|
|
438
440
|
const setterName = tsPattern.match(setter).with({ type: types.AST_NODE_TYPES.Identifier }, (id2) => id2.name).otherwise(() => eff._);
|
|
439
441
|
if (setterName == null || !setterName.startsWith("set")) {
|
|
440
|
-
context.report({ messageId: "
|
|
442
|
+
context.report({ messageId: "invalidSetterNaming", node });
|
|
441
443
|
return;
|
|
442
444
|
}
|
|
443
445
|
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 }) => {
|
|
@@ -450,7 +452,7 @@ function create5(context) {
|
|
|
450
452
|
return values.join("_");
|
|
451
453
|
}).otherwise(() => eff._);
|
|
452
454
|
if (valueName == null || `set_${valueName}` !== stringTs.snakeCase(setterName)) {
|
|
453
|
-
context.report({ messageId: "
|
|
455
|
+
context.report({ messageId: "invalidSetterNaming", node });
|
|
454
456
|
return;
|
|
455
457
|
}
|
|
456
458
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ var rules = {};
|
|
|
24
24
|
|
|
25
25
|
// package.json
|
|
26
26
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
27
|
-
var version = "1.36.
|
|
27
|
+
var version = "1.36.1-next.0";
|
|
28
28
|
var createRule = createRuleForPlugin("naming-convention");
|
|
29
29
|
|
|
30
30
|
// src/utils/regexp.ts
|
|
@@ -386,7 +386,8 @@ var use_state_default = createRule({
|
|
|
386
386
|
[Symbol.for("rule_features")]: RULE_FEATURES
|
|
387
387
|
},
|
|
388
388
|
messages: {
|
|
389
|
-
|
|
389
|
+
invalidSetterNaming: "The setter should be named 'set' followed by the capitalized state variable name, e.g., 'setState' for 'state'.",
|
|
390
|
+
missingDestructuring: "useState should be destructured into a value and setter pair, e.g., const [state, setState] = useState(...)."
|
|
390
391
|
},
|
|
391
392
|
schema: []
|
|
392
393
|
},
|
|
@@ -398,21 +399,22 @@ function create5(context) {
|
|
|
398
399
|
return {
|
|
399
400
|
"CallExpression[callee.name='useState']"(node) {
|
|
400
401
|
if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) {
|
|
401
|
-
context.report({ messageId: "
|
|
402
|
+
context.report({ messageId: "missingDestructuring", node });
|
|
403
|
+
return;
|
|
402
404
|
}
|
|
403
405
|
const id = getInstanceId(node);
|
|
404
406
|
if (id?.type !== AST_NODE_TYPES.ArrayPattern) {
|
|
405
|
-
context.report({ messageId: "
|
|
407
|
+
context.report({ messageId: "missingDestructuring", node });
|
|
406
408
|
return;
|
|
407
409
|
}
|
|
408
410
|
const [value, setter] = id.elements;
|
|
409
411
|
if (value == null || setter == null) {
|
|
410
|
-
context.report({ messageId: "
|
|
412
|
+
context.report({ messageId: "missingDestructuring", node });
|
|
411
413
|
return;
|
|
412
414
|
}
|
|
413
415
|
const setterName = match(setter).with({ type: AST_NODE_TYPES.Identifier }, (id2) => id2.name).otherwise(() => _);
|
|
414
416
|
if (setterName == null || !setterName.startsWith("set")) {
|
|
415
|
-
context.report({ messageId: "
|
|
417
|
+
context.report({ messageId: "invalidSetterNaming", node });
|
|
416
418
|
return;
|
|
417
419
|
}
|
|
418
420
|
const valueName = match(value).with({ type: AST_NODE_TYPES.Identifier }, ({ name: name3 }) => snakeCase(name3)).with({ type: AST_NODE_TYPES.ObjectPattern }, ({ properties }) => {
|
|
@@ -425,7 +427,7 @@ function create5(context) {
|
|
|
425
427
|
return values.join("_");
|
|
426
428
|
}).otherwise(() => _);
|
|
427
429
|
if (valueName == null || `set_${valueName}` !== snakeCase(setterName)) {
|
|
428
|
-
context.report({ messageId: "
|
|
430
|
+
context.report({ messageId: "invalidSetterNaming", node });
|
|
429
431
|
return;
|
|
430
432
|
}
|
|
431
433
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.1-next.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
"@typescript-eslint/utils": "^8.26.1",
|
|
50
50
|
"string-ts": "^2.2.1",
|
|
51
51
|
"ts-pattern": "^5.6.2",
|
|
52
|
-
"@eslint-react/ast": "1.36.
|
|
53
|
-
"@eslint-react/core": "1.36.
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
52
|
+
"@eslint-react/ast": "1.36.1-next.0",
|
|
53
|
+
"@eslint-react/core": "1.36.1-next.0",
|
|
54
|
+
"@eslint-react/shared": "1.36.1-next.0",
|
|
55
|
+
"@eslint-react/var": "1.36.1-next.0",
|
|
56
|
+
"@eslint-react/eff": "1.36.1-next.0",
|
|
57
|
+
"@eslint-react/jsx": "1.36.1-next.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@types/react": "^19.0.
|
|
60
|
+
"@types/react": "^19.0.11",
|
|
61
61
|
"@types/react-dom": "^19.0.4",
|
|
62
62
|
"tsup": "^8.4.0",
|
|
63
63
|
"@local/configs": "0.0.0"
|