@eslint-react/core 5.30.5 → 5.30.7

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 CHANGED
@@ -1,9 +1,9 @@
1
- import { TSESTreeClass, TSESTreeDirective, TSESTreeFunction, TSESTreeMethodOrPropertyDefinition } from "@eslint-react/ast";
2
1
  import { RuleContext } from "@eslint-react/eslint";
3
2
  import { TSESTree } from "@typescript-eslint/types";
3
+ import { TSESTreeClass, TSESTreeDirective, TSESTreeFunction, TSESTreeMethodOrPropertyDefinition } from "@eslint-react/ast";
4
+ import { ESLintUtils } from "@typescript-eslint/utils";
4
5
  import { RegExpLike } from "@eslint-react/shared";
5
6
  import ts from "typescript";
6
- import { ESLintUtils } from "@typescript-eslint/utils";
7
7
  export declare namespace isAPI {
8
8
  /** The dual-signature predicate type returned by {@link isAPI}. */
9
9
  type ReturnType = {
@@ -989,8 +989,12 @@ export declare const isUnknownType: (type: ts.Type) => boolean;
989
989
  * @param checker The TypeScript type checker.
990
990
  * @param symbol The symbol to get fully qualified name for.
991
991
  * @returns The fully qualified name of the symbol.
992
+ * @remarks
993
+ * Known approximations:
994
+ * - Symbols declared in a file with `export as namespace X` get the `X.` prefix even when they are not exported; this is deliberate for allow-list matching.
995
+ * - For symbols with merged declarations across files, the first declaration determines the source file used for the namespace lookup.
992
996
  */
993
- export declare function getFullyQualifiedNameEx(checker: ts.TypeChecker, symbol: ts.Symbol): string;
997
+ export declare function getFullyQualifiedName(checker: ts.TypeChecker, symbol: ts.Symbol): string;
994
998
  /** Represents the variant of a type for boolean expression analysis. */
995
999
  export type TypeVariant = "any" | "bigint" | "boolean" | "enum" | "never" | "nullish" | "number" | "object" | "string" | "unknown" | "falsy bigint" | "falsy boolean" | "falsy number" | "falsy string" | "truthy bigint" | "truthy boolean" | "truthy number" | "truthy string";
996
1000
  /**
package/dist/index.js CHANGED
@@ -851,19 +851,23 @@ const isTruthyNumberType = (type) => type.isNumberLiteral() && type.value !== 0;
851
851
  const isTruthyStringType = (type) => type.isStringLiteral() && type.value !== "";
852
852
  const isUnknownType = (type) => isTypeFlagSet(type, ts.TypeFlags.Unknown);
853
853
  // src/type-name.ts
854
- function getFullyQualifiedNameEx(checker, symbol) {
854
+ function getFullyQualifiedName(checker, symbol) {
855
855
  let name = symbol.name;
856
856
  let parent = symbol.declarations?.at(0)?.parent;
857
857
  if (parent == null) return checker.getFullyQualifiedName(symbol);
858
- while (parent.kind !== ts.SyntaxKind.SourceFile) {
858
+ let inGlobalAugmentation = false;
859
+ while (!ts.isSourceFile(parent)) {
859
860
  switch (true) {
860
861
  case ts.isInterfaceDeclaration(parent):
861
862
  case ts.isTypeAliasDeclaration(parent):
862
863
  case ts.isEnumDeclaration(parent):
864
+ name = `${parent.name.text}.${name}`;
865
+ break;
863
866
  case ts.isModuleDeclaration(parent):
864
- case ts.isNamespaceImport(parent):
865
- case ts.isNamespaceExport(parent):
866
- case ts.isNamespaceExportDeclaration(parent):
867
+ if ((parent.flags & ts.NodeFlags.GlobalAugmentation) !== 0) {
868
+ inGlobalAugmentation = true;
869
+ break;
870
+ }
867
871
  name = `${parent.name.text}.${name}`;
868
872
  break;
869
873
  case ts.isPropertySignature(parent) && ts.isIdentifier(parent.name):
@@ -871,6 +875,7 @@ function getFullyQualifiedNameEx(checker, symbol) {
871
875
  case ts.isMethodDeclaration(parent) && ts.isIdentifier(parent.name):
872
876
  case ts.isMethodSignature(parent) && ts.isIdentifier(parent.name):
873
877
  case ts.isPropertyAssignment(parent) && ts.isIdentifier(parent.name):
878
+ case ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name):
874
879
  name = `${parent.name.text}.${name}`;
875
880
  break;
876
881
  case ts.isFunctionDeclaration(parent) && parent.name != null:
@@ -878,8 +883,8 @@ function getFullyQualifiedNameEx(checker, symbol) {
878
883
  case ts.isClassDeclaration(parent) && parent.name != null:
879
884
  name = `${parent.name.text}.${name}`;
880
885
  break;
881
- case ts.isEnumMember(parent):
882
- name = `${parent.name.getText()}.${name}`;
886
+ case ts.isEnumMember(parent) && !ts.isComputedPropertyName(parent.name):
887
+ name = `${parent.name.text}.${name}`;
883
888
  break;
884
889
  case ts.isTypeLiteralNode(parent):
885
890
  case ts.isMappedTypeNode(parent):
@@ -889,8 +894,8 @@ function getFullyQualifiedNameEx(checker, symbol) {
889
894
  }
890
895
  parent = parent.parent;
891
896
  }
892
- const namespace = parent.getSourceFile().statements.find((n) => ts.isNamespaceExportDeclaration(n))?.name.text;
893
- if (namespace == null) return name;
897
+ const namespace = parent.statements.find((n) => ts.isNamespaceExportDeclaration(n))?.name.text;
898
+ if (namespace == null || inGlobalAugmentation) return name;
894
899
  if (name === namespace || name.startsWith(`${namespace}.`)) return name;
895
900
  return `${namespace}.${name}`;
896
901
  }
@@ -930,4 +935,4 @@ function getTypeVariants(types) {
930
935
  if (types.some(isNeverType)) variants.add("never");
931
936
  return variants;
932
937
  }
933
- export { DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, JSXDetectionHint, SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT, getClassComponentCollector, getClassId, 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, 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, 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 };
938
+ export { DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, JSXDetectionHint, SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT, getClassComponentCollector, getClassId, getFullyQualifiedName, 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, 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, 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.30.5",
3
+ "version": "5.30.7",
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,13 +29,13 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@eslint-react/ast": "5.30.5",
33
- "@eslint-react/eslint": "5.30.5",
34
- "@eslint-react/jsx": "5.30.5",
35
- "@eslint-react/shared": "5.30.5",
36
- "@eslint-react/var": "5.30.5",
37
- "@typescript-eslint/types": "^8.73.0",
38
- "@typescript-eslint/utils": "^8.73.0",
32
+ "@eslint-react/ast": "5.30.7",
33
+ "@eslint-react/eslint": "5.30.7",
34
+ "@eslint-react/jsx": "5.30.7",
35
+ "@eslint-react/shared": "5.30.7",
36
+ "@eslint-react/var": "5.30.7",
37
+ "@typescript-eslint/types": "^8.74.0",
38
+ "@typescript-eslint/utils": "^8.74.0",
39
39
  "ts-pattern": "^5.9.2"
40
40
  },
41
41
  "devDependencies": {
@@ -48,7 +48,7 @@
48
48
  "eslint": "^10.15.0",
49
49
  "tsdown": "^0.23.7",
50
50
  "typescript": "6.0.3",
51
- "vitest": "^5.1.0"
51
+ "vitest": "^5.1.2"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "eslint": "*",