@typescript-eslint/typescript-estree 8.51.1-alpha.2 → 8.51.1-alpha.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.
@@ -53,7 +53,7 @@ function astConverter(ast, parseSettings, shouldPreserveNodeMaps) {
53
53
  * Optionally convert and include all comments in the AST
54
54
  */
55
55
  if (parseSettings.comment) {
56
- estree.comments = (0, convert_comments_1.convertComments)(ast, parseSettings.codeFullText);
56
+ estree.comments = (0, convert_comments_1.convertComments)(ast);
57
57
  }
58
58
  const astMaps = instance.getASTMaps();
59
59
  return { astMaps, estree };
@@ -3,8 +3,7 @@ import type { TSESTree } from './ts-estree';
3
3
  /**
4
4
  * Convert all comments for the given AST.
5
5
  * @param ast the AST object
6
- * @param code the TypeScript code
7
6
  * @returns the converted ESTreeComment
8
7
  * @private
9
8
  */
10
- export declare function convertComments(ast: ts.SourceFile, code: string): TSESTree.Comment[];
9
+ export declare function convertComments(ast: ts.SourceFile): TSESTree.Comment[];
@@ -41,31 +41,21 @@ const ts_estree_1 = require("./ts-estree");
41
41
  /**
42
42
  * Convert all comments for the given AST.
43
43
  * @param ast the AST object
44
- * @param code the TypeScript code
45
44
  * @returns the converted ESTreeComment
46
45
  * @private
47
46
  */
48
- function convertComments(ast, code) {
49
- const comments = [];
50
- tsutils.forEachComment(ast, (_, comment) => {
51
- const type = comment.kind === ts.SyntaxKind.SingleLineCommentTrivia
47
+ function convertComments(ast) {
48
+ return Array.from(tsutils.iterateComments(ast), ({ end, kind, pos, value }) => {
49
+ const type = kind === ts.SyntaxKind.SingleLineCommentTrivia
52
50
  ? ts_estree_1.AST_TOKEN_TYPES.Line
53
51
  : ts_estree_1.AST_TOKEN_TYPES.Block;
54
- const range = [comment.pos, comment.end];
52
+ const range = [pos, end];
55
53
  const loc = (0, node_utils_1.getLocFor)(range, ast);
56
- // both comments start with 2 characters - /* or //
57
- const textStart = range[0] + 2;
58
- const textEnd = comment.kind === ts.SyntaxKind.SingleLineCommentTrivia
59
- ? // single line comments end at the end
60
- range[1]
61
- : // multiline comments end 2 characters early
62
- range[1] - 2;
63
- comments.push({
54
+ return {
64
55
  type,
65
56
  loc,
66
57
  range,
67
- value: code.slice(textStart, textEnd),
68
- });
69
- }, ast);
70
- return comments;
58
+ value,
59
+ };
60
+ });
71
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/typescript-estree",
3
- "version": "8.51.1-alpha.2",
3
+ "version": "8.51.1-alpha.4",
4
4
  "description": "A parser that converts TypeScript source code into an ESTree compatible form",
5
5
  "files": [
6
6
  "dist",
@@ -52,15 +52,15 @@
52
52
  "typecheck": "yarn run -BT nx typecheck"
53
53
  },
54
54
  "dependencies": {
55
- "@typescript-eslint/project-service": "8.51.1-alpha.2",
56
- "@typescript-eslint/tsconfig-utils": "8.51.1-alpha.2",
57
- "@typescript-eslint/types": "8.51.1-alpha.2",
58
- "@typescript-eslint/visitor-keys": "8.51.1-alpha.2",
55
+ "@typescript-eslint/project-service": "8.51.1-alpha.4",
56
+ "@typescript-eslint/tsconfig-utils": "8.51.1-alpha.4",
57
+ "@typescript-eslint/types": "8.51.1-alpha.4",
58
+ "@typescript-eslint/visitor-keys": "8.51.1-alpha.4",
59
59
  "debug": "^4.3.4",
60
60
  "minimatch": "^9.0.4",
61
61
  "semver": "^7.6.0",
62
62
  "tinyglobby": "^0.2.15",
63
- "ts-api-utils": "^2.2.0"
63
+ "ts-api-utils": "^2.3.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@vitest/coverage-v8": "^3.1.3",