@eslint-react/jsx 5.2.1-next.3 → 5.2.2-next.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 +10 -10
- package/dist/index.js +6 -7
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JSXAttributeLike, JSXElementLike } from "@eslint-react/ast";
|
|
2
2
|
import { TSESTree } from "@typescript-eslint/types";
|
|
3
3
|
import { RuleContext } from "@eslint-react/eslint";
|
|
4
4
|
|
|
@@ -29,7 +29,7 @@ import { RuleContext } from "@eslint-react/eslint";
|
|
|
29
29
|
* }
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
declare function findAttribute(context: RuleContext, element: TSESTree.JSXElement, name: string):
|
|
32
|
+
declare function findAttribute(context: RuleContext, element: TSESTree.JSXElement, name: string): JSXAttributeLike | undefined;
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/find-parent-attribute.d.ts
|
|
35
35
|
/**
|
|
@@ -237,7 +237,7 @@ declare function getAttributeValue(context: RuleContext, element: TSESTree.JSXEl
|
|
|
237
237
|
* const meaningful = getChildren(node);
|
|
238
238
|
* ```
|
|
239
239
|
*/
|
|
240
|
-
declare function getChildren(element:
|
|
240
|
+
declare function getChildren(element: JSXElementLike): TSESTree.JSXChild[];
|
|
241
241
|
//#endregion
|
|
242
242
|
//#region src/get-element-type.d.ts
|
|
243
243
|
/**
|
|
@@ -251,7 +251,7 @@ declare function getChildren(element: TSESTreeJSXElementLike): TSESTree.JSXChild
|
|
|
251
251
|
* @param node - A `JSXElement` or `JSXFragment` node.
|
|
252
252
|
* @returns The fully-qualified element type string.
|
|
253
253
|
*/
|
|
254
|
-
declare function getElementFullType(node:
|
|
254
|
+
declare function getElementFullType(node: JSXElementLike): string;
|
|
255
255
|
/**
|
|
256
256
|
* Get the **self name** (last dot-separated segment) of a JSX element type.
|
|
257
257
|
*
|
|
@@ -262,7 +262,7 @@ declare function getElementFullType(node: TSESTreeJSXElementLike): string;
|
|
|
262
262
|
* @param node - A `JSXElement` or `JSXFragment` node.
|
|
263
263
|
* @returns The last segment of the element type, or `""` for fragments.
|
|
264
264
|
*/
|
|
265
|
-
declare function getElementSelfType(node:
|
|
265
|
+
declare function getElementSelfType(node: JSXElementLike): string;
|
|
266
266
|
//#endregion
|
|
267
267
|
//#region src/has-any-attribute.d.ts
|
|
268
268
|
/**
|
|
@@ -346,7 +346,7 @@ declare function hasAttribute(context: RuleContext, element: TSESTree.JSXElement
|
|
|
346
346
|
* }
|
|
347
347
|
* ```
|
|
348
348
|
*/
|
|
349
|
-
declare function hasChildren(element:
|
|
349
|
+
declare function hasChildren(element: JSXElementLike): boolean;
|
|
350
350
|
//#endregion
|
|
351
351
|
//#region src/has-every-attribute.d.ts
|
|
352
352
|
/**
|
|
@@ -385,7 +385,7 @@ declare function hasEveryAttribute(context: RuleContext, element: TSESTree.JSXEl
|
|
|
385
385
|
* given strings
|
|
386
386
|
* - `function` — receives the element type string and returns a boolean
|
|
387
387
|
*/
|
|
388
|
-
type ElementTest = string | readonly string[] | ((elementType: string, node:
|
|
388
|
+
type ElementTest = string | readonly string[] | ((elementType: string, node: JSXElementLike) => boolean);
|
|
389
389
|
/**
|
|
390
390
|
* Check whether a node is a `JSXElement` (or `JSXFragment`) and optionally
|
|
391
391
|
* matches a given test.
|
|
@@ -418,7 +418,7 @@ type ElementTest = string | readonly string[] | ((elementType: string, node: TSE
|
|
|
418
418
|
* if (isElement(node, (type) => type.endsWith(".Provider"))) { … }
|
|
419
419
|
* ```
|
|
420
420
|
*/
|
|
421
|
-
declare function isElement(node: TSESTree.Node | null | undefined, test?: ElementTest): node is
|
|
421
|
+
declare function isElement(node: TSESTree.Node | null | undefined, test?: ElementTest): node is JSXElementLike;
|
|
422
422
|
//#endregion
|
|
423
423
|
//#region src/is-fragment-element.d.ts
|
|
424
424
|
/**
|
|
@@ -448,7 +448,7 @@ declare function isElement(node: TSESTree.Node | null | undefined, test?: Elemen
|
|
|
448
448
|
* if (isFragmentElement(node, config.jsxFragmentFactory)) { … }
|
|
449
449
|
* ```
|
|
450
450
|
*/
|
|
451
|
-
declare function isFragmentElement(node: TSESTree.Node, jsxFragmentFactory?: string): node is
|
|
451
|
+
declare function isFragmentElement(node: TSESTree.Node, jsxFragmentFactory?: string): node is JSXElementLike;
|
|
452
452
|
//#endregion
|
|
453
453
|
//#region src/is-host-element.d.ts
|
|
454
454
|
/**
|
|
@@ -678,6 +678,6 @@ declare function getJsxConfig(context: RuleContext): Required<JsxConfig>;
|
|
|
678
678
|
* }
|
|
679
679
|
* ```
|
|
680
680
|
*/
|
|
681
|
-
declare function resolveAttributeValue(context: RuleContext, attribute:
|
|
681
|
+
declare function resolveAttributeValue(context: RuleContext, attribute: JSXAttributeLike): JsxAttributeValue;
|
|
682
682
|
//#endregion
|
|
683
683
|
export { DEFAULT_JSX_DETECTION_HINT, ElementTest, JsxAttributeValue, JsxConfig, JsxDetectionHint, JsxEmit, findAttribute, findParentAttribute, getAttributeName, getAttributeStaticValue, getAttributeValue, getChildren, getElementFullType, getElementSelfType, getJsxConfig, getJsxConfigFromAnnotation, getJsxConfigFromCompilerOptions, hasAnyAttribute, hasAttribute, hasChildren, hasEveryAttribute, isElement, isFragmentElement, isHostElement, isJsxLike, isJsxText, isWhitespace, isWhitespaceText, resolveAttributeValue };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { findParent } from "@eslint-react/ast";
|
|
1
|
+
import { Check, Traverse } from "@eslint-react/ast";
|
|
3
2
|
import { resolve } from "@eslint-react/var";
|
|
4
3
|
import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/types";
|
|
5
4
|
import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
@@ -68,10 +67,10 @@ function findAttribute(context, element, name) {
|
|
|
68
67
|
switch (attr.argument.type) {
|
|
69
68
|
case AST_NODE_TYPES.Identifier: {
|
|
70
69
|
const initNode = resolve(context, attr.argument);
|
|
71
|
-
if (initNode?.type === AST_NODE_TYPES.ObjectExpression) return
|
|
70
|
+
if (initNode?.type === AST_NODE_TYPES.ObjectExpression) return Traverse.findProperty(initNode.properties, name) != null;
|
|
72
71
|
return false;
|
|
73
72
|
}
|
|
74
|
-
case AST_NODE_TYPES.ObjectExpression: return
|
|
73
|
+
case AST_NODE_TYPES.ObjectExpression: return Traverse.findProperty(attr.argument.properties, name) != null;
|
|
75
74
|
}
|
|
76
75
|
return false;
|
|
77
76
|
});
|
|
@@ -106,7 +105,7 @@ function findParentAttribute(node, test = () => true) {
|
|
|
106
105
|
const guard = (n) => {
|
|
107
106
|
return n.type === AST_NODE_TYPES.JSXAttribute && test(n);
|
|
108
107
|
};
|
|
109
|
-
return findParent(node, guard);
|
|
108
|
+
return Traverse.findParent(node, guard);
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
//#endregion
|
|
@@ -656,7 +655,7 @@ const DEFAULT_JSX_DETECTION_HINT = 0n | JsxDetectionHint.DoNotIncludeJsxWithNumb
|
|
|
656
655
|
*/
|
|
657
656
|
function isJsxLike(context, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
658
657
|
if (node == null) return false;
|
|
659
|
-
if (
|
|
658
|
+
if (Check.isJSX(node)) return true;
|
|
660
659
|
switch (node.type) {
|
|
661
660
|
case AST_NODE_TYPES.Literal:
|
|
662
661
|
switch (typeof node.value) {
|
|
@@ -691,7 +690,7 @@ function isJsxLike(context, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
691
690
|
return false;
|
|
692
691
|
case AST_NODE_TYPES.Identifier:
|
|
693
692
|
if (node.name === "undefined") return !(hint & JsxDetectionHint.DoNotIncludeJsxWithUndefinedValue);
|
|
694
|
-
if (
|
|
693
|
+
if (Check.isJSXTagNameExpression(node)) return true;
|
|
695
694
|
return isJsxLike(context, resolve(context, node), hint);
|
|
696
695
|
}
|
|
697
696
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2-next.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": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"@typescript-eslint/types": "^8.58.1",
|
|
34
34
|
"@typescript-eslint/utils": "^8.58.1",
|
|
35
35
|
"ts-pattern": "^5.9.0",
|
|
36
|
-
"@eslint-react/ast": "5.2.
|
|
37
|
-
"@eslint-react/eslint": "5.2.
|
|
38
|
-
"@eslint-react/shared": "5.2.
|
|
39
|
-
"@eslint-react/var": "5.2.
|
|
36
|
+
"@eslint-react/ast": "5.2.2-next.0",
|
|
37
|
+
"@eslint-react/eslint": "5.2.2-next.0",
|
|
38
|
+
"@eslint-react/shared": "5.2.2-next.0",
|
|
39
|
+
"@eslint-react/var": "5.2.2-next.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"tsdown": "^0.21.7",
|