eslint-plugin-react-x 2.11.2 → 2.12.0-beta.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.js +73 -18
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -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.
|
|
70
|
+
var version = "2.12.0-beta.0";
|
|
71
71
|
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region src/utils/create-rule.ts
|
|
@@ -125,6 +125,76 @@ const isTruthyStringType = (type) => type.isStringLiteral() && type.value !== ""
|
|
|
125
125
|
/** @internal */
|
|
126
126
|
const isUnknownType = (type) => isTypeFlagSet(type, ts.TypeFlags.Unknown);
|
|
127
127
|
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/utils/type-name.ts
|
|
130
|
+
/**
|
|
131
|
+
* An enhanced version of getFullyQualifiedName that handles cases that original function does not handle
|
|
132
|
+
* @param checker TypeScript type checker
|
|
133
|
+
* @param symbol Symbol to get fully qualified name for
|
|
134
|
+
* @returns Fully qualified name of the symbol
|
|
135
|
+
*/
|
|
136
|
+
function getFullyQualifiedNameEx(checker, symbol) {
|
|
137
|
+
let name = symbol.name;
|
|
138
|
+
let parent = symbol.declarations?.at(0)?.parent;
|
|
139
|
+
if (parent == null) return checker.getFullyQualifiedName(symbol);
|
|
140
|
+
while (parent.kind !== ts.SyntaxKind.SourceFile) {
|
|
141
|
+
switch (true) {
|
|
142
|
+
case ts.isInterfaceDeclaration(parent):
|
|
143
|
+
name = `${parent.name.text}.${name}`;
|
|
144
|
+
break;
|
|
145
|
+
case ts.isTypeAliasDeclaration(parent):
|
|
146
|
+
name = `${parent.name.text}.${name}`;
|
|
147
|
+
break;
|
|
148
|
+
case ts.isEnumDeclaration(parent):
|
|
149
|
+
name = `${parent.name.text}.${name}`;
|
|
150
|
+
break;
|
|
151
|
+
case ts.isClassDeclaration(parent) && parent.name != null:
|
|
152
|
+
name = `${parent.name.text}.${name}`;
|
|
153
|
+
break;
|
|
154
|
+
case ts.isModuleDeclaration(parent):
|
|
155
|
+
name = `${parent.name.text}.${name}`;
|
|
156
|
+
break;
|
|
157
|
+
case ts.isNamespaceImport(parent):
|
|
158
|
+
name = `${parent.name.text}.${name}`;
|
|
159
|
+
break;
|
|
160
|
+
case ts.isNamespaceExport(parent):
|
|
161
|
+
name = `${parent.name.text}.${name}`;
|
|
162
|
+
break;
|
|
163
|
+
case ts.isEnumMember(parent):
|
|
164
|
+
name = `${parent.name.getText()}.${name}`;
|
|
165
|
+
break;
|
|
166
|
+
case ts.isFunctionDeclaration(parent) && parent.name != null:
|
|
167
|
+
name = `${parent.name.text}.${name}`;
|
|
168
|
+
break;
|
|
169
|
+
case ts.isClassExpression(parent) && parent.name != null:
|
|
170
|
+
name = `${parent.name.text}.${name}`;
|
|
171
|
+
break;
|
|
172
|
+
case ts.isPropertySignature(parent) && ts.isIdentifier(parent.name):
|
|
173
|
+
name = `${parent.name.text}.${name}`;
|
|
174
|
+
break;
|
|
175
|
+
case ts.isPropertyDeclaration(parent) && ts.isIdentifier(parent.name):
|
|
176
|
+
name = `${parent.name.text}.${name}`;
|
|
177
|
+
break;
|
|
178
|
+
case ts.isMethodDeclaration(parent) && ts.isIdentifier(parent.name):
|
|
179
|
+
name = `${parent.name.text}.${name}`;
|
|
180
|
+
break;
|
|
181
|
+
case ts.isMethodSignature(parent) && ts.isIdentifier(parent.name):
|
|
182
|
+
name = `${parent.name.text}.${name}`;
|
|
183
|
+
break;
|
|
184
|
+
case ts.isPropertyAssignment(parent) && ts.isIdentifier(parent.name):
|
|
185
|
+
name = `${parent.name.text}.${name}`;
|
|
186
|
+
break;
|
|
187
|
+
case ts.isTypeLiteralNode(parent):
|
|
188
|
+
case ts.isMappedTypeNode(parent):
|
|
189
|
+
case ts.isObjectLiteralExpression(parent):
|
|
190
|
+
case ts.isIntersectionTypeNode(parent):
|
|
191
|
+
case ts.isUnionTypeNode(parent): break;
|
|
192
|
+
}
|
|
193
|
+
parent = parent.parent;
|
|
194
|
+
}
|
|
195
|
+
return name;
|
|
196
|
+
}
|
|
197
|
+
|
|
128
198
|
//#endregion
|
|
129
199
|
//#region src/utils/type-variant.ts
|
|
130
200
|
/**
|
|
@@ -1359,7 +1429,7 @@ function create$35(context) {
|
|
|
1359
1429
|
for (const type of unionConstituents(getConstrainedTypeAtLocation(services, node.argument))) {
|
|
1360
1430
|
const key = type.getProperty("key");
|
|
1361
1431
|
if (key == null) return;
|
|
1362
|
-
if (
|
|
1432
|
+
if (getFullyQualifiedNameEx(checker, key).endsWith("React.Attributes.key")) return;
|
|
1363
1433
|
context.report({
|
|
1364
1434
|
messageId: "default",
|
|
1365
1435
|
node
|
|
@@ -1367,21 +1437,6 @@ function create$35(context) {
|
|
|
1367
1437
|
}
|
|
1368
1438
|
} };
|
|
1369
1439
|
}
|
|
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
|
-
}
|
|
1385
1440
|
|
|
1386
1441
|
//#endregion
|
|
1387
1442
|
//#region src/rules/no-leaked-conditional-rendering.ts
|
|
@@ -1691,7 +1746,7 @@ var no_nested_component_definitions_default = createRule({
|
|
|
1691
1746
|
defaultOptions: []
|
|
1692
1747
|
});
|
|
1693
1748
|
function create$29(context) {
|
|
1694
|
-
const hint = core.ComponentDetectionHint.
|
|
1749
|
+
const hint = core.ComponentDetectionHint.DoNotIncludeJsxWithNumberValue | core.ComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | core.ComponentDetectionHint.DoNotIncludeJsxWithStringValue | core.ComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | core.ComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx | core.ComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayPattern | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayExpression | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback;
|
|
1695
1750
|
const fCollector = core.useComponentCollector(context, { hint });
|
|
1696
1751
|
const cCollector = core.useComponentCollectorLegacy(context);
|
|
1697
1752
|
return defineRuleListener(fCollector.visitor, cCollector.visitor, { "Program:exit"(program) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0-beta.0",
|
|
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.
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/shared": "2.
|
|
52
|
-
"@eslint-react/var": "2.
|
|
48
|
+
"@eslint-react/ast": "2.12.0-beta.0",
|
|
49
|
+
"@eslint-react/eff": "2.12.0-beta.0",
|
|
50
|
+
"@eslint-react/core": "2.12.0-beta.0",
|
|
51
|
+
"@eslint-react/shared": "2.12.0-beta.0",
|
|
52
|
+
"@eslint-react/var": "2.12.0-beta.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/react": "^19.2.13",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@local/configs": "0.0.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"eslint": "^8.57.0 || ^9.0.0",
|
|
61
|
+
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
62
62
|
"typescript": ">=4.8.4 <6.0.0"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|