@eslint-react/var 5.28.7 → 5.30.0-beta.0

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,7 +1,6 @@
1
1
  import { TSESTree } from "@typescript-eslint/types";
2
2
  import { Scope } from "@typescript-eslint/scope-manager";
3
3
  import { RuleContext } from "@eslint-react/eslint";
4
- //#region src/create-import-lookup.d.ts
5
4
  /**
6
5
  * A single local import binding, modeled after the specification's ImportEntry.
7
6
  *
@@ -109,8 +108,6 @@ export interface ImportLookupOptions {
109
108
  * ```
110
109
  */
111
110
  export declare function createImportLookup(program: TSESTree.Program, options: ImportLookupOptions): ImportLookup;
112
- //#endregion
113
- //#region src/is-assignment-target-equal.d.ts
114
111
  /**
115
112
  * Check if two assignment targets are equal, either directly or by their values.
116
113
  * @param context The ESLint rule context.
@@ -120,8 +117,6 @@ export declare function createImportLookup(program: TSESTree.Program, options: I
120
117
  * @internal
121
118
  */
122
119
  export declare function isAssignmentTargetEqual(context: RuleContext, a: TSESTree.Node, b: TSESTree.Node): boolean;
123
- //#endregion
124
- //#region src/is-initialized-from-react.d.ts
125
120
  /**
126
121
  * Check if a variable is initialized from a React import.
127
122
  * @param name The variable name.
@@ -131,8 +126,6 @@ export declare function isAssignmentTargetEqual(context: RuleContext, a: TSESTre
131
126
  * @internal
132
127
  */
133
128
  export declare function isInitializedFromReact(name: string, initialScope: Scope, importSource?: string): boolean;
134
- //#endregion
135
- //#region src/is-initialized-from-react-native.d.ts
136
129
  /**
137
130
  * Check if a variable is initialized from a React Native import.
138
131
  * @param name The variable name.
@@ -142,8 +135,6 @@ export declare function isInitializedFromReact(name: string, initialScope: Scope
142
135
  * @internal
143
136
  */
144
137
  export declare function isInitializedFromReactNative(name: string, initialScope: Scope, importSource?: string): boolean;
145
- //#endregion
146
- //#region src/is-value-equal.d.ts
147
138
  /**
148
139
  * Check if two nodes have equal values.
149
140
  * @param context The ESLint rule context.
@@ -152,8 +143,6 @@ export declare function isInitializedFromReactNative(name: string, initialScope:
152
143
  * @returns `true` if the two nodes have equal values.
153
144
  */
154
145
  export declare function isValueEqual(context: RuleContext, a: TSESTree.Node, b: TSESTree.Node): boolean;
155
- //#endregion
156
- //#region src/resolve.d.ts
157
146
  /**
158
147
  * Resolve an identifier to the AST node that represents its value,
159
148
  * suitable for use in ESLint rule analysis.
@@ -191,8 +180,6 @@ export declare function resolve(context: RuleContext, node: TSESTree.Identifier,
191
180
  at: number;
192
181
  localOnly: boolean;
193
182
  }>): TSESTree.Node | null;
194
- //#endregion
195
- //#region src/resolve-enclosing-assignment-target.d.ts
196
183
  /** The possible assignment targets returned by {@link resolveEnclosingAssignmentTarget}. */
197
184
  export type EnclosingAssignmentTarget = ReturnType<typeof resolveEnclosingAssignmentTarget>;
198
185
  /**
@@ -201,8 +188,6 @@ export type EnclosingAssignmentTarget = ReturnType<typeof resolveEnclosingAssign
201
188
  * @returns The enclosing assignment target node, or `null` when not found.
202
189
  */
203
190
  export declare function resolveEnclosingAssignmentTarget(node: TSESTree.Node): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | 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.TSDeclareFunctionNoDeclare | TSESTree.TSDeclareFunctionWithDeclare | TSESTree.TSEnumDeclaration | TSESTree.TSInstantiationExpression | TSESTree.TSInterfaceDeclaration | TSESTree.TSModuleDeclarationGlobal | TSESTree.TSModuleDeclarationModuleWithIdentifierId | TSESTree.TSModuleDeclarationModuleWithStringIdDeclared | TSESTree.TSModuleDeclarationModuleWithStringIdNotDeclared | TSESTree.TSModuleDeclarationNamespace | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAliasDeclaration | TSESTree.TSTypeAssertion | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.ConstDeclaration | TSESTree.LetOrVarDeclaredDeclaration | TSESTree.LetOrVarNonDeclaredDeclaration | TSESTree.UsingInForOfDeclaration | TSESTree.UsingInNormalContextDeclaration | TSESTree.YieldNoStarExpression | TSESTree.YieldStarExpression | null;
204
- //#endregion
205
- //#region src/resolve-import-source.d.ts
206
191
  /**
207
192
  * Resolve the import source of a variable by walking its latest definition.
208
193
  * @param name The variable name.
@@ -211,8 +196,6 @@ export declare function resolveEnclosingAssignmentTarget(node: TSESTree.Node): T
211
196
  * @returns The import source, or `null` when it cannot be resolved.
212
197
  */
213
198
  export declare function resolveImportSource(name: string, initialScope: Scope, seen?: Set<string>): string | null;
214
- //#endregion
215
- //#region src/resolve-object-type.d.ts
216
199
  /**
217
200
  * Represents the type classification of an object node.
218
201
  */
@@ -249,8 +232,6 @@ export type ObjectType = {
249
232
  * @returns The object type of the node, or `null` when it cannot be resolved.
250
233
  */
251
234
  export declare function resolveObjectType(context: RuleContext, node: TSESTree.Node | null | undefined): ObjectType | null;
252
- //#endregion
253
- //#region src/resolve-origin.d.ts
254
235
  /**
255
236
  * Resolve an identifier to the AST node its value **originates from**,
256
237
  * suitable for origin/pedigree tracking in ESLint rule analysis.
@@ -295,5 +276,4 @@ export declare function resolveObjectType(context: RuleContext, node: TSESTree.N
295
276
  export declare function resolveOrigin(context: RuleContext, node: TSESTree.Identifier, options?: Partial<{
296
277
  at: number;
297
278
  localOnly: boolean;
298
- }>): TSESTree.Node | null;
299
- //#endregion
279
+ }>): TSESTree.Node | null;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { Check, Compare, Extract, Traverse } from "@eslint-react/ast";
3
3
  import { findVariable, getStaticValue } from "@typescript-eslint/utils/ast-utils";
4
4
  import { DefinitionType } from "@typescript-eslint/scope-manager";
5
5
  import { P, isMatching } from "ts-pattern";
6
- //#region ../../.pkgs/eff/dist/index.js
6
+ // ../../.pkgs/eff/dist/index.js
7
7
  const pipeArguments = (self, args) => {
8
8
  switch (args.length) {
9
9
  case 0: return self;
@@ -100,8 +100,7 @@ dual(2, (self, predicate) => {
100
100
  while (idx < len && predicate(input[idx], idx)) idx++;
101
101
  return input.slice(0, idx);
102
102
  });
103
- //#endregion
104
- //#region src/create-import-lookup.ts
103
+ // src/create-import-lookup.ts
105
104
  function createImportLookup(program, options) {
106
105
  const { builtinNamespaces = [], source } = options;
107
106
  const entries = [];
@@ -172,8 +171,7 @@ function createImportLookup(program, options) {
172
171
  }
173
172
  };
174
173
  }
175
- //#endregion
176
- //#region src/resolve-origin.ts
174
+ // src/resolve-origin.ts
177
175
  function resolveOrigin(context, node, options) {
178
176
  const { at = 0, localOnly = false } = options ?? {};
179
177
  const scope = context.sourceCode.getScope(node);
@@ -201,8 +199,7 @@ function resolveOrigin(context, node, options) {
201
199
  default: return null;
202
200
  }
203
201
  }
204
- //#endregion
205
- //#region src/is-value-equal.ts
202
+ // src/is-value-equal.ts
206
203
  const thisBlockTypes = [
207
204
  AST_NODE_TYPES.FunctionDeclaration,
208
205
  AST_NODE_TYPES.FunctionExpression,
@@ -261,16 +258,14 @@ function isValueEqual(context, a, b) {
261
258
  }
262
259
  }
263
260
  }
264
- //#endregion
265
- //#region src/is-assignment-target-equal.ts
261
+ // src/is-assignment-target-equal.ts
266
262
  function isAssignmentTargetEqual(context, a, b) {
267
263
  const unwrappedA = Check.isTypeExpression(a) ? Extract.unwrap(a) : a;
268
264
  const unwrappedB = Check.isTypeExpression(b) ? Extract.unwrap(b) : b;
269
265
  if (Check.isIdentifier(unwrappedA) && Check.isIdentifier(unwrappedB)) return isValueEqual(context, unwrappedA, unwrappedB);
270
266
  return Compare.isEqual(unwrappedA, unwrappedB) || isValueEqual(context, unwrappedA, unwrappedB);
271
267
  }
272
- //#endregion
273
- //#region src/resolve-import-source.ts
268
+ // src/resolve-import-source.ts
274
269
  function getRequireExpressionArguments(node) {
275
270
  const expr = Extract.unwrap(node);
276
271
  if (expr.type === AST_NODE_TYPES.CallExpression) {
@@ -301,13 +296,11 @@ function resolveImportSource(name, initialScope, seen = /* @__PURE__ */ new Set(
301
296
  if (parent?.type === AST_NODE_TYPES.ImportDeclaration) return parent.source.value;
302
297
  return null;
303
298
  }
304
- //#endregion
305
- //#region src/is-initialized-from-react.ts
299
+ // src/is-initialized-from-react.ts
306
300
  function isInitializedFromReact(name, initialScope, importSource = "react") {
307
301
  return name.toLowerCase() === "react" || Boolean(resolveImportSource(name, initialScope)?.startsWith(importSource));
308
302
  }
309
- //#endregion
310
- //#region src/is-initialized-from-react-native.ts
303
+ // src/is-initialized-from-react-native.ts
311
304
  function isInitializedFromReactNative(name, initialScope, importSource = "react-native") {
312
305
  return [
313
306
  "react_native",
@@ -315,8 +308,7 @@ function isInitializedFromReactNative(name, initialScope, importSource = "react-
315
308
  "rn"
316
309
  ].includes(name.toLowerCase()) || Boolean(resolveImportSource(name, initialScope)?.startsWith(importSource));
317
310
  }
318
- //#endregion
319
- //#region src/resolve.ts
311
+ // src/resolve.ts
320
312
  function resolve(context, node, options) {
321
313
  const { at = 0, localOnly = false } = options ?? {};
322
314
  const scope = context.sourceCode.getScope(node);
@@ -345,8 +337,7 @@ function resolve(context, node, options) {
345
337
  default: return null;
346
338
  }
347
339
  }
348
- //#endregion
349
- //#region src/resolve-enclosing-assignment-target.ts
340
+ // src/resolve-enclosing-assignment-target.ts
350
341
  function resolveEnclosingAssignmentTarget(node) {
351
342
  switch (node.type) {
352
343
  case AST_NODE_TYPES.VariableDeclarator: return node.id;
@@ -358,8 +349,7 @@ function resolveEnclosingAssignmentTarget(node) {
358
349
  default: return resolveEnclosingAssignmentTarget(node.parent);
359
350
  }
360
351
  }
361
- //#endregion
362
- //#region src/resolve-object-type.ts
352
+ // src/resolve-object-type.ts
363
353
  function resolveObjectType(context, node) {
364
354
  if (node == null) return null;
365
355
  switch (node.type) {
@@ -461,5 +451,4 @@ function resolveObjectType(context, node) {
461
451
  return resolveObjectType(context, node.expression);
462
452
  }
463
453
  }
464
- //#endregion
465
454
  export { createImportLookup, isAssignmentTargetEqual, isInitializedFromReact, isInitializedFromReactNative, isValueEqual, resolve, resolveEnclosingAssignmentTarget, resolveImportSource, resolveObjectType, resolveOrigin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/var",
3
- "version": "5.28.7",
3
+ "version": "5.30.0-beta.0",
4
4
  "description": "ESLint React's TSESTree AST utility module for static analysis of variables.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -29,8 +29,8 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@eslint-react/ast": "5.28.7",
33
- "@eslint-react/eslint": "5.28.7",
32
+ "@eslint-react/ast": "5.30.0-beta.0",
33
+ "@eslint-react/eslint": "5.30.0-beta.0",
34
34
  "@typescript-eslint/scope-manager": "^8.72.0",
35
35
  "@typescript-eslint/types": "^8.72.0",
36
36
  "@typescript-eslint/utils": "^8.72.0",
@@ -44,7 +44,7 @@
44
44
  "@types/node": "^20.19.43",
45
45
  "@typescript-eslint/typescript-estree": "^8.72.0",
46
46
  "eslint": "^10.13.0",
47
- "tsdown": "^0.23.1",
47
+ "tsdown": "^0.23.2",
48
48
  "typescript": "6.0.3",
49
49
  "vitest": "^5.0.5"
50
50
  },