@eslint-react/core 1.28.0-next.4 → 1.28.0-next.5
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.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -369,11 +369,11 @@ declare function isFromReactMember(memberName: string, name: string): (context:
|
|
|
369
369
|
/**
|
|
370
370
|
* Check if an identifier is initialized from react
|
|
371
371
|
* @param name The top-level identifier's name
|
|
372
|
-
* @param
|
|
372
|
+
* @param importSource The import source to check against
|
|
373
373
|
* @param initialScope Initial scope to search for the identifier
|
|
374
374
|
* @returns Whether the identifier is initialized from react
|
|
375
375
|
*/
|
|
376
|
-
declare function isInitializedFromReact(name: string,
|
|
376
|
+
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
377
377
|
|
|
378
378
|
/**********************************************
|
|
379
379
|
* DO NOT MODIFY THIS FILE MANUALLY *
|
package/dist/index.d.ts
CHANGED
|
@@ -369,11 +369,11 @@ declare function isFromReactMember(memberName: string, name: string): (context:
|
|
|
369
369
|
/**
|
|
370
370
|
* Check if an identifier is initialized from react
|
|
371
371
|
* @param name The top-level identifier's name
|
|
372
|
-
* @param
|
|
372
|
+
* @param importSource The import source to check against
|
|
373
373
|
* @param initialScope Initial scope to search for the identifier
|
|
374
374
|
* @returns Whether the identifier is initialized from react
|
|
375
375
|
*/
|
|
376
|
-
declare function isInitializedFromReact(name: string,
|
|
376
|
+
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
377
377
|
|
|
378
378
|
/**********************************************
|
|
379
379
|
* DO NOT MODIFY THIS FILE MANUALLY *
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var birecord__default = /*#__PURE__*/_interopDefault(birecord);
|
|
|
38
38
|
function getRequireExpressionArguments(node) {
|
|
39
39
|
return tsPattern.match(node).with({ type: types.AST_NODE_TYPES.CallExpression, arguments: tsPattern.P.select(), callee: { type: types.AST_NODE_TYPES.Identifier, name: "require" } }, eff.identity).with({ type: types.AST_NODE_TYPES.MemberExpression, object: tsPattern.P.select() }, getRequireExpressionArguments).otherwise(() => eff._);
|
|
40
40
|
}
|
|
41
|
-
function isInitializedFromReact(name,
|
|
41
|
+
function isInitializedFromReact(name, importSource, initialScope) {
|
|
42
42
|
if (name.toLowerCase() === "react") return true;
|
|
43
43
|
const latestDef = VAR__namespace.findVariable(name, initialScope)?.defs.at(-1);
|
|
44
44
|
if (latestDef == null) return false;
|
|
@@ -46,19 +46,19 @@ function isInitializedFromReact(name, source, initialScope) {
|
|
|
46
46
|
if (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init != null) {
|
|
47
47
|
const { init } = node;
|
|
48
48
|
if (init.type === types.AST_NODE_TYPES.MemberExpression && init.object.type === types.AST_NODE_TYPES.Identifier) {
|
|
49
|
-
return isInitializedFromReact(init.object.name,
|
|
49
|
+
return isInitializedFromReact(init.object.name, importSource, initialScope);
|
|
50
50
|
}
|
|
51
51
|
if (init.type === types.AST_NODE_TYPES.Identifier) {
|
|
52
|
-
return isInitializedFromReact(init.name,
|
|
52
|
+
return isInitializedFromReact(init.name, importSource, initialScope);
|
|
53
53
|
}
|
|
54
54
|
const args = getRequireExpressionArguments(init);
|
|
55
55
|
const arg0 = args?.[0];
|
|
56
56
|
if (arg0 == null || !AST8__namespace.isKindOfLiteral(arg0, "string")) {
|
|
57
57
|
return false;
|
|
58
58
|
}
|
|
59
|
-
return arg0.value ===
|
|
59
|
+
return arg0.value === importSource || arg0.value.startsWith(`${importSource}/`);
|
|
60
60
|
}
|
|
61
|
-
return parent?.type === types.AST_NODE_TYPES.ImportDeclaration && parent.source.value ===
|
|
61
|
+
return parent?.type === types.AST_NODE_TYPES.ImportDeclaration && parent.source.value === importSource;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// src/utils/is-from-react.ts
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import birecord from 'birecord';
|
|
|
11
11
|
function getRequireExpressionArguments(node) {
|
|
12
12
|
return match(node).with({ type: AST_NODE_TYPES.CallExpression, arguments: P.select(), callee: { type: AST_NODE_TYPES.Identifier, name: "require" } }, identity).with({ type: AST_NODE_TYPES.MemberExpression, object: P.select() }, getRequireExpressionArguments).otherwise(() => _);
|
|
13
13
|
}
|
|
14
|
-
function isInitializedFromReact(name,
|
|
14
|
+
function isInitializedFromReact(name, importSource, initialScope) {
|
|
15
15
|
if (name.toLowerCase() === "react") return true;
|
|
16
16
|
const latestDef = VAR.findVariable(name, initialScope)?.defs.at(-1);
|
|
17
17
|
if (latestDef == null) return false;
|
|
@@ -19,19 +19,19 @@ function isInitializedFromReact(name, source, initialScope) {
|
|
|
19
19
|
if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) {
|
|
20
20
|
const { init } = node;
|
|
21
21
|
if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) {
|
|
22
|
-
return isInitializedFromReact(init.object.name,
|
|
22
|
+
return isInitializedFromReact(init.object.name, importSource, initialScope);
|
|
23
23
|
}
|
|
24
24
|
if (init.type === AST_NODE_TYPES.Identifier) {
|
|
25
|
-
return isInitializedFromReact(init.name,
|
|
25
|
+
return isInitializedFromReact(init.name, importSource, initialScope);
|
|
26
26
|
}
|
|
27
27
|
const args = getRequireExpressionArguments(init);
|
|
28
28
|
const arg0 = args?.[0];
|
|
29
29
|
if (arg0 == null || !AST8.isKindOfLiteral(arg0, "string")) {
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
32
|
-
return arg0.value ===
|
|
32
|
+
return arg0.value === importSource || arg0.value.startsWith(`${importSource}/`);
|
|
33
33
|
}
|
|
34
|
-
return parent?.type === AST_NODE_TYPES.ImportDeclaration && parent.source.value ===
|
|
34
|
+
return parent?.type === AST_NODE_TYPES.ImportDeclaration && parent.source.value === importSource;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// src/utils/is-from-react.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.28.0-next.
|
|
3
|
+
"version": "1.28.0-next.5",
|
|
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": {
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"@typescript-eslint/utils": "^8.25.0",
|
|
42
42
|
"birecord": "^0.1.1",
|
|
43
43
|
"ts-pattern": "^5.6.2",
|
|
44
|
-
"@eslint-react/ast": "1.28.0-next.
|
|
45
|
-
"@eslint-react/eff": "1.28.0-next.
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
44
|
+
"@eslint-react/ast": "1.28.0-next.5",
|
|
45
|
+
"@eslint-react/eff": "1.28.0-next.5",
|
|
46
|
+
"@eslint-react/jsx": "1.28.0-next.5",
|
|
47
|
+
"@eslint-react/shared": "1.28.0-next.5",
|
|
48
|
+
"@eslint-react/var": "1.28.0-next.5"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"tsup": "^8.
|
|
51
|
+
"tsup": "^8.4.0",
|
|
52
52
|
"@local/configs": "0.0.0"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|