@eslint-react/ast 5.30.0-beta.16 → 5.30.0-beta.18
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 +1 -34
- package/dist/index.js +0 -51
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -198,7 +198,7 @@ declare function getReturnStatements(node: TSESTree.Node): readonly TSESTree.Ret
|
|
|
198
198
|
*/
|
|
199
199
|
declare function getReturnExpressions(node: TSESTreeFunction): readonly TSESTree.Expression[];
|
|
200
200
|
declare namespace extract_d_exports {
|
|
201
|
-
export {
|
|
201
|
+
export { getCalleeName, getFullyQualifiedName, getJSXName, unwrap };
|
|
202
202
|
}
|
|
203
203
|
/**
|
|
204
204
|
* Recursively unwrap TypeScript type expressions and chain expressions to get the underlying expression.
|
|
@@ -226,39 +226,6 @@ declare function getFullyQualifiedName(node: TSESTree.Node, getText: (node: TSES
|
|
|
226
226
|
* @returns The callee name (ex: `"useState"`), or `null` for computed member expressions and other unsupported callee forms.
|
|
227
227
|
*/
|
|
228
228
|
declare function getCalleeName(node: TSESTree.CallExpression): string | null;
|
|
229
|
-
/**
|
|
230
|
-
* Get the member chain of an expression (ex: `[a, b, c]` for `a.b.c`), starting from the base object.
|
|
231
|
-
* Type expressions and chain expressions are unwrapped along the way.
|
|
232
|
-
* @param node The expression to inspect.
|
|
233
|
-
* @returns The base node followed by each member property in access order.
|
|
234
|
-
*/
|
|
235
|
-
declare function getMemberChain(node: TSESTree.Expression | TSESTree.PrivateIdentifier): (TSESTree.AccessorProperty | TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AssignmentPattern | TSESTree.AwaitExpression | TSESTree.BinaryExpression | TSESTree.BlockStatement | TSESTree.BreakStatement | TSESTree.CallExpression | TSESTree.CatchClause | TSESTree.ClassBody | TSESTree.ClassDeclaration | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.ContinueStatement | TSESTree.DebuggerStatement | TSESTree.Decorator | TSESTree.DoWhileStatement | TSESTree.EmptyStatement | TSESTree.ExportAllDeclaration | TSESTree.ExportDefaultDeclaration | TSESTree.ExportNamedDeclaration | TSESTree.ExportSpecifier | TSESTree.ExpressionStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.IfStatement | TSESTree.ImportAttribute | TSESTree.ImportDeclaration | TSESTree.ImportDefaultSpecifier | TSESTree.ImportExpression | TSESTree.ImportNamespaceSpecifier | TSESTree.ImportSpecifier | TSESTree.JSXAttribute | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXElement | TSESTree.JSXEmptyExpression | TSESTree.JSXExpressionContainer | TSESTree.JSXFragment | TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXSpreadChild | TSESTree.JSXText | TSESTree.LabeledStatement | TSESTree.Literal | TSESTree.LogicalExpression | TSESTree.MemberExpression | TSESTree.MetaProperty | TSESTree.MethodDefinition | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.PrivateIdentifier | TSESTree.Program | TSESTree.Property | TSESTree.PropertyDefinition | TSESTree.RestElement | TSESTree.ReturnStatement | TSESTree.SequenceExpression | TSESTree.SpreadElement | TSESTree.StaticBlock | TSESTree.Super | TSESTree.SwitchCase | TSESTree.SwitchStatement | TSESTree.TaggedTemplateExpression | TSESTree.TemplateElement | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.ThrowStatement | TSESTree.TryStatement | TSESTree.TSAbstractAccessorProperty | TSESTree.TSAbstractKeyword | TSESTree.TSAbstractMethodDefinition | TSESTree.TSAbstractPropertyDefinition | TSESTree.TSAnyKeyword | TSESTree.TSArrayType | TSESTree.TSAsyncKeyword | TSESTree.TSBigIntKeyword | TSESTree.TSBooleanKeyword | TSESTree.TSCallSignatureDeclaration | TSESTree.TSClassImplements | TSESTree.TSConditionalType | TSESTree.TSConstructorType | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSDeclareFunction | TSESTree.TSDeclareKeyword | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSEnumBody | TSESTree.TSEnumDeclaration | TSESTree.TSEnumMember | TSESTree.TSExportAssignment | TSESTree.TSExportKeyword | TSESTree.TSExternalModuleReference | TSESTree.TSFunctionType | TSESTree.TSImportEqualsDeclaration | TSESTree.TSImportType | TSESTree.TSIndexedAccessType | TSESTree.TSIndexSignature | TSESTree.TSInferType | TSESTree.TSInterfaceBody | TSESTree.TSInterfaceDeclaration | TSESTree.TSInterfaceHeritage | TSESTree.TSIntersectionType | TSESTree.TSIntrinsicKeyword | TSESTree.TSLiteralType | TSESTree.TSMappedType | TSESTree.TSMethodSignature | TSESTree.TSModuleBlock | TSESTree.TSModuleDeclaration | TSESTree.TSNamedTupleMember | TSESTree.TSNamespaceExportDeclaration | TSESTree.TSNeverKeyword | TSESTree.TSNullKeyword | TSESTree.TSNumberKeyword | TSESTree.TSObjectKeyword | TSESTree.TSOptionalType | TSESTree.TSParameterProperty | TSESTree.TSPrivateKeyword | TSESTree.TSPropertySignature | TSESTree.TSProtectedKeyword | TSESTree.TSPublicKeyword | TSESTree.TSQualifiedName | TSESTree.TSReadonlyKeyword | TSESTree.TSRestType | TSESTree.TSStaticKeyword | TSESTree.TSStringKeyword | TSESTree.TSSymbolKeyword | TSESTree.TSTemplateLiteralType | TSESTree.TSThisType | TSESTree.TSTupleType | TSESTree.TSTypeAliasDeclaration | TSESTree.TSTypeAnnotation | TSESTree.TSTypeLiteral | TSESTree.TSTypeOperator | TSESTree.TSTypeParameter | TSESTree.TSTypeParameterDeclaration | TSESTree.TSTypeParameterInstantiation | TSESTree.TSTypePredicate | TSESTree.TSTypeQuery | TSESTree.TSTypeReference | TSESTree.TSUndefinedKeyword | TSESTree.TSUnionType | TSESTree.TSUnknownKeyword | TSESTree.TSVoidKeyword | TSESTree.UnaryExpression | TSESTree.UpdateExpression | TSESTree.VariableDeclaration | TSESTree.VariableDeclarator | TSESTree.WhileStatement | TSESTree.WithStatement | TSESTree.YieldExpression)[];
|
|
236
|
-
/**
|
|
237
|
-
* Get the static name of an object property's key.
|
|
238
|
-
* @param property The property to inspect.
|
|
239
|
-
* @param effort `"min"` only matches plain identifiers; `"max"` also resolves string literals and simple template literals.
|
|
240
|
-
* @returns The property name, or `null` when it cannot be statically determined.
|
|
241
|
-
*/
|
|
242
|
-
declare function getPropertyName(property: TSESTree.Property, effort?: "min" | "max"): string | null;
|
|
243
|
-
/**
|
|
244
|
-
* Find a property by name in a list of object literal properties, recursing into spread object expressions.
|
|
245
|
-
*
|
|
246
|
-
* Names are resolved with maximum effort: in addition to non-computed identifiers, string-literal keys
|
|
247
|
-
* (computed or not) and template literals without expressions are matched.
|
|
248
|
-
* @param properties The object literal properties to search.
|
|
249
|
-
* @param name The property name to look for.
|
|
250
|
-
* @returns The matching `Property` node, or `null` when not found.
|
|
251
|
-
*/
|
|
252
|
-
declare function findProperty(properties: TSESTree.ObjectLiteralElement[], name: string): TSESTree.Property | null;
|
|
253
|
-
/**
|
|
254
|
-
* Collect every write target of an assignment or loop target, expanding
|
|
255
|
-
* destructuring patterns such as `[local, globalValue] = source` or
|
|
256
|
-
* `({ a: obj.x } = source)`. Defaults (`{ a = source }`) are not targets;
|
|
257
|
-
* their left side is.
|
|
258
|
-
* @param node The assignment left side or for-in/of loop target to inspect. Declaration-form loop targets are not expanded and return an empty array.
|
|
259
|
-
* @returns The identifier and member expression targets being written.
|
|
260
|
-
*/
|
|
261
|
-
declare function getAssignmentTargets(node: TSESTree.Node): (TSESTree.Identifier | TSESTree.MemberExpression)[];
|
|
262
229
|
declare namespace analyze_d_exports {
|
|
263
230
|
export { isTerminatingStatement, isUnconditionallyTerminating };
|
|
264
231
|
}
|
package/dist/index.js
CHANGED
|
@@ -244,9 +244,6 @@ dual(2, (a, b) => (data) => a(data) === b(data));
|
|
|
244
244
|
dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
|
|
245
245
|
dual(2, (a, b) => (data) => !a(data) && !b(data));
|
|
246
246
|
dual(2, (a, b) => (data) => !a(data) || !b(data));
|
|
247
|
-
function isString(input) {
|
|
248
|
-
return typeof input === "string";
|
|
249
|
-
}
|
|
250
247
|
function isFunction(input) {
|
|
251
248
|
return typeof input === "function";
|
|
252
249
|
}
|
|
@@ -270,13 +267,9 @@ dual(2, (self, predicate) => {
|
|
|
270
267
|
});
|
|
271
268
|
// src/extract.ts
|
|
272
269
|
var extract_exports = /* @__PURE__ */ __exportAll({
|
|
273
|
-
findProperty: () => findProperty,
|
|
274
|
-
getAssignmentTargets: () => getAssignmentTargets,
|
|
275
270
|
getCalleeName: () => getCalleeName,
|
|
276
271
|
getFullyQualifiedName: () => getFullyQualifiedName,
|
|
277
272
|
getJSXName: () => getJSXName,
|
|
278
|
-
getMemberChain: () => getMemberChain,
|
|
279
|
-
getPropertyName: () => getPropertyName,
|
|
280
273
|
unwrap: () => unwrap
|
|
281
274
|
});
|
|
282
275
|
function unwrap(node) {
|
|
@@ -312,50 +305,6 @@ function getCalleeName(node) {
|
|
|
312
305
|
if (callee.type === AST_NODE_TYPES.MemberExpression && !callee.computed && isIdentifier(callee.property)) return callee.property.name;
|
|
313
306
|
return null;
|
|
314
307
|
}
|
|
315
|
-
function getMemberChain(node) {
|
|
316
|
-
const members = [];
|
|
317
|
-
let current = unwrap(node);
|
|
318
|
-
while (current.type === AST_NODE_TYPES.MemberExpression) {
|
|
319
|
-
const property = unwrap(current.property);
|
|
320
|
-
members.unshift(property);
|
|
321
|
-
current = unwrap(current.object);
|
|
322
|
-
}
|
|
323
|
-
members.unshift(current);
|
|
324
|
-
return members;
|
|
325
|
-
}
|
|
326
|
-
function getPropertyName(property, effort = "min") {
|
|
327
|
-
const key = unwrap(property.key);
|
|
328
|
-
if (isIdentifier(key) && !property.computed) return key.name;
|
|
329
|
-
if (effort === "min") return null;
|
|
330
|
-
if (key.type === AST_NODE_TYPES.Literal && isString(key.value)) return key.value;
|
|
331
|
-
if (key.type === AST_NODE_TYPES.TemplateLiteral && key.expressions.length === 0) return key.quasis[0]?.value.cooked ?? key.quasis[0]?.value.raw ?? null;
|
|
332
|
-
return null;
|
|
333
|
-
}
|
|
334
|
-
function findProperty(properties, name) {
|
|
335
|
-
for (const property of properties) {
|
|
336
|
-
if (property.type === AST_NODE_TYPES.Property && getPropertyName(property, "max") === name) return property;
|
|
337
|
-
if (property.type === AST_NODE_TYPES.SpreadElement && property.argument.type === AST_NODE_TYPES.ObjectExpression) {
|
|
338
|
-
const found = findProperty(property.argument.properties, name);
|
|
339
|
-
if (found != null) return found;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
|
-
function getAssignmentTargets(node) {
|
|
345
|
-
const target = unwrap(node);
|
|
346
|
-
switch (target.type) {
|
|
347
|
-
case AST_NODE_TYPES.Identifier:
|
|
348
|
-
case AST_NODE_TYPES.MemberExpression: return [target];
|
|
349
|
-
case AST_NODE_TYPES.ArrayPattern: return target.elements.flatMap((element) => element == null ? [] : getAssignmentTargets(element));
|
|
350
|
-
case AST_NODE_TYPES.AssignmentPattern: return getAssignmentTargets(target.left);
|
|
351
|
-
case AST_NODE_TYPES.ObjectPattern: return target.properties.flatMap((property) => {
|
|
352
|
-
if (property.type === AST_NODE_TYPES.RestElement) return getAssignmentTargets(property.argument);
|
|
353
|
-
return getAssignmentTargets(property.value);
|
|
354
|
-
});
|
|
355
|
-
case AST_NODE_TYPES.RestElement: return getAssignmentTargets(target.argument);
|
|
356
|
-
default: return [];
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
308
|
// src/compare.ts
|
|
360
309
|
var compare_exports = /* @__PURE__ */ __exportAll({ isEqual: () => isEqual });
|
|
361
310
|
const isEqual = dual(2, (a, b) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "5.30.0-beta.
|
|
3
|
+
"version": "5.30.0-beta.18",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@local/testkit": "0.0.0",
|
|
40
40
|
"@tsconfig/node20": "^20.1.10",
|
|
41
41
|
"@types/node": "^20.19.43",
|
|
42
|
-
"eslint": "^10.
|
|
42
|
+
"eslint": "^10.14.0",
|
|
43
43
|
"tsdown": "^0.23.4",
|
|
44
44
|
"typescript": "6.0.3",
|
|
45
45
|
"vitest": "^5.0.5"
|