@eslint-react/ast 5.2.3-next.1 → 5.2.3-next.2

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
@@ -13,7 +13,7 @@ type TSESTreeDirective = TSESTree.ExpressionStatement & {
13
13
  };
14
14
  type TSESTreeTypeExpression = TSESTree.TSAsExpression | TSESTree.TSTypeAssertion | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSInstantiationExpression;
15
15
  declare namespace check_d_exports {
16
- export { directive, identifier, is, isClass, isFunction, isJSX, isJSXElement, isJSXFragment, isJSXLike, isJSXTagNameExpression, isMethodOrProperty, isOneOf, isProperty, isTypeAssertionExpression, isTypeExpression, literal, thisExpression };
16
+ export { is, isClass, isDirective, isFunction, isIdentifier, isJSX, isJSXElement, isJSXFragment, isJSXLike, isJSXTagNameExpression, isLiteral, isMethodOrProperty, isOneOf, isProperty, isTypeAssertionExpression, isTypeExpression };
17
17
  }
18
18
  declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
19
19
  type: NodeType;
@@ -21,14 +21,14 @@ declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node
21
21
  declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
22
22
  type: NodeTypes[number];
23
23
  }>;
24
- declare function identifier(node: TSESTree.Node | null, named?: string): node is TSESTree.Identifier;
25
- declare function literal(node: TSESTree.Node): node is TSESTree.Literal;
26
- declare function literal(node: TSESTree.Node, ofKind: "boolean"): node is TSESTree.BooleanLiteral;
27
- declare function literal(node: TSESTree.Node, ofKind: "null"): node is TSESTree.NullLiteral;
28
- declare function literal(node: TSESTree.Node, ofKind: "number"): node is TSESTree.NumberLiteral;
29
- declare function literal(node: TSESTree.Node, ofKind: "regexp"): node is TSESTree.RegExpLiteral;
30
- declare function literal(node: TSESTree.Node, ofKind: "string"): node is TSESTree.StringLiteral;
31
- declare function thisExpression(expression: TSESTree.Expression): boolean;
24
+ declare function isLiteral(): (node: TSESTree.Node) => node is TSESTree.Literal;
25
+ declare function isLiteral(kind: "boolean"): (node: TSESTree.Node) => node is TSESTree.BooleanLiteral;
26
+ declare function isLiteral(kind: "null"): (node: TSESTree.Node) => node is TSESTree.NullLiteral;
27
+ declare function isLiteral(kind: "number"): (node: TSESTree.Node) => node is TSESTree.NumberLiteral;
28
+ declare function isLiteral(kind: "regexp"): (node: TSESTree.Node) => node is TSESTree.RegExpLiteral;
29
+ declare function isLiteral(kind: "string"): (node: TSESTree.Node) => node is TSESTree.StringLiteral;
30
+ declare function isDirective(name: string): (node: TSESTree.Node) => node is TSESTreeDirective;
31
+ declare function isIdentifier(name: string): (node: TSESTree.Node) => node is TSESTree.Identifier;
32
32
  declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
33
33
  declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
34
34
  declare const isMethodOrProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.MethodDefinitionComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName;
@@ -40,7 +40,6 @@ declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) =
40
40
  declare const isJSX: (node: TSESTree.Node | null | undefined) => node is 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;
41
41
  declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
42
42
  declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
43
- declare function directive(node: TSESTree.Node): node is TSESTreeDirective;
44
43
  declare namespace compare_d_exports {
45
44
  export { areEqual };
46
45
  }
package/dist/index.js CHANGED
@@ -5,43 +5,44 @@ import { delimiterCase, replace, toLowerCase } from "string-ts";
5
5
 
6
6
  //#region src/check.ts
7
7
  var check_exports = /* @__PURE__ */ __exportAll({
8
- directive: () => directive,
9
- identifier: () => identifier,
10
8
  is: () => is,
11
9
  isClass: () => isClass,
10
+ isDirective: () => isDirective,
12
11
  isFunction: () => isFunction,
12
+ isIdentifier: () => isIdentifier,
13
13
  isJSX: () => isJSX,
14
14
  isJSXElement: () => isJSXElement,
15
15
  isJSXFragment: () => isJSXFragment,
16
16
  isJSXLike: () => isJSXLike,
17
17
  isJSXTagNameExpression: () => isJSXTagNameExpression,
18
+ isLiteral: () => isLiteral,
18
19
  isMethodOrProperty: () => isMethodOrProperty,
19
20
  isOneOf: () => isOneOf,
20
21
  isProperty: () => isProperty,
21
22
  isTypeAssertionExpression: () => isTypeAssertionExpression,
22
- isTypeExpression: () => isTypeExpression,
23
- literal: () => literal,
24
- thisExpression: () => thisExpression
23
+ isTypeExpression: () => isTypeExpression
25
24
  });
26
25
  const is = ASTUtils.isNodeOfType;
27
26
  const isOneOf = ASTUtils.isNodeOfTypes;
28
- function identifier(node, named) {
29
- return node?.type === AST_NODE_TYPES.Identifier && (named == null || node.name === named);
27
+ function isLiteral(kind) {
28
+ return (node) => {
29
+ if (node.type !== AST_NODE_TYPES.Literal) return false;
30
+ if (kind == null) return true;
31
+ switch (kind) {
32
+ case "boolean": return typeof node.value === "boolean";
33
+ case "null": return node.value === null;
34
+ case "number": return typeof node.value === "number";
35
+ case "regexp": return "regex" in node;
36
+ case "string": return typeof node.value === "string";
37
+ default: return false;
38
+ }
39
+ };
30
40
  }
31
- function literal(node, ofKind) {
32
- if (node.type !== AST_NODE_TYPES.Literal) return false;
33
- if (ofKind == null) return true;
34
- switch (ofKind) {
35
- case "boolean": return typeof node.value === "boolean";
36
- case "null": return node.value === null;
37
- case "number": return typeof node.value === "number";
38
- case "regexp": return "regex" in node;
39
- case "string": return typeof node.value === "string";
40
- default: return false;
41
- }
41
+ function isDirective(name) {
42
+ return (node) => node.type === AST_NODE_TYPES.ExpressionStatement && node.directive === name;
42
43
  }
43
- function thisExpression(expression) {
44
- return expression.type === AST_NODE_TYPES.ThisExpression;
44
+ function isIdentifier(name) {
45
+ return (node) => node.type === AST_NODE_TYPES.Identifier && node.name === name;
45
46
  }
46
47
  const isFunction = isOneOf([
47
48
  AST_NODE_TYPES.ArrowFunctionExpression,
@@ -94,9 +95,6 @@ const isTypeAssertionExpression = isOneOf([
94
95
  AST_NODE_TYPES.TSNonNullExpression,
95
96
  AST_NODE_TYPES.TSSatisfiesExpression
96
97
  ]);
97
- function directive(node) {
98
- return node.type === AST_NODE_TYPES.ExpressionStatement && node.directive != null;
99
- }
100
98
 
101
99
  //#endregion
102
100
  //#region ../../.pkgs/eff/dist/index.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "5.2.3-next.1",
3
+ "version": "5.2.3-next.2",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {