@eslint-react/core
Advanced tools
+13
-17
@@ -630,3 +630,3 @@ import * as ast from "@eslint-react/ast"; | ||
| node: TSESTree.JSXEmptyExpression; | ||
| toStatic(): "{}"; | ||
| toStatic(): null; | ||
| } | { | ||
@@ -638,3 +638,3 @@ kind: "boolean"; | ||
| node: TSESTree.JSXElement; | ||
| toStatic(): unknown; | ||
| toStatic(): null; | ||
| } | { | ||
@@ -652,3 +652,3 @@ kind: "literal"; | ||
| node: TSESTree.JSXSpreadAttribute["argument"]; | ||
| toStatic(): unknown; | ||
| toStatic(): null; | ||
| } | { | ||
@@ -658,3 +658,3 @@ kind: "spreadChild"; | ||
| node: TSESTree.JSXSpreadChild["expression"]; | ||
| toStatic(): unknown; | ||
| toStatic(): null; | ||
| }; | ||
@@ -793,5 +793,4 @@ //#endregion | ||
| * @param name The name of the attribute to find (e.g. `"className"`). | ||
| * @param initialScope An optional scope to use for resolving spread attributes. If not provided, | ||
| */ | ||
| findAttribute(node: TSESTree.JSXElement, name: string, initialScope?: Scope): ast.TSESTreeJSXAttributeLike | undefined; | ||
| findAttribute(node: TSESTree.JSXElement, name: string): ast.TSESTreeJSXAttributeLike | undefined; | ||
| /** | ||
@@ -818,6 +817,5 @@ * Get the stringified name of a `JSXAttribute` node | ||
| * @param name The name of the attribute to resolve (e.g. `"className"`). | ||
| * @param initialScope An optional scope to use for resolving spread attributes. If not provided, the scope will be determined from the context of the attribute node. | ||
| * @returns The static value of the attribute, or `undefined` if not found or not statically resolvable. | ||
| */ | ||
| getAttributeStaticValue(node: TSESTree.JSXElement, name: string, initialScope?: Scope): unknown; | ||
| getAttributeStaticValue(node: TSESTree.JSXElement, name: string): unknown; | ||
| /** | ||
@@ -830,6 +828,5 @@ * **All-in-one helper** – find an attribute by name on an element *and* | ||
| * @param name The name of the attribute to find and resolve (e.g. `"className"`). | ||
| * @param initialScope An optional scope to use for resolving spread attributes. If not provided, the scope will be determined from the context of the attribute node. | ||
| * @returns A descriptor of the attribute's value that can be further inspected, or `undefined` if the attribute is not found. | ||
| */ | ||
| getAttributeValue(node: TSESTree.JSXElement, name: string, initialScope?: Scope): JsxAttributeValue | undefined; | ||
| getAttributeValue(node: TSESTree.JSXElement, name: string): JsxAttributeValue | undefined; | ||
| /** | ||
@@ -858,6 +855,5 @@ * Get the **self name** (last segment) of a JSX element type. | ||
| * @param name The name of the attribute to check for (e.g. `"className"`). | ||
| * @param initialScope An optional scope to use for resolving spread attributes. If not provided, the scope will be determined from the context of the attribute node. | ||
| * @returns `true` if the attribute exists on the element, `false` otherwise. | ||
| */ | ||
| hasAttribute(node: TSESTree.JSXElement, name: string, initialScope?: Scope): boolean; | ||
| hasAttribute(node: TSESTree.JSXElement, name: string): boolean; | ||
| /** | ||
@@ -898,3 +894,3 @@ * Whether the node is a React **Fragment** element (either `<Fragment>` / | ||
| readonly node: TSESTree.JSXEmptyExpression; | ||
| readonly toStatic: () => "{}"; | ||
| readonly toStatic: () => null; | ||
| readonly getChildren?: never; | ||
@@ -913,10 +909,10 @@ } | { | ||
| readonly kind: "spreadChild"; | ||
| readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression; | ||
| readonly toStatic: () => null; | ||
| readonly getChildren: (_at: number) => null; | ||
| readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression; | ||
| readonly toStatic: () => unknown; | ||
| } | { | ||
| readonly kind: "spreadProps"; | ||
| readonly node: TSESTree.Expression; | ||
| readonly toStatic: () => null; | ||
| readonly getProperty: (name: string) => unknown; | ||
| readonly node: TSESTree.Expression; | ||
| readonly toStatic: () => unknown; | ||
| }; | ||
@@ -923,0 +919,0 @@ } |
+25
-30
@@ -599,6 +599,4 @@ import * as ast from "@eslint-react/ast"; | ||
| * @param name The name of the attribute to find (e.g. `"className"`). | ||
| * @param initialScope An optional scope to use for resolving spread attributes. If not provided, | ||
| */ | ||
| findAttribute(node, name, initialScope) { | ||
| initialScope ?? this.context.sourceCode.getScope(node); | ||
| findAttribute(node, name) { | ||
| return node.openingElement.attributes.findLast((attr) => { | ||
@@ -640,7 +638,6 @@ if (attr.type === AST_NODE_TYPES.JSXAttribute) return stringifyJsx(attr.name) === name; | ||
| * @param name The name of the attribute to resolve (e.g. `"className"`). | ||
| * @param initialScope An optional scope to use for resolving spread attributes. If not provided, the scope will be determined from the context of the attribute node. | ||
| * @returns The static value of the attribute, or `undefined` if not found or not statically resolvable. | ||
| */ | ||
| getAttributeStaticValue(node, name, initialScope) { | ||
| const attr = this.findAttribute(node, name, initialScope); | ||
| getAttributeStaticValue(node, name) { | ||
| const attr = this.findAttribute(node, name); | ||
| if (attr == null) return void 0; | ||
@@ -658,7 +655,6 @@ const resolved = this.resolveAttributeValue(attr); | ||
| * @param name The name of the attribute to find and resolve (e.g. `"className"`). | ||
| * @param initialScope An optional scope to use for resolving spread attributes. If not provided, the scope will be determined from the context of the attribute node. | ||
| * @returns A descriptor of the attribute's value that can be further inspected, or `undefined` if the attribute is not found. | ||
| */ | ||
| getAttributeValue(node, name, initialScope) { | ||
| const attr = this.findAttribute(node, name, initialScope); | ||
| getAttributeValue(node, name) { | ||
| const attr = this.findAttribute(node, name); | ||
| if (attr == null) return void 0; | ||
@@ -695,7 +691,6 @@ return this.resolveAttributeValue(attr); | ||
| * @param name The name of the attribute to check for (e.g. `"className"`). | ||
| * @param initialScope An optional scope to use for resolving spread attributes. If not provided, the scope will be determined from the context of the attribute node. | ||
| * @returns `true` if the attribute exists on the element, `false` otherwise. | ||
| */ | ||
| hasAttribute(node, name, initialScope) { | ||
| return this.findAttribute(node, name, initialScope) != null; | ||
| hasAttribute(node, name) { | ||
| return this.findAttribute(node, name) != null; | ||
| } | ||
@@ -732,7 +727,7 @@ /** | ||
| resolveAttributeValue(attribute) { | ||
| const initialScope = this.context.sourceCode.getScope(attribute); | ||
| if (attribute.type === AST_NODE_TYPES.JSXAttribute) return this.#resolveJsxAttribute(attribute, initialScope); | ||
| return this.#resolveJsxSpreadAttribute(attribute, initialScope); | ||
| if (attribute.type === AST_NODE_TYPES.JSXAttribute) return this.#resolveJsxAttribute(attribute); | ||
| return this.#resolveJsxSpreadAttribute(attribute); | ||
| } | ||
| #resolveJsxAttribute(node, initialScope) { | ||
| #resolveJsxAttribute(node) { | ||
| const scope = this.context.sourceCode.getScope(node); | ||
| if (node.value == null) return { | ||
@@ -761,3 +756,3 @@ kind: "boolean", | ||
| toStatic() { | ||
| return "{}"; | ||
| return null; | ||
| } | ||
@@ -769,3 +764,3 @@ }; | ||
| toStatic() { | ||
| return getStaticValue(expr, initialScope)?.value; | ||
| return getStaticValue(expr, scope)?.value; | ||
| } | ||
@@ -781,26 +776,26 @@ }; | ||
| }; | ||
| case AST_NODE_TYPES.JSXSpreadChild: { | ||
| const expr = node.value.expression; | ||
| case AST_NODE_TYPES.JSXSpreadChild: | ||
| node.value.expression; | ||
| return { | ||
| kind: "spreadChild", | ||
| node: node.value.expression, | ||
| toStatic() { | ||
| return null; | ||
| }, | ||
| getChildren(_at) { | ||
| return null; | ||
| }, | ||
| node: node.value.expression, | ||
| toStatic() { | ||
| return getStaticValue(expr, initialScope)?.value; | ||
| } | ||
| }; | ||
| } | ||
| } | ||
| } | ||
| #resolveJsxSpreadAttribute(node, initialScope) { | ||
| #resolveJsxSpreadAttribute(node) { | ||
| const scope = this.context.sourceCode.getScope(node); | ||
| return { | ||
| kind: "spreadProps", | ||
| getProperty(name) { | ||
| return match(getStaticValue(node.argument, initialScope)?.value).with({ [name]: P.select(P.any) }, identity).otherwise(() => null); | ||
| }, | ||
| node: node.argument, | ||
| toStatic() { | ||
| return getStaticValue(node.argument, initialScope)?.value; | ||
| return null; | ||
| }, | ||
| getProperty(name) { | ||
| return match(getStaticValue(node.argument, scope)?.value).with({ [name]: P.select(P.any) }, identity).otherwise(() => null); | ||
| } | ||
@@ -807,0 +802,0 @@ }; |
+5
-5
| { | ||
| "name": "@eslint-react/core", | ||
| "version": "3.0.0-next.70", | ||
| "version": "3.0.0-next.71", | ||
| "description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.", | ||
@@ -37,6 +37,6 @@ "homepage": "https://github.com/Rel1cx/eslint-react", | ||
| "ts-pattern": "^5.9.0", | ||
| "@eslint-react/ast": "3.0.0-next.70", | ||
| "@eslint-react/eff": "3.0.0-next.70", | ||
| "@eslint-react/var": "3.0.0-next.70", | ||
| "@eslint-react/shared": "3.0.0-next.70" | ||
| "@eslint-react/ast": "3.0.0-next.71", | ||
| "@eslint-react/eff": "3.0.0-next.71", | ||
| "@eslint-react/shared": "3.0.0-next.71", | ||
| "@eslint-react/var": "3.0.0-next.71" | ||
| }, | ||
@@ -43,0 +43,0 @@ "devDependencies": { |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
95691
-1.64%2216
-0.4%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed