@kongyo2/ts-comment-scanner 1.9.0 → 1.11.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/remove.d.ts CHANGED
@@ -5,6 +5,13 @@ export interface RemoveOptions {
5
5
  removeDirectives?: boolean;
6
6
  /** Also remove license/legal comments. Default: false (kept for safety). */
7
7
  removeLegal?: boolean;
8
+ /**
9
+ * Extra protection: return true to keep a comment the way directives are
10
+ * kept, for markers only a project's own tooling reads (a build template's
11
+ * placeholder, a custom linter tag). Wins over removeDirectives and
12
+ * removeLegal; such comments are reported in `kept`.
13
+ */
14
+ keep?: (comment: Comment) => boolean;
8
15
  /** Extra predicate: return false to leave a comment out of the removal entirely. */
9
16
  shouldRemove?: (comment: Comment) => boolean;
10
17
  }
@@ -14,11 +21,13 @@ export interface RemoveResult {
14
21
  removed: Comment[];
15
22
  /**
16
23
  * Comments kept because they are protected: directives, license headers,
17
- * comments whose removal would shift code under a next-line directive or
18
- * that sit between a directive and the code it reaches past them for, and
19
- * comments whose removal would move a position-dependent directive
20
- * (prettier's first-comment pragma, Deno's coverage file pragma, Bun's
21
- * file-start marker) into effect.
24
+ * comments the `keep` predicate claims, comments that make a directive
25
+ * trailing rather than standalone (ast-grep's suppression), comments whose
26
+ * removal would shift code under a next-line directive or
27
+ * that sit between a directive and the code it reaches past them for (or
28
+ * the JSX sibling it applies to), and comments whose removal would move a
29
+ * position-dependent directive (prettier's first-comment pragma, Deno's
30
+ * coverage file pragma, Bun's file-start marker) into effect.
22
31
  */
23
32
  kept: Comment[];
24
33
  /** Comments excluded from removal by the `shouldRemove` predicate. */
@@ -39,6 +48,17 @@ export interface RemoveResult {
39
48
  * shebang line), the leading comment is kept instead.
40
49
  * - A space is inserted where removing a block comment would merge two tokens,
41
50
  * and a line break is kept where the comment acted as one (ASI stays intact).
51
+ * - A JSX comment goes with its braces (`{/* note *​/}`), unless that would
52
+ * change what the element renders: the braces split the text around them
53
+ * into separate strings, so where they stand between text that renders,
54
+ * `{" "}` takes their place when that keeps the strings identical, and
55
+ * otherwise the braces stay as `{}`. The output is re-parsed to prove every
56
+ * element renders the same strings, under the whitespace rules of
57
+ * TypeScript, esbuild and Babel alike.
58
+ * - Blank lines that only separated a removed comment from the code around it
59
+ * go with it: no pile-up of blank lines where a comment stood between two
60
+ * of them, and at the start or end of the file or of a block only the blank
61
+ * lines already against that edge stay.
42
62
  * - A leading byte-order mark is preserved. Reported positions index into the
43
63
  * `source` string exactly as `scanComments(source)` reports them (a BOM
44
64
  * counts as its first character).
@@ -1 +1 @@
1
- {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../src/remove.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,wFAAwF;IACxF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,4EAA4E;IAC5E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oFAAoF;IACpF,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;CAC9C;AAED,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB;;;;;;;OAOG;IACH,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,sEAAsE;IACtE,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,YAAY,CA6CxF"}
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../src/remove.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CA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