@eslint-react/ast 2.12.4-next.0 → 2.12.4-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 +10 -30
- package/dist/index.js +30 -49
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -183,22 +183,6 @@ declare const getNestedCallExpressions: (node: TSESTree.Node) => TSESTree.CallEx
|
|
|
183
183
|
*/
|
|
184
184
|
declare function getFileDirectives(node: TSESTree.Program): TSESTreeDirective[];
|
|
185
185
|
//#endregion
|
|
186
|
-
//#region src/format.d.ts
|
|
187
|
-
/**
|
|
188
|
-
* Convert a node type to a delimiter format string
|
|
189
|
-
* @param node The AST node
|
|
190
|
-
* @param delimiter The delimiter to use
|
|
191
|
-
* @returns The delimiter format string
|
|
192
|
-
*/
|
|
193
|
-
declare function toDelimiterFormat(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
|
|
194
|
-
/**
|
|
195
|
-
* Incomplete but sufficient stringification of AST nodes for common use cases
|
|
196
|
-
* @param node The AST node
|
|
197
|
-
* @param getText A function to get the text representation of a node
|
|
198
|
-
* @returns A string representation of the node
|
|
199
|
-
*/
|
|
200
|
-
declare function toStringFormat(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
|
|
201
|
-
//#endregion
|
|
202
186
|
//#region src/function-directive.d.ts
|
|
203
187
|
/**
|
|
204
188
|
* Get all directive expression statements from the top of a function AST node
|
|
@@ -378,6 +362,13 @@ declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node
|
|
|
378
362
|
*/
|
|
379
363
|
declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
380
364
|
//#endregion
|
|
365
|
+
//#region src/kind.d.ts
|
|
366
|
+
declare function getHumanReadableKind(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/line.d.ts
|
|
369
|
+
declare function isMultiLine(node: TSESTree.Node): boolean;
|
|
370
|
+
declare function isLineBreak(node: TSESTree.Node): boolean;
|
|
371
|
+
//#endregion
|
|
381
372
|
//#region src/literal.d.ts
|
|
382
373
|
/**
|
|
383
374
|
* Check if a node is a literal value
|
|
@@ -391,19 +382,8 @@ declare function isLiteral(node: TSESTree.Node, type: "number"): node is TSESTre
|
|
|
391
382
|
declare function isLiteral(node: TSESTree.Node, type: "regexp"): node is TSESTree.RegExpLiteral;
|
|
392
383
|
declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTree.StringLiteral;
|
|
393
384
|
//#endregion
|
|
394
|
-
//#region src/
|
|
395
|
-
|
|
396
|
-
* Check if a node spans multiple lines
|
|
397
|
-
* @param node The AST node to check
|
|
398
|
-
* @returns `true` if the node spans multiple lines, `false` otherwise
|
|
399
|
-
*/
|
|
400
|
-
declare function isMultiLine(node: TSESTree.Node): boolean;
|
|
401
|
-
/**
|
|
402
|
-
* Check if a node is a line break (whitespace spanning multiple lines)
|
|
403
|
-
* @param node The AST node to check
|
|
404
|
-
* @returns `true` if the node is a line break, `false` otherwise
|
|
405
|
-
*/
|
|
406
|
-
declare function isLineBreak(node: TSESTree.Node): boolean;
|
|
385
|
+
//#region src/name.d.ts
|
|
386
|
+
declare function getFullyQualifiedName(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
|
|
407
387
|
//#endregion
|
|
408
388
|
//#region src/process-env-node-env.d.ts
|
|
409
389
|
/**
|
|
@@ -502,4 +482,4 @@ declare function isViMock(node: TSESTree.Node | null | unit): node is TSESTree.M
|
|
|
502
482
|
*/
|
|
503
483
|
declare function isViMockCallback(node: TSESTree.Node | null | unit): boolean;
|
|
504
484
|
//#endregion
|
|
505
|
-
export { DirectiveKind, DisplayNameAssignmentExpression, FunctionID, FunctionInitPath, ImplicitReturnArrowFunctionExpression, ObjectDestructuringVariableDeclarator, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeDirective, TSESTreeDirectiveLike, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParentNode, getClassId, getFileDirectives, getFunctionDirectives, getFunctionId, getFunctionInitPath, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback
|
|
485
|
+
export { DirectiveKind, DisplayNameAssignmentExpression, FunctionID, FunctionInitPath, ImplicitReturnArrowFunctionExpression, ObjectDestructuringVariableDeclarator, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeDirective, TSESTreeDirectiveLike, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParentNode, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback };
|
package/dist/index.js
CHANGED
|
@@ -504,43 +504,6 @@ function getFileDirectives(node) {
|
|
|
504
504
|
return directives;
|
|
505
505
|
}
|
|
506
506
|
|
|
507
|
-
//#endregion
|
|
508
|
-
//#region src/format.ts
|
|
509
|
-
/**
|
|
510
|
-
* Convert a node type to a delimiter format string
|
|
511
|
-
* @param node The AST node
|
|
512
|
-
* @param delimiter The delimiter to use
|
|
513
|
-
* @returns The delimiter format string
|
|
514
|
-
*/
|
|
515
|
-
function toDelimiterFormat(node, delimiter = " ") {
|
|
516
|
-
if (node.type === AST_NODE_TYPES.Literal) {
|
|
517
|
-
if ("regex" in node) return "RegExp literal";
|
|
518
|
-
if (node.value === null) return "null literal";
|
|
519
|
-
return `${typeof node.value} literal`;
|
|
520
|
-
}
|
|
521
|
-
if (isJSX(node)) return `JSX ${toLowerCase(delimiterCase(replace(node.type, "JSX", ""), delimiter))}`;
|
|
522
|
-
return toLowerCase(delimiterCase(node.type, delimiter));
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Incomplete but sufficient stringification of AST nodes for common use cases
|
|
526
|
-
* @param node The AST node
|
|
527
|
-
* @param getText A function to get the text representation of a node
|
|
528
|
-
* @returns A string representation of the node
|
|
529
|
-
*/
|
|
530
|
-
function toStringFormat(node, getText) {
|
|
531
|
-
switch (node.type) {
|
|
532
|
-
case AST_NODE_TYPES.Identifier:
|
|
533
|
-
case AST_NODE_TYPES.JSXIdentifier:
|
|
534
|
-
case AST_NODE_TYPES.PrivateIdentifier: return node.name;
|
|
535
|
-
case AST_NODE_TYPES.MemberExpression:
|
|
536
|
-
case AST_NODE_TYPES.JSXMemberExpression: return `${toStringFormat(node.object, getText)}.${toStringFormat(node.property, getText)}`;
|
|
537
|
-
case AST_NODE_TYPES.JSXNamespacedName: return `${node.namespace.name}:${node.name.name}`;
|
|
538
|
-
case AST_NODE_TYPES.JSXText: return node.value;
|
|
539
|
-
case AST_NODE_TYPES.Literal: return node.raw;
|
|
540
|
-
default: return getText(node);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
507
|
//#endregion
|
|
545
508
|
//#region src/function-directive.ts
|
|
546
509
|
/**
|
|
@@ -694,24 +657,42 @@ function isIdentifierName(name) {
|
|
|
694
657
|
}
|
|
695
658
|
|
|
696
659
|
//#endregion
|
|
697
|
-
//#region src/
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
660
|
+
//#region src/kind.ts
|
|
661
|
+
function getHumanReadableKind(node, delimiter = " ") {
|
|
662
|
+
if (node.type === AST_NODE_TYPES.Literal) {
|
|
663
|
+
if ("regex" in node) return "RegExp literal";
|
|
664
|
+
if (node.value === null) return "null literal";
|
|
665
|
+
return `${typeof node.value} literal`;
|
|
666
|
+
}
|
|
667
|
+
if (isJSX(node)) return `JSX ${toLowerCase(delimiterCase(replace(node.type, "JSX", ""), delimiter))}`;
|
|
668
|
+
return toLowerCase(delimiterCase(node.type, delimiter));
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region src/line.ts
|
|
703
673
|
function isMultiLine(node) {
|
|
704
674
|
return node.loc.start.line !== node.loc.end.line;
|
|
705
675
|
}
|
|
706
|
-
/**
|
|
707
|
-
* Check if a node is a line break (whitespace spanning multiple lines)
|
|
708
|
-
* @param node The AST node to check
|
|
709
|
-
* @returns `true` if the node is a line break, `false` otherwise
|
|
710
|
-
*/
|
|
711
676
|
function isLineBreak(node) {
|
|
712
677
|
return isOneOf([AST_NODE_TYPES.Literal, AST_NODE_TYPES.JSXText])(node) && typeof node.value === "string" && node.value.trim() === "" && isMultiLine(node);
|
|
713
678
|
}
|
|
714
679
|
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/name.ts
|
|
682
|
+
function getFullyQualifiedName(node, getText) {
|
|
683
|
+
switch (node.type) {
|
|
684
|
+
case AST_NODE_TYPES.Identifier:
|
|
685
|
+
case AST_NODE_TYPES.JSXIdentifier:
|
|
686
|
+
case AST_NODE_TYPES.PrivateIdentifier: return node.name;
|
|
687
|
+
case AST_NODE_TYPES.MemberExpression:
|
|
688
|
+
case AST_NODE_TYPES.JSXMemberExpression: return `${getFullyQualifiedName(node.object, getText)}.${getFullyQualifiedName(node.property, getText)}`;
|
|
689
|
+
case AST_NODE_TYPES.JSXNamespacedName: return `${node.namespace.name}:${node.name.name}`;
|
|
690
|
+
case AST_NODE_TYPES.JSXText: return node.value;
|
|
691
|
+
case AST_NODE_TYPES.Literal: return node.raw;
|
|
692
|
+
default: return getText(node);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
715
696
|
//#endregion
|
|
716
697
|
//#region src/process-env-node-env.ts
|
|
717
698
|
/**
|
|
@@ -800,4 +781,4 @@ function isViMockCallback(node) {
|
|
|
800
781
|
}
|
|
801
782
|
|
|
802
783
|
//#endregion
|
|
803
|
-
export { SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, findParentNode, getClassId, getFileDirectives, getFunctionDirectives, getFunctionId, getFunctionInitPath, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback
|
|
784
|
+
export { SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, findParentNode, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "2.12.4-next.
|
|
3
|
+
"version": "2.12.4-next.2",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@typescript-eslint/typescript-estree": "^8.54.0",
|
|
35
35
|
"@typescript-eslint/utils": "^8.54.0",
|
|
36
36
|
"string-ts": "^2.3.1",
|
|
37
|
-
"@eslint-react/eff": "2.12.4-next.
|
|
37
|
+
"@eslint-react/eff": "2.12.4-next.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"tsdown": "^0.20.3",
|