eslint-plugin-react-x 2.11.2-next.0 → 2.11.2
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 +26 -10
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -9,8 +9,8 @@ import { findEnclosingAssignmentTarget, findVariable, getChildScopes, getObjectT
|
|
|
9
9
|
import { constFalse, constTrue, flow, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
|
|
10
10
|
import { compare } from "compare-versions";
|
|
11
11
|
import { getConstrainedTypeAtLocation, isTypeReadonly } from "@typescript-eslint/type-utils";
|
|
12
|
-
import { getStaticValue, isIdentifier, isVariableDeclarator } from "@typescript-eslint/utils/ast-utils";
|
|
13
12
|
import { isPropertyReadonlyInType, unionConstituents } from "ts-api-utils";
|
|
13
|
+
import { getStaticValue, isIdentifier, isVariableDeclarator } from "@typescript-eslint/utils/ast-utils";
|
|
14
14
|
import { getTypeImmutability, isImmutable, isReadonlyDeep, isReadonlyShallow, isUnknown } from "is-immutable-type";
|
|
15
15
|
|
|
16
16
|
//#region \0rolldown/runtime.js
|
|
@@ -67,7 +67,7 @@ const rules$7 = {
|
|
|
67
67
|
//#endregion
|
|
68
68
|
//#region package.json
|
|
69
69
|
var name$6 = "eslint-plugin-react-x";
|
|
70
|
-
var version = "2.11.2
|
|
70
|
+
var version = "2.11.2";
|
|
71
71
|
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region src/utils/create-rule.ts
|
|
@@ -1356,16 +1356,32 @@ function create$35(context) {
|
|
|
1356
1356
|
const services = ESLintUtils.getParserServices(context, false);
|
|
1357
1357
|
const checker = services.program.getTypeChecker();
|
|
1358
1358
|
return { JSXSpreadAttribute(node) {
|
|
1359
|
-
const
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1359
|
+
for (const type of unionConstituents(getConstrainedTypeAtLocation(services, node.argument))) {
|
|
1360
|
+
const key = type.getProperty("key");
|
|
1361
|
+
if (key == null) return;
|
|
1362
|
+
if (isReactInternalKey(checker, key)) return;
|
|
1363
|
+
context.report({
|
|
1364
|
+
messageId: "default",
|
|
1365
|
+
node
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1367
1368
|
} };
|
|
1368
1369
|
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Check if a symbol is a React internal key
|
|
1372
|
+
* @param checker TypeScript type checker
|
|
1373
|
+
* @param key Symbol to check
|
|
1374
|
+
* @returns True if the symbol is a React internal key, false otherwise
|
|
1375
|
+
*/
|
|
1376
|
+
function isReactInternalKey(checker, key) {
|
|
1377
|
+
if (checker.getFullyQualifiedName(key) === "React.Attributes.key") return true;
|
|
1378
|
+
let parent = key.declarations?.at(0)?.parent;
|
|
1379
|
+
while (parent != null && parent.kind !== ts.SyntaxKind.SourceFile) {
|
|
1380
|
+
if (ts.isModuleDeclaration(parent) && ts.isIdentifier(parent.name) && parent.name.text === "React") return true;
|
|
1381
|
+
parent = parent.parent;
|
|
1382
|
+
}
|
|
1383
|
+
return false;
|
|
1384
|
+
}
|
|
1369
1385
|
|
|
1370
1386
|
//#endregion
|
|
1371
1387
|
//#region src/rules/no-leaked-conditional-rendering.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "2.11.2
|
|
3
|
+
"version": "2.11.2",
|
|
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",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"is-immutable-type": "^5.0.1",
|
|
46
46
|
"ts-api-utils": "^2.4.0",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/ast": "2.11.2
|
|
49
|
-
"@eslint-react/core": "2.11.2
|
|
50
|
-
"@eslint-react/eff": "2.11.2
|
|
51
|
-
"@eslint-react/shared": "2.11.2
|
|
52
|
-
"@eslint-react/var": "2.11.2
|
|
48
|
+
"@eslint-react/ast": "2.11.2",
|
|
49
|
+
"@eslint-react/core": "2.11.2",
|
|
50
|
+
"@eslint-react/eff": "2.11.2",
|
|
51
|
+
"@eslint-react/shared": "2.11.2",
|
|
52
|
+
"@eslint-react/var": "2.11.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/react": "^19.2.13",
|