@eslint-react/core 2.3.2-beta.1 → 2.3.2-beta.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.ts +3 -3
- package/dist/index.js +8 -5
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -487,7 +487,7 @@ declare function resolveJsxAttributeValue(context: RuleContext, attribute: AST.T
|
|
|
487
487
|
readonly toStatic: () => string | number | bigint | boolean | RegExp | null;
|
|
488
488
|
} | {
|
|
489
489
|
readonly kind: "expression";
|
|
490
|
-
readonly node: TSESTree.
|
|
490
|
+
readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
|
|
491
491
|
readonly toStatic: () => unknown;
|
|
492
492
|
} | {
|
|
493
493
|
readonly kind: "element";
|
|
@@ -495,7 +495,7 @@ declare function resolveJsxAttributeValue(context: RuleContext, attribute: AST.T
|
|
|
495
495
|
readonly toStatic: () => undefined;
|
|
496
496
|
} | {
|
|
497
497
|
readonly kind: "spreadChild";
|
|
498
|
-
readonly node: TSESTree.
|
|
498
|
+
readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
|
|
499
499
|
readonly toStatic: () => undefined;
|
|
500
500
|
} | {
|
|
501
501
|
readonly kind: "spreadProps";
|
|
@@ -646,7 +646,7 @@ declare function stringifyJsx(node: TSESTree$1.JSXIdentifier | TSESTree$1.JSXNam
|
|
|
646
646
|
* @param prev The previous AST node in the traversal (used for context)
|
|
647
647
|
* @internal
|
|
648
648
|
*/
|
|
649
|
-
declare function getInstanceId(node: TSESTree.Node, prev?: TSESTree.Node): TSESTree.
|
|
649
|
+
declare function getInstanceId(node: TSESTree.Node, prev?: TSESTree.Node): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.PrivateIdentifier | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldExpression | undefined;
|
|
650
650
|
//#endregion
|
|
651
651
|
//#region src/utils/is-from-react.d.ts
|
|
652
652
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
2
2
|
import * as AST from "@eslint-react/ast";
|
|
3
3
|
import { constFalse, constTrue, dual, flip, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
|
|
4
|
-
import { RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE
|
|
4
|
+
import { IdGenerator, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE } from "@eslint-react/shared";
|
|
5
5
|
import { findProperty, findVariable, getVariableDefinitionNode, isNodeValueEqual } from "@eslint-react/var";
|
|
6
6
|
import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
7
7
|
import { P, isMatching, match } from "ts-pattern";
|
|
@@ -193,12 +193,13 @@ const isUseTransitionCall = flip(isReactHookCallWithName)("useTransition");
|
|
|
193
193
|
|
|
194
194
|
//#endregion
|
|
195
195
|
//#region src/hook/hook-collector.ts
|
|
196
|
+
const idGen$2 = new IdGenerator("hook_");
|
|
196
197
|
function useHookCollector() {
|
|
197
198
|
const hooks = /* @__PURE__ */ new Map();
|
|
198
199
|
const functionEntries = [];
|
|
199
200
|
const onFunctionEnter = (node) => {
|
|
200
201
|
const id = AST.getFunctionId(node);
|
|
201
|
-
const key =
|
|
202
|
+
const key = idGen$2.next();
|
|
202
203
|
const name = id?.name;
|
|
203
204
|
if (name != null && isReactHookName(name)) {
|
|
204
205
|
functionEntries.push({
|
|
@@ -895,6 +896,7 @@ function hasNoneOrLooseComponentName(context, fn) {
|
|
|
895
896
|
|
|
896
897
|
//#endregion
|
|
897
898
|
//#region src/component/component-collector.ts
|
|
899
|
+
const idGen$1 = new IdGenerator("function_component_");
|
|
898
900
|
/**
|
|
899
901
|
* Get a ctx and listeners for the rule to collect function components
|
|
900
902
|
* @param context The ESLint rule context
|
|
@@ -907,7 +909,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
907
909
|
const functionEntries = [];
|
|
908
910
|
const getCurrentEntry = () => functionEntries.at(-1);
|
|
909
911
|
const onFunctionEnter = (node) => {
|
|
910
|
-
const key =
|
|
912
|
+
const key = idGen$1.next();
|
|
911
913
|
functionEntries.push({
|
|
912
914
|
key,
|
|
913
915
|
node,
|
|
@@ -950,8 +952,8 @@ function useComponentCollector(context, options = {}) {
|
|
|
950
952
|
if (!(hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, body, hint) && isComponentDefinition(context, entry.node, hint))) return;
|
|
951
953
|
const initPath = AST.getFunctionInitPath(entry.node);
|
|
952
954
|
const id = getFunctionComponentId(context, entry.node);
|
|
955
|
+
const key = entry.key;
|
|
953
956
|
const name = getComponentNameFromId(id);
|
|
954
|
-
const key = getId();
|
|
955
957
|
components.set(key, {
|
|
956
958
|
id,
|
|
957
959
|
key,
|
|
@@ -1006,6 +1008,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
1006
1008
|
|
|
1007
1009
|
//#endregion
|
|
1008
1010
|
//#region src/component/component-collector-legacy.ts
|
|
1011
|
+
const idGen = new IdGenerator("class_component_");
|
|
1009
1012
|
/**
|
|
1010
1013
|
* Get a ctx and listeners object for the rule to collect class components
|
|
1011
1014
|
* @returns The context and listeners for the rule
|
|
@@ -1018,7 +1021,7 @@ function useComponentCollectorLegacy() {
|
|
|
1018
1021
|
const collect = (node) => {
|
|
1019
1022
|
if (!isClassComponent(node)) return;
|
|
1020
1023
|
const id = AST.getClassId(node);
|
|
1021
|
-
const key =
|
|
1024
|
+
const key = idGen.next();
|
|
1022
1025
|
const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None;
|
|
1023
1026
|
components.set(key, {
|
|
1024
1027
|
id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "2.3.2-beta.
|
|
3
|
+
"version": "2.3.2-beta.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": {
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"./package.json"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@typescript-eslint/scope-manager": "^8.46.
|
|
34
|
-
"@typescript-eslint/types": "^8.46.
|
|
35
|
-
"@typescript-eslint/utils": "^8.46.
|
|
33
|
+
"@typescript-eslint/scope-manager": "^8.46.3",
|
|
34
|
+
"@typescript-eslint/types": "^8.46.3",
|
|
35
|
+
"@typescript-eslint/utils": "^8.46.3",
|
|
36
36
|
"birecord": "^0.1.1",
|
|
37
37
|
"ts-pattern": "^5.9.0",
|
|
38
|
-
"@eslint-react/ast": "2.3.2-beta.
|
|
39
|
-
"@eslint-react/
|
|
40
|
-
"@eslint-react/
|
|
41
|
-
"@eslint-react/var": "2.3.2-beta.
|
|
38
|
+
"@eslint-react/ast": "2.3.2-beta.5",
|
|
39
|
+
"@eslint-react/shared": "2.3.2-beta.5",
|
|
40
|
+
"@eslint-react/eff": "2.3.2-beta.5",
|
|
41
|
+
"@eslint-react/var": "2.3.2-beta.5"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsdown": "^0.15.12",
|