@eslint-react/core 1.24.0-next.14 → 1.24.0-next.16
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -10
- package/dist/index.mjs +15 -11
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -363,7 +363,7 @@ type IsCallFromReactMember = {
|
|
|
363
363
|
};
|
|
364
364
|
declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
|
|
365
365
|
|
|
366
|
-
declare function isInitializedFromReact(name: string,
|
|
366
|
+
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
367
367
|
|
|
368
368
|
/**********************************************
|
|
369
369
|
* DO NOT MODIFY THIS FILE MANUALLY *
|
package/dist/index.d.ts
CHANGED
|
@@ -363,7 +363,7 @@ type IsCallFromReactMember = {
|
|
|
363
363
|
};
|
|
364
364
|
declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
|
|
365
365
|
|
|
366
|
-
declare function isInitializedFromReact(name: string,
|
|
366
|
+
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
367
367
|
|
|
368
368
|
/**********************************************
|
|
369
369
|
* DO NOT MODIFY THIS FILE MANUALLY *
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
|
|
|
34
34
|
var birecord__default = /*#__PURE__*/_interopDefault(birecord);
|
|
35
35
|
|
|
36
36
|
// src/component/component-collector.ts
|
|
37
|
-
function isInitializedFromReact(name,
|
|
37
|
+
function isInitializedFromReact(name, importSource, initialScope) {
|
|
38
38
|
return name.toLowerCase() === "react" || VAR__namespace.isInitializedFromSource(
|
|
39
39
|
name,
|
|
40
40
|
importSource,
|
|
@@ -52,12 +52,13 @@ function isFromReact(name) {
|
|
|
52
52
|
}
|
|
53
53
|
return node.name === name;
|
|
54
54
|
}
|
|
55
|
+
const importSource = settings.importSource ?? shared.DEFAULT_ESLINT_REACT_SETTINGS.importSource;
|
|
55
56
|
const initialScope = context.sourceCode.getScope(node);
|
|
56
57
|
if (node.type === types.AST_NODE_TYPES.MemberExpression) {
|
|
57
|
-
return node.object.type === types.AST_NODE_TYPES.Identifier && node.property.type === types.AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name,
|
|
58
|
+
return node.object.type === types.AST_NODE_TYPES.Identifier && node.property.type === types.AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name, importSource, initialScope);
|
|
58
59
|
}
|
|
59
60
|
if (node.name === name) {
|
|
60
|
-
return isInitializedFromReact(name,
|
|
61
|
+
return isInitializedFromReact(name, importSource, initialScope);
|
|
61
62
|
}
|
|
62
63
|
return false;
|
|
63
64
|
};
|
|
@@ -77,14 +78,15 @@ function isFromReactMember(memberName, name) {
|
|
|
77
78
|
}
|
|
78
79
|
return false;
|
|
79
80
|
}
|
|
81
|
+
const importSource = settings.importSource ?? shared.DEFAULT_ESLINT_REACT_SETTINGS.importSource;
|
|
80
82
|
const initialScope = context.sourceCode.getScope(node);
|
|
81
83
|
if (node.property.type !== types.AST_NODE_TYPES.Identifier || node.property.name !== name) {
|
|
82
84
|
return false;
|
|
83
85
|
}
|
|
84
86
|
if (node.object.type === types.AST_NODE_TYPES.Identifier && node.object.name === memberName) {
|
|
85
|
-
return isInitializedFromReact(node.object.name,
|
|
87
|
+
return isInitializedFromReact(node.object.name, importSource, initialScope);
|
|
86
88
|
}
|
|
87
|
-
if (node.object.type === types.AST_NODE_TYPES.MemberExpression && node.object.object.type === types.AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name,
|
|
89
|
+
if (node.object.type === types.AST_NODE_TYPES.MemberExpression && node.object.object.type === types.AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name, importSource, initialScope) && node.object.property.type === types.AST_NODE_TYPES.Identifier) {
|
|
88
90
|
return node.object.property.name === memberName;
|
|
89
91
|
}
|
|
90
92
|
return false;
|
|
@@ -186,13 +188,14 @@ function isReactHookCall(node) {
|
|
|
186
188
|
function isReactHookCallWithName(node, context) {
|
|
187
189
|
if (node == null) return eff.returnFalse;
|
|
188
190
|
const settings = shared.unsafeDecodeSettings(context.settings);
|
|
191
|
+
const importSource = settings.importSource ?? "react";
|
|
192
|
+
const initialScope = context.sourceCode.getScope(node);
|
|
189
193
|
return (name) => {
|
|
190
|
-
const initialScope = context.sourceCode.getScope(node);
|
|
191
194
|
switch (true) {
|
|
192
195
|
case (node.callee.type === types.AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
193
|
-
return !settings.strictImportCheck || isInitializedFromReact(name,
|
|
196
|
+
return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
194
197
|
case (node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
|
|
195
|
-
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name,
|
|
198
|
+
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
196
199
|
default:
|
|
197
200
|
return false;
|
|
198
201
|
}
|
|
@@ -213,13 +216,14 @@ function isReactHookCallWithNameLoose(node) {
|
|
|
213
216
|
}
|
|
214
217
|
function isReactHookCallWithNameAlias(name, context, alias) {
|
|
215
218
|
const settings = shared.unsafeDecodeSettings(context);
|
|
219
|
+
const importSource = settings.importSource ?? "react";
|
|
216
220
|
return (node) => {
|
|
217
221
|
const initialScope = context.sourceCode.getScope(node);
|
|
218
222
|
switch (true) {
|
|
219
223
|
case (node.callee.type === types.AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
220
|
-
return !settings.strictImportCheck || isInitializedFromReact(name,
|
|
224
|
+
return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
221
225
|
case (node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
|
|
222
|
-
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name,
|
|
226
|
+
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
223
227
|
default:
|
|
224
228
|
return alias.some(isReactHookCallWithNameLoose(node));
|
|
225
229
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as AST8 from '@eslint-react/ast';
|
|
2
2
|
import { flip, dual, _, returnFalse } from '@eslint-react/eff';
|
|
3
3
|
import * as JSX3 from '@eslint-react/jsx';
|
|
4
|
-
import { unsafeDecodeSettings, getId } from '@eslint-react/shared';
|
|
4
|
+
import { unsafeDecodeSettings, DEFAULT_ESLINT_REACT_SETTINGS, getId } from '@eslint-react/shared';
|
|
5
5
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
6
6
|
import * as VAR from '@eslint-react/var';
|
|
7
7
|
import birecord from 'birecord';
|
|
8
8
|
|
|
9
9
|
// src/component/component-collector.ts
|
|
10
|
-
function isInitializedFromReact(name,
|
|
10
|
+
function isInitializedFromReact(name, importSource, initialScope) {
|
|
11
11
|
return name.toLowerCase() === "react" || VAR.isInitializedFromSource(
|
|
12
12
|
name,
|
|
13
13
|
importSource,
|
|
@@ -25,12 +25,13 @@ function isFromReact(name) {
|
|
|
25
25
|
}
|
|
26
26
|
return node.name === name;
|
|
27
27
|
}
|
|
28
|
+
const importSource = settings.importSource ?? DEFAULT_ESLINT_REACT_SETTINGS.importSource;
|
|
28
29
|
const initialScope = context.sourceCode.getScope(node);
|
|
29
30
|
if (node.type === AST_NODE_TYPES.MemberExpression) {
|
|
30
|
-
return node.object.type === AST_NODE_TYPES.Identifier && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name,
|
|
31
|
+
return node.object.type === AST_NODE_TYPES.Identifier && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name, importSource, initialScope);
|
|
31
32
|
}
|
|
32
33
|
if (node.name === name) {
|
|
33
|
-
return isInitializedFromReact(name,
|
|
34
|
+
return isInitializedFromReact(name, importSource, initialScope);
|
|
34
35
|
}
|
|
35
36
|
return false;
|
|
36
37
|
};
|
|
@@ -50,14 +51,15 @@ function isFromReactMember(memberName, name) {
|
|
|
50
51
|
}
|
|
51
52
|
return false;
|
|
52
53
|
}
|
|
54
|
+
const importSource = settings.importSource ?? DEFAULT_ESLINT_REACT_SETTINGS.importSource;
|
|
53
55
|
const initialScope = context.sourceCode.getScope(node);
|
|
54
56
|
if (node.property.type !== AST_NODE_TYPES.Identifier || node.property.name !== name) {
|
|
55
57
|
return false;
|
|
56
58
|
}
|
|
57
59
|
if (node.object.type === AST_NODE_TYPES.Identifier && node.object.name === memberName) {
|
|
58
|
-
return isInitializedFromReact(node.object.name,
|
|
60
|
+
return isInitializedFromReact(node.object.name, importSource, initialScope);
|
|
59
61
|
}
|
|
60
|
-
if (node.object.type === AST_NODE_TYPES.MemberExpression && node.object.object.type === AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name,
|
|
62
|
+
if (node.object.type === AST_NODE_TYPES.MemberExpression && node.object.object.type === AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name, importSource, initialScope) && node.object.property.type === AST_NODE_TYPES.Identifier) {
|
|
61
63
|
return node.object.property.name === memberName;
|
|
62
64
|
}
|
|
63
65
|
return false;
|
|
@@ -159,13 +161,14 @@ function isReactHookCall(node) {
|
|
|
159
161
|
function isReactHookCallWithName(node, context) {
|
|
160
162
|
if (node == null) return returnFalse;
|
|
161
163
|
const settings = unsafeDecodeSettings(context.settings);
|
|
164
|
+
const importSource = settings.importSource ?? "react";
|
|
165
|
+
const initialScope = context.sourceCode.getScope(node);
|
|
162
166
|
return (name) => {
|
|
163
|
-
const initialScope = context.sourceCode.getScope(node);
|
|
164
167
|
switch (true) {
|
|
165
168
|
case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
166
|
-
return !settings.strictImportCheck || isInitializedFromReact(name,
|
|
169
|
+
return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
167
170
|
case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
|
|
168
|
-
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name,
|
|
171
|
+
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
169
172
|
default:
|
|
170
173
|
return false;
|
|
171
174
|
}
|
|
@@ -186,13 +189,14 @@ function isReactHookCallWithNameLoose(node) {
|
|
|
186
189
|
}
|
|
187
190
|
function isReactHookCallWithNameAlias(name, context, alias) {
|
|
188
191
|
const settings = unsafeDecodeSettings(context);
|
|
192
|
+
const importSource = settings.importSource ?? "react";
|
|
189
193
|
return (node) => {
|
|
190
194
|
const initialScope = context.sourceCode.getScope(node);
|
|
191
195
|
switch (true) {
|
|
192
196
|
case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
193
|
-
return !settings.strictImportCheck || isInitializedFromReact(name,
|
|
197
|
+
return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
194
198
|
case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
|
|
195
|
-
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name,
|
|
199
|
+
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
196
200
|
default:
|
|
197
201
|
return alias.some(isReactHookCallWithNameLoose(node));
|
|
198
202
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.24.0-next.
|
|
3
|
+
"version": "1.24.0-next.16",
|
|
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": {
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"@typescript-eslint/utils": "^8.20.0",
|
|
40
40
|
"birecord": "^0.1.1",
|
|
41
41
|
"ts-pattern": "^5.6.0",
|
|
42
|
-
"@eslint-react/ast": "1.24.0-next.
|
|
43
|
-
"@eslint-react/eff": "1.24.0-next.
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
42
|
+
"@eslint-react/ast": "1.24.0-next.16",
|
|
43
|
+
"@eslint-react/eff": "1.24.0-next.16",
|
|
44
|
+
"@eslint-react/jsx": "1.24.0-next.16",
|
|
45
|
+
"@eslint-react/shared": "1.24.0-next.16",
|
|
46
|
+
"@eslint-react/var": "1.24.0-next.16"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"tsup": "^8.3.5",
|