@kongyo2/ts-comment-scanner 0.0.0 → 1.0.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/README.md +97 -17
- package/dist/args.d.ts +15 -1
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +146 -6
- package/dist/args.js.map +1 -1
- package/dist/directives.d.ts +12 -0
- package/dist/directives.d.ts.map +1 -0
- package/dist/directives.js +133 -0
- package/dist/directives.js.map +1 -0
- package/dist/files.d.ts +12 -0
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +84 -20
- package/dist/files.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/remove.d.ts +38 -0
- package/dist/remove.d.ts.map +1 -0
- package/dist/remove.js +223 -0
- package/dist/remove.js.map +1 -0
- package/dist/report.d.ts +8 -0
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +46 -12
- package/dist/report.js.map +1 -1
- package/dist/run.d.ts +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +156 -20
- package/dist/run.js.map +1 -1
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.js +31 -7
- package/dist/scanner.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# ts-comment-scanner
|
|
2
2
|
|
|
3
|
-
TypeScript
|
|
3
|
+
TypeScript プロジェクト内のコメントを検出・一覧・集計し、安全に削除もできる CLI / ライブラリです。TypeScript の AST を使って解析するため、文字列・テンプレートリテラル・正規表現・JSX テキストを誤検出しません。
|
|
4
4
|
|
|
5
5
|
## 特徴
|
|
6
6
|
|
|
7
|
-
- `.ts` `.tsx` `.mts` `.cts`
|
|
7
|
+
- `.ts` `.tsx` `.mts` `.cts` を再帰的にスキャン(`node_modules` と `.git` は除外)
|
|
8
8
|
- 行コメント (`//`) とブロックコメント (`/* */`) を位置情報つきで報告
|
|
9
|
-
-
|
|
9
|
+
- テキスト / JSON / **GitHub Actions アノテーション**の 3 形式で出力
|
|
10
|
+
- `@ts-ignore` や `eslint-disable` などの**コンパイラ・リンター指示子(ディレクティブ)を自動判別**し、絞り込み・除外が可能
|
|
11
|
+
- **安全なコメント削除**(コードクリーンアップ): ディレクティブとライセンスヘッダーはデフォルトで保持
|
|
12
|
+
- Glob による**カスタム無視パターン** (`--ignore`)、対象拡張子の変更 (`--ext`)
|
|
13
|
+
- CI 向けの `--fail-on-comment`(コメント検出時に終了コード 1)
|
|
10
14
|
- CLI としても、ライブラリとしても利用可能
|
|
11
15
|
|
|
12
16
|
## インストール
|
|
@@ -26,13 +30,33 @@ npx @kongyo2/ts-comment-scanner src
|
|
|
26
30
|
```
|
|
27
31
|
ts-comment-scanner [options] [paths...]
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
--json
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
出力:
|
|
34
|
+
--format <fmt> 出力形式: text / json / github(既定: text)
|
|
35
|
+
--json --format json の短縮形
|
|
36
|
+
|
|
37
|
+
フィルタリング:
|
|
38
|
+
--ignore <glob> Glob に一致するファイル・ディレクトリを除外(複数指定可)
|
|
39
|
+
--ext <list> スキャン対象の拡張子(カンマ区切り、既定: .ts,.tsx,.mts,.cts)
|
|
40
|
+
--skip-directives コンパイラ・リンター指示子を結果から除外
|
|
41
|
+
--only-directives 指示子のみを報告
|
|
42
|
+
|
|
43
|
+
CI:
|
|
44
|
+
--fail-on-comment コメントが報告された場合に終了コード 1 で終了
|
|
45
|
+
|
|
46
|
+
削除:
|
|
47
|
+
--remove 報告対象のコメントをファイルから削除(インプレース)
|
|
48
|
+
--dry-run --remove と併用: 変更せずに削除対象のみ表示
|
|
49
|
+
--remove-directives --remove と併用: 指示子コメントも削除
|
|
50
|
+
--remove-legal --remove と併用: ライセンス・法的コメントも削除
|
|
51
|
+
|
|
52
|
+
その他:
|
|
53
|
+
-h, --help ヘルプを表示
|
|
54
|
+
-v, --version バージョンを表示
|
|
33
55
|
```
|
|
34
56
|
|
|
35
|
-
|
|
57
|
+
パスを省略するとカレントディレクトリを対象にします。スラッシュを含まない Glob(例: `*.test.ts`)はファイル名に、含むもの(例: `src/legacy/**`)はパスに一致します。明示的に指定したファイルは `--ignore` の対象になりません。
|
|
58
|
+
|
|
59
|
+
**終了コード**: `0` 成功 / `1` `--fail-on-comment` 指定時にコメントを検出 / `2` 引数・実行時エラー
|
|
36
60
|
|
|
37
61
|
### 出力例
|
|
38
62
|
|
|
@@ -40,8 +64,9 @@ Options:
|
|
|
40
64
|
$ ts-comment-scanner src
|
|
41
65
|
src/index.ts:1:1 [line] // エントリーポイント
|
|
42
66
|
src/scanner.ts:8:3 [block] /* AST を走査する */
|
|
67
|
+
src/legacy.ts:3:1 [line] [@ts-ignore] // @ts-ignore 後で直す
|
|
43
68
|
|
|
44
|
-
|
|
69
|
+
3 comments across 3 files
|
|
45
70
|
```
|
|
46
71
|
|
|
47
72
|
JSON 出力:
|
|
@@ -49,42 +74,97 @@ JSON 出力:
|
|
|
49
74
|
```bash
|
|
50
75
|
$ ts-comment-scanner --json src
|
|
51
76
|
{
|
|
52
|
-
"summary": { "files": 1, "comments": 1 },
|
|
77
|
+
"summary": { "files": 1, "comments": 1, "directives": 0 },
|
|
53
78
|
"files": [
|
|
54
79
|
{
|
|
55
80
|
"file": "src/index.ts",
|
|
56
81
|
"comments": [
|
|
57
|
-
{
|
|
82
|
+
{
|
|
83
|
+
"kind": "line",
|
|
84
|
+
"text": "// エントリーポイント",
|
|
85
|
+
"start": 0,
|
|
86
|
+
"end": 12,
|
|
87
|
+
"line": 1,
|
|
88
|
+
"column": 1,
|
|
89
|
+
"endLine": 1,
|
|
90
|
+
"endColumn": 13
|
|
91
|
+
}
|
|
58
92
|
]
|
|
59
93
|
}
|
|
60
94
|
]
|
|
61
95
|
}
|
|
62
96
|
```
|
|
63
97
|
|
|
98
|
+
ディレクティブと判定されたコメントには `"directive": "@ts-ignore"` のように名前が付きます。
|
|
99
|
+
|
|
100
|
+
### GitHub Actions で使う
|
|
101
|
+
|
|
102
|
+
`--format github` は各コメントを [workflow command](https://docs.github.com/actions/reference/workflow-commands-for-github-actions) として出力するため、PR の該当行にアノテーションが表示されます。
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
- name: Check for stray comments
|
|
106
|
+
run: npx @kongyo2/ts-comment-scanner --format github --skip-directives --fail-on-comment src
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
::notice file=src/index.ts,line=1,endLine=1,col=1,endColumn=13,title=line comment::// エントリーポイント
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### コメントの一括削除(コードクリーンアップ)
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# まず削除対象を確認
|
|
117
|
+
ts-comment-scanner --remove --dry-run src
|
|
118
|
+
|
|
119
|
+
# 実際に削除(ディレクティブとライセンスヘッダーは保持される)
|
|
120
|
+
ts-comment-scanner --remove src
|
|
121
|
+
|
|
122
|
+
# 指示子・ライセンスも含めて完全に削除
|
|
123
|
+
ts-comment-scanner --remove --remove-directives --remove-legal src
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
削除は AST のコメント範囲に基づいて行われるため、文字列やコードには影響しません。さらに:
|
|
127
|
+
|
|
128
|
+
- `@ts-expect-error` / `eslint-disable` などの指示子は、削除するとビルドやリントが壊れるため**デフォルトで保持**
|
|
129
|
+
- `/*! ... */` や `@license` / `@preserve` / `@copyright` を含む法的コメントも**デフォルトで保持**
|
|
130
|
+
- ブロックコメント除去でトークンが結合してしまう位置には空白を挿入(`a/* x */b` → `a b`)
|
|
131
|
+
- コメントだけの行は行ごと削除、行末コメントは手前の空白ごと削除
|
|
132
|
+
- 削除後のソースを再スキャンして検証し、想定外の結果になる場合はファイルを変更せずエラー報告
|
|
133
|
+
|
|
134
|
+
### 検出できるディレクティブ(抜粋)
|
|
135
|
+
|
|
136
|
+
`@ts-ignore` `@ts-expect-error` `@ts-nocheck` `@ts-check` / `eslint-disable` 系・`eslint-env`・`/* global */` / `tslint:` / `oxlint-disable` 系 / `biome-ignore` 系 / `deno-lint-ignore` 系 / `prettier-ignore` / `istanbul ignore`・`c8 ignore`・`v8 ignore`・`node:coverage` / `webpackChunkName:` などの webpack マジックコメント / `@vite-ignore` / `#__PURE__` / `//# sourceMappingURL=`・`//# sourceURL=` / `@jsx` 系プラグマ / `@jest-environment`・`@vitest-environment` / `/// <reference>` / `#region`・`#endregion`
|
|
137
|
+
|
|
64
138
|
## ライブラリとして使う
|
|
65
139
|
|
|
66
140
|
```ts
|
|
67
|
-
import { scanPaths, scanComments, formatText } from "@kongyo2/ts-comment-scanner";
|
|
141
|
+
import { scanPaths, scanComments, removeComments, formatText } from "@kongyo2/ts-comment-scanner";
|
|
68
142
|
|
|
69
143
|
// ファイル / ディレクトリをまとめてスキャン
|
|
70
|
-
const results = await scanPaths(["src"]);
|
|
144
|
+
const results = await scanPaths(["src"], { ignore: ["**/*.test.ts"] });
|
|
71
145
|
console.log(formatText(results));
|
|
72
146
|
|
|
73
147
|
// ソース文字列を直接スキャン
|
|
74
148
|
const comments = scanComments("// hello\nconst x = 1;");
|
|
149
|
+
|
|
150
|
+
// コメントを安全に削除
|
|
151
|
+
const { code, removed, kept } = removeComments("// note\nconst x = 1;\n");
|
|
75
152
|
```
|
|
76
153
|
|
|
77
154
|
### 主な API
|
|
78
155
|
|
|
79
156
|
| 関数 | 概要 |
|
|
80
157
|
| --- | --- |
|
|
81
|
-
| `scanComments(source, options?)` |
|
|
158
|
+
| `scanComments(source, options?)` | ソース文字列からコメント配列を取得(`options.jsx` で TSX を解析) |
|
|
82
159
|
| `scanFile(file)` | 1 ファイルをスキャン |
|
|
83
|
-
| `scanPaths(inputs, options?)` | ファイル / ディレクトリ群を再帰的にスキャン |
|
|
160
|
+
| `scanPaths(inputs, options?)` | ファイル / ディレクトリ群を再帰的にスキャン(`ignore` / `extensions` 対応) |
|
|
84
161
|
| `collectFiles(inputs, options?)` | 対象ファイルのパス一覧を収集 |
|
|
85
|
-
| `
|
|
162
|
+
| `removeComments(source, options?)` | コメントを安全に削除(`removeDirectives` / `removeLegal` / `shouldRemove`) |
|
|
163
|
+
| `detectDirective(kind, text)` | コメントがディレクティブなら正規化した名前を返す |
|
|
164
|
+
| `isLegalComment(text)` | ライセンス・法的コメントかどうかを判定 |
|
|
165
|
+
| `formatText(results)` / `formatJson(results)` / `formatGitHub(results)` | スキャン結果を整形 |
|
|
86
166
|
|
|
87
|
-
型: `Comment` / `CommentKind` / `FileScanResult` / `ScanOptions` / `CollectOptions`
|
|
167
|
+
型: `Comment` / `CommentKind` / `FileScanResult` / `ScanOptions` / `CollectOptions` / `RemoveOptions` / `RemoveResult`
|
|
88
168
|
|
|
89
169
|
## 必要環境
|
|
90
170
|
|
package/dist/args.d.ts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
export type OutputFormat = "text" | "json" | "github";
|
|
2
|
+
export type DirectiveMode = "include" | "skip" | "only";
|
|
1
3
|
export interface CliOptions {
|
|
2
4
|
paths: string[];
|
|
3
|
-
|
|
5
|
+
format: OutputFormat;
|
|
6
|
+
ignore: string[];
|
|
7
|
+
extensions: string[] | undefined;
|
|
8
|
+
directives: DirectiveMode;
|
|
9
|
+
failOnComment: boolean;
|
|
10
|
+
remove: boolean;
|
|
11
|
+
removeDirectives: boolean;
|
|
12
|
+
removeLegal: boolean;
|
|
13
|
+
dryRun: boolean;
|
|
4
14
|
help: boolean;
|
|
5
15
|
version: boolean;
|
|
6
16
|
}
|
|
17
|
+
/** Invalid command line input; the CLI reports the message and exits with code 2. */
|
|
18
|
+
export declare class UsageError extends Error {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
7
21
|
export declare function parseArgs(argv: string[]): CliOptions;
|
|
8
22
|
//# sourceMappingURL=args.d.ts.map
|
package/dist/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AACtD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,aAAa,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qFAAqF;AACrF,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM;CAI5B;AAKD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAqJpD"}
|
package/dist/args.js
CHANGED
|
@@ -1,25 +1,165 @@
|
|
|
1
|
+
/** Invalid command line input; the CLI reports the message and exits with code 2. */
|
|
2
|
+
export class UsageError extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "UsageError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
const FORMATS = ["text", "json", "github"];
|
|
9
|
+
const DIRECTIVE_CONFLICT = "--skip-directives and --only-directives cannot be combined";
|
|
1
10
|
export function parseArgs(argv) {
|
|
2
11
|
const paths = [];
|
|
3
|
-
|
|
12
|
+
const ignore = [];
|
|
13
|
+
const extensions = [];
|
|
14
|
+
let format = "text";
|
|
15
|
+
let directives = "include";
|
|
16
|
+
let failOnComment = false;
|
|
17
|
+
let remove = false;
|
|
18
|
+
let removeDirectives = false;
|
|
19
|
+
let removeLegal = false;
|
|
20
|
+
let dryRun = false;
|
|
4
21
|
let help = false;
|
|
5
22
|
let version = false;
|
|
6
|
-
|
|
7
|
-
|
|
23
|
+
let pathsOnly = false;
|
|
24
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
25
|
+
const arg = argv[index];
|
|
26
|
+
if (pathsOnly || !arg.startsWith("-") || arg === "-") {
|
|
27
|
+
paths.push(arg);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const [flag, inlineValue] = splitFlag(arg);
|
|
31
|
+
const readValue = () => {
|
|
32
|
+
if (inlineValue !== undefined)
|
|
33
|
+
return inlineValue;
|
|
34
|
+
const next = argv[index + 1];
|
|
35
|
+
if (next === undefined)
|
|
36
|
+
throw new UsageError(`option ${flag} requires a value`);
|
|
37
|
+
index += 1;
|
|
38
|
+
return next;
|
|
39
|
+
};
|
|
40
|
+
const rejectValue = () => {
|
|
41
|
+
if (inlineValue !== undefined)
|
|
42
|
+
throw new UsageError(`option ${flag} does not take a value`);
|
|
43
|
+
};
|
|
44
|
+
switch (flag) {
|
|
45
|
+
case "--":
|
|
46
|
+
rejectValue();
|
|
47
|
+
pathsOnly = true;
|
|
48
|
+
break;
|
|
49
|
+
case "--format": {
|
|
50
|
+
const value = readValue();
|
|
51
|
+
if (!FORMATS.includes(value)) {
|
|
52
|
+
throw new UsageError(`unknown format: ${value} (expected ${FORMATS.join(", ")})`);
|
|
53
|
+
}
|
|
54
|
+
format = value;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
8
57
|
case "--json":
|
|
9
|
-
|
|
58
|
+
rejectValue();
|
|
59
|
+
format = "json";
|
|
60
|
+
break;
|
|
61
|
+
case "--ignore":
|
|
62
|
+
ignore.push(readValue());
|
|
63
|
+
break;
|
|
64
|
+
case "--ext": {
|
|
65
|
+
const parsed = readValue()
|
|
66
|
+
.split(",")
|
|
67
|
+
.map((extension) => extension.trim())
|
|
68
|
+
.filter((extension) => extension !== "");
|
|
69
|
+
if (parsed.length === 0) {
|
|
70
|
+
throw new UsageError("option --ext requires at least one extension");
|
|
71
|
+
}
|
|
72
|
+
extensions.push(...parsed);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case "--skip-directives":
|
|
76
|
+
rejectValue();
|
|
77
|
+
if (directives === "only")
|
|
78
|
+
throw new UsageError(DIRECTIVE_CONFLICT);
|
|
79
|
+
directives = "skip";
|
|
80
|
+
break;
|
|
81
|
+
case "--only-directives":
|
|
82
|
+
rejectValue();
|
|
83
|
+
if (directives === "skip")
|
|
84
|
+
throw new UsageError(DIRECTIVE_CONFLICT);
|
|
85
|
+
directives = "only";
|
|
86
|
+
break;
|
|
87
|
+
case "--fail-on-comment":
|
|
88
|
+
rejectValue();
|
|
89
|
+
failOnComment = true;
|
|
90
|
+
break;
|
|
91
|
+
case "--remove":
|
|
92
|
+
rejectValue();
|
|
93
|
+
remove = true;
|
|
94
|
+
break;
|
|
95
|
+
case "--remove-directives":
|
|
96
|
+
rejectValue();
|
|
97
|
+
removeDirectives = true;
|
|
98
|
+
break;
|
|
99
|
+
case "--remove-legal":
|
|
100
|
+
rejectValue();
|
|
101
|
+
removeLegal = true;
|
|
102
|
+
break;
|
|
103
|
+
case "--dry-run":
|
|
104
|
+
rejectValue();
|
|
105
|
+
dryRun = true;
|
|
10
106
|
break;
|
|
11
107
|
case "-h":
|
|
12
108
|
case "--help":
|
|
109
|
+
rejectValue();
|
|
13
110
|
help = true;
|
|
14
111
|
break;
|
|
15
112
|
case "-v":
|
|
16
113
|
case "--version":
|
|
114
|
+
rejectValue();
|
|
17
115
|
version = true;
|
|
18
116
|
break;
|
|
19
117
|
default:
|
|
20
|
-
|
|
118
|
+
throw new UsageError(`unknown option: ${flag}`);
|
|
21
119
|
}
|
|
22
120
|
}
|
|
23
|
-
|
|
121
|
+
if (!remove) {
|
|
122
|
+
for (const [set, flag] of [
|
|
123
|
+
[dryRun, "--dry-run"],
|
|
124
|
+
[removeDirectives, "--remove-directives"],
|
|
125
|
+
[removeLegal, "--remove-legal"],
|
|
126
|
+
]) {
|
|
127
|
+
if (set)
|
|
128
|
+
throw new UsageError(`${flag} requires --remove`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (remove && failOnComment) {
|
|
132
|
+
throw new UsageError("--fail-on-comment cannot be combined with --remove");
|
|
133
|
+
}
|
|
134
|
+
if (remove && format === "github") {
|
|
135
|
+
throw new UsageError("--format github cannot be combined with --remove");
|
|
136
|
+
}
|
|
137
|
+
if (remove && directives === "only" && !removeDirectives) {
|
|
138
|
+
throw new UsageError("--remove --only-directives would remove nothing; add --remove-directives to delete directives");
|
|
139
|
+
}
|
|
140
|
+
if (remove && directives === "skip" && removeDirectives) {
|
|
141
|
+
throw new UsageError("--remove-directives cannot be combined with --skip-directives");
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
paths: paths.length > 0 ? paths : ["."],
|
|
145
|
+
format,
|
|
146
|
+
ignore,
|
|
147
|
+
extensions: extensions.length > 0 ? extensions : undefined,
|
|
148
|
+
directives,
|
|
149
|
+
failOnComment,
|
|
150
|
+
remove,
|
|
151
|
+
removeDirectives,
|
|
152
|
+
removeLegal,
|
|
153
|
+
dryRun,
|
|
154
|
+
help,
|
|
155
|
+
version,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function splitFlag(arg) {
|
|
159
|
+
const equalsIndex = arg.indexOf("=");
|
|
160
|
+
if (arg.startsWith("--") && equalsIndex > 2) {
|
|
161
|
+
return [arg.slice(0, equalsIndex), arg.slice(equalsIndex + 1)];
|
|
162
|
+
}
|
|
163
|
+
return [arg, undefined];
|
|
24
164
|
}
|
|
25
165
|
//# sourceMappingURL=args.js.map
|
package/dist/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAkBA,qFAAqF;AACrF,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,OAAO,GAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AACpE,MAAM,kBAAkB,GAAG,4DAA4D,CAAC;AAExF,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,IAAI,MAAM,GAAiB,MAAM,CAAC;IAClC,IAAI,UAAU,GAAkB,SAAS,CAAC;IAC1C,IAAI,aAAa,GAAG,KAAK,CAAC;IAC1B,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAW,CAAC;QAElC,IAA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,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACvC,MAAM;QACN,MAAM;QACN,UAAU,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;QAC1D,UAAU;QACV,aAAa;QACb,MAAM;QACN,gBAAgB;QAChB,WAAW;QACX,MAAM;QACN,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,GAAW;IAC5B,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommentKind } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the canonical name of the compiler/linter/tooling directive the
|
|
4
|
+
* comment represents, or `undefined` when the comment is an ordinary comment.
|
|
5
|
+
*/
|
|
6
|
+
export declare function detectDirective(kind: CommentKind, text: string): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* True for license/legal comments (`/*!`, `@license`, `@preserve`, `@copyright`)
|
|
9
|
+
* that build tools conventionally keep when stripping comments.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isLegalComment(text: string): boolean;
|
|
12
|
+
//# sourceMappingURL=directives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../src/directives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmE9C;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkCnF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
const RULES = [
|
|
2
|
+
// ESLint
|
|
3
|
+
{ pattern: /^eslint-(?:disable|enable)(?:-next-line|-line)?\b/ },
|
|
4
|
+
{ pattern: /^eslint-env\b/ },
|
|
5
|
+
{ pattern: /^eslint\s+\S/, name: "eslint", blockOnly: true },
|
|
6
|
+
{ pattern: /^(globals?|exported)\s+\S/, name: (match) => match[1] ?? "global", blockOnly: true },
|
|
7
|
+
// TSLint (legacy)
|
|
8
|
+
{ pattern: /^tslint:[a-z-]+/ },
|
|
9
|
+
// oxlint
|
|
10
|
+
{ pattern: /^oxlint-(?:disable|enable)(?:-next-line|-line)?\b/ },
|
|
11
|
+
// Biome
|
|
12
|
+
{ pattern: /^biome-ignore(?:-all|-start|-end)?\b/ },
|
|
13
|
+
// Deno
|
|
14
|
+
{ pattern: /^deno-(?:lint-ignore(?:-file)?|fmt-ignore(?:-file)?|coverage-ignore(?:-file|-start|-stop)?)\b/ },
|
|
15
|
+
// Prettier
|
|
16
|
+
{ pattern: /^prettier-ignore(?:-start|-end)?\b/ },
|
|
17
|
+
// Coverage tools. The mode is part of the name so that consumers can tell
|
|
18
|
+
// next-statement pragmas (`next`, `if`, ...) from file/range ones (`file`,
|
|
19
|
+
// `start`, `stop`). Istanbul hints work in either comment kind; the V8-based
|
|
20
|
+
// tools (c8, v8, node:coverage) only document and parse block comments.
|
|
21
|
+
{ pattern: /^istanbul\s+ignore\s+([a-z]+)/, name: (match) => `istanbul-ignore-${match[1]}` },
|
|
22
|
+
{ pattern: /^istanbul\s+ignore\b/, name: "istanbul-ignore" },
|
|
23
|
+
{ pattern: /^c8\s+ignore\s+([a-z]+)/, name: (match) => `c8-ignore-${match[1]}`, blockOnly: true },
|
|
24
|
+
{ pattern: /^c8\s+ignore\b/, name: "c8-ignore", blockOnly: true },
|
|
25
|
+
{ pattern: /^v8\s+ignore\s+([a-z]+)/, name: (match) => `v8-ignore-${match[1]}`, blockOnly: true },
|
|
26
|
+
{ pattern: /^v8\s+ignore\b/, name: "v8-ignore", blockOnly: true },
|
|
27
|
+
{
|
|
28
|
+
pattern: /^node:coverage\s+(disable|enable|ignore)\b/,
|
|
29
|
+
name: (match) => `node:coverage-${match[1]}`,
|
|
30
|
+
blockOnly: true,
|
|
31
|
+
},
|
|
32
|
+
// Bundlers
|
|
33
|
+
{ pattern: /^webpack[A-Z][A-Za-z]*\s*:/, name: "webpack-magic-comment" },
|
|
34
|
+
{ pattern: /^@vite-ignore\b/ },
|
|
35
|
+
{ pattern: /^[#@]__(?:PURE|NO_SIDE_EFFECTS|INLINE|NOINLINE)__/ },
|
|
36
|
+
// Source maps (`//# sourceMappingURL=`, legacy `//@`, and the block form)
|
|
37
|
+
{ pattern: /^[#@]\s*(source(?:Mapping)?URL)=/, name: (match) => match[1] ?? "sourceMappingURL" },
|
|
38
|
+
// JSX pragmas (docblock pragmas: block comments only, honoured on any line)
|
|
39
|
+
{ pattern: /^@jsx(?:Runtime|ImportSource|Frag)?\b/, blockOnly: true, anyLine: true },
|
|
40
|
+
// Test runners (docblock pragmas as well)
|
|
41
|
+
{ pattern: /^@(?:jest|vitest)-environment\b/, blockOnly: true, anyLine: true },
|
|
42
|
+
// Editor folding
|
|
43
|
+
{ pattern: /^#(?:region|endregion)\b/ },
|
|
44
|
+
];
|
|
45
|
+
const TRIPLE_SLASH = /^\/\/\/\s*<(reference|amd-dependency|amd-module)\b/;
|
|
46
|
+
// Mirrors the TypeScript compiler's own comment-directive matching, verified
|
|
47
|
+
// against tsc: the suppression directives are case-sensitive PREFIX matches
|
|
48
|
+
// (`@ts-ignoreTODO` is active), while the file-wide check pragmas are
|
|
49
|
+
// case-insensitive and must end at a word boundary (`@ts-nocheckfoo` is not).
|
|
50
|
+
const TS_LINE_SUPPRESSION = /^\/\/\/?\s*@ts-(ignore|expect-error)/;
|
|
51
|
+
const TS_LINE_CHECK_PRAGMA = /^\/\/\/?\s*@ts-(nocheck|check)\b/i;
|
|
52
|
+
// Block comments: only the suppression directives, and only on the last line.
|
|
53
|
+
const TS_BLOCK_SUPPRESSION = /^[\s/*]*@ts-(ignore|expect-error)/;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the canonical name of the compiler/linter/tooling directive the
|
|
56
|
+
* comment represents, or `undefined` when the comment is an ordinary comment.
|
|
57
|
+
*/
|
|
58
|
+
export function detectDirective(kind, text) {
|
|
59
|
+
if (kind === "line") {
|
|
60
|
+
const tripleSlash = TRIPLE_SLASH.exec(text);
|
|
61
|
+
if (tripleSlash) {
|
|
62
|
+
return `triple-slash-${tripleSlash[1]}`;
|
|
63
|
+
}
|
|
64
|
+
const suppression = TS_LINE_SUPPRESSION.exec(text);
|
|
65
|
+
if (suppression) {
|
|
66
|
+
return `@ts-${suppression[1]}`;
|
|
67
|
+
}
|
|
68
|
+
const checkPragma = TS_LINE_CHECK_PRAGMA.exec(text);
|
|
69
|
+
if (checkPragma) {
|
|
70
|
+
return `@ts-${checkPragma[1]?.toLowerCase()}`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const suppression = TS_BLOCK_SUPPRESSION.exec(lastContentLine(text));
|
|
75
|
+
if (suppression) {
|
|
76
|
+
return `@ts-${suppression[1]}`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const lines = contentLines(kind, text);
|
|
80
|
+
for (const rule of RULES) {
|
|
81
|
+
if (rule.blockOnly === true && kind !== "block")
|
|
82
|
+
continue;
|
|
83
|
+
const candidates = rule.anyLine === true ? lines : lines.slice(0, 1);
|
|
84
|
+
for (const line of candidates) {
|
|
85
|
+
const match = rule.pattern.exec(line);
|
|
86
|
+
if (!match)
|
|
87
|
+
continue;
|
|
88
|
+
if (typeof rule.name === "string")
|
|
89
|
+
return rule.name;
|
|
90
|
+
if (typeof rule.name === "function")
|
|
91
|
+
return rule.name(match);
|
|
92
|
+
return match[0];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* True for license/legal comments (`/*!`, `@license`, `@preserve`, `@copyright`)
|
|
99
|
+
* that build tools conventionally keep when stripping comments.
|
|
100
|
+
*/
|
|
101
|
+
export function isLegalComment(text) {
|
|
102
|
+
if (text.startsWith("/*!") || text.startsWith("//!"))
|
|
103
|
+
return true;
|
|
104
|
+
return /@(?:license|preserve|copyright)\b/i.test(text);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Non-empty content lines of the comment, with comment markers stripped.
|
|
108
|
+
* For line comments only the `//` marker itself is removed: extra slashes or
|
|
109
|
+
* stars are content, so `//// @ts-ignore` and `// * prettier-ignore` stay
|
|
110
|
+
* ordinary. JSDoc-style `*` prefixes are stripped for block comments only.
|
|
111
|
+
*/
|
|
112
|
+
function contentLines(kind, text) {
|
|
113
|
+
const inner = kind === "line" ? text.replace(/^\/\//, "") : text.replace(/^\/\*+/, "").replace(/\*+\/\s*$/, "");
|
|
114
|
+
const lines = [];
|
|
115
|
+
for (const line of inner.split(/\r?\n/)) {
|
|
116
|
+
const stripped = (kind === "block" ? line.replace(/^\s*\*+\s*/, "") : line).trim();
|
|
117
|
+
if (stripped !== "")
|
|
118
|
+
lines.push(stripped);
|
|
119
|
+
}
|
|
120
|
+
return lines;
|
|
121
|
+
}
|
|
122
|
+
/** Last non-blank line of the comment, with the closing comment marker stripped. */
|
|
123
|
+
function lastContentLine(text) {
|
|
124
|
+
const inner = text.replace(/\*+\/\s*$/, "");
|
|
125
|
+
const lines = inner.split(/\r?\n/);
|
|
126
|
+
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
127
|
+
const line = lines[index] ?? "";
|
|
128
|
+
if (line.trim() !== "")
|
|
129
|
+
return line;
|
|
130
|
+
}
|
|
131
|
+
return "";
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=directives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../src/directives.ts"],"names":[],"mappings":"AAWA,MAAM,KAAK,GAAoB;IAC7B,SAAS;IACT,EAAE,OAAO,EAAE,mDAAmD,EAAE;IAChE,EAAE,OAAO,EAAE,eAAe,EAAE;IAC5B,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE;IAC5D,EAAE,OAAO,EAAE,2BAA2B,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE;IAChG,kBAAkB;IAClB,EAAE,OAAO,EAAE,iBAAiB,EAAE;IAC9B,SAAS;IACT,EAAE,OAAO,EAAE,mDAAmD,EAAE;IAChE,QAAQ;IACR,EAAE,OAAO,EAAE,sCAAsC,EAAE;IACnD,OAAO;IACP,EAAE,OAAO,EAAE,+FAA+F,EAAE;IAC5G,WAAW;IACX,EAAE,OAAO,EAAE,oCAAoC,EAAE;IACjD,0EAA0E;IAC1E,2EAA2E;IAC3E,6EAA6E;IAC7E,wEAAwE;IACxE,EAAE,OAAO,EAAE,+BAA+B,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IAC5F,EAAE,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,iBAAiB,EAAE;IAC5D,EAAE,OAAO,EAAE,yBAAyB,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,KAAK,CAAC,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C,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;QACnF,IAAI,QAAQ,KAAK,EAAE;YAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,oFAAoF;AACpF,SAAS,eAAe,CAAC,IAAY;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnC,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;IACtC,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/dist/files.d.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import type { FileScanResult } from "./types.js";
|
|
2
2
|
export interface CollectOptions {
|
|
3
|
+
/** File extensions to include (with or without a leading dot, case-insensitive). */
|
|
3
4
|
extensions?: string[];
|
|
5
|
+
/** Directory names that are never traversed. Default: node_modules, .git */
|
|
4
6
|
ignoreDirs?: string[];
|
|
7
|
+
/**
|
|
8
|
+
* Glob patterns for files and directories to skip (picomatch syntax).
|
|
9
|
+
* Patterns without a slash match against base names, e.g. `*.test.ts`.
|
|
10
|
+
* Explicitly listed input files bypass these patterns.
|
|
11
|
+
*/
|
|
12
|
+
ignore?: string[];
|
|
5
13
|
}
|
|
6
14
|
export declare function collectFiles(inputs: string[], options?: CollectOptions): Promise<string[]>;
|
|
15
|
+
export declare function isJsxFile(file: string): boolean;
|
|
7
16
|
export declare function scanFile(file: string): Promise<FileScanResult>;
|
|
8
17
|
export declare function scanPaths(inputs: string[], options?: CollectOptions): Promise<FileScanResult[]>;
|
|
18
|
+
export declare const FILE_CONCURRENCY = 16;
|
|
19
|
+
/** Concurrency-limited map that keeps input order and starts work as slots free up. */
|
|
20
|
+
export declare function mapLimit<T, R>(items: readonly T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]>;
|
|
9
21
|
//# sourceMappingURL=files.d.ts.map
|
package/dist/files.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjD,MAAM,WAAW,cAAc;IAC7B,oFAAoF;IACpF,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAID,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA2BpG;AA2ED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAG/C;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAMpE;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAGzG;AAED,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,uFAAuF;AACvF,wBAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAclH"}
|