eslint-plugin-react-x 5.9.0 → 5.9.1
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 +33 -17
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { compare } from "compare-versions";
|
|
|
13
13
|
import { getConstrainedTypeAtLocation } from "@typescript-eslint/type-utils";
|
|
14
14
|
import { unionConstituents } from "ts-api-utils";
|
|
15
15
|
import { simpleTraverse } from "@typescript-eslint/typescript-estree";
|
|
16
|
-
import { snakeCase } from "string-ts";
|
|
16
|
+
import { delimiterCase, snakeCase, toLowerCase } from "string-ts";
|
|
17
17
|
|
|
18
18
|
//#region \0rolldown/runtime.js
|
|
19
19
|
var __defProp = Object.defineProperty;
|
|
@@ -143,7 +143,7 @@ const rules$6 = {
|
|
|
143
143
|
//#endregion
|
|
144
144
|
//#region package.json
|
|
145
145
|
var name$6 = "eslint-plugin-react-x";
|
|
146
|
-
var version = "5.9.
|
|
146
|
+
var version = "5.9.1";
|
|
147
147
|
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/utils/create-rule.ts
|
|
@@ -1804,7 +1804,7 @@ function report$2(context) {
|
|
|
1804
1804
|
* `map` and `forEach` also cover `Children.map` and `Children.forEach`,
|
|
1805
1805
|
* whose callback is the second argument instead of the first.
|
|
1806
1806
|
*/
|
|
1807
|
-
const INDEX_PARAM_POSITIONS = new Map([
|
|
1807
|
+
const INDEX_PARAM_POSITIONS$1 = new Map([
|
|
1808
1808
|
["every", 1],
|
|
1809
1809
|
["filter", 1],
|
|
1810
1810
|
["find", 1],
|
|
@@ -1837,7 +1837,7 @@ function isArrayIndexReference(context, node) {
|
|
|
1837
1837
|
const callee = Extract.unwrap(call.callee);
|
|
1838
1838
|
if (callee.type !== AST_NODE_TYPES.MemberExpression) return false;
|
|
1839
1839
|
if (callee.property.type !== AST_NODE_TYPES.Identifier) return false;
|
|
1840
|
-
const indexPosition = INDEX_PARAM_POSITIONS.get(callee.property.name);
|
|
1840
|
+
const indexPosition = INDEX_PARAM_POSITIONS$1.get(callee.property.name);
|
|
1841
1841
|
if (indexPosition == null) return false;
|
|
1842
1842
|
const callbackPosition = core.isChildrenMap(context, callee) || core.isChildrenForEach(context, callee) ? 1 : 0;
|
|
1843
1843
|
if (call.arguments[callbackPosition] !== argument) return false;
|
|
@@ -2818,6 +2818,16 @@ function create$25(context) {
|
|
|
2818
2818
|
//#endregion
|
|
2819
2819
|
//#region src/rules/no-missing-key/lib.ts
|
|
2820
2820
|
/**
|
|
2821
|
+
* Iterator-like methods whose callback's return value becomes an item in a rendered list,
|
|
2822
|
+
* mapped to the position of the callback in the call's argument list.
|
|
2823
|
+
* `from` covers `Array.from(iterable, mapFn)`.
|
|
2824
|
+
*/
|
|
2825
|
+
const INDEX_PARAM_POSITIONS = new Map([
|
|
2826
|
+
["flatMap", 0],
|
|
2827
|
+
["from", 1],
|
|
2828
|
+
["map", 0]
|
|
2829
|
+
]);
|
|
2830
|
+
/**
|
|
2821
2831
|
* Creates a report function for the given rule context.
|
|
2822
2832
|
* @param context The ESLint rule context.
|
|
2823
2833
|
* @returns A function that can be used to report violations.
|
|
@@ -2847,16 +2857,6 @@ function getNestedReturnStatements$1(node) {
|
|
|
2847
2857
|
//#endregion
|
|
2848
2858
|
//#region src/rules/no-missing-key/no-missing-key.ts
|
|
2849
2859
|
const RULE_NAME$24 = "no-missing-key";
|
|
2850
|
-
/**
|
|
2851
|
-
* Iterator-like methods whose callback's return value becomes an item in a rendered list,
|
|
2852
|
-
* mapped to the position of the callback in the call's argument list.
|
|
2853
|
-
* `from` covers `Array.from(iterable, mapFn)`.
|
|
2854
|
-
*/
|
|
2855
|
-
const ITERATOR_METHOD_CALLBACK_POSITIONS = new Map([
|
|
2856
|
-
["flatMap", 0],
|
|
2857
|
-
["from", 1],
|
|
2858
|
-
["map", 0]
|
|
2859
|
-
]);
|
|
2860
2860
|
var no_missing_key_default = createRule({
|
|
2861
2861
|
meta: {
|
|
2862
2862
|
type: "problem",
|
|
@@ -2880,7 +2880,7 @@ function getIteratorCallback(node) {
|
|
|
2880
2880
|
const callee = Extract.unwrap(node.callee);
|
|
2881
2881
|
if (callee.type !== AST_NODE_TYPES.MemberExpression) return null;
|
|
2882
2882
|
if (callee.property.type !== AST_NODE_TYPES.Identifier) return null;
|
|
2883
|
-
const position =
|
|
2883
|
+
const position = INDEX_PARAM_POSITIONS.get(callee.property.name);
|
|
2884
2884
|
if (position == null) return null;
|
|
2885
2885
|
const callback = node.arguments[position];
|
|
2886
2886
|
if (callback == null || !Check.isFunction(callback)) return null;
|
|
@@ -3401,6 +3401,14 @@ function isContextName(name, isReact18OrBelow) {
|
|
|
3401
3401
|
if (!isReact18OrBelow) return name.endsWith("Context") || name.endsWith("CONTEXT");
|
|
3402
3402
|
return false;
|
|
3403
3403
|
}
|
|
3404
|
+
function getHumanReadableKind$1(node) {
|
|
3405
|
+
if (node.type === AST_NODE_TYPES.Literal) {
|
|
3406
|
+
if ("regex" in node) return "regexp literal";
|
|
3407
|
+
if (node.value === null) return "null literal";
|
|
3408
|
+
return `${typeof node.value} literal`;
|
|
3409
|
+
}
|
|
3410
|
+
return toLowerCase(delimiterCase(node.type, " "));
|
|
3411
|
+
}
|
|
3404
3412
|
|
|
3405
3413
|
//#endregion
|
|
3406
3414
|
//#region src/rules/no-unstable-context-value/no-unstable-context-value.ts
|
|
@@ -3449,7 +3457,7 @@ function create$13(context) {
|
|
|
3449
3457
|
const suggestion = kind === "function" ? "Consider wrapping it in a useCallback hook." : "Consider wrapping it in a useMemo hook.";
|
|
3450
3458
|
context.report({
|
|
3451
3459
|
data: {
|
|
3452
|
-
kind:
|
|
3460
|
+
kind: getHumanReadableKind$1(constructionNode),
|
|
3453
3461
|
suggestion
|
|
3454
3462
|
},
|
|
3455
3463
|
messageId: "unstableContextValue",
|
|
@@ -3468,6 +3476,14 @@ const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
|
|
|
3468
3476
|
"[id.type='ObjectPattern']",
|
|
3469
3477
|
"[init.type='Identifier']"
|
|
3470
3478
|
].join("");
|
|
3479
|
+
function getHumanReadableKind(node) {
|
|
3480
|
+
if (node.type === AST_NODE_TYPES.Literal) {
|
|
3481
|
+
if ("regex" in node) return "regexp literal";
|
|
3482
|
+
if (node.value === null) return "null literal";
|
|
3483
|
+
return `${typeof node.value} literal`;
|
|
3484
|
+
}
|
|
3485
|
+
return toLowerCase(delimiterCase(node.type, " "));
|
|
3486
|
+
}
|
|
3471
3487
|
|
|
3472
3488
|
//#endregion
|
|
3473
3489
|
//#region src/rules/no-unstable-default-props/no-unstable-default-props.ts
|
|
@@ -3536,7 +3552,7 @@ function create$12(context, [options]) {
|
|
|
3536
3552
|
if (identifier != null && safePatterns.some((pattern) => pattern.test(identifier))) continue;
|
|
3537
3553
|
}
|
|
3538
3554
|
context.report({
|
|
3539
|
-
data: { kind:
|
|
3555
|
+
data: { kind: getHumanReadableKind(right) },
|
|
3540
3556
|
messageId: "default",
|
|
3541
3557
|
node: right
|
|
3542
3558
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.1",
|
|
4
4
|
"description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -36,30 +36,30 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@typescript-eslint/scope-manager": "^8.61.
|
|
40
|
-
"@typescript-eslint/type-utils": "^8.61.
|
|
41
|
-
"@typescript-eslint/types": "^8.61.
|
|
42
|
-
"@typescript-eslint/typescript-estree": "^8.61.
|
|
43
|
-
"@typescript-eslint/utils": "^8.61.
|
|
39
|
+
"@typescript-eslint/scope-manager": "^8.61.1",
|
|
40
|
+
"@typescript-eslint/type-utils": "^8.61.1",
|
|
41
|
+
"@typescript-eslint/types": "^8.61.1",
|
|
42
|
+
"@typescript-eslint/typescript-estree": "^8.61.1",
|
|
43
|
+
"@typescript-eslint/utils": "^8.61.1",
|
|
44
44
|
"compare-versions": "^6.1.1",
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-api-utils": "^2.5.0",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/jsx": "5.9.
|
|
53
|
-
"@eslint-react/shared": "5.9.
|
|
48
|
+
"@eslint-react/ast": "5.9.1",
|
|
49
|
+
"@eslint-react/core": "5.9.1",
|
|
50
|
+
"@eslint-react/eslint": "5.9.1",
|
|
51
|
+
"@eslint-react/var": "5.9.1",
|
|
52
|
+
"@eslint-react/jsx": "5.9.1",
|
|
53
|
+
"@eslint-react/shared": "5.9.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/react": "^19.2.17",
|
|
57
57
|
"@types/react-dom": "^19.2.3",
|
|
58
58
|
"dedent": "^1.7.2",
|
|
59
|
-
"eslint": "^10.
|
|
59
|
+
"eslint": "^10.5.0",
|
|
60
60
|
"react": "^19.2.7",
|
|
61
61
|
"react-dom": "^19.2.7",
|
|
62
|
-
"tsdown": "^0.22.
|
|
62
|
+
"tsdown": "^0.22.3",
|
|
63
63
|
"tsl": "^1.0.30",
|
|
64
64
|
"tsl-dx": "^0.12.2",
|
|
65
65
|
"typescript": "6.0.3",
|