eslint-plugin-react-naming-convention 2.4.0-next.0 → 2.4.0-next.10
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 +21 -13
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ const rules = {
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region package.json
|
|
41
41
|
var name = "eslint-plugin-react-naming-convention";
|
|
42
|
-
var version = "2.4.0-next.
|
|
42
|
+
var version = "2.4.0-next.10";
|
|
43
43
|
|
|
44
44
|
//#endregion
|
|
45
45
|
//#region src/utils/create-rule.ts
|
|
@@ -384,12 +384,24 @@ function create$1(context) {
|
|
|
384
384
|
//#endregion
|
|
385
385
|
//#region src/rules/use-state.ts
|
|
386
386
|
const RULE_NAME = "use-state";
|
|
387
|
-
const RULE_FEATURES = [];
|
|
388
|
-
const defaultOptions = [{
|
|
387
|
+
const RULE_FEATURES = ["CFG"];
|
|
388
|
+
const defaultOptions = [{
|
|
389
|
+
enforceAssignment: false,
|
|
390
|
+
enforceSetterName: true
|
|
391
|
+
}];
|
|
389
392
|
const schema = [{
|
|
390
393
|
type: "object",
|
|
391
394
|
additionalProperties: false,
|
|
392
|
-
properties: {
|
|
395
|
+
properties: {
|
|
396
|
+
enforceAssignment: {
|
|
397
|
+
type: "boolean",
|
|
398
|
+
default: false
|
|
399
|
+
},
|
|
400
|
+
enforceSetterName: {
|
|
401
|
+
type: "boolean",
|
|
402
|
+
default: true
|
|
403
|
+
}
|
|
404
|
+
}
|
|
393
405
|
}];
|
|
394
406
|
var use_state_default = createRule({
|
|
395
407
|
meta: {
|
|
@@ -409,10 +421,11 @@ var use_state_default = createRule({
|
|
|
409
421
|
defaultOptions
|
|
410
422
|
});
|
|
411
423
|
function create(context) {
|
|
412
|
-
const
|
|
424
|
+
const { enforceAssignment = false, enforceSetterName = true } = context.options[0] ?? defaultOptions[0];
|
|
413
425
|
return { CallExpression(node) {
|
|
414
426
|
if (!isUseStateCall(node)) return;
|
|
415
427
|
if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) {
|
|
428
|
+
if (!enforceAssignment) return;
|
|
416
429
|
context.report({
|
|
417
430
|
messageId: "invalidAssignment",
|
|
418
431
|
node
|
|
@@ -421,6 +434,7 @@ function create(context) {
|
|
|
421
434
|
}
|
|
422
435
|
const id = getInstanceId(node);
|
|
423
436
|
if (id?.type !== AST_NODE_TYPES.ArrayPattern) {
|
|
437
|
+
if (!enforceAssignment) return;
|
|
424
438
|
context.report({
|
|
425
439
|
messageId: "invalidAssignment",
|
|
426
440
|
node: id ?? node
|
|
@@ -429,20 +443,14 @@ function create(context) {
|
|
|
429
443
|
}
|
|
430
444
|
const [value, setter] = id.elements;
|
|
431
445
|
if (value == null) {
|
|
446
|
+
if (!enforceAssignment) return;
|
|
432
447
|
context.report({
|
|
433
448
|
messageId: "invalidAssignment",
|
|
434
449
|
node: id
|
|
435
450
|
});
|
|
436
451
|
return;
|
|
437
452
|
}
|
|
438
|
-
if (setter == null)
|
|
439
|
-
if (!enforceSetterExistence) return;
|
|
440
|
-
context.report({
|
|
441
|
-
messageId: "invalidAssignment",
|
|
442
|
-
node: id
|
|
443
|
-
});
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
453
|
+
if (setter == null || !enforceSetterName) return;
|
|
446
454
|
const setterName = match(setter).with({ type: AST_NODE_TYPES.Identifier }, (id$1) => id$1.name).otherwise(() => null);
|
|
447
455
|
if (setterName == null || !setterName.startsWith("set")) {
|
|
448
456
|
context.report({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "2.4.0-next.
|
|
3
|
+
"version": "2.4.0-next.10",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -38,22 +38,22 @@
|
|
|
38
38
|
"./package.json"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
42
|
-
"@typescript-eslint/type-utils": "^8.
|
|
43
|
-
"@typescript-eslint/types": "^8.
|
|
44
|
-
"@typescript-eslint/utils": "^8.
|
|
41
|
+
"@typescript-eslint/scope-manager": "^8.50.0",
|
|
42
|
+
"@typescript-eslint/type-utils": "^8.50.0",
|
|
43
|
+
"@typescript-eslint/types": "^8.50.0",
|
|
44
|
+
"@typescript-eslint/utils": "^8.50.0",
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-pattern": "^5.9.0",
|
|
47
|
-
"@eslint-react/ast": "2.4.0-next.
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/shared": "2.4.0-next.
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
47
|
+
"@eslint-react/ast": "2.4.0-next.10",
|
|
48
|
+
"@eslint-react/core": "2.4.0-next.10",
|
|
49
|
+
"@eslint-react/shared": "2.4.0-next.10",
|
|
50
|
+
"@eslint-react/var": "2.4.0-next.10",
|
|
51
|
+
"@eslint-react/eff": "2.4.0-next.10"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.2.7",
|
|
55
55
|
"@types/react-dom": "^19.2.3",
|
|
56
|
-
"tsdown": "^0.
|
|
56
|
+
"tsdown": "^0.18.1",
|
|
57
57
|
"@local/configs": "0.0.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|