@eslint-react/core 3.0.0-next.77 → 3.0.0-next.79
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 +14 -14
- package/dist/index.js +8 -8
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ declare function findImportSource(name: string, initialScope: Scope): string | n
|
|
|
19
19
|
* Check if a variable is initialized from React import
|
|
20
20
|
* @param name The variable name
|
|
21
21
|
* @param initialScope The initial scope
|
|
22
|
-
* @param importSource Alternative import source of React (
|
|
22
|
+
* @param importSource Alternative import source of React (ex: "preact/compat")
|
|
23
23
|
* @returns True if the variable is initialized or derived from React import
|
|
24
24
|
*/
|
|
25
25
|
declare function isInitializedFromReact(name: string, initialScope: Scope, importSource?: string): boolean;
|
|
@@ -29,7 +29,7 @@ declare function isInitializedFromReact(name: string, initialScope: Scope, impor
|
|
|
29
29
|
* if a variable is initialized from React Native import
|
|
30
30
|
* @param name The variable name
|
|
31
31
|
* @param initialScope The initial scope
|
|
32
|
-
* @param importSource Alternative import source of React Native (
|
|
32
|
+
* @param importSource Alternative import source of React Native (ex: "react-native-web")
|
|
33
33
|
* @returns True if the variable is initialized from React Native import
|
|
34
34
|
*/
|
|
35
35
|
declare function isInitializedFromReactNative(name: string, initialScope: Scope, importSource?: string): boolean;
|
|
@@ -43,7 +43,7 @@ declare namespace isReactAPI {
|
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Check if the node is a React API identifier or member expression
|
|
46
|
-
* @param api The React API name to check against (
|
|
46
|
+
* @param api The React API name to check against (ex: "useState", "React.memo")
|
|
47
47
|
* @returns A predicate function to check if a node matches the API
|
|
48
48
|
*/
|
|
49
49
|
declare function isReactAPI(api: string): isReactAPI.ReturnType;
|
|
@@ -164,7 +164,7 @@ interface SemanticFunc extends SemanticNode {
|
|
|
164
164
|
type: TSESTree.TSTypeAnnotation | null;
|
|
165
165
|
/** The body of the function */
|
|
166
166
|
body: TSESTree.BlockStatement | TSESTree.Expression;
|
|
167
|
-
/** The directives of the function (
|
|
167
|
+
/** The directives of the function (ex: "use strict", "use client", "use server", etc.) */
|
|
168
168
|
directives: ast.TSESTreeDirective[];
|
|
169
169
|
/** The parameters of the function */
|
|
170
170
|
parameters: TSESTree.Parameter[];
|
|
@@ -222,7 +222,7 @@ interface FunctionComponentSemanticNode extends SemanticNode {
|
|
|
222
222
|
*/
|
|
223
223
|
displayName: null | TSESTree.Expression;
|
|
224
224
|
/**
|
|
225
|
-
* The directives used in the function (
|
|
225
|
+
* The directives used in the function (ex: "use strict", "use client", etc.)
|
|
226
226
|
*/
|
|
227
227
|
directives: ast.TSESTreeDirective[];
|
|
228
228
|
}
|
|
@@ -394,10 +394,10 @@ declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): b
|
|
|
394
394
|
* Component flag constants
|
|
395
395
|
*/
|
|
396
396
|
declare const ComponentFlag: {
|
|
397
|
-
/** Indicates the component creates elements using `createElement` instead of JSX */CreateElement: bigint; /** Indicates the component forwards a ref (
|
|
398
|
-
ForwardRef: bigint; /** Indicates the component is memoized (
|
|
397
|
+
/** Indicates the component creates elements using `createElement` instead of JSX */CreateElement: bigint; /** Indicates the component forwards a ref (ex: React.forwardRef) */
|
|
398
|
+
ForwardRef: bigint; /** Indicates the component is memoized (ex: React.memo) */
|
|
399
399
|
Memo: bigint; /** No flags set */
|
|
400
|
-
None: bigint; /** Indicates the component is a pure component (
|
|
400
|
+
None: bigint; /** Indicates the component is a pure component (ex: extends PureComponent) */
|
|
401
401
|
PureComponent: bigint;
|
|
402
402
|
};
|
|
403
403
|
/**
|
|
@@ -522,7 +522,7 @@ interface HookSemanticNode extends SemanticNode {
|
|
|
522
522
|
name: string;
|
|
523
523
|
/** The other hooks called by the hook */
|
|
524
524
|
hookCalls: TSESTree.CallExpression[];
|
|
525
|
-
/** The directives used in the function (
|
|
525
|
+
/** The directives used in the function (ex: "use strict", "use client", etc.) */
|
|
526
526
|
directives: TSESTree.StringLiteral[];
|
|
527
527
|
}
|
|
528
528
|
//#endregion
|
|
@@ -785,12 +785,12 @@ declare class JsxInspector {
|
|
|
785
785
|
* Returns the **last** matching attribute (to mirror React's behaviour where
|
|
786
786
|
* later props win), or `undefined` if not found.
|
|
787
787
|
* @param node The JSX element to search for the attribute.
|
|
788
|
-
* @param name The name of the attribute to find (
|
|
788
|
+
* @param name The name of the attribute to find (ex: `"className"`).
|
|
789
789
|
*/
|
|
790
790
|
findAttribute(node: TSESTree.JSXElement, name: string): ast.TSESTreeJSXAttributeLike | undefined;
|
|
791
791
|
/**
|
|
792
792
|
* Get the stringified name of a `JSXAttribute` node
|
|
793
|
-
* (
|
|
793
|
+
* (ex: `"className"`, `"aria-label"`, `"xml:space"`).
|
|
794
794
|
* @param node The `JSXAttribute` node to extract the name from.
|
|
795
795
|
* @returns The stringified name of the attribute.
|
|
796
796
|
*/
|
|
@@ -808,7 +808,7 @@ declare class JsxInspector {
|
|
|
808
808
|
* Returns `undefined` when the attribute is not present or its value
|
|
809
809
|
* cannot be statically determined.
|
|
810
810
|
* @param node The JSX element to search for the attribute.
|
|
811
|
-
* @param name The name of the attribute to resolve (
|
|
811
|
+
* @param name The name of the attribute to resolve (ex: `"className"`).
|
|
812
812
|
* @returns The static value of the attribute, or `undefined` if not found or not statically resolvable.
|
|
813
813
|
*/
|
|
814
814
|
getAttributeStaticValue(node: TSESTree.JSXElement, name: string): unknown;
|
|
@@ -818,7 +818,7 @@ declare class JsxInspector {
|
|
|
818
818
|
*
|
|
819
819
|
* Returns `undefined` when the attribute is not present.
|
|
820
820
|
* @param node The JSX element to search for the attribute.
|
|
821
|
-
* @param name The name of the attribute to find and resolve (
|
|
821
|
+
* @param name The name of the attribute to find and resolve (ex: `"className"`).
|
|
822
822
|
* @returns A descriptor of the attribute's value that can be further inspected, or `undefined` if the attribute is not found.
|
|
823
823
|
*/
|
|
824
824
|
getAttributeValue(node: TSESTree.JSXElement, name: string): JsxAttributeValue | undefined;
|
|
@@ -844,7 +844,7 @@ declare class JsxInspector {
|
|
|
844
844
|
/**
|
|
845
845
|
* Shorthand: check whether an attribute exists on the element.
|
|
846
846
|
* @param node The JSX element to check for the attribute.
|
|
847
|
-
* @param name The name of the attribute to check for (
|
|
847
|
+
* @param name The name of the attribute to check for (ex: `"className"`).
|
|
848
848
|
* @returns `true` if the attribute exists on the element, `false` otherwise.
|
|
849
849
|
*/
|
|
850
850
|
hasAttribute(node: TSESTree.JSXElement, name: string): boolean;
|
package/dist/index.js
CHANGED
|
@@ -213,7 +213,7 @@ function findImportSource(name, initialScope) {
|
|
|
213
213
|
* Check if a variable is initialized from React import
|
|
214
214
|
* @param name The variable name
|
|
215
215
|
* @param initialScope The initial scope
|
|
216
|
-
* @param importSource Alternative import source of React (
|
|
216
|
+
* @param importSource Alternative import source of React (ex: "preact/compat")
|
|
217
217
|
* @returns True if the variable is initialized or derived from React import
|
|
218
218
|
*/
|
|
219
219
|
function isInitializedFromReact(name, initialScope, importSource = "react") {
|
|
@@ -226,7 +226,7 @@ function isInitializedFromReact(name, initialScope, importSource = "react") {
|
|
|
226
226
|
* if a variable is initialized from React Native import
|
|
227
227
|
* @param name The variable name
|
|
228
228
|
* @param initialScope The initial scope
|
|
229
|
-
* @param importSource Alternative import source of React Native (
|
|
229
|
+
* @param importSource Alternative import source of React Native (ex: "react-native-web")
|
|
230
230
|
* @returns True if the variable is initialized from React Native import
|
|
231
231
|
*/
|
|
232
232
|
function isInitializedFromReactNative(name, initialScope, importSource = "react-native") {
|
|
@@ -241,7 +241,7 @@ function isInitializedFromReactNative(name, initialScope, importSource = "react-
|
|
|
241
241
|
//#region src/api/is-react-api.ts
|
|
242
242
|
/**
|
|
243
243
|
* Check if the node is a React API identifier or member expression
|
|
244
|
-
* @param api The React API name to check against (
|
|
244
|
+
* @param api The React API name to check against (ex: "useState", "React.memo")
|
|
245
245
|
* @returns A predicate function to check if a node matches the API
|
|
246
246
|
*/
|
|
247
247
|
function isReactAPI(api) {
|
|
@@ -753,7 +753,7 @@ var JsxInspector = class JsxInspector {
|
|
|
753
753
|
* Returns the **last** matching attribute (to mirror React's behaviour where
|
|
754
754
|
* later props win), or `undefined` if not found.
|
|
755
755
|
* @param node The JSX element to search for the attribute.
|
|
756
|
-
* @param name The name of the attribute to find (
|
|
756
|
+
* @param name The name of the attribute to find (ex: `"className"`).
|
|
757
757
|
*/
|
|
758
758
|
findAttribute(node, name) {
|
|
759
759
|
return node.openingElement.attributes.findLast((attr) => {
|
|
@@ -771,7 +771,7 @@ var JsxInspector = class JsxInspector {
|
|
|
771
771
|
}
|
|
772
772
|
/**
|
|
773
773
|
* Get the stringified name of a `JSXAttribute` node
|
|
774
|
-
* (
|
|
774
|
+
* (ex: `"className"`, `"aria-label"`, `"xml:space"`).
|
|
775
775
|
* @param node The `JSXAttribute` node to extract the name from.
|
|
776
776
|
* @returns The stringified name of the attribute.
|
|
777
777
|
*/
|
|
@@ -791,7 +791,7 @@ var JsxInspector = class JsxInspector {
|
|
|
791
791
|
* Returns `undefined` when the attribute is not present or its value
|
|
792
792
|
* cannot be statically determined.
|
|
793
793
|
* @param node The JSX element to search for the attribute.
|
|
794
|
-
* @param name The name of the attribute to resolve (
|
|
794
|
+
* @param name The name of the attribute to resolve (ex: `"className"`).
|
|
795
795
|
* @returns The static value of the attribute, or `undefined` if not found or not statically resolvable.
|
|
796
796
|
*/
|
|
797
797
|
getAttributeStaticValue(node, name) {
|
|
@@ -807,7 +807,7 @@ var JsxInspector = class JsxInspector {
|
|
|
807
807
|
*
|
|
808
808
|
* Returns `undefined` when the attribute is not present.
|
|
809
809
|
* @param node The JSX element to search for the attribute.
|
|
810
|
-
* @param name The name of the attribute to find and resolve (
|
|
810
|
+
* @param name The name of the attribute to find and resolve (ex: `"className"`).
|
|
811
811
|
* @returns A descriptor of the attribute's value that can be further inspected, or `undefined` if the attribute is not found.
|
|
812
812
|
*/
|
|
813
813
|
getAttributeValue(node, name) {
|
|
@@ -842,7 +842,7 @@ var JsxInspector = class JsxInspector {
|
|
|
842
842
|
/**
|
|
843
843
|
* Shorthand: check whether an attribute exists on the element.
|
|
844
844
|
* @param node The JSX element to check for the attribute.
|
|
845
|
-
* @param name The name of the attribute to check for (
|
|
845
|
+
* @param name The name of the attribute to check for (ex: `"className"`).
|
|
846
846
|
* @returns `true` if the attribute exists on the element, `false` otherwise.
|
|
847
847
|
*/
|
|
848
848
|
hasAttribute(node, name) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.79",
|
|
4
4
|
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"@typescript-eslint/types": "canary",
|
|
35
35
|
"@typescript-eslint/utils": "canary",
|
|
36
36
|
"ts-pattern": "^5.9.0",
|
|
37
|
-
"@eslint-react/ast": "3.0.0-next.
|
|
38
|
-
"@eslint-react/
|
|
39
|
-
"@eslint-react/
|
|
37
|
+
"@eslint-react/ast": "3.0.0-next.79",
|
|
38
|
+
"@eslint-react/var": "3.0.0-next.79",
|
|
39
|
+
"@eslint-react/shared": "3.0.0-next.79"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"tsdown": "^0.21.0
|
|
42
|
+
"tsdown": "^0.21.0",
|
|
43
43
|
"@local/configs": "0.0.0",
|
|
44
44
|
"@local/eff": "3.0.0-beta.72"
|
|
45
45
|
},
|