@eslint-react/core 1.17.2-next.5 → 1.17.2-next.6
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 +2045 -30
- package/dist/index.d.ts +2045 -30
- package/dist/index.js +1 -36
- package/dist/index.mjs +3 -37
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -41,38 +41,7 @@ function isInitializedFromReact(name, initialScope, settings) {
|
|
|
41
41
|
if (!settings.strictImportCheck) return true;
|
|
42
42
|
if (name.toLowerCase() === "react") return true;
|
|
43
43
|
const { importSource = "react" } = settings;
|
|
44
|
-
|
|
45
|
-
if (tools.O.isNone(maybeLatestDef)) return false;
|
|
46
|
-
const latestDef = maybeLatestDef.value;
|
|
47
|
-
const { node, parent } = latestDef;
|
|
48
|
-
if (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init) {
|
|
49
|
-
const { init } = node;
|
|
50
|
-
if (init.type === types.AST_NODE_TYPES.MemberExpression && init.object.type === types.AST_NODE_TYPES.Identifier) {
|
|
51
|
-
return isInitializedFromReact(init.object.name, initialScope, settings);
|
|
52
|
-
}
|
|
53
|
-
if (init.type === types.AST_NODE_TYPES.Identifier) {
|
|
54
|
-
return isInitializedFromReact(init.name, initialScope, settings);
|
|
55
|
-
}
|
|
56
|
-
const maybeRequireExpression = tsPattern.match(init).with({
|
|
57
|
-
type: types.AST_NODE_TYPES.CallExpression,
|
|
58
|
-
callee: { type: types.AST_NODE_TYPES.Identifier, name: "require" }
|
|
59
|
-
}, (exp) => tools.O.some(exp)).with(
|
|
60
|
-
{
|
|
61
|
-
type: types.AST_NODE_TYPES.MemberExpression,
|
|
62
|
-
object: {
|
|
63
|
-
type: types.AST_NODE_TYPES.CallExpression,
|
|
64
|
-
callee: { type: types.AST_NODE_TYPES.Identifier, name: "require" }
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
({ object }) => tools.O.some(object)
|
|
68
|
-
).otherwise(tools.O.none);
|
|
69
|
-
if (tools.O.isNone(maybeRequireExpression)) return false;
|
|
70
|
-
const requireExpression = maybeRequireExpression.value;
|
|
71
|
-
const [firstArg] = requireExpression.arguments;
|
|
72
|
-
if (firstArg?.type !== types.AST_NODE_TYPES.Literal || !tools.isString(firstArg.value)) return false;
|
|
73
|
-
return firstArg.value === importSource || firstArg.value.startsWith(`${importSource}/`);
|
|
74
|
-
}
|
|
75
|
-
return tsPattern.isMatching({ type: "ImportDeclaration", source: { value: importSource } }, parent);
|
|
44
|
+
return VAR__namespace.isInitializedFromSource(name, importSource, initialScope);
|
|
76
45
|
}
|
|
77
46
|
|
|
78
47
|
// src/is-from-react.ts
|
|
@@ -665,9 +634,6 @@ var PHASE_RELEVANCE = birecord__default.default({
|
|
|
665
634
|
setup: "cleanup"
|
|
666
635
|
});
|
|
667
636
|
var isInversePhase = tools.F.dual(2, (a, b) => PHASE_RELEVANCE.get(a) === b);
|
|
668
|
-
function getPhaseKindOfFunction(node) {
|
|
669
|
-
return tsPattern.match(node).when(isSetupFunction, () => tools.O.some("setup")).when(isCleanupFunction, () => tools.O.some("cleanup")).when(isComponentDidMountFunction, () => tools.O.some("mount")).when(isComponentWillUnmountFunction, () => tools.O.some("unmount")).otherwise(tools.O.none);
|
|
670
|
-
}
|
|
671
637
|
function isDirectValueOfRenderPropertyLoose(node) {
|
|
672
638
|
const matching = tsPattern.isMatching({
|
|
673
639
|
key: {
|
|
@@ -724,7 +690,6 @@ exports.RE_COMPONENT_NAME = RE_COMPONENT_NAME;
|
|
|
724
690
|
exports.RE_HOOK_NAME = RE_HOOK_NAME;
|
|
725
691
|
exports.getComponentNameFromIdentifier = getComponentNameFromIdentifier;
|
|
726
692
|
exports.getFunctionComponentIdentifier = getFunctionComponentIdentifier;
|
|
727
|
-
exports.getPhaseKindOfFunction = getPhaseKindOfFunction;
|
|
728
693
|
exports.hasNoneOrValidComponentName = hasNoneOrValidComponentName;
|
|
729
694
|
exports.isCallFromReact = isCallFromReact;
|
|
730
695
|
exports.isCallFromReactMember = isCallFromReactMember;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as AST9 from '@eslint-react/ast';
|
|
2
2
|
import * as JSX3 from '@eslint-react/jsx';
|
|
3
|
-
import { F, O
|
|
3
|
+
import { F, O } from '@eslint-react/tools';
|
|
4
4
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
5
5
|
import ShortUniqueId from 'short-unique-id';
|
|
6
6
|
import { isMatching, P, match } from 'ts-pattern';
|
|
@@ -13,38 +13,7 @@ function isInitializedFromReact(name, initialScope, settings) {
|
|
|
13
13
|
if (!settings.strictImportCheck) return true;
|
|
14
14
|
if (name.toLowerCase() === "react") return true;
|
|
15
15
|
const { importSource = "react" } = settings;
|
|
16
|
-
|
|
17
|
-
if (O.isNone(maybeLatestDef)) return false;
|
|
18
|
-
const latestDef = maybeLatestDef.value;
|
|
19
|
-
const { node, parent } = latestDef;
|
|
20
|
-
if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init) {
|
|
21
|
-
const { init } = node;
|
|
22
|
-
if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) {
|
|
23
|
-
return isInitializedFromReact(init.object.name, initialScope, settings);
|
|
24
|
-
}
|
|
25
|
-
if (init.type === AST_NODE_TYPES.Identifier) {
|
|
26
|
-
return isInitializedFromReact(init.name, initialScope, settings);
|
|
27
|
-
}
|
|
28
|
-
const maybeRequireExpression = match(init).with({
|
|
29
|
-
type: AST_NODE_TYPES.CallExpression,
|
|
30
|
-
callee: { type: AST_NODE_TYPES.Identifier, name: "require" }
|
|
31
|
-
}, (exp) => O.some(exp)).with(
|
|
32
|
-
{
|
|
33
|
-
type: AST_NODE_TYPES.MemberExpression,
|
|
34
|
-
object: {
|
|
35
|
-
type: AST_NODE_TYPES.CallExpression,
|
|
36
|
-
callee: { type: AST_NODE_TYPES.Identifier, name: "require" }
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
({ object }) => O.some(object)
|
|
40
|
-
).otherwise(O.none);
|
|
41
|
-
if (O.isNone(maybeRequireExpression)) return false;
|
|
42
|
-
const requireExpression = maybeRequireExpression.value;
|
|
43
|
-
const [firstArg] = requireExpression.arguments;
|
|
44
|
-
if (firstArg?.type !== AST_NODE_TYPES.Literal || !isString(firstArg.value)) return false;
|
|
45
|
-
return firstArg.value === importSource || firstArg.value.startsWith(`${importSource}/`);
|
|
46
|
-
}
|
|
47
|
-
return isMatching({ type: "ImportDeclaration", source: { value: importSource } }, parent);
|
|
16
|
+
return VAR.isInitializedFromSource(name, importSource, initialScope);
|
|
48
17
|
}
|
|
49
18
|
|
|
50
19
|
// src/is-from-react.ts
|
|
@@ -637,9 +606,6 @@ var PHASE_RELEVANCE = birecord({
|
|
|
637
606
|
setup: "cleanup"
|
|
638
607
|
});
|
|
639
608
|
var isInversePhase = F.dual(2, (a, b) => PHASE_RELEVANCE.get(a) === b);
|
|
640
|
-
function getPhaseKindOfFunction(node) {
|
|
641
|
-
return match(node).when(isSetupFunction, () => O.some("setup")).when(isCleanupFunction, () => O.some("cleanup")).when(isComponentDidMountFunction, () => O.some("mount")).when(isComponentWillUnmountFunction, () => O.some("unmount")).otherwise(O.none);
|
|
642
|
-
}
|
|
643
609
|
function isDirectValueOfRenderPropertyLoose(node) {
|
|
644
610
|
const matching = isMatching({
|
|
645
611
|
key: {
|
|
@@ -687,4 +653,4 @@ function isThisSetState(node) {
|
|
|
687
653
|
return callee.type === AST_NODE_TYPES.MemberExpression && AST9.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
|
|
688
654
|
}
|
|
689
655
|
|
|
690
|
-
export { DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag, PHASE_RELEVANCE, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier,
|
|
656
|
+
export { DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag, PHASE_RELEVANCE, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideReactHookCall, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.17.2-next.
|
|
3
|
+
"version": "1.17.2-next.6",
|
|
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": {
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"birecord": "^0.1.1",
|
|
43
43
|
"short-unique-id": "^5.2.0",
|
|
44
44
|
"ts-pattern": "^5.5.0",
|
|
45
|
-
"@eslint-react/ast": "1.17.2-next.
|
|
46
|
-
"@eslint-react/jsx": "1.17.2-next.
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/types": "1.17.2-next.
|
|
50
|
-
"@eslint-react/var": "1.17.2-next.
|
|
45
|
+
"@eslint-react/ast": "1.17.2-next.6",
|
|
46
|
+
"@eslint-react/jsx": "1.17.2-next.6",
|
|
47
|
+
"@eslint-react/shared": "1.17.2-next.6",
|
|
48
|
+
"@eslint-react/tools": "1.17.2-next.6",
|
|
49
|
+
"@eslint-react/types": "1.17.2-next.6",
|
|
50
|
+
"@eslint-react/var": "1.17.2-next.6"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"tsup": "^8.3.5"
|