@kongyo2/ts-comment-scanner 1.7.0 → 1.9.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.en.md +13 -8
- package/README.md +13 -8
- package/dist/args.d.ts +2 -1
- package/dist/args.d.ts.map +1 -1
- package/dist/directives.d.ts +27 -9
- package/dist/directives.d.ts.map +1 -1
- package/dist/directives.js +391 -164
- package/dist/directives.js.map +1 -1
- package/dist/docblock.d.ts +7 -0
- package/dist/docblock.d.ts.map +1 -0
- package/dist/docblock.js +51 -0
- package/dist/docblock.js.map +1 -0
- package/dist/remove.d.ts +6 -4
- package/dist/remove.d.ts.map +1 -1
- package/dist/remove.js +185 -28
- package/dist/remove.js.map +1 -1
- package/dist/run.d.ts +0 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +7 -5
- package/dist/run.js.map +1 -1
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.js +18 -5
- package/dist/scanner.js.map +1 -1
- package/package.json +4 -2
- package/src/args.ts +1 -1
- package/src/directives.ts +424 -170
- package/src/docblock.ts +49 -0
- package/src/remove.ts +198 -30
- package/src/run.ts +11 -10
- package/src/scanner.ts +18 -5
package/README.en.md
CHANGED
|
@@ -150,7 +150,8 @@ Removal is driven by the AST's comment ranges, so it never touches strings or co
|
|
|
150
150
|
- Directives such as `@ts-expect-error` / `eslint-disable` are **kept by default**, because removing them would break the build or the linter
|
|
151
151
|
- Legal comments — `/*! ... */` or those containing `@license` / `@preserve` / `@copyright` or the `SPDX-License-Identifier:` / `SPDX-FileCopyrightText:` tags — are also **kept by default**
|
|
152
152
|
- **The line structure below next-line directives** (`@ts-expect-error`, `eslint-disable-next-line`, ...) **is preserved**: when removing comments would delete a line and shift the directive's target (e.g. a comment-only line), those comments are kept instead
|
|
153
|
-
- **
|
|
153
|
+
- **Comments a directive looks past for its target are kept too**: below tsc's `@ts-ignore`/`@ts-expect-error`, which skip blank and `//` lines to find their target, the first line tsc 6 or tsc 7 stops at (a block-comment line, say) is kept; between a directive that only counts as the last comment before its target (`@deno-types`, `/* GraphQL */`, ESLint's `// falls through`, ...) and that target, every comment is kept
|
|
154
|
+
- **Position-dependent directives are never activated by a removal**: when deleting a leading comment would make prettier's `@format`/`@prettier` pragma or Deno's `deno-coverage-ignore-file` (honoured only in the file's first comment) or Bun's `// @bun` marker (honoured only at the very start of the file or on the line after a shebang) newly take effect in a kept comment, the leading comment is kept as well
|
|
154
155
|
- Whitespace is inserted where removing a block comment would otherwise join tokens together (`a/* x */b` → `a b`)
|
|
155
156
|
- Comment-only lines are removed entirely, and trailing comments are removed together with the preceding whitespace
|
|
156
157
|
- The result is re-scanned to verify that the surviving comments match the protected set, directive meaning included; if the outcome is unexpected the file is left unchanged and an error is reported
|
|
@@ -177,16 +178,20 @@ This is designed for workflows like letting a coding agent do some work and then
|
|
|
177
178
|
|
|
178
179
|
### Detectable directives (excerpt)
|
|
179
180
|
|
|
180
|
-
Each directive is matched the way the real tool's parser matches it (its regex or string comparison).
|
|
181
|
+
Each directive is matched the way the real tool's parser matches it (its regex or string comparison). Where tools or versions disagree, every form any of them honours counts as a directive, so removal errs on the side of keeping the comment.
|
|
181
182
|
|
|
182
|
-
- **Compiler / types**: `@ts-ignore` `@ts-expect-error` `@ts-nocheck` `@ts-check` / `/// <reference>` / `@ts-strict-ignore`, `@ts-strict` (typescript-strict-plugin) / `@deno-types=`, `@ts-types=`, `@ts-self-types=` (Deno)
|
|
183
|
-
- **Linters**: the `eslint-disable` family, `eslint-env`, `/* global */`, `/* exported
|
|
184
|
-
- **Formatters**: `prettier-ignore`, the `@format`/`@prettier`/`@noformat`/`@noprettier` pragmas / `oxfmt-ignore` / `dprint-ignore`, `dprint-ignore-file` / `organize-imports-ignore` / `beautify ignore/preserve` (legacy)
|
|
185
|
-
- **Coverage / testing**: `istanbul ignore`, `c8 ignore`, `v8 ignore`, `node:coverage` / `@jest-environment(-options)`, `@vitest-environment(-options)`, `@module-tag` (Vitest 4) / `Stryker disable/restore` / `type-coverage:ignore-line/-next-line` / `ts-prune-ignore-next`
|
|
186
|
-
- **Bundlers / runtimes**: webpack and turbopack magic comments such as `webpackChunkName:` / `@vite-ignore` / `#__PURE__`, `@__NO_SIDE_EFFECTS__`, `@__INLINE__`, `@__KEY__`, `@__MANGLE_PROP__` (terser/rollup annotations) / `// @bun` (Bun) / `@refresh reset/skip/reload` (react-refresh / solid-refresh) / `million-ignore` / `nx-ignore-next-line` (Nx) / `@unocss-include/-ignore/-skip-start/-skip-end` / `@next-codemod-error/-ignore` (Next.js) / `/* GraphQL */`, `/* HTML */` tag comments / `//# sourceMappingURL=`, `//# sourceURL=` / `@jsx`-family pragmas
|
|
183
|
+
- **Compiler / types**: `@ts-ignore` `@ts-expect-error` `@ts-nocheck` `@ts-check` (tsc 6, tsc 7, and Flow checking TypeScript files) / the `/// <reference>` family / `@ts-strict-ignore`, `@ts-strict` (typescript-strict-plugin's CLI and IDE plugin) / `@deno-types=`, `@ts-types=`, `@ts-self-types=` (Deno)
|
|
184
|
+
- **Linters**: the `eslint-disable` family, `eslint-env`, `/* global */`, `/* exported */`, `// falls through` (no-fallthrough), `// no default` (default-case; both only in front of the `case`, `default` or `}` ESLint reads them before) / the `eslint-disable … react-hooks/…` and `$FlowFixMe[react-rule…]` suppressions React Compiler reads / the `oxlint-disable` family / the `biome-ignore` family, `rome-ignore` / the `deno-lint-ignore` family / `stylelint-disable`, `stylelint-disable-line`, `stylelint-disable-next-line`, `stylelint-enable` (stylelint) / `@flow`, `@noflow`, the `$FlowFixMe` family, `flowlint` (Flow) / `tslint:`, `jshint`, `jscs:`, `jslint` (legacy)
|
|
185
|
+
- **Formatters**: `prettier-ignore`, the `@format`/`@prettier`/`@noformat`/`@noprettier` pragmas, `/** @type */` / `/** @satisfies */` type-cast comments (prettier) / `oxfmt-ignore` / `dprint-ignore`, `dprint-ignore-file`, `deno-fmt-ignore`, `deno-fmt-ignore-file` (dprint / deno fmt) / `organize-imports-ignore`, `sort-imports-ignore` / `beautify ignore/preserve` (legacy)
|
|
186
|
+
- **Coverage / testing**: `istanbul ignore`, `c8 ignore`, `v8 ignore`, `node:coverage`, the `deno-coverage-ignore` family / `@jest-environment(-options)`, `@vitest-environment(-options)`, `@module-tag` (Vitest 4+) / `Stryker disable/restore` / `type-coverage:ignore-line/-next-line` / `ts-prune-ignore-next`
|
|
187
|
+
- **Bundlers / runtimes**: webpack and turbopack magic comments such as `webpackChunkName:` / `@vite-ignore` / `#__PURE__`, `@__NO_SIDE_EFFECTS__`, `@__INLINE__`, `@__KEY__`, `@__MANGLE_PROP__` (terser/rollup annotations) / `// @bun` (Bun) / `@refresh reset/skip/reload/jsx-skip` (react-refresh / solid-refresh) / `million-ignore` / `nx-ignore-next-line` (Nx) / `@unocss-include/-ignore/-ide-include/-skip-start/-skip-end` / `@next-codemod-error/-ignore` (Next.js) / `/* GraphQL */`, `/* HTML */` tag comments / `//# sourceMappingURL=`, `//# sourceURL=` / `@jsx`-family pragmas (Deno's `@jsxImportSourceTypes` included)
|
|
187
188
|
- **Security / static analysis**: `NOSONAR` (SonarQube) / `nosemgrep` (Semgrep) / `lgtm[...]`, `codeql[...]` (CodeQL) / `skipcq` (DeepSource) / `deepcode ignore` (Snyk Code) / `no-dd-sa`, `datadog-disable` (Datadog) / `gitleaks:allow` / `trufflehog:ignore` / `pragma: allowlist secret` (detect-secrets)
|
|
188
189
|
- **Spell checkers**: the `cspell:` family (including the `cSpell:`, `spell-checker:`, `spellchecker:` aliases), `LocalWords` / `codespell:ignore`
|
|
189
|
-
- **Editors / IDEs**: `#region`, `#endregion` / `noinspection`, `<editor-fold>`, `language=` (JetBrains) / `ReSharper disable/restore`
|
|
190
|
+
- **Editors / IDEs**: `#region`, `#endregion`, `// region` (VS Code / JetBrains) / `noinspection`, `//file:noinspection`, `<editor-fold>`, `language=` (JetBrains) / `ReSharper disable/restore`
|
|
191
|
+
|
|
192
|
+
The prettier rules copy prettier's own implementation: `prettier-ignore` is an exact match on the trimmed comment body (JS/TS has no `prettier-ignore-start`/`-end`, so those stay ordinary comments), the `@format`-family pragmas go through the same docblock parsing as jest-docblock (the file's first block comment only, `@` at the start of a line, spaces only before it), `/** @type */` and `/** @satisfies */` are the type-cast comments whose following parentheses prettier keeps (and which tsc honours in JavaScript), and `@flow`/`@noflow` in the leading comments is what switches its babel parser to Flow syntax. The test suite cross-checks these rules against the real prettier.
|
|
193
|
+
|
|
194
|
+
The TypeScript rules follow both tsc 6 (the JavaScript compiler) and tsc 7 (the Go port). `//// @ts-ignore` and a `/// <reference types="node">` without its closing `/>` are live to tsc 7 alone, and an `@ts-ignore` behind a no-break space after `//` to tsc 6 alone; all of them count as directives. The test suite cross-checks these rules against the real tsc 6 as well.
|
|
190
195
|
|
|
191
196
|
## Using it as a library
|
|
192
197
|
|
package/README.md
CHANGED
|
@@ -150,7 +150,8 @@ ts-comment-scanner --remove --remove-directives --remove-legal src
|
|
|
150
150
|
- `@ts-expect-error` / `eslint-disable` などの指示子は、削除するとビルドやリントが壊れるため**デフォルトで保持**
|
|
151
151
|
- `/*! ... */` や `@license` / `@preserve` / `@copyright`、`SPDX-License-Identifier:` / `SPDX-FileCopyrightText:` タグを含む法的コメントも**デフォルトで保持**
|
|
152
152
|
- `@ts-expect-error` や `eslint-disable-next-line` など**次行を対象にする指示子の直下の行構造を保持**: 削除すると行が消えて指示子の適用先がずれる場合(コメントだけの行など)、その行のコメントは削除せずに保持
|
|
153
|
-
-
|
|
153
|
+
- **指示子が対象を探す途中のコメントも保持**: 空行と `//` 行を読み飛ばして対象行を探す tsc の `@ts-ignore`/`@ts-expect-error` では、tsc 6・tsc 7 がそれぞれ読み飛ばせずに止まる最初の行(ブロックコメントの行など)を保持。対象の直前にある最後のコメントでのみ有効な指示子(`@deno-types`・`/* GraphQL */`・ESLint の `// falls through` など)では、指示子と対象の間のコメントをすべて保持
|
|
154
|
+
- **位置依存ディレクティブを削除で有効化しない**: prettier の `@format`/`@prettier` pragma や Deno の `deno-coverage-ignore-file`(ファイル最初のコメントでのみ有効)、Bun の `// @bun`(ファイル先頭か shebang の次の行でのみ有効)が、手前のコメント削除によって保持コメント内で新たに効き始める場合は、その手前のコメントも保持
|
|
154
155
|
- ブロックコメント除去でトークンが結合してしまう位置には空白を挿入(`a/* x */b` → `a b`)
|
|
155
156
|
- コメントだけの行は行ごと削除、行末コメントは手前の空白ごと削除
|
|
156
157
|
- 削除後のソースを再スキャンし、残ったコメントが保持対象とディレクティブの意味ごと一致することを検証。想定外の結果になる場合はファイルを変更せずエラー報告
|
|
@@ -177,16 +178,20 @@ ts-comment-scanner --fail-on-comment --diff a1b2c3..d4e5f6 src
|
|
|
177
178
|
|
|
178
179
|
### 検出できるディレクティブ(抜粋)
|
|
179
180
|
|
|
180
|
-
各ディレクティブは実ツールのパーサー実装(正規表現・文字列比較)
|
|
181
|
+
各ディレクティブは実ツールのパーサー実装(正規表現・文字列比較)に合わせて判定されます。ツールやバージョンによって解釈が分かれる場合は、いずれかが有効とみなす形をすべてディレクティブとして扱います(削除時は保持側に倒れます)。
|
|
181
182
|
|
|
182
|
-
- **コンパイラ / 型**: `@ts-ignore` `@ts-expect-error` `@ts-nocheck` `@ts-check` / `/// <reference>` / `@ts-strict-ignore`・`@ts-strict`(typescript-strict-plugin) / `@deno-types=`・`@ts-types=`・`@ts-self-types=`(Deno)
|
|
183
|
-
- **リンター**: `eslint-disable` 系・`eslint-env`・`/* global */`・`/* exported
|
|
184
|
-
- **フォーマッタ**: `prettier-ignore`・`@format`/`@prettier`/`@noformat`/`@noprettier` pragma / `oxfmt-ignore` / `dprint-ignore`・`dprint-ignore-file` / `organize-imports-ignore` / `beautify ignore/preserve`(レガシー)
|
|
185
|
-
- **カバレッジ / テスト**: `istanbul ignore`・`c8 ignore`・`v8 ignore`・`node:coverage` / `@jest-environment(-options)`・`@vitest-environment(-options)`・`@module-tag`(Vitest 4) / `Stryker disable/restore` / `type-coverage:ignore-line/-next-line` / `ts-prune-ignore-next`
|
|
186
|
-
- **バンドラ / ランタイム**: `webpackChunkName:` などの webpack・turbopack マジックコメント / `@vite-ignore` / `#__PURE__`・`@__NO_SIDE_EFFECTS__`・`@__INLINE__`・`@__KEY__`・`@__MANGLE_PROP__`(terser/rollup 注釈) / `// @bun`(Bun) / `@refresh reset/skip/reload`(react-refresh / solid-refresh) / `million-ignore` / `nx-ignore-next-line`(Nx) / `@unocss-include/-ignore/-skip-start/-skip-end` / `@next-codemod-error/-ignore`(Next.js) / `/* GraphQL */`・`/* HTML */` タグコメント / `//# sourceMappingURL=`・`//# sourceURL=` / `@jsx` 系プラグマ
|
|
183
|
+
- **コンパイラ / 型**: `@ts-ignore` `@ts-expect-error` `@ts-nocheck` `@ts-check`(tsc 6・tsc 7、TypeScript ファイルを検査する Flow) / `/// <reference>` 系 / `@ts-strict-ignore`・`@ts-strict`(typescript-strict-plugin の CLI と IDE プラグイン) / `@deno-types=`・`@ts-types=`・`@ts-self-types=`(Deno)
|
|
184
|
+
- **リンター**: `eslint-disable` 系・`eslint-env`・`/* global */`・`/* exported */`・`// falls through`(no-fallthrough)・`// no default`(default-case。いずれも ESLint が読む `case`・`default`・`}` の直前のみ) / React Compiler が読む `eslint-disable … react-hooks/…`・`$FlowFixMe[react-rule…]` / `oxlint-disable` 系 / `biome-ignore` 系・`rome-ignore` / `deno-lint-ignore` 系 / `stylelint-disable`・`stylelint-disable-line`・`stylelint-disable-next-line`・`stylelint-enable`(stylelint) / `@flow`・`@noflow`・`$FlowFixMe` 系・`flowlint` 系(Flow) / `tslint:`・`jshint`・`jscs:`・`jslint`(レガシー)
|
|
185
|
+
- **フォーマッタ**: `prettier-ignore`・`@format`/`@prettier`/`@noformat`/`@noprettier` pragma・`/** @type */`/`/** @satisfies */` 型キャストコメント(prettier) / `oxfmt-ignore` / `dprint-ignore`・`dprint-ignore-file`・`deno-fmt-ignore`・`deno-fmt-ignore-file`(dprint / deno fmt) / `organize-imports-ignore`・`sort-imports-ignore` / `beautify ignore/preserve`(レガシー)
|
|
186
|
+
- **カバレッジ / テスト**: `istanbul ignore`・`c8 ignore`・`v8 ignore`・`node:coverage`・`deno-coverage-ignore` 系 / `@jest-environment(-options)`・`@vitest-environment(-options)`・`@module-tag`(Vitest 4 以降) / `Stryker disable/restore` / `type-coverage:ignore-line/-next-line` / `ts-prune-ignore-next`
|
|
187
|
+
- **バンドラ / ランタイム**: `webpackChunkName:` などの webpack・turbopack マジックコメント / `@vite-ignore` / `#__PURE__`・`@__NO_SIDE_EFFECTS__`・`@__INLINE__`・`@__KEY__`・`@__MANGLE_PROP__`(terser/rollup 注釈) / `// @bun`(Bun) / `@refresh reset/skip/reload/jsx-skip`(react-refresh / solid-refresh) / `million-ignore` / `nx-ignore-next-line`(Nx) / `@unocss-include/-ignore/-ide-include/-skip-start/-skip-end` / `@next-codemod-error/-ignore`(Next.js) / `/* GraphQL */`・`/* HTML */` タグコメント / `//# sourceMappingURL=`・`//# sourceURL=` / `@jsx` 系プラグマ(Deno の `@jsxImportSourceTypes` を含む)
|
|
187
188
|
- **セキュリティ / 静的解析**: `NOSONAR`(SonarQube) / `nosemgrep`(Semgrep) / `lgtm[...]`・`codeql[...]`(CodeQL) / `skipcq`(DeepSource) / `deepcode ignore`(Snyk Code) / `no-dd-sa`・`datadog-disable`(Datadog) / `gitleaks:allow` / `trufflehog:ignore` / `pragma: allowlist secret`(detect-secrets)
|
|
188
189
|
- **スペルチェック**: `cspell:` 系(`cSpell:`・`spell-checker:`・`spellchecker:` 別名込み)・`LocalWords` / `codespell:ignore`
|
|
189
|
-
- **エディタ / IDE**: `#region`・`#endregion` / `noinspection`・`<editor-fold>`・`language=`(JetBrains) / `ReSharper disable/restore`
|
|
190
|
+
- **エディタ / IDE**: `#region`・`#endregion`・`// region`(VS Code / JetBrains) / `noinspection`・`//file:noinspection`・`<editor-fold>`・`language=`(JetBrains) / `ReSharper disable/restore`
|
|
191
|
+
|
|
192
|
+
prettier 関連のルールは prettier 本体の実装をそのまま写しています。`prettier-ignore` はコメント本文を trim した完全一致(JS/TS に `prettier-ignore-start`/`-end` はなく、普通のコメント扱い)、`@format` 系 pragma は jest-docblock と同じ docblock 解析(ファイル最初のブロックコメントのみ、`@` は行頭、行頭の空白はスペースのみ)、`/** @type */`・`/** @satisfies */` は prettier が直後の括弧を保持する型キャストコメント(tsc も JavaScript で解釈)、先頭コメントの `@flow`/`@noflow` は babel パーサーを Flow 構文に切り替える判定です。テストスイートはこれらを実際の prettier と突き合わせて検証しています。
|
|
193
|
+
|
|
194
|
+
TypeScript 関連のルールは tsc 6(JavaScript 実装)と tsc 7(Go 移植版)の両方の実装に合わせています。たとえば `//// @ts-ignore` や閉じ `/>` のない `/// <reference types="node">` は tsc 7 だけが、`//` の直後に NBSP を挟んだ `@ts-ignore` は tsc 6 だけが有効とみなしますが、いずれもディレクティブとして扱います。テストスイートは実際の tsc 6 とも突き合わせて検証しています。
|
|
190
195
|
|
|
191
196
|
## ライブラリとして使う
|
|
192
197
|
|
package/dist/args.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type OutputFormat = "text" | "json" | "github";
|
|
2
2
|
export type DirectiveMode = "include" | "skip" | "only";
|
|
3
3
|
export interface CliOptions {
|
|
4
4
|
paths: string[];
|
|
@@ -20,4 +20,5 @@ export declare class UsageError extends Error {
|
|
|
20
20
|
constructor(message: string);
|
|
21
21
|
}
|
|
22
22
|
export declare function parseArgs(argv: string[]): CliOptions;
|
|
23
|
+
export {};
|
|
23
24
|
//# 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,
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAC/C,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,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,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,CAkKpD"}
|
package/dist/directives.d.ts
CHANGED
|
@@ -9,9 +9,27 @@ export interface DirectivePlacement {
|
|
|
9
9
|
header: boolean;
|
|
10
10
|
/** The comment is the file's first comment, preceded only by whitespace (or a shebang). */
|
|
11
11
|
firstComment: boolean;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* The comment starts where Bun looks for its `// @bun` marker: the very
|
|
14
|
+
* first character of the file, or the first character after the line break
|
|
15
|
+
* that ends a leading `#!` line (see bunMarkerOffset).
|
|
16
|
+
*/
|
|
13
17
|
fileStart: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The token that follows the comment past any further comments (`case`,
|
|
20
|
+
* `}`, an identifier, ...), or `""` when only comments follow. ESLint's
|
|
21
|
+
* switch-clause comments (`// falls through`, `// no default`) count only in
|
|
22
|
+
* front of certain tokens. Left out, any token is assumed.
|
|
23
|
+
*/
|
|
24
|
+
nextToken?: string;
|
|
14
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The offset at which Bun reads its `// @bun` marker (`has_bun_pragma` in its
|
|
28
|
+
* parser): the start of the text, or, when the text opens with a `#!` line,
|
|
29
|
+
* the character after that line's first `\n` — -1 when the shebang line is
|
|
30
|
+
* the whole text, leaving no place for the marker.
|
|
31
|
+
*/
|
|
32
|
+
export declare function bunMarkerOffset(text: string): number;
|
|
15
33
|
/**
|
|
16
34
|
* Returns the canonical name of the compiler/linter/tooling directive the
|
|
17
35
|
* comment represents, or `undefined` when the comment is an ordinary comment.
|
|
@@ -24,14 +42,14 @@ export interface DirectivePlacement {
|
|
|
24
42
|
*/
|
|
25
43
|
export declare function detectDirective(kind: CommentKind, text: string, placement?: DirectivePlacement): string | undefined;
|
|
26
44
|
/**
|
|
27
|
-
* The position-dependent directives (prettier's first-comment pragmas,
|
|
28
|
-
* file-start marker) the comment carries that are
|
|
29
|
-
* placement, sorted. Unlike detectDirective — which
|
|
30
|
-
* name — this sees through masking: an eslint config
|
|
31
|
-
* `@format` pragma, and whether that pragma is live
|
|
32
|
-
* name an earlier rule already claimed. Only
|
|
33
|
-
* gates are consulted; header-gated directives
|
|
34
|
-
* the comments around them change.
|
|
45
|
+
* The position-dependent directives (prettier's first-comment pragmas, Deno's
|
|
46
|
+
* coverage file pragma, Bun's file-start marker) the comment carries that are
|
|
47
|
+
* active at the given placement, sorted. Unlike detectDirective — which
|
|
48
|
+
* reports one canonical name — this sees through masking: an eslint config
|
|
49
|
+
* block can also hold a `@format` pragma, and whether that pragma is live
|
|
50
|
+
* must not hide behind the name an earlier rule already claimed. Only
|
|
51
|
+
* first-comment and file-start gates are consulted; header-gated directives
|
|
52
|
+
* cannot change activation when the comments around them change.
|
|
35
53
|
*/
|
|
36
54
|
export declare function activePositionalDirectives(kind: CommentKind, text: string, placement: DirectivePlacement): string[];
|
|
37
55
|
/**
|
package/dist/directives.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../src/directives.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../src/directives.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA+hB9C;;;;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;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIpD;AA6FD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,kBAAkB,GAAG,MAAM,GAAG,SAAS,CAgCnH;AAyCD;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAOnH;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIpD"}
|