@eslint-react/var 5.30.0-beta.3 → 5.30.0-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 +13 -1
- package/dist/index.js +8 -2
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -180,6 +180,18 @@ export declare function resolve(context: RuleContext, node: TSESTree.Identifier,
|
|
|
180
180
|
at: number;
|
|
181
181
|
localOnly: boolean;
|
|
182
182
|
}>): TSESTree.Node | null;
|
|
183
|
+
/**
|
|
184
|
+
* The result of {@link resolveBindingTarget}: an `AssignmentPattern` unwraps to its
|
|
185
|
+
* binding, while every other node is returned as is; `null` stays `null`.
|
|
186
|
+
*/
|
|
187
|
+
export type BindingTarget<T extends null | TSESTree.Node> = T extends null ? null : T extends TSESTree.AssignmentPattern ? TSESTree.BindingName : T;
|
|
188
|
+
/**
|
|
189
|
+
* Resolve the binding target of a pattern element, property value, or parameter:
|
|
190
|
+
* `AssignmentPattern` defaults unwrap to their left side, other nodes pass through.
|
|
191
|
+
* @param node The node to resolve.
|
|
192
|
+
* @returns The binding target, or `null` when `node` is `null`.
|
|
193
|
+
*/
|
|
194
|
+
export declare function resolveBindingTarget<T extends null | TSESTree.Node>(node: T): BindingTarget<T>;
|
|
183
195
|
/** The possible assignment targets returned by {@link resolveEnclosingAssignmentTarget}. */
|
|
184
196
|
export type EnclosingAssignmentTarget = ReturnType<typeof resolveEnclosingAssignmentTarget>;
|
|
185
197
|
/**
|
|
@@ -187,7 +199,7 @@ export type EnclosingAssignmentTarget = ReturnType<typeof resolveEnclosingAssign
|
|
|
187
199
|
* @param node The starting node for the upward search.
|
|
188
200
|
* @returns The enclosing assignment target node, or `null` when not found.
|
|
189
201
|
*/
|
|
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.
|
|
202
|
+
export declare function resolveEnclosingAssignmentTarget(node: TSESTree.Node): TSESTree.ChainExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | 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.TSDeclareFunctionNoDeclare | TSESTree.TSDeclareFunctionWithDeclare | TSESTree.TSEnumDeclaration | TSESTree.TSInterfaceDeclaration | TSESTree.TSModuleDeclarationGlobal | TSESTree.TSModuleDeclarationModuleWithIdentifierId | TSESTree.TSModuleDeclarationModuleWithStringIdDeclared | TSESTree.TSModuleDeclarationModuleWithStringIdNotDeclared | TSESTree.TSModuleDeclarationNamespace | TSESTree.TSTypeAliasDeclaration | 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;
|
|
191
203
|
/**
|
|
192
204
|
* Resolve the import source of a variable by walking its latest definition.
|
|
193
205
|
* @param name The variable name.
|
package/dist/index.js
CHANGED
|
@@ -201,8 +201,8 @@ function resolveOrigin(context, node, options) {
|
|
|
201
201
|
}
|
|
202
202
|
// src/is-value-equal.ts
|
|
203
203
|
const thisBlockTypes = [
|
|
204
|
-
AST_NODE_TYPES.FunctionDeclaration,
|
|
205
204
|
AST_NODE_TYPES.FunctionExpression,
|
|
205
|
+
AST_NODE_TYPES.FunctionDeclaration,
|
|
206
206
|
AST_NODE_TYPES.ClassBody,
|
|
207
207
|
AST_NODE_TYPES.Program
|
|
208
208
|
];
|
|
@@ -337,6 +337,12 @@ function resolve(context, node, options) {
|
|
|
337
337
|
default: return null;
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
+
// src/resolve-binding-target.ts
|
|
341
|
+
function resolveBindingTarget(node) {
|
|
342
|
+
if (node == null) return null;
|
|
343
|
+
if (node.type === AST_NODE_TYPES.AssignmentPattern) return node.left;
|
|
344
|
+
return node;
|
|
345
|
+
}
|
|
340
346
|
// src/resolve-enclosing-assignment-target.ts
|
|
341
347
|
function resolveEnclosingAssignmentTarget(node) {
|
|
342
348
|
switch (node.type) {
|
|
@@ -451,4 +457,4 @@ function resolveObjectType(context, node) {
|
|
|
451
457
|
return resolveObjectType(context, node.expression);
|
|
452
458
|
}
|
|
453
459
|
}
|
|
454
|
-
export { createImportLookup, isAssignmentTargetEqual, isInitializedFromReact, isInitializedFromReactNative, isValueEqual, resolve, resolveEnclosingAssignmentTarget, resolveImportSource, resolveObjectType, resolveOrigin };
|
|
460
|
+
export { createImportLookup, isAssignmentTargetEqual, isInitializedFromReact, isInitializedFromReactNative, isValueEqual, resolve, resolveBindingTarget, resolveEnclosingAssignmentTarget, resolveImportSource, resolveObjectType, resolveOrigin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/var",
|
|
3
|
-
"version": "5.30.0-beta.
|
|
3
|
+
"version": "5.30.0-beta.5",
|
|
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,11 +29,11 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@eslint-react/ast": "5.30.0-beta.
|
|
33
|
-
"@eslint-react/eslint": "5.30.0-beta.
|
|
34
|
-
"@typescript-eslint/scope-manager": "^8.72.
|
|
35
|
-
"@typescript-eslint/types": "^8.72.
|
|
36
|
-
"@typescript-eslint/utils": "^8.72.
|
|
32
|
+
"@eslint-react/ast": "5.30.0-beta.5",
|
|
33
|
+
"@eslint-react/eslint": "5.30.0-beta.5",
|
|
34
|
+
"@typescript-eslint/scope-manager": "^8.72.1",
|
|
35
|
+
"@typescript-eslint/types": "^8.72.1",
|
|
36
|
+
"@typescript-eslint/utils": "^8.72.1",
|
|
37
37
|
"ts-pattern": "^5.9.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|