@eslint-react/core 5.24.2 → 5.24.4
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.js +13 -33
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import { RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOU
|
|
|
5
5
|
import { resolve } from "@eslint-react/var";
|
|
6
6
|
import { P, isMatching, match } from "ts-pattern";
|
|
7
7
|
import ts from "typescript";
|
|
8
|
-
|
|
9
8
|
//#region src/api.ts
|
|
10
9
|
function isAPI(api) {
|
|
11
10
|
const func = (context, node) => {
|
|
@@ -95,7 +94,6 @@ const isUseRefCall = isAPICall("useRef");
|
|
|
95
94
|
const isUseStateCall = isAPICall("useState");
|
|
96
95
|
const isUseSyncExternalStoreCall = isAPICall("useSyncExternalStore");
|
|
97
96
|
const isUseTransitionCall = isAPICall("useTransition");
|
|
98
|
-
|
|
99
97
|
//#endregion
|
|
100
98
|
//#region src/class.ts
|
|
101
99
|
function getClassId(node) {
|
|
@@ -103,7 +101,6 @@ function getClassId(node) {
|
|
|
103
101
|
if (node.parent.type === AST_NODE_TYPES.VariableDeclarator) return node.parent.id;
|
|
104
102
|
return null;
|
|
105
103
|
}
|
|
106
|
-
|
|
107
104
|
//#endregion
|
|
108
105
|
//#region ../../.pkgs/eff/dist/index.js
|
|
109
106
|
const pipeArguments = (self, args) => {
|
|
@@ -128,7 +125,7 @@ const pipeArguments = (self, args) => {
|
|
|
128
125
|
const Prototype = { pipe() {
|
|
129
126
|
return pipeArguments(this, arguments);
|
|
130
127
|
} };
|
|
131
|
-
|
|
128
|
+
(function() {
|
|
132
129
|
function PipeableBase() {}
|
|
133
130
|
PipeableBase.prototype = Prototype;
|
|
134
131
|
return PipeableBase;
|
|
@@ -164,22 +161,19 @@ const dual = function(arity, body) {
|
|
|
164
161
|
const identity = (a) => a;
|
|
165
162
|
const cast = identity;
|
|
166
163
|
const constant = (value) => () => value;
|
|
167
|
-
const constTrue = constant(true);
|
|
168
164
|
const constFalse = constant(false);
|
|
169
|
-
|
|
170
|
-
const constUndefined = constant(void 0);
|
|
171
|
-
const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
165
|
+
dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
172
166
|
const absurd = (_) => {
|
|
173
167
|
throw new Error("Called `absurd` function which should be uncallable");
|
|
174
168
|
};
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
169
|
+
cast(absurd);
|
|
170
|
+
dual(2, (a, b) => (data) => a(data) && b(data));
|
|
171
|
+
dual(2, (a, b) => (data) => a(data) || b(data));
|
|
172
|
+
dual(2, (a, b) => (data) => a(data) !== b(data));
|
|
173
|
+
dual(2, (a, b) => (data) => a(data) === b(data));
|
|
174
|
+
dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
|
|
175
|
+
dual(2, (a, b) => (data) => !a(data) && !b(data));
|
|
176
|
+
dual(2, (a, b) => (data) => !a(data) || !b(data));
|
|
183
177
|
function isFunction(input) {
|
|
184
178
|
return typeof input === "function";
|
|
185
179
|
}
|
|
@@ -187,21 +181,20 @@ function isObjectKeyword(input) {
|
|
|
187
181
|
return typeof input === "object" && input !== null || isFunction(input);
|
|
188
182
|
}
|
|
189
183
|
const hasProperty = dual(2, (data, property) => isObjectKeyword(data) && property in data);
|
|
190
|
-
|
|
184
|
+
dual(2, (self, predicate) => {
|
|
191
185
|
const input = Array.isArray(self) ? self : Array.from(self);
|
|
192
186
|
const len = input.length;
|
|
193
187
|
let idx = 0;
|
|
194
188
|
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
195
189
|
return input.slice(idx);
|
|
196
190
|
});
|
|
197
|
-
|
|
191
|
+
dual(2, (self, predicate) => {
|
|
198
192
|
const input = Array.isArray(self) ? self : Array.from(self);
|
|
199
193
|
const len = input.length;
|
|
200
194
|
let idx = 0;
|
|
201
195
|
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
202
196
|
return input.slice(0, idx);
|
|
203
197
|
});
|
|
204
|
-
|
|
205
198
|
//#endregion
|
|
206
199
|
//#region src/class-component.ts
|
|
207
200
|
function isClassComponent(node) {
|
|
@@ -258,7 +251,6 @@ function isThisSetStateCall(node) {
|
|
|
258
251
|
const callee = Extract.unwrap(node.callee);
|
|
259
252
|
return callee.type === AST_NODE_TYPES.MemberExpression && Extract.unwrap(callee.object).type === AST_NODE_TYPES.ThisExpression && Extract.getCalleeName(node) === "setState";
|
|
260
253
|
}
|
|
261
|
-
|
|
262
254
|
//#endregion
|
|
263
255
|
//#region src/class-component-collector.ts
|
|
264
256
|
function getClassComponentCollector(context) {
|
|
@@ -291,7 +283,6 @@ function getClassComponentCollector(context) {
|
|
|
291
283
|
}
|
|
292
284
|
};
|
|
293
285
|
}
|
|
294
|
-
|
|
295
286
|
//#endregion
|
|
296
287
|
//#region src/create-element.ts
|
|
297
288
|
function getCreateElementTypeArgument(context, node) {
|
|
@@ -327,7 +318,6 @@ function isInsideCreateElementProps(context, node) {
|
|
|
327
318
|
if (prop == null) return false;
|
|
328
319
|
return prop === call.arguments[1];
|
|
329
320
|
}
|
|
330
|
-
|
|
331
321
|
//#endregion
|
|
332
322
|
//#region src/function.ts
|
|
333
323
|
function getFunctionId(node) {
|
|
@@ -421,7 +411,6 @@ const SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT = [
|
|
|
421
411
|
"[left.type='MemberExpression']",
|
|
422
412
|
"[left.property.name='displayName']"
|
|
423
413
|
].join("");
|
|
424
|
-
|
|
425
414
|
//#endregion
|
|
426
415
|
//#region src/jsx.ts
|
|
427
416
|
const JsxDetectionHint = {
|
|
@@ -475,7 +464,6 @@ function isJsxLike(context, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
475
464
|
}
|
|
476
465
|
return visit(node);
|
|
477
466
|
}
|
|
478
|
-
|
|
479
467
|
//#endregion
|
|
480
468
|
//#region src/function-component.ts
|
|
481
469
|
const FunctionComponentFlag = {
|
|
@@ -579,7 +567,6 @@ function isFunctionComponentDefinition(context, node, hint) {
|
|
|
579
567
|
if (significantParent == null) return true;
|
|
580
568
|
return significantParent.type !== AST_NODE_TYPES.JSXExpressionContainer;
|
|
581
569
|
}
|
|
582
|
-
|
|
583
570
|
//#endregion
|
|
584
571
|
//#region src/hook.ts
|
|
585
572
|
const REACT_BUILTIN_HOOK_NAMES = [
|
|
@@ -667,7 +654,6 @@ function isUseEffectCleanupCallback(node) {
|
|
|
667
654
|
if (enclosingFunction !== Traverse.findParent(returnStatement, Check.isFunction)) return false;
|
|
668
655
|
return isUseEffectSetupCallback(enclosingFunction);
|
|
669
656
|
}
|
|
670
|
-
|
|
671
657
|
//#endregion
|
|
672
658
|
//#region src/function-component-collector.ts
|
|
673
659
|
function getFunctionComponentCollector(context, options = {}) {
|
|
@@ -762,7 +748,6 @@ function getFunctionComponentCollector(context, options = {}) {
|
|
|
762
748
|
}
|
|
763
749
|
};
|
|
764
750
|
}
|
|
765
|
-
|
|
766
751
|
//#endregion
|
|
767
752
|
//#region src/hook-collector.ts
|
|
768
753
|
function getHookCollector(context) {
|
|
@@ -827,7 +812,6 @@ function getHookCollector(context) {
|
|
|
827
812
|
}
|
|
828
813
|
};
|
|
829
814
|
}
|
|
830
|
-
|
|
831
815
|
//#endregion
|
|
832
816
|
//#region src/jsx-config.ts
|
|
833
817
|
const annotationCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -874,7 +858,6 @@ function getJsxConfig(context) {
|
|
|
874
858
|
mergedCache.set(context.sourceCode, merged);
|
|
875
859
|
return merged;
|
|
876
860
|
}
|
|
877
|
-
|
|
878
861
|
//#endregion
|
|
879
862
|
//#region src/type-is.ts
|
|
880
863
|
function isFlagSet(allFlags, flag) {
|
|
@@ -905,7 +888,6 @@ const isTruthyBigIntType = (type) => type.isLiteral() && isMatching({ value: { b
|
|
|
905
888
|
const isTruthyNumberType = (type) => type.isNumberLiteral() && type.value !== 0;
|
|
906
889
|
const isTruthyStringType = (type) => type.isStringLiteral() && type.value !== "";
|
|
907
890
|
const isUnknownType = (type) => isTypeFlagSet(type, ts.TypeFlags.Unknown);
|
|
908
|
-
|
|
909
891
|
//#endregion
|
|
910
892
|
//#region src/type-name.ts
|
|
911
893
|
function getFullyQualifiedNameEx(checker, symbol) {
|
|
@@ -951,7 +933,6 @@ function getFullyQualifiedNameEx(checker, symbol) {
|
|
|
951
933
|
if (name.startsWith(`${namespace}.`)) return name;
|
|
952
934
|
return `${namespace}.${name}`;
|
|
953
935
|
}
|
|
954
|
-
|
|
955
936
|
//#endregion
|
|
956
937
|
//#region src/type-variant.ts
|
|
957
938
|
function getTypeVariants(types) {
|
|
@@ -988,6 +969,5 @@ function getTypeVariants(types) {
|
|
|
988
969
|
if (types.some(isNeverType)) variants.add("never");
|
|
989
970
|
return variants;
|
|
990
971
|
}
|
|
991
|
-
|
|
992
972
|
//#endregion
|
|
993
|
-
export { DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, JsxDetectionHint, REACT_BUILTIN_HOOK_NAMES, SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT, getClassComponentCollector, getClassId, getCreateElementChildrenArguments, getCreateElementProp, getCreateElementPropsObject, getCreateElementTypeArgument, getFullyQualifiedNameEx, getFunctionComponentCollector, getFunctionComponentFlagFromInitPath, getFunctionComponentId, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHookCollector, getJsxConfig, getJsxConfigFromAnnotation, getJsxConfigFromCompilerOptions, getTypeVariants, isAPI, isAPICall, isAnyType, isBigIntType, isBooleanLiteralType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateElementChildrenArgument, isCreateRef, isCreateRefCall, isEnumType, isFalseLiteralType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isFunctionComponentDefinition, isFunctionComponentName, isFunctionComponentNameLoose, isFunctionComponentWrapperCall, isFunctionComponentWrapperCallback, isFunctionEmpty, isFunctionHasCallInInitPath, isFunctionHasDirective, isFunctionWithLooseComponentName, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHookCall, isHookDefinition, isHookId, isHookName, isHookTag, isInsideCreateElementProps, isJsxLike, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isPureComponent, isRender, isRenderMethodCallback, isRenderMethodLike, isShouldComponentUpdate, isStringType, isThisSetStateCall, isTrueLiteralType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUse, isUseActionState, isUseActionStateCall, isUseCall, isUseCallback, isUseCallbackCall, isUseContext, isUseContextCall, isUseDebugValue, isUseDebugValueCall, isUseDeferredValue, isUseDeferredValueCall, isUseEffect, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatus, isUseFormStatusCall, isUseId, isUseIdCall, isUseImperativeHandle, isUseImperativeHandleCall, isUseInsertionEffect, isUseInsertionEffectCall, isUseLayoutEffect, isUseLayoutEffectCall, isUseMemo, isUseMemoCall, isUseOptimistic, isUseOptimisticCall, isUseReducer, isUseReducerCall, isUseRef, isUseRefCall, isUseRefLikeCall, isUseState, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStore, isUseSyncExternalStoreCall, isUseTransition, isUseTransitionCall };
|
|
973
|
+
export { DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, JsxDetectionHint, REACT_BUILTIN_HOOK_NAMES, SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT, getClassComponentCollector, getClassId, getCreateElementChildrenArguments, getCreateElementProp, getCreateElementPropsObject, getCreateElementTypeArgument, getFullyQualifiedNameEx, getFunctionComponentCollector, getFunctionComponentFlagFromInitPath, getFunctionComponentId, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHookCollector, getJsxConfig, getJsxConfigFromAnnotation, getJsxConfigFromCompilerOptions, getTypeVariants, isAPI, isAPICall, isAnyType, isBigIntType, isBooleanLiteralType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateElementChildrenArgument, isCreateRef, isCreateRefCall, isEnumType, isFalseLiteralType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isFunctionComponentDefinition, isFunctionComponentName, isFunctionComponentNameLoose, isFunctionComponentWrapperCall, isFunctionComponentWrapperCallback, isFunctionEmpty, isFunctionHasCallInInitPath, isFunctionHasDirective, isFunctionWithLooseComponentName, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHookCall, isHookDefinition, isHookId, isHookName, isHookTag, isInsideCreateElementProps, isJsxLike, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isPureComponent, isRender, isRenderMethodCallback, isRenderMethodLike, isShouldComponentUpdate, isStringType, isThisSetStateCall, isTrueLiteralType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUse, isUseActionState, isUseActionStateCall, isUseCall, isUseCallback, isUseCallbackCall, isUseContext, isUseContextCall, isUseDebugValue, isUseDebugValueCall, isUseDeferredValue, isUseDeferredValueCall, isUseEffect, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatus, isUseFormStatusCall, isUseId, isUseIdCall, isUseImperativeHandle, isUseImperativeHandleCall, isUseInsertionEffect, isUseInsertionEffectCall, isUseLayoutEffect, isUseLayoutEffectCall, isUseMemo, isUseMemoCall, isUseOptimistic, isUseOptimisticCall, isUseReducer, isUseReducerCall, isUseRef, isUseRefCall, isUseRefLikeCall, isUseState, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStore, isUseSyncExternalStoreCall, isUseTransition, isUseTransitionCall };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "5.24.
|
|
3
|
+
"version": "5.24.4",
|
|
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": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@eslint-react/ast": "5.24.
|
|
33
|
-
"@eslint-react/eslint": "5.24.
|
|
34
|
-
"@eslint-react/shared": "5.24.
|
|
35
|
-
"@eslint-react/var": "5.24.
|
|
32
|
+
"@eslint-react/ast": "5.24.4",
|
|
33
|
+
"@eslint-react/eslint": "5.24.4",
|
|
34
|
+
"@eslint-react/shared": "5.24.4",
|
|
35
|
+
"@eslint-react/var": "5.24.4",
|
|
36
36
|
"@typescript-eslint/types": "^8.71.0",
|
|
37
37
|
"@typescript-eslint/utils": "^8.71.0",
|
|
38
38
|
"ts-pattern": "^5.9.0"
|