@eslint-react/jsx 5.9.2 → 5.9.3
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 +5 -4
- package/dist/index.js +12 -6
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -69,12 +69,13 @@ declare function getAttributeName(node: TSESTree.JSXAttribute): string;
|
|
|
69
69
|
* {@link resolveAttributeValue} -> `toStatic()`, with automatic handling of the
|
|
70
70
|
* `spreadProps` case (extracts the named property from the spread object).
|
|
71
71
|
*
|
|
72
|
-
* Returns `
|
|
73
|
-
* statically determined
|
|
72
|
+
* Returns `null` when the attribute is absent, `undefined` when the value cannot
|
|
73
|
+
* be statically determined (including empty expression containers), and the
|
|
74
|
+
* resolved static value otherwise.
|
|
74
75
|
* @param context The ESLint rule context
|
|
75
76
|
* @param element The `JSXElement` node to inspect
|
|
76
77
|
* @param name The attribute name to look up (ex: "className")
|
|
77
|
-
* @returns The static value of the attribute, or `undefined`
|
|
78
|
+
* @returns The static value of the attribute, `null` when absent, or `undefined` when indeterminate
|
|
78
79
|
*/
|
|
79
80
|
declare function getAttributeStaticValue(context: RuleContext, element: TSESTree.JSXElement, name: string): unknown;
|
|
80
81
|
//#endregion
|
|
@@ -120,7 +121,7 @@ interface JsxAttributeValueMissing {
|
|
|
120
121
|
/** Spread child expression (ex: `{...items}` as children) */
|
|
121
122
|
interface JsxAttributeValueSpreadChild {
|
|
122
123
|
readonly kind: "spreadChild";
|
|
123
|
-
getChildren(
|
|
124
|
+
getChildren(): unknown;
|
|
124
125
|
readonly node: TSESTree.JSXSpreadChild["expression"];
|
|
125
126
|
toStatic(): null;
|
|
126
127
|
}
|
package/dist/index.js
CHANGED
|
@@ -178,7 +178,7 @@ function resolveJsxAttribute(context, node) {
|
|
|
178
178
|
};
|
|
179
179
|
case AST_NODE_TYPES.JSXSpreadChild: return {
|
|
180
180
|
kind: "spreadChild",
|
|
181
|
-
getChildren(
|
|
181
|
+
getChildren() {
|
|
182
182
|
return null;
|
|
183
183
|
},
|
|
184
184
|
node: node.value.expression,
|
|
@@ -212,18 +212,20 @@ function resolveJsxSpreadAttribute(context, node) {
|
|
|
212
212
|
* {@link resolveAttributeValue} -> `toStatic()`, with automatic handling of the
|
|
213
213
|
* `spreadProps` case (extracts the named property from the spread object).
|
|
214
214
|
*
|
|
215
|
-
* Returns `
|
|
216
|
-
* statically determined
|
|
215
|
+
* Returns `null` when the attribute is absent, `undefined` when the value cannot
|
|
216
|
+
* be statically determined (including empty expression containers), and the
|
|
217
|
+
* resolved static value otherwise.
|
|
217
218
|
* @param context The ESLint rule context
|
|
218
219
|
* @param element The `JSXElement` node to inspect
|
|
219
220
|
* @param name The attribute name to look up (ex: "className")
|
|
220
|
-
* @returns The static value of the attribute, or `undefined`
|
|
221
|
+
* @returns The static value of the attribute, `null` when absent, or `undefined` when indeterminate
|
|
221
222
|
*/
|
|
222
223
|
function getAttributeStaticValue(context, element, name) {
|
|
223
224
|
const attr = findAttribute(context, element, name);
|
|
224
|
-
if (attr == null) return
|
|
225
|
+
if (attr == null) return null;
|
|
225
226
|
const resolved = resolveAttributeValue(context, attr);
|
|
226
227
|
if (resolved.kind === "spreadProps") return resolved.getProperty(name);
|
|
228
|
+
if (resolved.kind === "missing") return;
|
|
227
229
|
return resolved.toStatic();
|
|
228
230
|
}
|
|
229
231
|
|
|
@@ -510,7 +512,11 @@ function isFragmentElement(node, jsxFragmentFactory = "React.Fragment") {
|
|
|
510
512
|
* @returns `true` when the node is a `JSXElement` with a lowercase tag name
|
|
511
513
|
*/
|
|
512
514
|
function isHostElement(node) {
|
|
513
|
-
|
|
515
|
+
if (node.type !== AST_NODE_TYPES.JSXElement) return false;
|
|
516
|
+
const name = node.openingElement.name;
|
|
517
|
+
if (name.type === AST_NODE_TYPES.JSXIdentifier) return /^[a-z]/u.test(name.name);
|
|
518
|
+
if (name.type === AST_NODE_TYPES.JSXNamespacedName) return /^[a-z]/u.test(name.name.name);
|
|
519
|
+
return false;
|
|
514
520
|
}
|
|
515
521
|
|
|
516
522
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.3",
|
|
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": {
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@typescript-eslint/types": "^8.
|
|
33
|
-
"@typescript-eslint/utils": "^8.
|
|
32
|
+
"@typescript-eslint/types": "^8.62.0",
|
|
33
|
+
"@typescript-eslint/utils": "^8.62.0",
|
|
34
34
|
"ts-pattern": "^5.9.0",
|
|
35
|
-
"@eslint-react/
|
|
36
|
-
"@eslint-react/
|
|
37
|
-
"@eslint-react/
|
|
38
|
-
"@eslint-react/
|
|
35
|
+
"@eslint-react/eslint": "5.9.3",
|
|
36
|
+
"@eslint-react/ast": "5.9.3",
|
|
37
|
+
"@eslint-react/var": "5.9.3",
|
|
38
|
+
"@eslint-react/shared": "5.9.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"eslint": "^10.5.0",
|