@eslint-react/jsx 5.15.0 → 5.16.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.d.ts +1 -0
- package/dist/index.js +18 -3
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ declare function collapseMultilineText(text: string): string | null;
|
|
|
26
26
|
*
|
|
27
27
|
* Spread attributes are resolved when possible: if the spread argument is an identifier
|
|
28
28
|
* that resolves to an object expression, the object's properties are searched for a matching key.
|
|
29
|
+
* Nested object expressions and nested spread identifiers are also resolved.
|
|
29
30
|
* @param context The ESLint rule context (needed for variable resolution in spread attributes)
|
|
30
31
|
* @param element The `JSXElement` node to search
|
|
31
32
|
* @param name The attribute name to look for (ex: "className")
|
package/dist/index.js
CHANGED
|
@@ -66,17 +66,32 @@ function getAttributeName(node) {
|
|
|
66
66
|
*
|
|
67
67
|
* Spread attributes are resolved when possible: if the spread argument is an identifier
|
|
68
68
|
* that resolves to an object expression, the object's properties are searched for a matching key.
|
|
69
|
+
* Nested object expressions and nested spread identifiers are also resolved.
|
|
69
70
|
* @param context The ESLint rule context (needed for variable resolution in spread attributes)
|
|
70
71
|
* @param element The `JSXElement` node to search
|
|
71
72
|
* @param name The attribute name to look for (ex: "className")
|
|
72
73
|
* @returns The matching `JSXAttribute` or `JSXSpreadAttribute`, or `undefined` when not found
|
|
73
74
|
*/
|
|
74
75
|
function findAttribute(context, element, name) {
|
|
75
|
-
function findProperty(properties, name) {
|
|
76
|
+
function findProperty(properties, name, seen = /* @__PURE__ */ new Set()) {
|
|
76
77
|
for (const property of properties) {
|
|
77
78
|
if (property.type === AST_NODE_TYPES.Property && !property.computed && property.key.type === AST_NODE_TYPES.Identifier && property.key.name === name) return property;
|
|
78
|
-
if (property.type
|
|
79
|
-
|
|
79
|
+
if (property.type !== AST_NODE_TYPES.SpreadElement) continue;
|
|
80
|
+
const argument = property.argument;
|
|
81
|
+
if (argument.type === AST_NODE_TYPES.Identifier) {
|
|
82
|
+
const initNode = resolve(context, argument);
|
|
83
|
+
if (initNode?.type === AST_NODE_TYPES.ObjectExpression) {
|
|
84
|
+
if (seen.has(initNode)) continue;
|
|
85
|
+
seen.add(initNode);
|
|
86
|
+
const found = findProperty(initNode.properties, name, seen);
|
|
87
|
+
if (found != null) return found;
|
|
88
|
+
}
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (argument.type === AST_NODE_TYPES.ObjectExpression) {
|
|
92
|
+
if (seen.has(argument)) continue;
|
|
93
|
+
seen.add(argument);
|
|
94
|
+
const found = findProperty(argument.properties, name, seen);
|
|
80
95
|
if (found != null) return found;
|
|
81
96
|
}
|
|
82
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.16.0",
|
|
4
4
|
"description": "ESLint React's TSESTree JSX utility module for static analysis of JSX patterns.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"@typescript-eslint/types": "^8.64.0",
|
|
33
33
|
"@typescript-eslint/utils": "^8.64.0",
|
|
34
34
|
"ts-pattern": "^5.9.0",
|
|
35
|
-
"@eslint-react/ast": "5.
|
|
36
|
-
"@eslint-react/eslint": "5.
|
|
37
|
-
"@eslint-react/
|
|
38
|
-
"@eslint-react/
|
|
35
|
+
"@eslint-react/ast": "5.16.0",
|
|
36
|
+
"@eslint-react/eslint": "5.16.0",
|
|
37
|
+
"@eslint-react/shared": "5.16.0",
|
|
38
|
+
"@eslint-react/var": "5.16.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"eslint": "^10.7.0",
|