@eslint-react/ast 5.16.0 → 5.16.1

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
@@ -49,17 +49,12 @@ declare const isEqual: {
49
49
  (a: TSESTree.Node, b: TSESTree.Node): boolean;
50
50
  };
51
51
  declare namespace extract_d_exports {
52
- export { getCalleeName, getFullyQualifiedName, getRootIdentifier, unwrap };
52
+ export { getCalleeName, getFullyQualifiedName, getRootIdentifier, getStaticPropertyName, unwrap };
53
53
  }
54
54
  declare function unwrap(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
55
55
  declare function getRootIdentifier(node: TSESTree.Expression | TSESTree.PrivateIdentifier): TSESTree.Identifier | null;
56
- /**
57
- * Get the name of a call expression's callee when it is an identifier
58
- * or a non-computed member expression whose property is an identifier
59
- * @param node The call expression node
60
- * @returns The callee name, or `null` if it cannot be determined
61
- */
62
56
  declare function getCalleeName(node: TSESTree.CallExpression): string | null;
57
+ declare function getStaticPropertyName(prop: TSESTree.Property): string | null;
63
58
  declare function getFullyQualifiedName(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
64
59
  declare namespace traverse_d_exports {
65
60
  export { findParent };
package/dist/index.js CHANGED
@@ -242,6 +242,7 @@ var extract_exports = /* @__PURE__ */ __exportAll({
242
242
  getCalleeName: () => getCalleeName,
243
243
  getFullyQualifiedName: () => getFullyQualifiedName,
244
244
  getRootIdentifier: () => getRootIdentifier,
245
+ getStaticPropertyName: () => getStaticPropertyName,
245
246
  unwrap: () => unwrap
246
247
  });
247
248
  function unwrap(node) {
@@ -254,18 +255,19 @@ function getRootIdentifier(node) {
254
255
  if (expr.type === AST_NODE_TYPES.MemberExpression) return getRootIdentifier(expr.object);
255
256
  return null;
256
257
  }
257
- /**
258
- * Get the name of a call expression's callee when it is an identifier
259
- * or a non-computed member expression whose property is an identifier
260
- * @param node The call expression node
261
- * @returns The callee name, or `null` if it cannot be determined
262
- */
263
258
  function getCalleeName(node) {
264
259
  const callee = unwrap(node.callee);
265
260
  if (callee.type === AST_NODE_TYPES.Identifier) return callee.name;
266
261
  if (callee.type === AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES.Identifier) return callee.property.name;
267
262
  return null;
268
263
  }
264
+ function getStaticPropertyName(prop) {
265
+ const key = unwrap(prop.key);
266
+ if (key.type === AST_NODE_TYPES.Identifier && !prop.computed) return key.name;
267
+ if (key.type === AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
268
+ if (key.type === AST_NODE_TYPES.TemplateLiteral && key.expressions.length === 0) return key.quasis[0]?.value.cooked ?? key.quasis[0]?.value.raw ?? null;
269
+ return null;
270
+ }
269
271
  function getFullyQualifiedName(node, getText) {
270
272
  const expr = unwrap(node);
271
273
  switch (expr.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "5.16.0",
3
+ "version": "5.16.1",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -40,8 +40,8 @@
40
40
  "tsdown": "^0.22.7",
41
41
  "typescript": "6.0.3",
42
42
  "vitest": "^4.1.10",
43
- "@local/eff": "0.0.0",
44
- "@local/configs": "0.0.0"
43
+ "@local/configs": "0.0.0",
44
+ "@local/eff": "0.0.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "eslint": "*",