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.
Files changed (2) hide show
  1. package/dist/index.js +26 -10
  2. 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-next.0";
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 key = getConstrainedTypeAtLocation(services, node.argument).getProperty("key");
1360
- if (key == null) return;
1361
- if (checker.getFullyQualifiedName(key) === "React.Attributes.key") return;
1362
- if (key.declarations?.at(0)?.getText().trim().startsWith("key?: Key | null | undefined")) return;
1363
- context.report({
1364
- messageId: "default",
1365
- node
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-next.0",
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-next.0",
49
- "@eslint-react/core": "2.11.2-next.0",
50
- "@eslint-react/eff": "2.11.2-next.0",
51
- "@eslint-react/shared": "2.11.2-next.0",
52
- "@eslint-react/var": "2.11.2-next.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"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.13",