@eslint-react/jsx 0.8.8-beta.3 → 0.8.8-beta.4

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.
Files changed (51) hide show
  1. package/dist/index.cjs +2 -2
  2. package/dist/index.d.mts +26 -31
  3. package/dist/index.d.ts +26 -31
  4. package/dist/index.js +2 -2
  5. package/dist/index.mjs +2 -2
  6. package/node_modules/@eslint-react/ast/dist/index.cjs +129 -149
  7. package/node_modules/@eslint-react/ast/dist/index.d.mts +52 -60
  8. package/node_modules/@eslint-react/ast/dist/index.d.ts +52 -60
  9. package/node_modules/@eslint-react/ast/dist/index.js +129 -149
  10. package/node_modules/@eslint-react/ast/dist/index.mjs +131 -150
  11. package/node_modules/@eslint-react/ast/package.json +4 -4
  12. package/node_modules/@eslint-react/tools/package.json +1 -1
  13. package/node_modules/@eslint-react/types/package.json +3 -3
  14. package/node_modules/@typescript-eslint/scope-manager/dist/ScopeManager.d.ts +2 -2
  15. package/node_modules/@typescript-eslint/scope-manager/dist/ScopeManager.d.ts.map +1 -1
  16. package/node_modules/@typescript-eslint/scope-manager/dist/ScopeManager.js.map +1 -1
  17. package/node_modules/@typescript-eslint/scope-manager/dist/analyze.d.ts +2 -2
  18. package/node_modules/@typescript-eslint/scope-manager/dist/analyze.d.ts.map +1 -1
  19. package/node_modules/@typescript-eslint/scope-manager/dist/assert.js.map +1 -1
  20. package/node_modules/@typescript-eslint/scope-manager/dist/lib/es5.d.ts.map +1 -1
  21. package/node_modules/@typescript-eslint/scope-manager/dist/lib/es5.js +1 -0
  22. package/node_modules/@typescript-eslint/scope-manager/dist/lib/es5.js.map +1 -1
  23. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/ClassVisitor.d.ts.map +1 -1
  24. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/ClassVisitor.js +2 -12
  25. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/ClassVisitor.js.map +1 -1
  26. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/ExportVisitor.js.map +1 -1
  27. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.d.ts.map +1 -1
  28. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.js +2 -2
  29. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.js.map +1 -1
  30. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Reference.js.map +1 -1
  31. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.js.map +1 -1
  32. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/TypeVisitor.js +1 -1
  33. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/TypeVisitor.js.map +1 -1
  34. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Visitor.js.map +1 -1
  35. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/VisitorBase.js.map +1 -1
  36. package/node_modules/@typescript-eslint/scope-manager/dist/scope/FunctionExpressionNameScope.js.map +1 -1
  37. package/node_modules/@typescript-eslint/scope-manager/dist/scope/FunctionScope.js.map +1 -1
  38. package/node_modules/@typescript-eslint/scope-manager/dist/scope/GlobalScope.js +1 -1
  39. package/node_modules/@typescript-eslint/scope-manager/dist/scope/GlobalScope.js.map +1 -1
  40. package/node_modules/@typescript-eslint/scope-manager/dist/scope/ScopeBase.d.ts.map +1 -1
  41. package/node_modules/@typescript-eslint/scope-manager/dist/scope/ScopeBase.js +4 -11
  42. package/node_modules/@typescript-eslint/scope-manager/dist/scope/ScopeBase.js.map +1 -1
  43. package/node_modules/@typescript-eslint/scope-manager/dist/scope/WithScope.js.map +1 -1
  44. package/node_modules/@typescript-eslint/scope-manager/dist/variable/Variable.js.map +1 -1
  45. package/node_modules/@typescript-eslint/scope-manager/package.json +5 -5
  46. package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.d.ts +57 -8
  47. package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.d.ts.map +1 -1
  48. package/node_modules/@typescript-eslint/types/dist/parser-options.d.ts +4 -2
  49. package/node_modules/@typescript-eslint/types/dist/parser-options.d.ts.map +1 -1
  50. package/node_modules/@typescript-eslint/types/package.json +2 -2
  51. package/package.json +7 -7
@@ -48,14 +48,26 @@ type Construction = Data.TaggedEnum<{
48
48
  };
49
49
  }>;
50
50
  declare const Construction: {
51
- readonly None: Data.Case.Constructor<Data.Data<{
52
- readonly _tag: "None";
53
- }>, "_tag">;
54
51
  readonly Array: Data.Case.Constructor<Data.Data<{
55
52
  readonly _tag: "Array";
56
53
  readonly node: TSESTree.ArrayExpression;
57
54
  readonly usage: O.Option<TSESTree.Node>;
58
55
  }>, "_tag">;
56
+ readonly JSXElement: Data.Case.Constructor<Data.Data<{
57
+ readonly _tag: "JSXElement";
58
+ readonly node: TSESTree.JSXElement;
59
+ readonly usage: O.Option<TSESTree.Node>;
60
+ }>, "_tag">;
61
+ readonly JSXFragment: Data.Case.Constructor<Data.Data<{
62
+ readonly _tag: "JSXFragment";
63
+ readonly node: TSESTree.JSXFragment;
64
+ readonly usage: O.Option<TSESTree.Node>;
65
+ }>, "_tag">;
66
+ readonly FunctionExpression: Data.Case.Constructor<Data.Data<{
67
+ readonly _tag: "FunctionExpression";
68
+ readonly node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
69
+ readonly usage: O.Option<TSESTree.Node>;
70
+ }>, "_tag">;
59
71
  readonly AssignmentExpression: Data.Case.Constructor<Data.Data<{
60
72
  readonly _tag: "AssignmentExpression";
61
73
  readonly node: TSESTree.Node;
@@ -71,21 +83,6 @@ declare const Construction: {
71
83
  readonly node: TSESTree.FunctionDeclaration;
72
84
  readonly usage: O.Option<TSESTree.Expression | TSESTree.Identifier>;
73
85
  }>, "_tag">;
74
- readonly FunctionExpression: Data.Case.Constructor<Data.Data<{
75
- readonly _tag: "FunctionExpression";
76
- readonly node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
77
- readonly usage: O.Option<TSESTree.Node>;
78
- }>, "_tag">;
79
- readonly JSXElement: Data.Case.Constructor<Data.Data<{
80
- readonly _tag: "JSXElement";
81
- readonly node: TSESTree.JSXElement;
82
- readonly usage: O.Option<TSESTree.Node>;
83
- }>, "_tag">;
84
- readonly JSXFragment: Data.Case.Constructor<Data.Data<{
85
- readonly _tag: "JSXFragment";
86
- readonly node: TSESTree.JSXFragment;
87
- readonly usage: O.Option<TSESTree.Node>;
88
- }>, "_tag">;
89
86
  readonly NewExpression: Data.Case.Constructor<Data.Data<{
90
87
  readonly _tag: "NewExpression";
91
88
  readonly node: TSESTree.NewExpression;
@@ -96,6 +93,9 @@ declare const Construction: {
96
93
  readonly node: TSESTree.ObjectExpression;
97
94
  readonly usage: O.Option<TSESTree.Node>;
98
95
  }>, "_tag">;
96
+ readonly None: Data.Case.Constructor<Data.Data<{
97
+ readonly _tag: "None";
98
+ }>, "_tag">;
99
99
  readonly RegExpLiteral: Data.Case.Constructor<Data.Data<{
100
100
  readonly _tag: "RegExpLiteral";
101
101
  readonly node: TSESTree.Literal;
@@ -119,6 +119,15 @@ declare function isUnstableAssignmentPattern(node: TSESTree.AssignmentPattern):
119
119
  right: TSESTree.RegExpLiteral | typeof unstableAssignmentPatternTypes[number];
120
120
  }>;
121
121
 
122
+ /**
123
+ * Determines whether node equals to another node
124
+ * @param a node to compare
125
+ * @param b node to compare
126
+ * @returns `true` if node equal
127
+ * @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
128
+ */
129
+ declare function isNodeEqual(a: TSESTree.Node, b: TSESTree.Node): boolean;
130
+
122
131
  /**
123
132
  * Get the proper location of a given function node to report.
124
133
  * @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getfunctionheadlocation}
@@ -186,20 +195,6 @@ declare const isParenthesized: {
186
195
  (times: number, node: TSESTree.Node, sourceCode: TSESLint.SourceCode): boolean;
187
196
  };
188
197
 
189
- /**
190
- * Gets nested identifiers in a node
191
- * @param node The AST node
192
- * @returns The nested identifiers
193
- */
194
- declare function getNestedIdentifiers(node: TSESTree.Node): TSESTree.Identifier[];
195
-
196
- /**
197
- * Gets nested return statements in a node
198
- * @param node The AST node
199
- * @returns The nested return statements
200
- */
201
- declare function getNestedReturnStatements(node: TSESTree.Node): TSESTree.ReturnStatement[];
202
-
203
198
  /**
204
199
  * Checks if the given node is a function expression or arrow function expression of a object method.
205
200
  * @param node The node to check.
@@ -230,7 +225,9 @@ type TSESTreeProperty = TSESTree$1.PropertyDefinition | TSESTree$1.TSIndexSignat
230
225
  type TSESTreeJSX = TSESTree$1.JSXAttribute | TSESTree$1.JSXChild | TSESTree$1.JSXClosingElement | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXElement | TSESTree$1.JSXEmptyExpression | TSESTree$1.JSXExpression | TSESTree$1.JSXExpressionContainer | TSESTree$1.JSXFragment | TSESTree$1.JSXIdentifier | TSESTree$1.JSXIdentifierToken | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXSpreadAttribute | TSESTree$1.JSXSpreadChild | TSESTree$1.JSXTagNameExpression | TSESTree$1.JSXText | TSESTree$1.JSXTextToken;
231
226
  type TSESTreeDestructuringPattern = TSESTree$1.ArrayPattern | TSESTree$1.AssignmentPattern | TSESTree$1.ObjectPattern | TSESTree$1.RestElement;
232
227
  type TSESTreeTypeDeclaration = TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TSTypeAliasDeclaration;
233
- declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree$1.Node | null | undefined) => node is Extract<TSESTree$1.AccessorPropertyComputedName, {
228
+ declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree$1.Node | null | undefined) => node is Extract<TSESTree$1.Program, {
229
+ type: NodeType;
230
+ }> | Extract<TSESTree$1.AccessorPropertyComputedName, {
234
231
  type: NodeType;
235
232
  }> | Extract<TSESTree$1.AccessorPropertyNonComputedName, {
236
233
  type: NodeType;
@@ -384,8 +381,6 @@ declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node
384
381
  type: NodeType;
385
382
  }> | Extract<TSESTree$1.PrivateIdentifier, {
386
383
  type: NodeType;
387
- }> | Extract<TSESTree$1.Program, {
388
- type: NodeType;
389
384
  }> | Extract<TSESTree$1.PropertyComputedName, {
390
385
  type: NodeType;
391
386
  }> | Extract<TSESTree$1.PropertyNonComputedName, {
@@ -606,7 +601,7 @@ declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node
606
601
  type: NodeType;
607
602
  }> | Extract<TSESTree$1.UsingInForOfDeclaration, {
608
603
  type: NodeType;
609
- }> | Extract<TSESTree$1.UsingInNomalConextDeclaration, {
604
+ }> | Extract<TSESTree$1.UsingInNormalContextDeclaration, {
610
605
  type: NodeType;
611
606
  }> | Extract<TSESTree$1.LetOrConstOrVarDeclarator, {
612
607
  type: NodeType;
@@ -621,7 +616,9 @@ declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node
621
616
  }> | Extract<TSESTree$1.YieldExpression, {
622
617
  type: NodeType;
623
618
  }>;
624
- declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree$1.Node | null | undefined) => node is Extract<TSESTree$1.AccessorPropertyComputedName, {
619
+ declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree$1.Node | null | undefined) => node is Extract<TSESTree$1.Program, {
620
+ type: NodeTypes[number];
621
+ }> | Extract<TSESTree$1.AccessorPropertyComputedName, {
625
622
  type: NodeTypes[number];
626
623
  }> | Extract<TSESTree$1.AccessorPropertyNonComputedName, {
627
624
  type: NodeTypes[number];
@@ -775,8 +772,6 @@ declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES[]>(nodeTypes:
775
772
  type: NodeTypes[number];
776
773
  }> | Extract<TSESTree$1.PrivateIdentifier, {
777
774
  type: NodeTypes[number];
778
- }> | Extract<TSESTree$1.Program, {
779
- type: NodeTypes[number];
780
775
  }> | Extract<TSESTree$1.PropertyComputedName, {
781
776
  type: NodeTypes[number];
782
777
  }> | Extract<TSESTree$1.PropertyNonComputedName, {
@@ -997,7 +992,7 @@ declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES[]>(nodeTypes:
997
992
  type: NodeTypes[number];
998
993
  }> | Extract<TSESTree$1.UsingInForOfDeclaration, {
999
994
  type: NodeTypes[number];
1000
- }> | Extract<TSESTree$1.UsingInNomalConextDeclaration, {
995
+ }> | Extract<TSESTree$1.UsingInNormalContextDeclaration, {
1001
996
  type: NodeTypes[number];
1002
997
  }> | Extract<TSESTree$1.LetOrConstOrVarDeclarator, {
1003
998
  type: NodeTypes[number];
@@ -1027,6 +1022,14 @@ declare const isTypeDeclaration: (node: TSESTree$1.Node | null | undefined) => n
1027
1022
  declare const isLeftHandSideExpression: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionExpression | TSESTree$1.ClassExpression | TSESTree$1.JSXElement | TSESTree$1.JSXFragment | TSESTree$1.ArrayPattern | TSESTree$1.ObjectPattern | TSESTree$1.ArrayExpression | TSESTree$1.CallExpression | TSESTree$1.Identifier | TSESTree$1.BigIntLiteral | TSESTree$1.BooleanLiteral | TSESTree$1.NullLiteral | TSESTree$1.NumberLiteral | TSESTree$1.RegExpLiteral | TSESTree$1.StringLiteral | TSESTree$1.MemberExpressionComputedName | TSESTree$1.MemberExpressionNonComputedName | TSESTree$1.MetaProperty | TSESTree$1.ObjectExpression | TSESTree$1.SequenceExpression | TSESTree$1.Super | TSESTree$1.TaggedTemplateExpression | TSESTree$1.TemplateLiteral | TSESTree$1.ThisExpression;
1028
1023
  declare const isLeftHandSideExpressionType: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionExpression | TSESTree$1.ClassExpression | TSESTree$1.JSXElement | TSESTree$1.JSXFragment | TSESTree$1.ArrayPattern | TSESTree$1.ObjectPattern | TSESTree$1.ArrayExpression | TSESTree$1.CallExpression | TSESTree$1.Identifier | TSESTree$1.BigIntLiteral | TSESTree$1.BooleanLiteral | TSESTree$1.NullLiteral | TSESTree$1.NumberLiteral | TSESTree$1.RegExpLiteral | TSESTree$1.StringLiteral | TSESTree$1.MemberExpressionComputedName | TSESTree$1.MemberExpressionNonComputedName | TSESTree$1.MetaProperty | TSESTree$1.ObjectExpression | TSESTree$1.SequenceExpression | TSESTree$1.Super | TSESTree$1.TaggedTemplateExpression | TSESTree$1.TemplateLiteral | TSESTree$1.ThisExpression | TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSTypeAssertion;
1029
1024
 
1025
+ /**
1026
+ * Returns human readable node type for given AST node
1027
+ * @param node AST node
1028
+ * @returns Human readable node type
1029
+ */
1030
+ declare function readableNodeType(node: TSESTree.Node): "RegExp literal" | "Object literal" | "Number literal" | "Boolean literal" | "String literal" | "Null literal" | "Array literal" | "NaN literal" | "Function literal" | "Undefined literal" | "Async literal" | "Promise literal" | "Symbol literal" | "Set literal" | "Error literal" | "Map literal" | "WeakMap literal" | "Generator literal" | "GeneratorFunction literal" | "BigInt literal" | "ArrayBuffer literal" | "Date literal" | "identifier" | "member expression" | "JSX attribute" | "JSX element" | "JSX fragment" | "JSX identifier" | "JSX text" | "JSX closing element" | "JSX closing fragment" | "JSX empty expression" | "JSX expression container" | "JSX member expression" | "JSX namespaced name" | "JSX opening element" | "JSX opening fragment" | "JSX spread attribute" | "JSX spread child" | "property" | "decorator" | "program" | "super" | "accessor property" | "array expression" | "array pattern" | "function expression" | "arrow function expression" | "assignment expression" | "assignment pattern" | "await expression" | "binary expression" | "block statement" | "break statement" | "call expression" | "catch clause" | "chain expression" | "class body" | "class declaration" | "class expression" | "conditional expression" | "continue statement" | "debugger statement" | "while statement" | "do while statement" | "empty statement" | "export all declaration" | "export default declaration" | "export named declaration" | "export specifier" | "expression statement" | "for in statement" | "for of statement" | "for statement" | "function declaration" | "if statement" | "import attribute" | "import declaration" | "import default specifier" | "import expression" | "import namespace specifier" | "import specifier" | "labeled statement" | "logical expression" | "meta property" | "method definition" | "new expression" | "object expression" | "object pattern" | "private identifier" | "property definition" | "rest element" | "return statement" | "sequence expression" | "spread element" | "static block" | "switch case" | "switch statement" | "tagged template expression" | "template element" | "template literal" | "this expression" | "throw statement" | "try statement" | "unary expression" | "update expression" | "variable declaration" | "variable declarator" | "with statement" | "yield expression" | "ts abstract accessor property" | "ts abstract keyword" | "ts abstract method definition" | "ts abstract property definition" | "ts any keyword" | "ts array type" | "ts as expression" | "ts async keyword" | "ts big int keyword" | "ts boolean keyword" | "ts call signature declaration" | "ts class implements" | "ts conditional type" | "ts constructor type" | "ts construct signature declaration" | "ts declare function" | "ts declare keyword" | "ts empty body function expression" | "ts enum declaration" | "ts enum member" | "ts export assignment" | "ts export keyword" | "ts external module reference" | "ts function type" | "ts instantiation expression" | "ts import equals declaration" | "ts import type" | "ts indexed access type" | "ts index signature" | "ts infer type" | "ts interface body" | "ts interface declaration" | "ts interface heritage" | "ts intersection type" | "ts intrinsic keyword" | "ts literal type" | "ts mapped type" | "ts method signature" | "ts module block" | "ts module declaration" | "ts named tuple member" | "ts namespace export declaration" | "ts never keyword" | "ts non null expression" | "ts null keyword" | "ts number keyword" | "ts object keyword" | "ts optional type" | "ts parameter property" | "ts private keyword" | "ts property signature" | "ts protected keyword" | "ts public keyword" | "ts qualified name" | "ts readonly keyword" | "ts rest type" | "ts satisfies expression" | "ts static keyword" | "ts string keyword" | "ts symbol keyword" | "ts template literal type" | "ts this type" | "ts tuple type" | "ts type alias declaration" | "ts type annotation" | "ts type assertion" | "ts type literal" | "ts type operator" | "ts type parameter" | "ts type parameter declaration" | "ts type parameter instantiation" | "ts type predicate" | "ts type query" | "ts type reference" | "ts undefined keyword" | "ts union type" | "ts unknown keyword" | "ts void keyword";
1031
+ type ReadableNodeType = ReturnType<typeof readableNodeType>;
1032
+
1030
1033
  /**
1031
1034
  * Checks if a node is an identifier with a given name
1032
1035
  * @param node The AST node
@@ -1057,15 +1060,12 @@ declare function getFunctionIdentifier(node: TSESTreeFunction): TSESTree.Identif
1057
1060
  * @returns class identifier or null
1058
1061
  */
1059
1062
  declare function getClassIdentifier(node: TSESTreeClass): TSESTree.Identifier | null;
1060
-
1061
1063
  /**
1062
- * Determines whether node equals to another node
1063
- * @param a node to compare
1064
- * @param b node to compare
1065
- * @returns `true` if node equal
1066
- * @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
1064
+ * Gets nested identifiers in a node
1065
+ * @param node The AST node
1066
+ * @returns The nested identifiers
1067
1067
  */
1068
- declare function isNodeEqual(a: TSESTree.Node, b: TSESTree.Node): boolean;
1068
+ declare function getNestedIdentifiers(node: TSESTree.Node): TSESTree.Identifier[];
1069
1069
 
1070
1070
  declare function isRegExpLiteral(node: TSESTree.Node): node is TSESTree.RegExpLiteral;
1071
1071
  declare function isStringLiteral(node: TSESTree.Node | null | undefined): node is TSESTree.StringLiteral;
@@ -1116,12 +1116,11 @@ declare function isPropertyWithIdentifierKey<const T extends string>(node: TSEST
1116
1116
  declare function findPropertyWithIdentifierKey(properties: TSESTree.ObjectLiteralElement[], key: string): TSESTree.ObjectLiteralElement | undefined;
1117
1117
 
1118
1118
  /**
1119
- * Returns human readable node type for given AST node
1120
- * @param node AST node
1121
- * @returns Human readable node type
1119
+ * Gets nested return statements in a node
1120
+ * @param node The AST node
1121
+ * @returns The nested return statements
1122
1122
  */
1123
- declare function readableNodeType(node: TSESTree.Node): "property" | "RegExp literal" | "Array literal" | "String literal" | "Object literal" | "Number literal" | "Boolean literal" | "Null literal" | "NaN literal" | "Function literal" | "Undefined literal" | "Async literal" | "Promise literal" | "Symbol literal" | "Set literal" | "Error literal" | "Map literal" | "WeakMap literal" | "Generator literal" | "GeneratorFunction literal" | "BigInt literal" | "ArrayBuffer literal" | "Date literal" | "identifier" | "member expression" | "JSX identifier" | "JSX attribute" | "JSX element" | "JSX fragment" | "JSX text" | "JSX member expression" | "JSX closing element" | "JSX closing fragment" | "JSX empty expression" | "JSX expression container" | "JSX namespaced name" | "JSX opening element" | "JSX opening fragment" | "JSX spread attribute" | "JSX spread child" | "decorator" | "program" | "super" | "accessor property" | "array expression" | "array pattern" | "function expression" | "arrow function expression" | "assignment expression" | "assignment pattern" | "await expression" | "binary expression" | "block statement" | "break statement" | "call expression" | "catch clause" | "chain expression" | "class body" | "class declaration" | "class expression" | "conditional expression" | "continue statement" | "debugger statement" | "while statement" | "do while statement" | "empty statement" | "export all declaration" | "export default declaration" | "export named declaration" | "export specifier" | "expression statement" | "for in statement" | "for of statement" | "for statement" | "function declaration" | "if statement" | "import attribute" | "import declaration" | "import default specifier" | "import expression" | "import namespace specifier" | "import specifier" | "labeled statement" | "logical expression" | "meta property" | "method definition" | "new expression" | "object expression" | "object pattern" | "private identifier" | "property definition" | "rest element" | "return statement" | "sequence expression" | "spread element" | "static block" | "switch case" | "switch statement" | "tagged template expression" | "template element" | "template literal" | "this expression" | "throw statement" | "try statement" | "unary expression" | "update expression" | "variable declaration" | "variable declarator" | "with statement" | "yield expression" | "ts abstract accessor property" | "ts abstract keyword" | "ts abstract method definition" | "ts abstract property definition" | "ts any keyword" | "ts array type" | "ts as expression" | "ts async keyword" | "ts big int keyword" | "ts boolean keyword" | "ts call signature declaration" | "ts class implements" | "ts conditional type" | "ts constructor type" | "ts construct signature declaration" | "ts declare function" | "ts declare keyword" | "ts empty body function expression" | "ts enum declaration" | "ts enum member" | "ts export assignment" | "ts export keyword" | "ts external module reference" | "ts function type" | "ts instantiation expression" | "ts import equals declaration" | "ts import type" | "ts indexed access type" | "ts index signature" | "ts infer type" | "ts interface body" | "ts interface declaration" | "ts interface heritage" | "ts intersection type" | "ts intrinsic keyword" | "ts literal type" | "ts mapped type" | "ts method signature" | "ts module block" | "ts module declaration" | "ts named tuple member" | "ts namespace export declaration" | "ts never keyword" | "ts non null expression" | "ts null keyword" | "ts number keyword" | "ts object keyword" | "ts optional type" | "ts parameter property" | "ts private keyword" | "ts property signature" | "ts protected keyword" | "ts public keyword" | "ts qualified name" | "ts readonly keyword" | "ts rest type" | "ts satisfies expression" | "ts static keyword" | "ts string keyword" | "ts symbol keyword" | "ts template literal type" | "ts this type" | "ts tuple type" | "ts type alias declaration" | "ts type annotation" | "ts type assertion" | "ts type literal" | "ts type operator" | "ts type parameter" | "ts type parameter declaration" | "ts type parameter instantiation" | "ts type predicate" | "ts type query" | "ts type reference" | "ts undefined keyword" | "ts union type" | "ts unknown keyword" | "ts void keyword";
1124
- type ReadableNodeType = ReturnType<typeof readableNodeType>;
1123
+ declare function getNestedReturnStatements(node: TSESTree.Node): TSESTree.ReturnStatement[];
1125
1124
 
1126
1125
  declare function isDeclaredInNode({ functionNode, reference, scopeManager, }: {
1127
1126
  functionNode: TSESTree.Node;
@@ -1150,13 +1149,6 @@ declare function traverseUp(node: TSESTree.Node, predicate: (node: TSESTree.Node
1150
1149
  */
1151
1150
  declare function traverseUpGuard<T extends TSESTree.Node>(node: TSESTree.Node, predicate: (node: TSESTree.Node) => node is T): T | null;
1152
1151
 
1153
- /**
1154
- * Get all unary operators in a nested unary expression.
1155
- * @param node The node to get the operators from.
1156
- * @returns All unary operators in a nested unary expression.
1157
- */
1158
- declare function getNestedUnaryOperators(node: TSESTree.UnaryExpression): TSESTree.UnaryExpression["operator"][];
1159
-
1160
1152
  /**
1161
1153
  * Find a variable through a list of variables by name
1162
1154
  * @param name The name of the variable to find
@@ -1182,4 +1174,4 @@ declare function resolveDefinitionInit(def: Definition): O.Option<TSESTree.Expre
1182
1174
  declare function getVariableInit(at: number): (variable: Variable) => O.Option<TSESTree.Expression | TSESTree.LetOrConstOrVarDeclaration>;
1183
1175
  declare function getVariableInitExpression(at: number): (variable: Variable) => O.Option<TSESTree.Expression>;
1184
1176
 
1185
- export { Construction, NodeType, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeProperty, type TSESTreeTypeDeclaration, constructionDetector, findPropertyWithIdentifierKey, findVariableByName, findVariableByNameUpToGlobal, getClassIdentifier, getExternalRefs, getFunctionHeadLocation, getFunctionIdentifier, getFunctionNameWithKind, getNestedIdentifiers, getNestedReturnStatements, getNestedUnaryOperators, getPropertyName, getStaticValue, getStringIfConstant, getVariableInit, getVariableInitExpression, getVariablesUpToGlobal, hasSideEffect, is, isArrayTupleType, isClass, isDeclaredInNode, isDestructuringPattern, isFunction, isFunctionOfClassMethod, isFunctionOfClassProperty, isFunctionOfObjectMethod, isFunctionType, isIdentifierWithName, isIdentifierWithOneOfNames, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMultiLine, isNodeEqual, isOneOf, isParenthesized, isProperty, isPropertyOfObjectExpression, isPropertyWithIdentifierKey, isRegExpLiteral, isStringLiteral, isTypeDeclaration, isUnstableAssignmentPattern, readableNodeType, resolveDefinitionInit, traverseUp, traverseUpGuard, unsafeIsArrayFromCall, unsafeIsMapCall, unsafeIsStringCall, unsafeIsToStringCall, unstableAssignmentPatternTypes };
1177
+ export { Construction, NodeType, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeProperty, type TSESTreeTypeDeclaration, constructionDetector, findPropertyWithIdentifierKey, findVariableByName, findVariableByNameUpToGlobal, getClassIdentifier, getExternalRefs, getFunctionHeadLocation, getFunctionIdentifier, getFunctionNameWithKind, getNestedIdentifiers, getNestedReturnStatements, getPropertyName, getStaticValue, getStringIfConstant, getVariableInit, getVariableInitExpression, getVariablesUpToGlobal, hasSideEffect, is, isArrayTupleType, isClass, isDeclaredInNode, isDestructuringPattern, isFunction, isFunctionOfClassMethod, isFunctionOfClassProperty, isFunctionOfObjectMethod, isFunctionType, isIdentifierWithName, isIdentifierWithOneOfNames, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMultiLine, isNodeEqual, isOneOf, isParenthesized, isProperty, isPropertyOfObjectExpression, isPropertyWithIdentifierKey, isRegExpLiteral, isStringLiteral, isTypeDeclaration, isUnstableAssignmentPattern, readableNodeType, resolveDefinitionInit, traverseUp, traverseUpGuard, unsafeIsArrayFromCall, unsafeIsMapCall, unsafeIsStringCall, unsafeIsToStringCall, unstableAssignmentPatternTypes };
@@ -5,8 +5,8 @@ var scopeManager = require('@typescript-eslint/scope-manager');
5
5
  var rambda = require('rambda');
6
6
  var types = require('@typescript-eslint/types');
7
7
  var utils = require('@typescript-eslint/utils');
8
- var eslintUtils = require('@eslint-community/eslint-utils');
9
8
  var stringTs = require('string-ts');
9
+ var eslintUtils = require('@eslint-community/eslint-utils');
10
10
 
11
11
  function _interopNamespaceDefault(e) {
12
12
  var n = Object.create(null);
@@ -239,6 +239,23 @@ const isLeftHandSideExpressionType = isOneOf([
239
239
  NodeType.TSTypeAssertion
240
240
  ]);
241
241
 
242
+ /**
243
+ * Returns human readable node type for given AST node
244
+ * @param node AST node
245
+ * @returns Human readable node type
246
+ */ function readableNodeType(node) {
247
+ if (node.type === NodeType.Literal) {
248
+ if ("regex" in node) {
249
+ return "RegExp literal";
250
+ }
251
+ return `${rambda.type(node.value)} literal`;
252
+ }
253
+ if (isJSX(node)) {
254
+ return `JSX ${stringTs.toLowerCase(stringTs.delimiterCase(stringTs.replace(node.type, "JSX", ""), " "))}`;
255
+ }
256
+ return stringTs.toLowerCase(stringTs.delimiterCase(node.type, " "));
257
+ }
258
+
242
259
  const Construction = tools.Data.taggedEnum();
243
260
  const None = Construction.None();
244
261
  /**
@@ -386,6 +403,31 @@ const unstableAssignmentPatternTypes = [
386
403
  return isOneOf(unstableAssignmentPatternTypes)(right);
387
404
  }
388
405
 
406
+ /**
407
+ * Determines whether node equals to another node
408
+ * @param a node to compare
409
+ * @param b node to compare
410
+ * @returns `true` if node equal
411
+ * @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
412
+ */ function isNodeEqual(a, b) {
413
+ if (a.type !== b.type) {
414
+ return false;
415
+ }
416
+ if (a.type === NodeType.ThisExpression && b.type === NodeType.ThisExpression) {
417
+ return true;
418
+ }
419
+ if (a.type === NodeType.Literal && b.type === NodeType.Literal) {
420
+ return a.value === b.value;
421
+ }
422
+ if (a.type === NodeType.Identifier && b.type === NodeType.Identifier) {
423
+ return a.name === b.name;
424
+ }
425
+ if (a.type === NodeType.MemberExpression && b.type === NodeType.MemberExpression) {
426
+ return isNodeEqual(a.property, b.property) && isNodeEqual(a.object, b.object);
427
+ }
428
+ return false;
429
+ }
430
+
389
431
  // Ported from: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/utils/src/ast-utils/eslint-utils/astUtilities.ts
390
432
  /**
391
433
  * Get the proper location of a given function node to report.
@@ -440,105 +482,6 @@ const unstableAssignmentPatternTypes = [
440
482
  */ const hasSideEffect = eslintUtils__namespace.hasSideEffect;
441
483
  const isParenthesized = eslintUtils__namespace.isParenthesized;
442
484
 
443
- /**
444
- * Gets nested identifiers in a node
445
- * @param node The AST node
446
- * @returns The nested identifiers
447
- */ function getNestedIdentifiers(node) {
448
- const identifiers = [];
449
- if (node.type === NodeType.Identifier) {
450
- identifiers.push(node);
451
- }
452
- if ("arguments" in node) {
453
- node.arguments.forEach((x)=>{
454
- identifiers.push(...getNestedIdentifiers(x));
455
- });
456
- }
457
- if ("elements" in node) {
458
- node.elements.forEach((x)=>{
459
- if (x !== null) {
460
- identifiers.push(...getNestedIdentifiers(x));
461
- }
462
- });
463
- }
464
- if ("properties" in node) {
465
- node.properties.forEach((x)=>{
466
- identifiers.push(...getNestedIdentifiers(x));
467
- });
468
- }
469
- if ("expressions" in node) {
470
- node.expressions.forEach((x)=>{
471
- identifiers.push(...getNestedIdentifiers(x));
472
- });
473
- }
474
- if (node.type === NodeType.Property) {
475
- identifiers.push(...getNestedIdentifiers(node.value));
476
- }
477
- if (node.type === NodeType.SpreadElement) {
478
- identifiers.push(...getNestedIdentifiers(node.argument));
479
- }
480
- if (node.type === NodeType.MemberExpression) {
481
- identifiers.push(...getNestedIdentifiers(node.object));
482
- }
483
- if (node.type === NodeType.UnaryExpression) {
484
- identifiers.push(...getNestedIdentifiers(node.argument));
485
- }
486
- if (node.type === NodeType.ChainExpression) {
487
- identifiers.push(...getNestedIdentifiers(node.expression));
488
- }
489
- if (node.type === NodeType.TSNonNullExpression) {
490
- identifiers.push(...getNestedIdentifiers(node.expression));
491
- }
492
- return identifiers;
493
- }
494
-
495
- /**
496
- * Gets nested return statements in a node
497
- * @param node The AST node
498
- * @returns The nested return statements
499
- */ function getNestedReturnStatements(node) {
500
- const returnStatements = [];
501
- if (node.type === NodeType.ReturnStatement) {
502
- returnStatements.push(node);
503
- }
504
- if ("body" in node && !rambda.isNil(node.body)) {
505
- Array.isArray(node.body) ? node.body.forEach((x)=>{
506
- returnStatements.push(...getNestedReturnStatements(x));
507
- }) : returnStatements.push(...getNestedReturnStatements(node.body));
508
- }
509
- if ("consequent" in node) {
510
- Array.isArray(node.consequent) ? node.consequent.forEach((x)=>{
511
- returnStatements.push(...getNestedReturnStatements(x));
512
- }) : returnStatements.push(...getNestedReturnStatements(node.consequent));
513
- }
514
- if ("alternate" in node && node.alternate !== null) {
515
- Array.isArray(node.alternate) ? node.alternate.forEach((x)=>{
516
- returnStatements.push(...getNestedReturnStatements(x));
517
- }) : returnStatements.push(...getNestedReturnStatements(node.alternate));
518
- }
519
- if ("cases" in node) {
520
- node.cases.forEach((x)=>{
521
- returnStatements.push(...getNestedReturnStatements(x));
522
- });
523
- }
524
- if ("block" in node) {
525
- returnStatements.push(...getNestedReturnStatements(node.block));
526
- }
527
- if ("handler" in node && node.handler !== null) {
528
- returnStatements.push(...getNestedReturnStatements(node.handler));
529
- }
530
- if ("finalizer" in node && node.finalizer !== null) {
531
- returnStatements.push(...getNestedReturnStatements(node.finalizer));
532
- }
533
- if ("expression" in node && node.expression !== true && node.expression !== false) {
534
- returnStatements.push(...getNestedReturnStatements(node.expression));
535
- }
536
- if ("test" in node && node.test !== null) {
537
- returnStatements.push(...getNestedReturnStatements(node.test));
538
- }
539
- return returnStatements;
540
- }
541
-
542
485
  /**
543
486
  * Checks if the given node is a function expression or arrow function expression of a object method.
544
487
  * @param node The node to check.
@@ -637,30 +580,56 @@ const isParenthesized = eslintUtils__namespace.isParenthesized;
637
580
  }
638
581
  }, (x)=>x.parent.id).otherwise(()=>null);
639
582
  }
640
-
641
583
  /**
642
- * Determines whether node equals to another node
643
- * @param a node to compare
644
- * @param b node to compare
645
- * @returns `true` if node equal
646
- * @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
647
- */ function isNodeEqual(a, b) {
648
- if (a.type !== b.type) {
649
- return false;
584
+ * Gets nested identifiers in a node
585
+ * @param node The AST node
586
+ * @returns The nested identifiers
587
+ */ function getNestedIdentifiers(node) {
588
+ const identifiers = [];
589
+ if (node.type === NodeType.Identifier) {
590
+ identifiers.push(node);
650
591
  }
651
- if (a.type === NodeType.ThisExpression && b.type === NodeType.ThisExpression) {
652
- return true;
592
+ if ("arguments" in node) {
593
+ node.arguments.forEach((x)=>{
594
+ identifiers.push(...getNestedIdentifiers(x));
595
+ });
653
596
  }
654
- if (a.type === NodeType.Literal && b.type === NodeType.Literal) {
655
- return a.value === b.value;
597
+ if ("elements" in node) {
598
+ node.elements.forEach((x)=>{
599
+ if (x !== null) {
600
+ identifiers.push(...getNestedIdentifiers(x));
601
+ }
602
+ });
656
603
  }
657
- if (a.type === NodeType.Identifier && b.type === NodeType.Identifier) {
658
- return a.name === b.name;
604
+ if ("properties" in node) {
605
+ node.properties.forEach((x)=>{
606
+ identifiers.push(...getNestedIdentifiers(x));
607
+ });
659
608
  }
660
- if (a.type === NodeType.MemberExpression && b.type === NodeType.MemberExpression) {
661
- return isNodeEqual(a.property, b.property) && isNodeEqual(a.object, b.object);
609
+ if ("expressions" in node) {
610
+ node.expressions.forEach((x)=>{
611
+ identifiers.push(...getNestedIdentifiers(x));
612
+ });
662
613
  }
663
- return false;
614
+ if (node.type === NodeType.Property) {
615
+ identifiers.push(...getNestedIdentifiers(node.value));
616
+ }
617
+ if (node.type === NodeType.SpreadElement) {
618
+ identifiers.push(...getNestedIdentifiers(node.argument));
619
+ }
620
+ if (node.type === NodeType.MemberExpression) {
621
+ identifiers.push(...getNestedIdentifiers(node.object));
622
+ }
623
+ if (node.type === NodeType.UnaryExpression) {
624
+ identifiers.push(...getNestedIdentifiers(node.argument));
625
+ }
626
+ if (node.type === NodeType.ChainExpression) {
627
+ identifiers.push(...getNestedIdentifiers(node.expression));
628
+ }
629
+ if (node.type === NodeType.TSNonNullExpression) {
630
+ identifiers.push(...getNestedIdentifiers(node.expression));
631
+ }
632
+ return identifiers;
664
633
  }
665
634
 
666
635
  function isRegExpLiteral(node) {
@@ -743,20 +712,50 @@ function findPropertyWithIdentifierKey(properties, key) {
743
712
  }
744
713
 
745
714
  /**
746
- * Returns human readable node type for given AST node
747
- * @param node AST node
748
- * @returns Human readable node type
749
- */ function readableNodeType(node) {
750
- if (node.type === NodeType.Literal) {
751
- if ("regex" in node) {
752
- return "RegExp literal";
753
- }
754
- return `${rambda.type(node.value)} literal`;
715
+ * Gets nested return statements in a node
716
+ * @param node The AST node
717
+ * @returns The nested return statements
718
+ */ function getNestedReturnStatements(node) {
719
+ const returnStatements = [];
720
+ if (node.type === NodeType.ReturnStatement) {
721
+ returnStatements.push(node);
755
722
  }
756
- if (isJSX(node)) {
757
- return `JSX ${stringTs.toLowerCase(stringTs.delimiterCase(stringTs.replace(node.type, "JSX", ""), " "))}`;
723
+ if ("body" in node && !rambda.isNil(node.body)) {
724
+ Array.isArray(node.body) ? node.body.forEach((x)=>{
725
+ returnStatements.push(...getNestedReturnStatements(x));
726
+ }) : returnStatements.push(...getNestedReturnStatements(node.body));
758
727
  }
759
- return stringTs.toLowerCase(stringTs.delimiterCase(node.type, " "));
728
+ if ("consequent" in node) {
729
+ Array.isArray(node.consequent) ? node.consequent.forEach((x)=>{
730
+ returnStatements.push(...getNestedReturnStatements(x));
731
+ }) : returnStatements.push(...getNestedReturnStatements(node.consequent));
732
+ }
733
+ if ("alternate" in node && node.alternate !== null) {
734
+ Array.isArray(node.alternate) ? node.alternate.forEach((x)=>{
735
+ returnStatements.push(...getNestedReturnStatements(x));
736
+ }) : returnStatements.push(...getNestedReturnStatements(node.alternate));
737
+ }
738
+ if ("cases" in node) {
739
+ node.cases.forEach((x)=>{
740
+ returnStatements.push(...getNestedReturnStatements(x));
741
+ });
742
+ }
743
+ if ("block" in node) {
744
+ returnStatements.push(...getNestedReturnStatements(node.block));
745
+ }
746
+ if ("handler" in node && node.handler !== null) {
747
+ returnStatements.push(...getNestedReturnStatements(node.handler));
748
+ }
749
+ if ("finalizer" in node && node.finalizer !== null) {
750
+ returnStatements.push(...getNestedReturnStatements(node.finalizer));
751
+ }
752
+ if ("expression" in node && node.expression !== true && node.expression !== false) {
753
+ returnStatements.push(...getNestedReturnStatements(node.expression));
754
+ }
755
+ if ("test" in node && node.test !== null) {
756
+ returnStatements.push(...getNestedReturnStatements(node.test));
757
+ }
758
+ return returnStatements;
760
759
  }
761
760
 
762
761
  /**
@@ -816,24 +815,6 @@ function getExternalRefs(params) {
816
815
  return tools.uniqueBy(externalRefs, (x)=>x.text).map((x)=>x.variable);
817
816
  }
818
817
 
819
- /**
820
- * Get all unary operators in a nested unary expression.
821
- * @param node The node to get the operators from.
822
- * @returns All unary operators in a nested unary expression.
823
- */ function getNestedUnaryOperators(node) {
824
- const { operator } = node;
825
- const { argument } = node;
826
- if (argument.type === NodeType.UnaryExpression) {
827
- return [
828
- operator,
829
- ...getNestedUnaryOperators(argument)
830
- ];
831
- }
832
- return [
833
- operator
834
- ];
835
- }
836
-
837
818
  /**
838
819
  * Find a variable through a list of variables by name
839
820
  * @param name The name of the variable to find
@@ -901,7 +882,6 @@ exports.getFunctionIdentifier = getFunctionIdentifier;
901
882
  exports.getFunctionNameWithKind = getFunctionNameWithKind;
902
883
  exports.getNestedIdentifiers = getNestedIdentifiers;
903
884
  exports.getNestedReturnStatements = getNestedReturnStatements;
904
- exports.getNestedUnaryOperators = getNestedUnaryOperators;
905
885
  exports.getPropertyName = getPropertyName;
906
886
  exports.getStaticValue = getStaticValue;
907
887
  exports.getStringIfConstant = getStringIfConstant;