@kongyo2/ts-comment-scanner 1.11.1 → 1.15.0
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/astgrep.d.ts +51 -0
- package/dist/astgrep.d.ts.map +1 -0
- package/dist/astgrep.js +85 -0
- package/dist/astgrep.js.map +1 -0
- package/dist/directives.d.ts +32 -4
- package/dist/directives.d.ts.map +1 -1
- package/dist/directives.js +219 -90
- package/dist/directives.js.map +1 -1
- package/dist/remove.d.ts +9 -7
- package/dist/remove.d.ts.map +1 -1
- package/dist/remove.js +163 -80
- package/dist/remove.js.map +1 -1
- package/dist/scanner.d.ts +3 -11
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.js +73 -23
- package/dist/scanner.js.map +1 -1
- package/dist/splice.d.ts.map +1 -1
- package/dist/splice.js +19 -9
- package/dist/splice.js.map +1 -1
- package/package.json +1 -1
- package/src/astgrep.ts +115 -0
- package/src/directives.ts +252 -94
- package/src/remove.ts +205 -85
- package/src/scanner.ts +79 -24
- package/src/splice.ts +19 -9
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type Range } from "./ranges.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether a comment from `start` to `end` sits where an ast-grep suppression
|
|
4
|
+
* covers the whole file (0.38.4 on): it opens the first row, and the next
|
|
5
|
+
* node (code or another comment) starts two or more rows down, or nothing
|
|
6
|
+
* follows at all.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isFileWidePosition(text: string, start: number, end: number): boolean;
|
|
9
|
+
/** Start offset of every tree-sitter row: the text's start and each offset just past a line feed. */
|
|
10
|
+
export declare function rowStartOffsets(text: string): number[];
|
|
11
|
+
/** What stands in front of a comment in tree-sitter's tree, which ast-grep reads a suppression's reach from. */
|
|
12
|
+
export interface PrecedingNode {
|
|
13
|
+
/** Where the comment's previous sibling starts; absent when nothing precedes the comment. */
|
|
14
|
+
start?: number;
|
|
15
|
+
/** Where the last token in front of the comment ends, 0 when none does. */
|
|
16
|
+
tokenEnd: number;
|
|
17
|
+
}
|
|
18
|
+
/** What a surviving ast-grep suppression needs the removal to leave in place. */
|
|
19
|
+
export interface AstGrepReach {
|
|
20
|
+
/** Whether deleting the removal unit could change what the suppression covers. */
|
|
21
|
+
holds(unit: Range): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The rest of its row and the next row when some release suppresses that
|
|
24
|
+
* next row: the lines there have to stay, blank ones included.
|
|
25
|
+
*/
|
|
26
|
+
nextRow: Range | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* What an ast-grep suppression comment covers depends on the node in front
|
|
30
|
+
* of it (tree-sitter's previous sibling). From 0.44.0 the comment trails
|
|
31
|
+
* that node when the node ends on the comment's row, and then covers the
|
|
32
|
+
* matches starting on the row the node starts on; up to 0.43 it trails only
|
|
33
|
+
* a node starting on its row, and covers that row. Otherwise it covers the
|
|
34
|
+
* row after the one it starts on, which a comment spanning three rows fills
|
|
35
|
+
* itself. Opening the first row, with the next node two rows down or nothing
|
|
36
|
+
* after it, it covers the file.
|
|
37
|
+
*
|
|
38
|
+
* Every release has to read the same thing after the removal, so the
|
|
39
|
+
* removal must not swap the node in front of the comment (the units after
|
|
40
|
+
* the last token in front of it, on its row), nor join or split the rows a
|
|
41
|
+
* release keys the comment to. Units holding a line break join or split rows
|
|
42
|
+
* when deleted, so those ending on its row in front of it stay, as do those
|
|
43
|
+
* after it on its row and those touching the row its node starts on; when a
|
|
44
|
+
* release covers the next row, so do those starting there, and that row's
|
|
45
|
+
* lines stay (see nextRow). On the first row, the units after it on the row
|
|
46
|
+
* it ends on stay as well: the next node decides whether it covers the file.
|
|
47
|
+
* The releases this follows parse with tree-sitter 0.24 or later (ast-grep
|
|
48
|
+
* 0.31.1 on); before, comments in JSX braces read as standing alone.
|
|
49
|
+
*/
|
|
50
|
+
export declare function astGrepReach(text: string, rowStarts: readonly number[], comment: Range, preceding: PrecedingNode): AstGrepReach;
|
|
51
|
+
//# sourceMappingURL=astgrep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astgrep.d.ts","sourceRoot":"","sources":["../src/astgrep.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAkB9D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAIpF;AAMD,qGAAqG;AACrG,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAMtD;AAED,gHAAgH;AAChH,MAAM,WAAW,aAAa;IAC5B,6FAA6F;IAC7F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,iFAAiF;AACjF,MAAM,WAAW,YAAY;IAC3B,kFAAkF;IAClF,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC;IAC5B;;;OAGG;IACH,OAAO,EAAE,KAAK,GAAG,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,OAAO,EAAE,KAAK,EACd,SAAS,EAAE,aAAa,GACvB,YAAY,CAwBd"}
|
package/dist/astgrep.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { LINE_TERMINATOR } from "./lines.js";
|
|
2
|
+
import { firstIndexAtOrAfter } from "./ranges.js";
|
|
3
|
+
/**
|
|
4
|
+
* Where ast-grep's suppression comments apply (`get_suppression_kind` in its
|
|
5
|
+
* `crates/config/src/combined.rs`). ast-grep reads them off tree-sitter's
|
|
6
|
+
* syntax tree, so positions here are tree-sitter's: rows end at a line feed
|
|
7
|
+
* alone (a lone CR, U+2028 and U+2029 start no row), and whitespace is
|
|
8
|
+
* JavaScript's plus U+200B and U+2060 (tree-sitter-javascript's extras).
|
|
9
|
+
*/
|
|
10
|
+
const TREE_SITTER_BLANK = /^[\s\u200B\u2060]*$/;
|
|
11
|
+
const TREE_SITTER_CONTENT = /[^\s\u200B\u2060]/;
|
|
12
|
+
/** Whether only whitespace, and no line feed, precedes the offset: the start of tree-sitter's first row. */
|
|
13
|
+
function opensFirstRow(text, offset) {
|
|
14
|
+
const before = text.slice(0, offset);
|
|
15
|
+
return TREE_SITTER_BLANK.test(before) && !before.includes("\n");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether a comment from `start` to `end` sits where an ast-grep suppression
|
|
19
|
+
* covers the whole file (0.38.4 on): it opens the first row, and the next
|
|
20
|
+
* node (code or another comment) starts two or more rows down, or nothing
|
|
21
|
+
* follows at all.
|
|
22
|
+
*/
|
|
23
|
+
export function isFileWidePosition(text, start, end) {
|
|
24
|
+
if (!opensFirstRow(text, start))
|
|
25
|
+
return false;
|
|
26
|
+
const next = text.slice(end).search(TREE_SITTER_CONTENT);
|
|
27
|
+
return next === -1 || lineFeedCount(text.slice(0, end + next)) >= 2;
|
|
28
|
+
}
|
|
29
|
+
function lineFeedCount(text) {
|
|
30
|
+
return text.split("\n").length - 1;
|
|
31
|
+
}
|
|
32
|
+
/** Start offset of every tree-sitter row: the text's start and each offset just past a line feed. */
|
|
33
|
+
export function rowStartOffsets(text) {
|
|
34
|
+
const starts = [0];
|
|
35
|
+
for (let index = text.indexOf("\n"); index !== -1; index = text.indexOf("\n", index + 1)) {
|
|
36
|
+
starts.push(index + 1);
|
|
37
|
+
}
|
|
38
|
+
return starts;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* What an ast-grep suppression comment covers depends on the node in front
|
|
42
|
+
* of it (tree-sitter's previous sibling). From 0.44.0 the comment trails
|
|
43
|
+
* that node when the node ends on the comment's row, and then covers the
|
|
44
|
+
* matches starting on the row the node starts on; up to 0.43 it trails only
|
|
45
|
+
* a node starting on its row, and covers that row. Otherwise it covers the
|
|
46
|
+
* row after the one it starts on, which a comment spanning three rows fills
|
|
47
|
+
* itself. Opening the first row, with the next node two rows down or nothing
|
|
48
|
+
* after it, it covers the file.
|
|
49
|
+
*
|
|
50
|
+
* Every release has to read the same thing after the removal, so the
|
|
51
|
+
* removal must not swap the node in front of the comment (the units after
|
|
52
|
+
* the last token in front of it, on its row), nor join or split the rows a
|
|
53
|
+
* release keys the comment to. Units holding a line break join or split rows
|
|
54
|
+
* when deleted, so those ending on its row in front of it stay, as do those
|
|
55
|
+
* after it on its row and those touching the row its node starts on; when a
|
|
56
|
+
* release covers the next row, so do those starting there, and that row's
|
|
57
|
+
* lines stay (see nextRow). On the first row, the units after it on the row
|
|
58
|
+
* it ends on stay as well: the next node decides whether it covers the file.
|
|
59
|
+
* The releases this follows parse with tree-sitter 0.24 or later (ast-grep
|
|
60
|
+
* 0.31.1 on); before, comments in JSX braces read as standing alone.
|
|
61
|
+
*/
|
|
62
|
+
export function astGrepReach(text, rowStarts, comment, preceding) {
|
|
63
|
+
const rowOf = (offset) => firstIndexAtOrAfter(rowStarts, offset + 1, (start) => start) - 1;
|
|
64
|
+
const rowStart = (row) => rowStarts[row] ?? text.length;
|
|
65
|
+
const breaks = (unit) => LINE_TERMINATOR.test(text.slice(unit.start, unit.end));
|
|
66
|
+
const row = rowOf(comment.start);
|
|
67
|
+
const endRow = rowOf(comment.end - 1);
|
|
68
|
+
const ownRow = rowStart(row);
|
|
69
|
+
// With nothing in front of it on its row, no node in front ends there.
|
|
70
|
+
const trailing = TREE_SITTER_CONTENT.test(text.slice(ownRow, comment.start));
|
|
71
|
+
const precedingRow = trailing && preceding.start !== undefined ? rowOf(preceding.start) : undefined;
|
|
72
|
+
const coversNextRow = precedingRow !== row && endRow <= row + 1;
|
|
73
|
+
const breaking = [{ start: comment.end, end: rowStart(row + (coversNextRow ? 2 : 1)) }];
|
|
74
|
+
if (precedingRow !== undefined && precedingRow < row) {
|
|
75
|
+
breaking.push({ start: rowStart(precedingRow), end: rowStart(precedingRow + 1) });
|
|
76
|
+
}
|
|
77
|
+
const nextNode = endRow < 2 && opensFirstRow(text, comment.start) ? { start: comment.end, end: rowStart(endRow + 1) } : undefined;
|
|
78
|
+
return {
|
|
79
|
+
holds: (unit) => (unit.end > ownRow && unit.end <= comment.start && (unit.start >= preceding.tokenEnd || breaks(unit))) ||
|
|
80
|
+
(nextNode !== undefined && unit.start >= nextNode.start && unit.start < nextNode.end) ||
|
|
81
|
+
(breaking.some((span) => unit.start < span.end && unit.end >= span.start) && breaks(unit)),
|
|
82
|
+
nextRow: coversNextRow ? { start: comment.end, end: rowStart(row + 2) } : undefined,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=astgrep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astgrep.js","sourceRoot":"","sources":["../src/astgrep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAc,MAAM,aAAa,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAChD,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAEhD,4GAA4G;AAC5G,SAAS,aAAa,CAAC,IAAY,EAAE,MAAc;IACjD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACrC,OAAO,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,KAAa,EAAE,GAAW;IACzE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9C,MAAM,IAA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AE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACnH,OAAO;QACL,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CACd,CAAC,IAAI,CAAC,GAAG,GAAG,MAAM,IAAI,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,SAAS,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YACtG,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC;YACrF,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5F,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;KACpF,CAAC;AACJ,CAAC"}
|
package/dist/directives.d.ts
CHANGED
|
@@ -17,9 +17,10 @@ export interface DirectivePlacement {
|
|
|
17
17
|
fileStart: boolean;
|
|
18
18
|
/**
|
|
19
19
|
* The comment sits where ast-grep's suppression comment applies to the
|
|
20
|
-
* whole file: it
|
|
21
|
-
* it) and whatever follows it starts two or more
|
|
22
|
-
* nothing does. Left out, the comment is
|
|
20
|
+
* whole file: it opens tree-sitter's first row (nothing but whitespace
|
|
21
|
+
* before it) and whatever follows it starts two or more rows further down,
|
|
22
|
+
* or nothing does (see isFileWidePosition). Left out, the comment is
|
|
23
|
+
* assumed not to.
|
|
23
24
|
*/
|
|
24
25
|
fileWide?: boolean;
|
|
25
26
|
/**
|
|
@@ -37,6 +38,24 @@ export interface DirectivePlacement {
|
|
|
37
38
|
* (oxlint). Left out, nextToken decides.
|
|
38
39
|
*/
|
|
39
40
|
noDefaultSlot?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The comment sits inside a block that holds no statements — a function
|
|
43
|
+
* body, a class static block, any other `{}` block — or inside a `switch`
|
|
44
|
+
* with no clauses. The linters' empty-block rules count any comment there as
|
|
45
|
+
* the block's content and leave the block unreported (see EMPTY_BLOCK). In
|
|
46
|
+
* an empty class static block, the stretch between `static` and the opening
|
|
47
|
+
* brace counts too: oxlint's no-empty-static-block reads its comments from
|
|
48
|
+
* the keyword on. Left out, the comment is assumed not to.
|
|
49
|
+
*/
|
|
50
|
+
emptyBlock?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The file holds no code: nothing but empty statements, blocks holding only
|
|
53
|
+
* those, and a directive prologue (`"use strict";`). The no-empty-file
|
|
54
|
+
* rules of oxlint and eslint-plugin-unicorn report such a file unless one
|
|
55
|
+
* of its line comments opens with `///` (see EMPTY_FILE). Left out, the
|
|
56
|
+
* file is assumed to hold code.
|
|
57
|
+
*/
|
|
58
|
+
emptyFile?: boolean;
|
|
40
59
|
/**
|
|
41
60
|
* The token that follows the comment past any further comments (`case`,
|
|
42
61
|
* `}`, an identifier, ...), or `""` when only comments follow: a coarser
|
|
@@ -61,9 +80,18 @@ export declare function bunMarkerOffset(text: string): number;
|
|
|
61
80
|
* honours in certain positions (header pragmas, prettier's docblock pragma,
|
|
62
81
|
* `// @bun`) are skipped elsewhere — and the remaining rules still run, so a
|
|
63
82
|
* live directive later in the same comment (`// deno-lint-ignore-file
|
|
64
|
-
* nosemgrep` in mid-file) is not masked by a positionally dead one.
|
|
83
|
+
* nosemgrep` in mid-file) is not masked by a positionally dead one. A comment
|
|
84
|
+
* no rule names is still `empty-block` where the placement puts it inside an
|
|
85
|
+
* empty block, and a `///` line comment `empty-file` in a file that holds no
|
|
86
|
+
* code.
|
|
65
87
|
*/
|
|
66
88
|
export declare function detectDirective(kind: CommentKind, text: string, placement?: DirectivePlacement): string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Whether some ast-grep release reads the comment as a suppression. A
|
|
91
|
+
* comment named for another directive can carry one too (`// @ts-ignore
|
|
92
|
+
* ast-grep-ignore`), so the removal asks this rather than the name.
|
|
93
|
+
*/
|
|
94
|
+
export declare function carriesAstGrepSuppression(text: string): boolean;
|
|
67
95
|
/**
|
|
68
96
|
* The position-dependent directives (prettier's first-comment pragmas, Jest's
|
|
69
97
|
* docblock pragmas, Deno's coverage file pragma, Bun's file-start marker,
|
package/dist/directives.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../src/directives.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../src/directives.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAyqB9C;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,MAAM,EAAE,OAAO,CAAC;IAChB,2FAA2F;IAC3F,YAAY,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA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