@kongyo2/ts-comment-scanner 1.4.0 → 1.6.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/run.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAuC,MAAM,WAAW,CAAC;AACvF,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,gBAAgB,GAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ1C,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CxB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAc,EAAE,EAAS;IACjD,+DAA+D;IAC/D,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAClB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,OAAmB,CAAC;IACxB,IAAI,CAAC;QACH,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC5B,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AG,IAAI,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClE,KAAK,CAAC,IAAI,CACR,EAAE,EACF,GAAG,YAAY,IAAI,KAAK,CAAC,YAAY,EAAE,SAAS,CAAC,WAAW,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,QAAQ,GAAG,WAAW,EAAE,CAC7H,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kongyo2/ts-comment-scanner",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "CLI to detect, report and safely remove comments across a TypeScript project.",
5
5
  "keywords": [
6
6
  "typescript",
package/src/args.ts CHANGED
@@ -81,9 +81,12 @@ export function parseArgs(argv: string[]): CliOptions {
81
81
  rejectValue();
82
82
  format = "json";
83
83
  break;
84
- case "--ignore":
85
- ignore.push(readValue());
84
+ case "--ignore": {
85
+ const value = readValue();
86
+ if (value === "") throw new UsageError("option --ignore requires a glob pattern");
87
+ ignore.push(value);
86
88
  break;
89
+ }
87
90
  case "--ext": {
88
91
  const parsed = readValue()
89
92
  .split(",")
package/src/directives.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { lastLine, splitLines } from "./lines.js";
1
2
  import type { CommentKind } from "./types.js";
2
3
 
3
4
  interface DirectiveRule {
@@ -307,7 +308,26 @@ const RULES: DirectiveRule[] = [
307
308
  { pattern: /^#(?:region|endregion)\b/ },
308
309
  ];
309
310
 
310
- const TRIPLE_SLASH = /^\/\/\/\s*<(reference|amd-dependency|amd-module)\b/;
311
+ // Mirrors tsc's tripleSlashXMLCommentStartRegEx: the directive name (matched
312
+ // case-insensitively) must be followed by whitespace and the tag has to close
313
+ // with `/>` — `/// <reference>` and `/// <reference types="node">` are plain
314
+ // comments to the compiler. The AMD directives additionally need their
315
+ // mandatory quoted argument, or tsc drops the pragma altogether.
316
+ const TRIPLE_SLASH = /^\/\/\/\s*<(reference|amd-dependency|amd-module)\s.*?\/>/i;
317
+ const TRIPLE_SLASH_REQUIRED_ARGUMENT: Readonly<Record<string, RegExp>> = {
318
+ "amd-dependency": /\spath\s*=\s*(?:'[^']*'|"[^"]*")/i,
319
+ "amd-module": /\sname\s*=\s*(?:'[^']*'|"[^"]*")/i,
320
+ };
321
+
322
+ /** The canonical triple-slash directive name the line comment carries, if tsc would honour it. */
323
+ function tripleSlashDirective(text: string): string | undefined {
324
+ const match = TRIPLE_SLASH.exec(text);
325
+ if (!match) return undefined;
326
+ const name = (match[1] as string).toLowerCase();
327
+ const requiredArgument = TRIPLE_SLASH_REQUIRED_ARGUMENT[name];
328
+ if (requiredArgument !== undefined && !requiredArgument.test(text)) return undefined;
329
+ return `triple-slash-${name}`;
330
+ }
311
331
 
312
332
  /**
313
333
  * Where a comment sits in its file, for directives that are only honoured in
@@ -373,10 +393,12 @@ function isActiveAt(name: string, placement: DirectivePlacement): boolean {
373
393
 
374
394
  // Mirrors the TypeScript compiler's own comment-directive matching, verified
375
395
  // against tsc: the suppression directives are case-sensitive PREFIX matches
376
- // (`@ts-ignoreTODO` is active), while the file-wide check pragmas are
377
- // case-insensitive and must end at a word boundary (`@ts-nocheckfoo` is not).
396
+ // (`@ts-ignoreTODO` is active), while the file-wide check pragmas go through
397
+ // the case-insensitive pragma parser, whose name runs up to the next
398
+ // whitespace or colon (`@ts-nocheck:reason` is active, `@ts-nocheckfoo` and
399
+ // `@ts-nocheck-foo` are not).
378
400
  const TS_LINE_SUPPRESSION = /^\/\/\/?\s*@ts-(ignore|expect-error)/;
379
- const TS_LINE_CHECK_PRAGMA = /^\/\/\/?\s*@ts-(nocheck|check)\b/i;
401
+ const TS_LINE_CHECK_PRAGMA = /^\/\/\/?\s*@ts-(nocheck|check)(?=[^\S\r\n]|:|$)/i;
380
402
  // Block comments: only the suppression directives, and only on the comment's
381
403
  // literal last line (`*/` included), even when that line is otherwise blank.
382
404
  // tsc trims the line and then allows one run of `/`/`*` characters before the
@@ -396,11 +418,8 @@ const TS_BLOCK_SUPPRESSION = /^\s*[/*]*\s*@ts-(ignore|expect-error)/;
396
418
  export function detectDirective(kind: CommentKind, text: string, placement?: DirectivePlacement): string | undefined {
397
419
  const at = placement ?? ANY_PLACEMENT;
398
420
  if (kind === "line") {
399
- const tripleSlash = TRIPLE_SLASH.exec(text);
400
- if (tripleSlash) {
401
- const name = `triple-slash-${tripleSlash[1]}`;
402
- if (isActiveAt(name, at)) return name;
403
- }
421
+ const tripleSlash = tripleSlashDirective(text);
422
+ if (tripleSlash !== undefined && isActiveAt(tripleSlash, at)) return tripleSlash;
404
423
  const suppression = TS_LINE_SUPPRESSION.exec(text);
405
424
  if (suppression) {
406
425
  return `@ts-${suppression[1]}`;
@@ -417,6 +436,14 @@ export function detectDirective(kind: CommentKind, text: string, placement?: Dir
417
436
  }
418
437
  }
419
438
 
439
+ for (const name of ruleMatches(kind, text)) {
440
+ if (isActiveAt(name, at)) return name;
441
+ }
442
+ return undefined;
443
+ }
444
+
445
+ /** Directive names of every rule the comment matches, in rule order. */
446
+ function* ruleMatches(kind: CommentKind, text: string): Generator<string> {
420
447
  const lines = contentLines(kind, text, false);
421
448
  const literalLines = kind === "block" ? contentLines(kind, text, true) : lines;
422
449
  for (const rule of RULES) {
@@ -435,12 +462,28 @@ export function detectDirective(kind: CommentKind, text: string, placement?: Dir
435
462
  for (const line of candidates) {
436
463
  const match = rule.pattern.exec(line);
437
464
  if (!match) continue;
438
- const name =
439
- typeof rule.name === "string" ? rule.name : typeof rule.name === "function" ? rule.name(match) : match[0];
440
- if (isActiveAt(name, at)) return name;
465
+ yield typeof rule.name === "string" ? rule.name : typeof rule.name === "function" ? rule.name(match) : match[0];
441
466
  }
442
467
  }
443
- return undefined;
468
+ }
469
+
470
+ /**
471
+ * The position-dependent directives (prettier's first-comment pragmas, Bun's
472
+ * file-start marker) the comment carries that are active at the given
473
+ * placement, sorted. Unlike detectDirective — which reports one canonical
474
+ * name — this sees through masking: an eslint config block can also hold a
475
+ * `@format` pragma, and whether that pragma is live must not hide behind the
476
+ * name an earlier rule already claimed. Only first-comment and file-start
477
+ * gates are consulted; header-gated directives cannot change activation when
478
+ * the comments around them change.
479
+ */
480
+ export function activePositionalDirectives(kind: CommentKind, text: string, placement: DirectivePlacement): string[] {
481
+ const names = new Set<string>();
482
+ for (const name of ruleMatches(kind, text)) {
483
+ if (!FIRST_COMMENT_ONLY_DIRECTIVES.has(name) && !FILE_START_ONLY_DIRECTIVES.has(name)) continue;
484
+ if (isActiveAt(name, placement)) names.add(name);
485
+ }
486
+ return [...names].sort();
444
487
  }
445
488
 
446
489
  /**
@@ -455,10 +498,6 @@ export function isLegalComment(text: string): boolean {
455
498
  return /@(?:license|preserve|copyright)\b/i.test(text);
456
499
  }
457
500
 
458
- // Every ECMAScript line terminator, the way the scanner breaks lines: CRLF as
459
- // one break, plus lone LF / CR and the U+2028/U+2029 separators.
460
- const LINE_BREAK = /\r\n|[\n\r\u2028\u2029]/;
461
-
462
501
  /**
463
502
  * Non-empty content lines of the comment, with comment markers stripped.
464
503
  * For line comments only the `//` marker itself is removed: extra slashes or
@@ -478,15 +517,9 @@ function contentLines(kind: CommentKind, text: string, keepStars: boolean): stri
478
517
  ? text.replace(/^\/\*/, "").replace(/\*\/\s*$/, "")
479
518
  : text.replace(/^\/\*+/, "").replace(/\*+\/\s*$/, "");
480
519
  const lines: string[] = [];
481
- for (const line of inner.split(LINE_BREAK)) {
520
+ for (const line of splitLines(inner)) {
482
521
  const stripped = (kind === "block" && !keepStars ? line.replace(/^\s*\*+\s*/, "") : line).trim();
483
522
  if (stripped !== "") lines.push(stripped);
484
523
  }
485
524
  return lines;
486
525
  }
487
-
488
- /** Literal last line of the comment, closing marker included, exactly as tsc slices it. */
489
- function lastLine(text: string): string {
490
- const lines = text.split(LINE_BREAK);
491
- return lines[lines.length - 1] as string;
492
- }
package/src/files.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import type { Stats } from "node:fs";
2
+ import type { Dirent, Stats } from "node:fs";
3
3
  import { chmod, open, readFile, readdir, realpath, rename, rm, stat } from "node:fs/promises";
4
4
  import { basename, dirname, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
5
5
  import picomatch from "picomatch";
@@ -12,33 +12,43 @@ const DEFAULT_IGNORE_DIRS = ["node_modules", ".git"];
12
12
  export interface CollectOptions {
13
13
  /** File extensions to include (with or without a leading dot, case-insensitive). */
14
14
  extensions?: string[];
15
- /** Directory names that are never traversed. Default: node_modules, .git */
15
+ /**
16
+ * Directory names that are never traversed, input directories included
17
+ * (case-insensitively on Windows). Default: node_modules, .git
18
+ */
16
19
  ignoreDirs?: string[];
17
20
  /**
18
21
  * Glob patterns for files and directories to skip (picomatch syntax).
19
- * Patterns without a slash match against base names, e.g. `*.test.ts`.
20
- * Explicitly listed input files bypass these patterns.
22
+ * Patterns without a slash match against base names, e.g. `*.test.ts`;
23
+ * a trailing slash restricts a pattern to directories, e.g. `dist/`, like
24
+ * in .gitignore. Explicitly listed input files bypass these patterns.
21
25
  */
22
26
  ignore?: string[];
23
27
  }
24
28
 
25
- type IgnoreMatcher = (path: string, root: string) => boolean;
29
+ /** Whether the path (a directory when `isDirectory`) is excluded by the ignore patterns. */
30
+ type IgnoreMatcher = (path: string, root: string, isDirectory: boolean) => boolean;
26
31
 
27
32
  export async function collectFiles(inputs: string[], options: CollectOptions = {}): Promise<string[]> {
28
33
  const extensions = normalizeExtensions(options.extensions ?? DEFAULT_EXTENSIONS);
29
- const ignoreDirs = new Set(options.ignoreDirs ?? DEFAULT_IGNORE_DIRS);
34
+ const ignoreDirs = new Set((options.ignoreDirs ?? DEFAULT_IGNORE_DIRS).map(foldPathCase));
30
35
  const isIgnored = buildIgnoreMatcher(options.ignore ?? []);
31
- // Keyed by the resolved path so different spellings of one file (relative vs
32
- // absolute, `.` segments, case on Windows) collapse into a single entry; the
33
- // first spelling seen is the one reported.
36
+ // Keyed by the real path so different spellings of one file (relative vs
37
+ // absolute, `.` segments, case on Windows, symlink aliases) collapse into a
38
+ // single entry; the first spelling seen is the one reported.
34
39
  const found = new Map<string, string>();
35
- const remember = (path: string): void => {
36
- const key = canonicalKey(path);
40
+ const remember = (path: string, realPath: string): void => {
41
+ const key = canonicalKey(realPath);
37
42
  if (!found.has(key)) found.set(key, path);
38
43
  };
39
44
 
45
+ // Walks remember their discoveries mid-traversal; explicitly listed files
46
+ // are resolved concurrently but remembered afterwards in input order, so
47
+ // which spelling of an aliased file gets reported never depends on
48
+ // filesystem timing.
49
+ const explicitFiles = new Array<{ path: string; real: string } | undefined>(inputs.length);
40
50
  await Promise.all(
41
- inputs.map(async (rawInput) => {
51
+ inputs.map(async (rawInput, index) => {
42
52
  if (rawInput === "") {
43
53
  // normalize("") would resolve to "." and silently widen the scan.
44
54
  throw new Error("empty path is not a valid input");
@@ -46,30 +56,51 @@ export async function collectFiles(inputs: string[], options: CollectOptions = {
46
56
  const input = normalize(rawInput);
47
57
  const info = await statInput(input);
48
58
  if (info.isDirectory()) {
49
- // Directory inputs are themselves subject to the ignore patterns;
50
- // only explicitly listed files bypass them.
51
- if (!isIgnored(input, input)) {
59
+ // Directory inputs are themselves subject to the ignored directory
60
+ // names and the ignore patterns; only explicitly listed files bypass
61
+ // them.
62
+ if (!ignoreDirs.has(foldPathCase(basename(input))) && !isIgnored(input, input, true)) {
52
63
  await walk(input, { extensions, ignoreDirs, isIgnored, root: input, visited: new Set() }, remember);
53
64
  }
54
65
  } else {
55
- remember(input);
66
+ explicitFiles[index] = { path: input, real: await realpathInput(input) };
56
67
  }
57
68
  }),
58
69
  );
70
+ for (const file of explicitFiles) {
71
+ if (file !== undefined) remember(file.path, file.real);
72
+ }
59
73
 
60
74
  return [...found.values()].sort();
61
75
  }
62
76
 
77
+ /** Identity key of a file: its absolute path, case-folded where the platform compares paths that way. */
63
78
  function canonicalKey(path: string): string {
64
- const resolved = resolve(path);
65
- // Windows paths are case-insensitive; a case-folded key keeps `Foo.ts` and
66
- // `foo.ts` from being treated as two files.
67
- return process.platform === "win32" ? resolved.toLowerCase() : resolved;
79
+ return foldPathCase(resolve(path));
80
+ }
81
+
82
+ /**
83
+ * Folds a path or name the way the platform compares it: Windows paths are
84
+ * case-insensitive (`Foo.ts` and `foo.ts` are one file), everywhere else the
85
+ * spelling is exact.
86
+ */
87
+ export function foldPathCase(path: string): string {
88
+ return process.platform === "win32" ? path.toLowerCase() : path;
68
89
  }
69
90
 
70
91
  async function statInput(input: string): Promise<Stats> {
92
+ return withFriendlyNotFound(input, () => stat(input));
93
+ }
94
+
95
+ /** Real path of an explicit input, with the same friendly error statInput gives. */
96
+ async function realpathInput(input: string): Promise<string> {
97
+ return withFriendlyNotFound(input, () => realpath(input));
98
+ }
99
+
100
+ /** Runs the lookup, reporting a missing path under the name the user spelled it with. */
101
+ async function withFriendlyNotFound<T>(input: string, lookup: () => Promise<T>): Promise<T> {
71
102
  try {
72
- return await stat(input);
103
+ return await lookup();
73
104
  } catch (error) {
74
105
  if ((error as NodeJS.ErrnoException).code === "ENOENT") {
75
106
  throw new Error(`path not found: ${input}`, { cause: error });
@@ -78,6 +109,17 @@ async function statInput(input: string): Promise<Stats> {
78
109
  }
79
110
  }
80
111
 
112
+ /**
113
+ * True for the errors a walk may step over: entries that vanished mid-walk
114
+ * (ENOENT, ENOTDIR after a directory was replaced) and symlinks that do not
115
+ * resolve (broken targets, ELOOP cycles). Anything else — permissions, I/O
116
+ * failures — propagates, so a partial scan cannot masquerade as a clean one.
117
+ */
118
+ function isSkippableWalkError(error: unknown): boolean {
119
+ const code = (error as NodeJS.ErrnoException).code;
120
+ return code === "ENOENT" || code === "ENOTDIR" || code === "ELOOP";
121
+ }
122
+
81
123
  interface WalkContext {
82
124
  extensions: string[];
83
125
  ignoreDirs: Set<string>;
@@ -88,17 +130,28 @@ interface WalkContext {
88
130
  visited: Set<string>;
89
131
  }
90
132
 
91
- async function walk(dir: string, context: WalkContext, remember: (path: string) => void): Promise<void> {
133
+ async function walk(
134
+ dir: string,
135
+ context: WalkContext,
136
+ remember: (path: string, realPath: string) => void,
137
+ ): Promise<void> {
92
138
  let real: string;
93
139
  try {
94
140
  real = await realpath(dir);
95
- } catch {
96
- return; // the directory vanished mid-walk
141
+ } catch (error) {
142
+ if (isSkippableWalkError(error)) return; // the directory vanished mid-walk
143
+ throw error;
97
144
  }
98
145
  if (context.visited.has(real)) return;
99
146
  context.visited.add(real);
100
147
 
101
- const entries = await readdir(dir, { withFileTypes: true });
148
+ let entries: Dirent[];
149
+ try {
150
+ entries = await readdir(dir, { withFileTypes: true });
151
+ } catch (error) {
152
+ if (isSkippableWalkError(error)) return; // the directory vanished after it resolved
153
+ throw error;
154
+ }
102
155
 
103
156
  await Promise.all(
104
157
  entries.map(async (entry) => {
@@ -112,16 +165,30 @@ async function walk(dir: string, context: WalkContext, remember: (path: string)
112
165
  const info = await stat(full);
113
166
  isDirectory = info.isDirectory();
114
167
  isFile = info.isFile();
115
- } catch {
116
- return; // broken symlink
168
+ } catch (error) {
169
+ if (isSkippableWalkError(error)) return; // broken symlink
170
+ throw error;
117
171
  }
118
172
  }
119
173
  if (isDirectory) {
120
- if (!context.ignoreDirs.has(entry.name) && !context.isIgnored(full, context.root)) {
174
+ if (!context.ignoreDirs.has(foldPathCase(entry.name)) && !context.isIgnored(full, context.root, true)) {
121
175
  await walk(full, context, remember);
122
176
  }
123
- } else if (isFile && hasExtension(entry.name, context.extensions) && !context.isIgnored(full, context.root)) {
124
- remember(full);
177
+ } else if (
178
+ isFile &&
179
+ hasExtension(entry.name, context.extensions) &&
180
+ !context.isIgnored(full, context.root, false)
181
+ ) {
182
+ // Remembered under its real path, so several symlinks to one target
183
+ // (or a link plus the target itself) count — and get rewritten — once.
184
+ let realFile: string;
185
+ try {
186
+ realFile = await realpath(full);
187
+ } catch (error) {
188
+ if (isSkippableWalkError(error)) return; // the file vanished mid-walk
189
+ throw error;
190
+ }
191
+ remember(full, realFile);
125
192
  }
126
193
  }),
127
194
  );
@@ -140,28 +207,57 @@ function hasExtension(name: string, extensions: string[]): boolean {
140
207
  return extensions.some((extension) => lower.endsWith(extension));
141
208
  }
142
209
 
210
+ interface IgnorePattern {
211
+ glob: string;
212
+ /** The pattern ended in a slash, so it only excludes directories (`dist/`). */
213
+ directoriesOnly: boolean;
214
+ }
215
+
216
+ function parseIgnorePattern(pattern: string): IgnorePattern {
217
+ const glob = pattern.replace(/\/+$/, "");
218
+ if (glob === "") {
219
+ // picomatch would reject it with an internal-sounding error; name the input instead.
220
+ throw new Error(`invalid ignore pattern: ${JSON.stringify(pattern)}`);
221
+ }
222
+ return { glob, directoriesOnly: glob !== pattern };
223
+ }
224
+
143
225
  function buildIgnoreMatcher(patterns: string[]): IgnoreMatcher {
144
- if (patterns.length === 0) return () => false;
226
+ const parsed = patterns.map(parseIgnorePattern);
227
+ if (parsed.length === 0) return () => false;
145
228
 
146
- // Gitignore-like split: patterns without a slash match base names, patterns
147
- // with a slash match whole paths. (picomatch's `basename` option would apply
148
- // to every pattern, breaking path globs, so two matchers are needed.)
149
- const matchers: Array<(path: string) => boolean> = [];
150
- const byBasename = patterns.filter((pattern) => !pattern.includes("/"));
151
- const byPath = patterns.filter((pattern) => pattern.includes("/"));
152
- if (byBasename.length > 0) matchers.push(picomatch(byBasename, { dot: true, basename: true }));
153
- if (byPath.length > 0) matchers.push(picomatch(byPath, { dot: true }));
154
- const match = (path: string): boolean => matchers.some((matcher) => matcher(path));
229
+ const matchesAny = compileGlobs(parsed.filter((pattern) => !pattern.directoriesOnly).map((pattern) => pattern.glob));
230
+ const matchesDirectory = compileGlobs(
231
+ parsed.filter((pattern) => pattern.directoriesOnly).map((pattern) => pattern.glob),
232
+ );
233
+ const match = (path: string, isDirectory: boolean): boolean =>
234
+ matchesAny(path) || (isDirectory && matchesDirectory(path));
155
235
 
156
236
  // Anchored patterns like `src/legacy/**` are tried against the path as
157
237
  // spelled, relative to the scanned root, and relative to the working
158
238
  // directory, so they work regardless of where the scan was started from.
159
- return (path, root) => {
160
- if (match(toPosix(path))) return true;
161
- return relativeMatches(root, path, match) || relativeMatches(process.cwd(), path, match);
239
+ return (path, root, isDirectory) => {
240
+ const matches = (candidate: string): boolean => match(candidate, isDirectory);
241
+ if (matches(toPosix(path))) return true;
242
+ return relativeMatches(root, path, matches) || relativeMatches(process.cwd(), path, matches);
162
243
  };
163
244
  }
164
245
 
246
+ /**
247
+ * One predicate over gitignore-like globs: patterns without a slash match
248
+ * base names, patterns with a slash match whole paths. (picomatch's
249
+ * `basename` option would apply to every pattern, breaking path globs, so
250
+ * the two groups get separate matchers.)
251
+ */
252
+ function compileGlobs(globs: string[]): (path: string) => boolean {
253
+ const matchers: Array<(path: string) => boolean> = [];
254
+ const byBasename = globs.filter((glob) => !glob.includes("/"));
255
+ const byPath = globs.filter((glob) => glob.includes("/"));
256
+ if (byBasename.length > 0) matchers.push(picomatch(byBasename, { dot: true, basename: true }));
257
+ if (byPath.length > 0) matchers.push(picomatch(byPath, { dot: true }));
258
+ return (path) => matchers.some((matcher) => matcher(path));
259
+ }
260
+
165
261
  function relativeMatches(base: string, path: string, match: (path: string) => boolean): boolean {
166
262
  const relativePath = relative(base, path);
167
263
  if (relativePath === "" || isAbsolute(relativePath)) return false;
@@ -176,9 +272,14 @@ function toPosix(path: string): string {
176
272
  return sep === "/" ? path : path.split(sep).join("/");
177
273
  }
178
274
 
275
+ // TypeScript parses plain JavaScript with the JSX language variant, so `.js`
276
+ // belongs here: read as TS instead, `<div>http://x</div>` in a React file
277
+ // becomes a type assertion followed by a phantom `//x` comment.
278
+ const JSX_EXTENSIONS = [".tsx", ".jsx", ".js", ".mjs", ".cjs"];
279
+
280
+ /** True for files whose syntax admits JSX (`.tsx`, `.jsx` and plain JavaScript), case-insensitively. */
179
281
  export function isJsxFile(file: string): boolean {
180
- const lower = file.toLowerCase();
181
- return lower.endsWith(".tsx") || lower.endsWith(".jsx");
282
+ return hasExtension(file, JSX_EXTENSIONS);
182
283
  }
183
284
 
184
285
  export type FileEncoding = "utf8" | "utf16le" | "utf16be";
@@ -204,26 +305,29 @@ export interface FileText {
204
305
  * editors, GitHub annotations and the removal report.
205
306
  */
206
307
  export function decodeFileText(data: Buffer): FileText {
207
- let encoding: FileEncoding = "utf8";
208
- let bom = false;
209
- let body = data;
210
- if (data.length >= 2 && data[0] === 0xff && data[1] === 0xfe) {
211
- encoding = "utf16le";
212
- bom = true;
213
- body = data.subarray(2);
214
- } else if (data.length >= 2 && data[0] === 0xfe && data[1] === 0xff) {
215
- encoding = "utf16be";
216
- bom = true;
217
- body = data.subarray(2);
218
- } else if (data.length >= 3 && data[0] === 0xef && data[1] === 0xbb && data[2] === 0xbf) {
219
- bom = true;
220
- body = data.subarray(3);
221
- }
308
+ const marked = detectByteOrderMark(data);
309
+ const encoding = marked ?? "utf8";
310
+ const bom = marked !== undefined;
311
+ const body = bom ? data.subarray(BYTE_ORDER_MARKS[encoding].length) : data;
222
312
  const text = encoding === "utf16be" ? decodeUtf16Be(body) : body.toString(encoding);
223
313
  const lossless = encodeFileText(text, { encoding, bom }).equals(data);
224
314
  return { text, encoding, bom, lossless };
225
315
  }
226
316
 
317
+ const BYTE_ORDER_MARKS: Readonly<Record<FileEncoding, Buffer>> = {
318
+ utf8: Buffer.from([0xef, 0xbb, 0xbf]),
319
+ utf16le: Buffer.from([0xff, 0xfe]),
320
+ utf16be: Buffer.from([0xfe, 0xff]),
321
+ };
322
+
323
+ /** The encoding whose byte-order mark opens the data, if any. */
324
+ function detectByteOrderMark(data: Buffer): FileEncoding | undefined {
325
+ return (Object.keys(BYTE_ORDER_MARKS) as FileEncoding[]).find((encoding) => {
326
+ const mark = BYTE_ORDER_MARKS[encoding];
327
+ return data.subarray(0, mark.length).equals(mark);
328
+ });
329
+ }
330
+
227
331
  function decodeUtf16Be(body: Buffer): string {
228
332
  // swap16() refuses odd-length buffers; drop the dangling byte the same way
229
333
  // the LE decoder does and let the lossless round-trip flag the truncation.
@@ -231,16 +335,16 @@ function decodeUtf16Be(body: Buffer): string {
231
335
  return Buffer.from(even).swap16().toString("utf16le");
232
336
  }
233
337
 
234
- /** Re-encodes decoded text in the encoding (and BOM) it was read with. */
338
+ /**
339
+ * Re-encodes decoded text in the encoding (and BOM) it was read with. Note
340
+ * that `bom: false` UTF-16 output cannot be recognised by decodeFileText,
341
+ * which identifies UTF-16 by its byte-order mark — request it only for
342
+ * consumers that expect mark-less UTF-16.
343
+ */
235
344
  export function encodeFileText(text: string, target: { encoding: FileEncoding; bom: boolean }): Buffer {
236
- if (target.encoding === "utf16le") {
237
- return Buffer.concat([Buffer.from([0xff, 0xfe]), Buffer.from(text, "utf16le")]);
238
- }
239
- if (target.encoding === "utf16be") {
240
- return Buffer.concat([Buffer.from([0xfe, 0xff]), Buffer.from(text, "utf16le").swap16()]);
241
- }
242
- const bom = target.bom ? Buffer.from([0xef, 0xbb, 0xbf]) : Buffer.alloc(0);
243
- return Buffer.concat([bom, Buffer.from(text, "utf8")]);
345
+ const body =
346
+ target.encoding === "utf16be" ? Buffer.from(text, "utf16le").swap16() : Buffer.from(text, target.encoding);
347
+ return target.bom ? Buffer.concat([BYTE_ORDER_MARKS[target.encoding], body]) : body;
244
348
  }
245
349
 
246
350
  export async function readFileText(file: string): Promise<FileText> {
@@ -255,10 +359,11 @@ export async function readFileText(file: string): Promise<FileText> {
255
359
  */
256
360
  export async function writeFileAtomic(file: string, data: Buffer): Promise<void> {
257
361
  const target = await realpath(file);
258
- const mode = (await stat(target)).mode;
362
+ // Permission bits only: stat()'s mode also carries the file-type bits.
363
+ const permissions = (await stat(target)).mode & 0o7777;
259
364
  const temp = join(dirname(target), `.${basename(target)}.${randomUUID()}.tmp`);
260
365
  try {
261
- const handle = await open(temp, "wx", mode);
366
+ const handle = await open(temp, "wx", permissions);
262
367
  try {
263
368
  await handle.writeFile(data);
264
369
  await handle.sync();
@@ -266,7 +371,7 @@ export async function writeFileAtomic(file: string, data: Buffer): Promise<void>
266
371
  await handle.close();
267
372
  }
268
373
  // open()'s mode is filtered through the umask; restore the original exactly.
269
- await chmod(temp, mode & 0o7777);
374
+ await chmod(temp, permissions);
270
375
  await rename(temp, target);
271
376
  } catch (error) {
272
377
  await rm(temp, { force: true }).catch(() => undefined);
package/src/git.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { execFile } from "node:child_process";
2
+ import { existsSync } from "node:fs";
2
3
  import { realpath } from "node:fs/promises";
3
4
  import { resolve } from "node:path";
4
5
  import { promisify } from "node:util";
@@ -56,13 +57,16 @@ async function git(args: string[], cwd: string): Promise<string> {
56
57
  const { stdout } = await execFileAsync("git", args, { cwd, maxBuffer: MAX_OUTPUT_BYTES });
57
58
  return stdout;
58
59
  } catch (error) {
59
- throw new Error(describeFailure(args[0] as string, error), { cause: error });
60
+ throw new Error(describeFailure(args[0] as string, cwd, error), { cause: error });
60
61
  }
61
62
  }
62
63
 
63
- function describeFailure(subcommand: string, error: unknown): string {
64
+ function describeFailure(subcommand: string, cwd: string, error: unknown): string {
64
65
  const failure = error as { code?: unknown; stderr?: unknown; message?: unknown };
65
66
  if (failure.code === "ENOENT") {
67
+ // spawn reports a missing working directory with the very same error as
68
+ // a missing executable; only the directory check tells them apart.
69
+ if (!existsSync(cwd)) return `directory not found: ${cwd}`;
66
70
  return "git executable not found (is git installed and on PATH?)";
67
71
  }
68
72
  const stderr = typeof failure.stderr === "string" ? failure.stderr.trim() : "";