@redocly/recheck 0.2.0 → 0.3.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 +28 -11
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/run.d.ts +2 -0
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +19 -5
- package/dist/commands/run.js.map +1 -1
- package/dist/core/rule-filters.d.ts +17 -0
- package/dist/core/rule-filters.d.ts.map +1 -1
- package/dist/core/rule-filters.js +64 -0
- package/dist/core/rule-filters.js.map +1 -1
- package/dist/data/proper-nouns.d.ts.map +1 -1
- package/dist/data/proper-nouns.js +14 -175
- package/dist/data/proper-nouns.js.map +1 -1
- package/dist/rules/scope/capitalization.d.ts.map +1 -1
- package/dist/rules/scope/capitalization.js +6 -4
- package/dist/rules/scope/capitalization.js.map +1 -1
- package/dist/rules/scope/title-case.d.ts +15 -11
- package/dist/rules/scope/title-case.d.ts.map +1 -1
- package/dist/rules/scope/title-case.js +65 -28
- package/dist/rules/scope/title-case.js.map +1 -1
- package/dist/scopes/sentences.d.ts +8 -0
- package/dist/scopes/sentences.d.ts.map +1 -1
- package/dist/scopes/sentences.js +11 -2
- package/dist/scopes/sentences.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ pnpm install
|
|
|
50
50
|
pnpm build
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
**Contributing to Recheck itself** (build-cache
|
|
53
|
+
**Contributing to Recheck itself** (build-cache problems, `pnpm parity`'s required `--corpus` flag, the `generate-examples.mjs`/`oxfmt` coupling) is covered in [CONTRIBUTING.md](CONTRIBUTING.md), not here — this README is for people adopting Recheck as a linter.
|
|
54
54
|
|
|
55
55
|
## Usage
|
|
56
56
|
|
|
@@ -79,6 +79,23 @@ node dist/cli.js run . --severity error
|
|
|
79
79
|
# Show all enabled rules (info and above)
|
|
80
80
|
node dist/cli.js run . --severity info
|
|
81
81
|
|
|
82
|
+
# Work one rule at a time. This helps you clear a large list of findings.
|
|
83
|
+
# Give the name that the report shows, or the full config key. Use the flag
|
|
84
|
+
# more than one time for more than one rule. A rule from a namespace other
|
|
85
|
+
# than `recheck/` keeps that namespace: use `google/passive-voice`.
|
|
86
|
+
node dist/cli.js run . --rule semantic-line-breaks
|
|
87
|
+
node dist/cli.js run . -r us-spelling -r recheck/oxford-comma
|
|
88
|
+
|
|
89
|
+
# ...and its inverse, to silence a rule you have already triaged
|
|
90
|
+
node dist/cli.js run . --exclude-rule semantic-line-breaks
|
|
91
|
+
|
|
92
|
+
# Use --rule with --fix to clear one rule's findings across all documents
|
|
93
|
+
node dist/cli.js run . --rule semantic-line-breaks --fix
|
|
94
|
+
|
|
95
|
+
# A name that matches no rule in your config is an error, not an empty run:
|
|
96
|
+
# a misspelled filter that reported "no issues" would look the same as a
|
|
97
|
+
# clean document set. The error message lists the rules your config loaded.
|
|
98
|
+
|
|
82
99
|
# Output formats (table is default)
|
|
83
100
|
node dist/cli.js run . --output table # Human-readable table (default)
|
|
84
101
|
node dist/cli.js run . --output json # Structured JSON for CI
|
|
@@ -996,7 +1013,7 @@ There is one exception. A rule may attach a milder severity to some of its own r
|
|
|
996
1013
|
- `recheck/markdoc-attributes` (mixed) — a missing required attribute, an enum or type violation, and a duplicate attribute report at `error`; an unknown attribute name, whether named or a stray positional value, always reports at `warn`. That `warn` is set per report by the rule itself, so it wins over the rule's configured severity: setting the rule to `severity: error` does not escalate those reports. Only `severity: 'off'` removes them, by disabling the rule.
|
|
997
1014
|
|
|
998
1015
|
**These rules only fire when Markdoc tokenization is also on.** Set `markdoc: true` (or the object form, see below) alongside `extends: [recheck/markdoc]`. Extending the preset without the flag validates, but prints a console warning that the four rules can never report. The flag stays an explicit opt-in because Liquid and Jinja templates use the same `{% %}` delimiters for unrelated syntax, so Recheck never assumes it.
|
|
999
|
-
- **`recheck/google`** — Google's developer documentation style guide (https://developers.google.com/style), CC BY 4.0, synced 2026-07-29. 99 rules covering heading/list/table/link structure, sentence-case headings, sentence length, voice and contractions, plain language, product naming, compound word forms, and inclusive/precise-language terminology — all derived from the *live* guide (see `packages/recheck/presets/google/PROVENANCE.md` for the rule -> source page -> quote -> verdict table, including everything considered and NOT shipped, and why). `extends: [recheck/google]` is a one-line adoption of Google's style; combine with `recheck/markdown` for full structural linting too. Rule ids are namespaced `google/<rule>` (not `recheck/<rule>`) so they never collide with the markdownlint-parity or other style-guide presets. Structural/mechanical rules (heading hierarchy, list mechanics, alt-text presence, sentence length) are `severity: error`; every word-choice, terminology, and punctuation-convention rule is `severity: warn`. See `packages/recheck/presets/google/sources.json` for the fetched-page hashes. **Adopting this preset has a real, measured performance cost — roughly 2.7× the standard `recheck/markdown`-only profile's lint time on a docs-sized
|
|
1016
|
+
- **`recheck/google`** — Google's developer documentation style guide (https://developers.google.com/style), CC BY 4.0, synced 2026-07-29. 99 rules covering heading/list/table/link structure, sentence-case headings, sentence length, voice and contractions, plain language, product naming, compound word forms, and inclusive/precise-language terminology — all derived from the *live* guide (see `packages/recheck/presets/google/PROVENANCE.md` for the rule -> source page -> quote -> verdict table, including everything considered and NOT shipped, and why). `extends: [recheck/google]` is a one-line adoption of Google's style; combine with `recheck/markdown` for full structural linting too. Rule ids are namespaced `google/<rule>` (not `recheck/<rule>`) so they never collide with the markdownlint-parity or other style-guide presets. Structural/mechanical rules (heading hierarchy, list mechanics, alt-text presence, sentence length) are `severity: error`; every word-choice, terminology, and punctuation-convention rule is `severity: warn`. See `packages/recheck/presets/google/sources.json` for the fetched-page hashes. **Adopting this preset has a real, measured performance cost — roughly 2.7× the standard `recheck/markdown`-only profile's lint time on a docs-sized document set** — see [Performance](#performance) below (Phase 4) before turning it on in CI.
|
|
1000
1017
|
- **`recheck/microsoft`** — the Microsoft Writing Style Guide (https://learn.microsoft.com/en-us/style-guide/welcome/), CC BY 4.0 (via the guide's backing GitHub repository's LICENSE file — no `learn.microsoft.com` page states the licence itself, see `packages/recheck/presets/microsoft/PROVENANCE.md`), synced 2026-07-30. 93 rules covering heading/list/table/alt-text structure, the guide's own numeric thresholds (paragraph length, list length, comma density, alt-text length), its signature "use contractions" rule, US spelling, bias-free and people-first terminology, and a large A-Z terminology word list — all derived from the *live* guide and checked against four independent verification passes (~490 rules/entries across ~340 page fetches), with every Tier-1 pair anchored or demoted to detection-only wherever it was found capable of rewriting correct prose. Rule ids are namespaced `microsoft/<rule>`. Structural rules and the A-Z word list's three unconditional tiers are `severity: error`; voice, punctuation-convention, and UI-terminology rules are `severity: warn`. Audience-conditional and UI-conditional entries (Microsoft's own "Tier 4") are never enforced, and developer-audience carve-outs relevant to API documentation (`header`, `context menu`, `disk`, `directory`) are excluded rather than misfiring on Redocly's own docs — see `packages/recheck/presets/microsoft/PROVENANCE.md` for the full table, every excluded candidate, and why. Unlike `recheck/google` (which allows `click`), this preset bans all input-specific UI verbs (`click`, `press`, `hit`) in favor of `select` — the sharpest divergence between the two guides. See `packages/recheck/presets/microsoft/sources.json` for the fetched-page hashes.
|
|
1001
1018
|
- **`recheck/inclusive-language`** — composable, guide-agnostic: the *intersection* of `recheck/google` and `recheck/microsoft`'s inclusive/bias-free/ableist/accessibility content — terminology both flagship guides independently state should be avoided (`slave`, `master/slave`, `blacklist`/`whitelist`, `DMZ`, `grayed-out`, `he/she`, `normal person`/`healthy person`, `suffering from`/`victim of`, `differently abled`, `crippled`, `nuke`). All `warn` severity, all detection-only. Needed no new web fetch — every term was already confirmed against a live page by five existing verification reports; see `packages/recheck/presets/inclusive-language/PROVENANCE.md` for the report → row → term table and every single-guide term left out on purpose. Layer it onto either flagship or onto `recheck/prose`: `extends: [recheck/google, recheck/inclusive-language]`. **Because it's built as an intersection, every one of its 11 rules is already shipped by at least one flagship's own preset** (measured: 7 of 11 duplicate a `google/*` finding on the same span when stacked onto `recheck/google` alone, 6 of 11 duplicate a `microsoft/*` finding when stacked onto `recheck/microsoft` alone — see `packages/recheck/presets/inclusive-language/PROVENANCE.md`'s "Duplicate-finding audit"). Its full, zero-duplicate value is realized standalone, with `recheck/prose`, or on a project using neither flagship; stacked onto exactly one flagship it still fills that flagship's own gaps, but expect a majority of its findings to be reported twice.
|
|
1002
1019
|
- **`recheck/plain-language`** — composable, derived from the *live* US federal plain-language guidance (`digital.gov/guides/plain-language`; public domain, no attribution constraint). Smaller than a first read of the old `plainlanguage.gov` site would suggest: that site is now dead and redirects to a much thinner overview, so there's no sentence-length or readability-`metric` rule (`metric` stays a documented [opt-in](#opt-in-prose-assertions), unchanged) — only paragraph length (the one family with real, quotable numbers), filler/wordy phrases, complex-word substitutes, redundant pairs, double negatives, and jargon-to-plain examples. **`shall` is never flagged** — it's a defined RFC 2119 normative keyword used throughout specs and API docs, exactly what Recheck lints; `implement` and `command` carry the identical technical-sense collision and are excluded the same way. All `warn`/`error` (paragraph-length ceiling only) severity, all detection-only. `in order to` and `utilize`/`utilization` are deliberately NOT shipped despite being live, verbatim guide content — both flagships already ship the identical pair, so keeping them here would only ever produce a duplicate finding, never new coverage (measured: this cut duplicate findings on the same fixture from 6 to 3 against `recheck/google`, and from 5 to 3 against `recheck/microsoft`). The 3 that remain are an accepted paragraph-length overlap with `recheck/microsoft` (two independently-sourced numbers, not the same fact restated) and a coincidental substring collision with `use-contractions`, not content duplication. See `packages/recheck/presets/plain-language/PROVENANCE.md` for every rule's source quote, every family considered and left out, and the full duplicate-finding audit.
|
|
@@ -1199,7 +1216,7 @@ Token-rule options aren't individually schema-validated, so an option name a rul
|
|
|
1199
1216
|
|
|
1200
1217
|
### Parity with markdownlint
|
|
1201
1218
|
|
|
1202
|
-
The 53 ported rules are checked against upstream markdownlint by a differential harness (`pnpm parity`, `benchmarks/parity/run-parity.mjs`): the harness lints the same real-world
|
|
1219
|
+
The 53 ported rules are checked against upstream markdownlint by a differential harness (`pnpm parity`, `benchmarks/parity/run-parity.mjs`): the harness lints the same real-world document set with both Recheck (via a config translated from markdownlint's option surface) and markdownlint itself, then set-diffs the findings. As of this writing it reports **zero unexplained differences** across:
|
|
1203
1220
|
|
|
1204
1221
|
- `mdn-content` (MDN Web Docs, ~14.5k files)
|
|
1205
1222
|
- `electron` (Electron's docs + repo markdown)
|
|
@@ -1207,7 +1224,7 @@ The 53 ported rules are checked against upstream markdownlint by a differential
|
|
|
1207
1224
|
|
|
1208
1225
|
on both the `default` profile (full `recheck/markdown` preset vs. markdownlint `{ default: true }`) and a `rebilly` profile (a real third-party `.markdownlint.yaml` translated to Recheck config). A small, explicitly documented allowlist (`benchmarks/parity/allowlist.json`) covers the one known permanent engine-surface gap — inline `markdownlint-disable` directives (see [Known differences](#known-differences-from-markdownlint) above) — scoped to the exact rules it can affect (MD010, MD011, MD033, MD059). Everything else matches exactly.
|
|
1209
1226
|
|
|
1210
|
-
**`pnpm parity` requires `--corpus`** — running it bare exits `2` with a usage error (`Usage: node benchmarks/parity/run-parity.mjs --corpus <name> [--profile default|rebilly] [--rules MD001,MD013]`) rather than running against a default
|
|
1227
|
+
**`pnpm parity` requires `--corpus`** — running it bare exits `2` with a usage error (`Usage: node benchmarks/parity/run-parity.mjs --corpus <name> [--profile default|rebilly] [--rules MD001,MD013]`) rather than running against a default document set. Always pass a document-set name, e.g. `pnpm parity --corpus monorepo-docs --profile default`.
|
|
1211
1228
|
|
|
1212
1229
|
## GitHub Actions Integration
|
|
1213
1230
|
|
|
@@ -1259,10 +1276,10 @@ This creates both inline file annotations AND summary comments when combined wit
|
|
|
1259
1276
|
|
|
1260
1277
|
Recheck's file-first, parse-once architecture is benchmarked directly against `markdownlint`'s own library API (`benchmarks/run-markdownlint.mjs`) on the same corpora, using `pnpm bench` (see `benchmarks/bench.mjs`):
|
|
1261
1278
|
|
|
1262
|
-
- **Phase 1** (10 native scope rules vs. markdownlint's default rules, `monorepo-docs`
|
|
1279
|
+
- **Phase 1** (10 native scope rules vs. markdownlint's default rules, `monorepo-docs` document set, 953 files): recheck **0.91×** markdownlint's median time (3219ms vs. 3521ms) — see `benchmarks/results/phase1-ast-core.json` / `baseline-markdownlint.json`.
|
|
1263
1280
|
- **Phase 2** (all 53 markdownlint-parity rules via `extends: [recheck/markdown]` vs. markdownlint's `{ default: true }`, equivalent rule sets):
|
|
1264
1281
|
- `monorepo-docs` (954 files): recheck 4468ms vs. markdownlint 3755ms — **1.19×**.
|
|
1265
|
-
- `mdn-content` (14,515 files, real-world OSS
|
|
1282
|
+
- `mdn-content` (14,515 files, a real-world OSS document set): recheck 41839ms vs. markdownlint 34548ms — **1.21×**.
|
|
1266
1283
|
|
|
1267
1284
|
Both Phase 2 numbers sit comfortably inside the ±40% parity gate (recheck's median must fall within `[0.6×, 1.4×]` of markdownlint's on an equivalent rule set) enforced by:
|
|
1268
1285
|
|
|
@@ -1273,21 +1290,21 @@ pnpm bench --subject benchmarks/run-markdownlint.mjs --corpus monorepo-docs --re
|
|
|
1273
1290
|
|
|
1274
1291
|
Recheck trades a bit of the Phase 1 constant-factor lead for full rule-count parity (53 rules vs. 10) — still within budget, and the shared AST-parse-once architecture means adding prose/style rules on top costs little extra, since markdown structure parsing is already paid for.
|
|
1275
1292
|
|
|
1276
|
-
- **Phase 3** (prose profile — the standard Phase 2 rule set vs. that same set plus the Vale-parity prose additions, `monorepo-docs`
|
|
1277
|
-
- Standard profile (`recheck-mdl-preset.yaml`, `extends: [recheck/markdown]`, 53 rules, `run-recheck-mdl-preset.mjs`, 965 files): **4072ms** median — **-8.9% vs the Phase 2 recording** (`phase2-parity-recheck`, 4468ms, 954 files), i.e. no regression from the Phase 3 rule-registry additions, since the standard profile doesn't exercise any of them (the small speedup is run-to-run variance plus the
|
|
1293
|
+
- **Phase 3** (prose profile — the standard Phase 2 rule set vs. that same set plus the Vale-parity prose additions, `monorepo-docs` document set, the same set on both sides):
|
|
1294
|
+
- Standard profile (`recheck-mdl-preset.yaml`, `extends: [recheck/markdown]`, 53 rules, `run-recheck-mdl-preset.mjs`, 965 files): **4072ms** median — **-8.9% vs the Phase 2 recording** (`phase2-parity-recheck`, 4468ms, 954 files), i.e. no regression from the Phase 3 rule-registry additions, since the standard profile doesn't exercise any of them (the small speedup is run-to-run variance plus the document-set size difference, not an optimization claim).
|
|
1278
1295
|
- Prose profile (`recheck-prose-bench.yaml`, `extends: [recheck/markdown, recheck/prose]` plus one opt-in `occurrence` rule and one opt-in `conditional` rule, 58 rules, `run-recheck-prose.mjs`, same 965 files): **4547ms** median — **+11.7%** vs. the standard profile above, for the five added prose/scope rules (`repetition`, `consistency`, `capitalization`, and the two opt-ins). Comfortably under the "investigate if >2x standard" threshold; no pathological per-rule cost found. There is no hard pass/fail gate for this profile (new profile, first recording) — these numbers establish its baseline.
|
|
1279
1296
|
- Measured 2026-07-27 (local time; the result JSONs record the UTC date `2026-07-28`, so the file dates and this measurement date differ by design, not by error) at commit `27a8b6feb10` (immediately prior to the commit that added this benchmark profile), on an Apple M2 Max / Darwin 24.6.0 / Node v23.7.0 machine; single 3-run session, not a statistically rigorous multi-session average — treat the deltas as directional, not precise. `pnpm bench --subject <script> --corpus monorepo-docs --runs 3 --record <label>` (median of 3 timed runs after 1 warm-up); recorded to `benchmarks/results/phase3-prose-standard.json` / `phase3-prose-profile.json`. A `--corpus self` (2-file) smoke pair recorded to `phase3-prose-standard-self.json` / `phase3-prose-profile-self.json` proves the harness/subject-script mechanics end-to-end but isn't large enough to be a meaningful timing signal on its own.
|
|
1280
1297
|
|
|
1281
|
-
- **Phase 4** (refreshed standard/prose figures plus the new `recheck/google` profile, `monorepo-docs`
|
|
1298
|
+
- **Phase 4** (refreshed standard/prose figures plus the new `recheck/google` profile, `monorepo-docs` document set, the same set across all three, 968 files — the document set grew by 3 files since the Phase 3 recording):
|
|
1282
1299
|
- Standard profile (same config as Phase 2/3, `recheck-mdl-preset.yaml`, 53 rules): **4350ms** median (runs 4341/4350/4369ms — 28ms spread, 0.6% of median: a tight, trustworthy measurement). This refreshes — and for current comparisons supersedes — Phase 3's `4072ms`/965-file recording; the ~7% difference is within normal session-to-session noise (different process/cache/scheduler state), not a regression, and there is still no rule-registry change that would affect this profile.
|
|
1283
1300
|
- Prose profile (same config as Phase 3, `recheck-prose-bench.yaml`, 58 rules): **4801ms** median (runs 4599/4801/4840ms — 241ms spread, 5.0% of median) — **+10.4%** vs. the refreshed standard profile above. This is the requested refresh of the Phase 3 prose figures, which the `capitalization` default's AP-title-case → sentence-case change (2026-07-29, see [`extends` presets](#extends-presets) below) made marginally stale, since this profile's `capitalization` rule is exactly what that change touched. The new delta (+10.4%) is close to Phase 3's original (+11.7%); given the 5.0% run-to-run spread observed here, treat both numbers as directionally consistent, not as proof of a precise change in cost — same posture Phase 3 itself took.
|
|
1284
1301
|
- **`recheck/google` profile** (new — `recheck-google-bench.yaml`, `extends: [recheck/markdown, recheck/google]`, 152 rules total: the same 53-rule structural set plus all 99 rules `recheck/google` ships, `run-recheck-google.mjs`, same 968 files): **11792ms** median (runs 11628/11792/12164ms — 536ms spread, 4.5% of median).
|
|
1285
1302
|
- **This profile is substantially more expensive than either profile above: roughly 2.7× (~+171%) the standard profile's median time**, a materially different result from the ~1.1–1.2× range Phase 2/3 established for the markdownlint-parity and Vale-parity workloads. This is recorded as a **new baseline on its own terms, not a regression against the standard-profile's ±40% parity gate** — that gate applies only to `recheck/markdown` vs. markdownlint's equivalent rule set (Phase 2, unaffected by this preset's addition) and was never meant to bound a ~99-rule prose-preset workload layered on top of it. The number is reported as measured, without tuning the preset to improve it.
|
|
1286
1303
|
- The ~171% delta is far larger than the ≤5% run-to-run spread measured on all three profiles this session, so the *direction and rough magnitude* of "the Google preset costs several times more than the structural set alone" is trustworthy; the precise "171%" is not — this is a single 3-run-median session on one developer machine, not a statistically rigorous benchmark. Read it as "roughly 2.5–3×," not as a number with two decimal digits of meaning.
|
|
1287
|
-
- **What this means for adopters**: turning on `extends: [recheck/google]` roughly triples per-run lint time on a docs-sized
|
|
1304
|
+
- **What this means for adopters**: turning on `extends: [recheck/google]` roughly triples per-run lint time on a docs-sized document set (968 files: ~4.3s → ~11.8s). That is a real, user-facing cost, stated here so it is visible before adoption rather than discovered later in CI — projects sensitive to CI duration should budget for it explicitly (e.g., a separate, non-blocking job, or a scheduled run) rather than assuming `recheck/google` is free to layer on top of `recheck/markdown`.
|
|
1288
1305
|
- Measured 2026-07-30 at commit `7c50caaaf05` (immediately prior to the commit that adds this benchmark profile), on the same Apple M2 Max / Darwin 24.6.0 / Node v23.7.0 machine as Phase 1–3; single 3-run session per profile (1 warm-up + 3 timed runs), same caveats as Phase 3 — treat deltas as directional, not precise. `pnpm bench --subject <script> --corpus monorepo-docs --runs 3 --record <label>`; recorded to `benchmarks/results/phase4-google-standard.json` / `phase4-google-prose-refresh.json` / `phase4-google-profile.json`.
|
|
1289
1306
|
|
|
1290
|
-
- **Markdoc parse cost** (`parseMarkdown` in isolation — no rules, no config validation — flag off vs. flag on, `monorepo-docs`
|
|
1307
|
+
- **Markdoc parse cost** (`parseMarkdown` in isolation — no rules, no config validation — flag off vs. flag on, `monorepo-docs` document set, 981 files, `run-recheck-parse.mjs` / `run-recheck-parse-markdoc.mjs`): flag off **2825ms** median (runs 2784/2825/2966ms) vs. flag on **2896ms** median (runs 2864/2896/3101ms) — **+2.5%**. That gap is smaller than the ~240–280ms run-to-run spread on either side, so read it as "no measurable parse-time cost from turning `markdoc: true` on" rather than a precise 2.5% overhead; the number is reported as measured. This is its own baseline row — there is no earlier "parse only, flag off" recording to compare against — and it is deliberately not gated against the ±40% markdownlint-parity budget above, which covers the 53-rule structural comparison and never sets this flag. Measured 2026-08-02 at commit `db8df4378ff`, on the same Apple M2 Max / Darwin 24.6.0 / Node v23.7.0 machine as the phases above; single 3-run session per side. `pnpm bench --subject benchmarks/run-recheck-parse.mjs --corpus monorepo-docs --runs 3 --record <label>` (and the `-markdoc` sibling script for the flag-on side); recorded to `benchmarks/results/markdoc-parse-cost-flag-off.json` / `markdoc-parse-cost-flag-on.json`.
|
|
1291
1308
|
- ✅ **Scalable**: File-first architecture with rule indexing optimizes for large repositories; the same micromark AST backs both markdown-structure rules and prose-scope rules, so combining both rule families costs one parse, not two.
|
|
1292
1309
|
|
|
1293
1310
|
## Dependencies
|
package/dist/cli.js
CHANGED
|
@@ -49,6 +49,17 @@ function createYargsInterface() {
|
|
|
49
49
|
.option('tags', {
|
|
50
50
|
type: 'array',
|
|
51
51
|
describe: 'Filter by tags',
|
|
52
|
+
})
|
|
53
|
+
.option('rule', {
|
|
54
|
+
alias: 'r',
|
|
55
|
+
type: 'array',
|
|
56
|
+
string: true,
|
|
57
|
+
describe: 'Run only these rules (repeatable; accepts the full key or the short name shown in output)',
|
|
58
|
+
})
|
|
59
|
+
.option('exclude-rule', {
|
|
60
|
+
type: 'array',
|
|
61
|
+
string: true,
|
|
62
|
+
describe: 'Run everything except these rules (repeatable)',
|
|
52
63
|
})
|
|
53
64
|
.option('stats', {
|
|
54
65
|
type: 'boolean',
|
|
@@ -90,6 +101,8 @@ function createYargsInterface() {
|
|
|
90
101
|
outputPath: argv['output-path'],
|
|
91
102
|
severity: argv.severity,
|
|
92
103
|
tags: argv.tags,
|
|
104
|
+
rules: argv.rule,
|
|
105
|
+
excludeRules: argv['exclude-rule'],
|
|
93
106
|
stats: argv.stats,
|
|
94
107
|
fix: argv.fix,
|
|
95
108
|
annotationsLimit: argv['annotations-limit'],
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,SAAS,oBAAoB;IAC3B,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,I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E;SACT,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,MAAM;IACnB,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,GAAG,CAAC,UAAU,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACvB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,mBAAmB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IAClG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/commands/run.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export interface RunOptions {
|
|
|
3
3
|
output?: 'table' | 'json' | 'sarif' | 'github-actions';
|
|
4
4
|
severity?: 'off' | 'info' | 'warn' | 'warning' | 'error';
|
|
5
5
|
tags?: (string | number)[];
|
|
6
|
+
rules?: string[];
|
|
7
|
+
excludeRules?: string[];
|
|
6
8
|
stats?: boolean;
|
|
7
9
|
fix?: boolean;
|
|
8
10
|
annotationsLimit?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,gBAAgB,CAAC;IACvD,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,YAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAkMzF"}
|
package/dist/commands/run.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as fs from 'fs/promises';
|
|
|
2
2
|
import * as pathModule from 'path';
|
|
3
3
|
import { red, green, yellow, cyan } from 'colorette';
|
|
4
4
|
import { findAndLoadConfig } from '../config/load.js';
|
|
5
|
-
import { applyFilters } from '../core/rule-filters.js';
|
|
5
|
+
import { applyFilters, UnknownRuleNameError } from '../core/rule-filters.js';
|
|
6
6
|
import { runRules, runRulesUntilStable } from '../core/runner.js';
|
|
7
7
|
import { generateReport, generateEmptyReport } from '../reporter/index.js';
|
|
8
8
|
import { buildSummary, printSummary } from '../reporter/summary.js';
|
|
@@ -31,10 +31,24 @@ export async function runCommand(path = '.', options) {
|
|
|
31
31
|
console.log(green(`✅ Configuration loaded successfully!`));
|
|
32
32
|
console.log(` Config file: ${result.configPath}`);
|
|
33
33
|
console.log(` Loaded ${result.rules.length} rule(s)`);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
let rulesToRun;
|
|
35
|
+
let disabledCount;
|
|
36
|
+
try {
|
|
37
|
+
({ filtered: rulesToRun, disabledCount } = applyFilters(result.rules, {
|
|
38
|
+
severity: options.severity,
|
|
39
|
+
tags: options.tags,
|
|
40
|
+
rules: options.rules,
|
|
41
|
+
excludeRules: options.excludeRules,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (error instanceof UnknownRuleNameError) {
|
|
46
|
+
console.log(red(`❌ ${error.message}`));
|
|
47
|
+
console.log(` Available: ${error.available.join(', ')}`);
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
38
52
|
if (disabledCount > 0) {
|
|
39
53
|
console.log(` Disabled ${disabledCount} rule(s) (severity: off)`);
|
|
40
54
|
}
|
package/dist/commands/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,UAAU,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,UAAU,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAE,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AAG,CAAC,mBAAmB,KAAK,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;YACxD,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,GAAG,CAAC,6BAA6B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAC7F,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QACxD,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,eAAe,CAAC,OAAmB;IAChD,MAAM,mBAAmB,CAAC;QACxB,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,OAAO;QACjC,SAAS,EAAE,OAAO,CAAC,KAAK;QACxB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,YAAY,GAAG,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACzC,MAAM,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACzE,CAAC;AACH,CAAC"}
|
|
@@ -2,7 +2,24 @@ import type { NormalizedRule } from '../types/index.js';
|
|
|
2
2
|
export interface FilterOptions {
|
|
3
3
|
severity?: 'off' | 'info' | 'warn' | 'warning' | 'error';
|
|
4
4
|
tags?: (string | number)[];
|
|
5
|
+
/** Run only these rules (see `matchesRuleName` for accepted spellings). */
|
|
6
|
+
rules?: string[];
|
|
7
|
+
/** Run everything except these rules. */
|
|
8
|
+
excludeRules?: string[];
|
|
5
9
|
}
|
|
10
|
+
export declare class UnknownRuleNameError extends Error {
|
|
11
|
+
readonly unknown: string[];
|
|
12
|
+
readonly available: string[];
|
|
13
|
+
constructor(unknown: string[], available: string[]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Restricts the run to the named rules. Unknown names throw rather than
|
|
17
|
+
* silently narrowing to nothing: a typo'd `--rule` that reported "no issues"
|
|
18
|
+
* would read exactly like a clean run.
|
|
19
|
+
*/
|
|
20
|
+
export declare function filterByRuleNames(rules: NormalizedRule[], names: string[]): NormalizedRule[];
|
|
21
|
+
/** Inverse of `filterByRuleNames`, with the same name matching and typo check. */
|
|
22
|
+
export declare function excludeByRuleNames(rules: NormalizedRule[], names: string[]): NormalizedRule[];
|
|
6
23
|
/**
|
|
7
24
|
* Filter out disabled rules (severity: 'off')
|
|
8
25
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-filters.d.ts","sourceRoot":"","sources":["../../src/core/rule-filters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"rule-filters.d.ts","sourceRoot":"","sources":["../../src/core/rule-filters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC3B,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE;IAF9B,YACW,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,MAAM,EAAE,EAI7B;CACF;AAkBD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAU5F;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAU7F;AAUD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG;IAC3D,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;CACvB,CAIA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,EAAE,CAS/F;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,cAAc,EAAE,CAIjG;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,aAAa,GACrB;IACD,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;CACvB,CAyBA"}
|
|
@@ -1,3 +1,60 @@
|
|
|
1
|
+
export class UnknownRuleNameError extends Error {
|
|
2
|
+
constructor(unknown, available) {
|
|
3
|
+
super(`no rule in this configuration matches ${unknown.map((n) => `"${n}"`).join(', ')}`);
|
|
4
|
+
Object.defineProperty(this, "unknown", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true,
|
|
8
|
+
value: unknown
|
|
9
|
+
});
|
|
10
|
+
Object.defineProperty(this, "available", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: available
|
|
15
|
+
});
|
|
16
|
+
this.name = 'UnknownRuleNameError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A rule matches a `--rule`/`--exclude-rule` value when the value equals its
|
|
21
|
+
* full config key (`recheck/us-spelling`) or its `shortName` -- the exact
|
|
22
|
+
* string the report prints, so you can filter by what you just read.
|
|
23
|
+
*
|
|
24
|
+
* `shortName` removes only the `recheck/` prefix (see config/validate.ts), so
|
|
25
|
+
* a rule from another namespace keeps that namespace: `google/passive-voice`
|
|
26
|
+
* stays `google/passive-voice`. Do not match on the last path segment
|
|
27
|
+
* instead. Preset rule keys share 20 bare names -- `no-trailing-punctuation`
|
|
28
|
+
* exists in `recheck/`, `google/`, and `microsoft/` -- so one bare name would
|
|
29
|
+
* select three different rules at once.
|
|
30
|
+
*/
|
|
31
|
+
function matchesRuleName(rule, name) {
|
|
32
|
+
return rule.name === name || rule.shortName === name;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Restricts the run to the named rules. Unknown names throw rather than
|
|
36
|
+
* silently narrowing to nothing: a typo'd `--rule` that reported "no issues"
|
|
37
|
+
* would read exactly like a clean run.
|
|
38
|
+
*/
|
|
39
|
+
export function filterByRuleNames(rules, names) {
|
|
40
|
+
if (!names.length)
|
|
41
|
+
return rules;
|
|
42
|
+
const unknown = names.filter((name) => !rules.some((rule) => matchesRuleName(rule, name)));
|
|
43
|
+
if (unknown.length > 0) {
|
|
44
|
+
throw new UnknownRuleNameError(unknown, rules.map((rule) => rule.name));
|
|
45
|
+
}
|
|
46
|
+
return rules.filter((rule) => names.some((name) => matchesRuleName(rule, name)));
|
|
47
|
+
}
|
|
48
|
+
/** Inverse of `filterByRuleNames`, with the same name matching and typo check. */
|
|
49
|
+
export function excludeByRuleNames(rules, names) {
|
|
50
|
+
if (!names.length)
|
|
51
|
+
return rules;
|
|
52
|
+
const unknown = names.filter((name) => !rules.some((rule) => matchesRuleName(rule, name)));
|
|
53
|
+
if (unknown.length > 0) {
|
|
54
|
+
throw new UnknownRuleNameError(unknown, rules.map((rule) => rule.name));
|
|
55
|
+
}
|
|
56
|
+
return rules.filter((rule) => !names.some((name) => matchesRuleName(rule, name)));
|
|
57
|
+
}
|
|
1
58
|
const SEVERITY_LEVELS = {
|
|
2
59
|
off: -1,
|
|
3
60
|
info: 0,
|
|
@@ -49,6 +106,13 @@ export function applyFilters(rules, options) {
|
|
|
49
106
|
if (options.tags?.length) {
|
|
50
107
|
filtered = filterByTags(filtered, options.tags);
|
|
51
108
|
}
|
|
109
|
+
// Name filters run last so they can narrow whatever the broader filters left.
|
|
110
|
+
if (options.rules?.length) {
|
|
111
|
+
filtered = filterByRuleNames(filtered, options.rules);
|
|
112
|
+
}
|
|
113
|
+
if (options.excludeRules?.length) {
|
|
114
|
+
filtered = excludeByRuleNames(filtered, options.excludeRules);
|
|
115
|
+
}
|
|
52
116
|
return { filtered, disabledCount };
|
|
53
117
|
}
|
|
54
118
|
//# sourceMappingURL=rule-filters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-filters.js","sourceRoot":"","sources":["../../src/core/rule-filters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rule-filters.js","sourceRoot":"","sources":["../../src/core/rule-filters.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YACW,OAAiB,EACjB,SAAmB;QAE5B,KAAK,CAAC,yCAAyC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,C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AAE,CAAC;QACjC,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proper-nouns.d.ts","sourceRoot":"","sources":["../../src/data/proper-nouns.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proper-nouns.d.ts","sourceRoot":"","sources":["../../src/data/proper-nouns.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAgCnD,CAAC"}
|
|
@@ -1,183 +1,22 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// The FIRST version of this list (Task 8's initial landing) required
|
|
16
|
-
// "exotic" casing to qualify -- an internal capital, a dot, or forced
|
|
17
|
-
// lowercase -- reasoning that ordinary Title-Case brand names carry no
|
|
18
|
-
// casing fact ordinary English capitalization doesn't already supply. That
|
|
19
|
-
// reasoning was wrong: `capitalization`'s `$sentence` style lowercases
|
|
20
|
-
// EVERY non-first word that isn't ALL-CAPS or an exception, regardless of
|
|
21
|
-
// how "ordinary" its casing looks -- so a plain Title-Case brand name like
|
|
22
|
-
// `Redocly` or `Docker` needs protection exactly as much as `Node.js` does.
|
|
23
|
-
// The bar's real intent, per spec §5.5's prose, is narrower than "exotic
|
|
24
|
-
// casing only": exclude an entry only when listing it would WEAKEN
|
|
25
|
-
// capitalization checks. Two exclusion classes, and only these two:
|
|
26
|
-
//
|
|
27
|
-
// 1. Pure ALL-CAPS acronyms (`JWT`, `YAML`) -- `isAllCapsWord`
|
|
28
|
-
// (title-case.ts) already leaves these untouched structurally in both
|
|
29
|
-
// `capitalization` and `spelling`, so listing them adds maintenance
|
|
30
|
-
// for no behavior change. Note this is narrower than "all-caps-ISH":
|
|
31
|
-
// `OAuth` and `AsyncAPI` are mixed-case, not pure ALL-CAPS, and DO
|
|
32
|
-
// qualify.
|
|
33
|
-
// 2. Words with legitimate lowercase prose usage -- listing them would
|
|
34
|
-
// force-capitalize ordinary English. `cloud` and `apps` are the
|
|
35
|
-
// generic-English examples; `node` (common technical noun, "each node
|
|
36
|
-
// in the graph" -- superseded by the `Node.js` phrase entry for the
|
|
37
|
-
// platform specifically) and `realm`/`replay`/`respect` (Redocly
|
|
38
|
-
// product names that are ALSO ordinary English words -- as
|
|
39
|
-
// exceptions they would rewrite ordinary usage like "we respect your
|
|
40
|
-
// privacy" into "we Respect your privacy") are the project-specific
|
|
41
|
-
// ones. Of the Redocly-name group, only `Redoc` is included: it is a
|
|
42
|
-
// coined word with no ordinary English sense. `Realm`, `Replay`,
|
|
43
|
-
// `Respect` and `Reunite` are all excluded, because forcing their
|
|
44
|
-
// casing for every user of this library would rewrite ordinary prose
|
|
45
|
-
// ("the teams will reunite next quarter"). `Redocly` itself is included
|
|
46
|
-
// on the same basis as `Redoc` -- not an English word.
|
|
47
|
-
//
|
|
48
|
-
// Redocly's own product names belong in Redocly's own configuration,
|
|
49
|
-
// not in a vocabulary shipped to everyone. Note for whoever writes that
|
|
50
|
-
// rule: lowercase `reunite` is legitimate in Redocly's docs as an
|
|
51
|
-
// identifier prefix -- ClickHouse tables (`reunite.api_access_logs`),
|
|
52
|
-
// package names (`reunite-ui`), and URL path segments -- so it must be
|
|
53
|
-
// prose-scoped with code spans excluded, which is the default.
|
|
54
|
-
//
|
|
55
|
-
// Everything else that is a real technology/product/company name qualifies
|
|
56
|
-
// now, including ordinary Title-Case brand names -- this list is no longer
|
|
57
|
-
// scoped to "casing is the protected fact", it is the general technical-
|
|
58
|
-
// vocabulary list spec §5.5 actually describes.
|
|
59
|
-
//
|
|
60
|
-
// Two automated guards enforce this (src/data/__tests__/proper-nouns.test.ts):
|
|
61
|
-
// 1. A bar guard, MECHANIZED (final-review fix wave): no entry may be pure
|
|
62
|
-
// ALL-CAPS (already covered structurally by isAllCapsWord), and no
|
|
63
|
-
// single-token entry's plain lowercase form may be a real English word
|
|
64
|
-
// as judged by the ACTUAL spelling dictionary (`dictionary-en`/`nspell`,
|
|
65
|
-
// the exact pair `spelling` loads at runtime -- see
|
|
66
|
-
// rules/scope/spelling.ts), unless it is named in an explicit
|
|
67
|
-
// accepted-risk allowlist alongside its reason. This replaced a
|
|
68
|
-
// hand-written six-word denylist (`cloud`, `apps`, `node`, `realm`,
|
|
69
|
-
// `replay`, `respect`) that only ever caught re-additions of words its
|
|
70
|
-
// author had already thought of -- and so passed cleanly while
|
|
71
|
-
// `Chrome`/`Markdown`/`Postman`/`Prettier`/`Safari`/`Swagger`/`Windows`
|
|
72
|
-
// shipped as entries despite each failing this exact bar (see the
|
|
73
|
-
// "Task 8 fix-wave audit" section below). A guard narrower than the
|
|
74
|
-
// rule it claims to enforce is worse than none: it produces false
|
|
75
|
-
// confidence. Deriving the check from the real dictionary instead of a
|
|
76
|
-
// hand list means a FUTURE entry that happens to double as an ordinary
|
|
77
|
-
// word is caught automatically, without requiring a test author to have
|
|
78
|
-
// already thought of that specific word.
|
|
79
|
-
// 2. A round-trip (dead-entry) guard -- the direct lesson of the
|
|
80
|
-
// `Node.js`/`VS Code` finding (Task 7 of this phase): every entry is
|
|
81
|
-
// driven through the REAL `capitalization` rule inside a heading and
|
|
82
|
-
// must survive unmodified, and through `spelling` and must not be
|
|
83
|
-
// flagged. An entry that cannot actually be protected fails the suite
|
|
84
|
-
// instead of sitting in the list looking effective.
|
|
85
|
-
//
|
|
86
|
-
// -- Multi-token entries -----------------------------------------------------
|
|
87
|
-
//
|
|
88
|
-
// Before Task 7 of this phase, the exception tokenizer split on dots and
|
|
89
|
-
// whitespace, so a phrase like `Node.js` or `VS Code` could never match as
|
|
90
|
-
// written and was dead config -- see title-case.ts's buildExceptionPlan/
|
|
91
|
-
// recaseWords for the phrase-aware matching that now makes these
|
|
92
|
-
// real entries instead of the single-token approximations (`Node`, `VS`) the
|
|
93
|
-
// Phase 3 preset list had to settle for.
|
|
94
|
-
//
|
|
95
|
-
// -- Seed and what stays excluded --------------------------------------------
|
|
96
|
-
//
|
|
97
|
-
// Seeded from the Phase 3 `recheck/prose` preset's 38-entry starter list
|
|
98
|
-
// (see git history / config/presets/prose.ts) plus the six multi-token names
|
|
99
|
-
// Task 7 makes possible (`Node.js`, `VS Code`, `Visual Studio Code`,
|
|
100
|
-
// `GitHub Actions`, `Google Cloud`, `Azure DevOps`), filtered through the bar
|
|
101
|
-
// above. Under the widened bar, only three classes are excluded, each for a
|
|
102
|
-
// stated reason so nobody re-adds them:
|
|
103
|
-
//
|
|
104
|
-
// | Entry | Why excluded |
|
|
105
|
-
// |------------------------------|-----------------------------------------|
|
|
106
|
-
// | `JWT`, `YAML` | pure ALL-CAPS; isAllCapsWord handles |
|
|
107
|
-
// | | them structurally |
|
|
108
|
-
// | `Realm`, `Replay`, `Respect`,| Redocly product names that are also |
|
|
109
|
-
// | `Reunite` | common English words -- as exceptions |
|
|
110
|
-
// | | they would rewrite ordinary usage ("we |
|
|
111
|
-
// | | respect your privacy" -> "we Respect |
|
|
112
|
-
// | | your privacy"; "the teams will reunite" |
|
|
113
|
-
// | | -> "will Reunite"). Only `Redoc` and |
|
|
114
|
-
// | | `Redocly` are included from the Redocly |
|
|
115
|
-
// | | group -- neither is an English word. |
|
|
116
|
-
// | | Enforcing the rest belongs in Redocly's |
|
|
117
|
-
// | | own config, not a shipped vocabulary. |
|
|
118
|
-
// | `Node` | common technical noun ("each node in |
|
|
119
|
-
// | | the graph"); `Node.js` now works as a |
|
|
120
|
-
// | | phrase entry, which covers the platform |
|
|
121
|
-
//
|
|
122
|
-
// None of these are silently lost: a project that relies on one of these for
|
|
123
|
-
// its own brand or prose adds it back via its OWN rule's `exceptions`/
|
|
124
|
-
// `vocab`, which compose with this built-in list rather than replacing it.
|
|
125
|
-
//
|
|
126
|
-
// -- Task 8 fix-wave audit (final-review fix wave) ---------------------------
|
|
127
|
-
//
|
|
128
|
-
// The widened bar above was correct in principle but was never actually RUN
|
|
129
|
-
// against every entry it admitted. Four ordinary English words --
|
|
130
|
-
// `Postman`, `Prettier`, `Safari`, `Windows` -- shipped as
|
|
131
|
-
// forced-capitalization exceptions despite failing class 2 outright: with
|
|
132
|
-
// `extends: [recheck/prose]`, a heading like "Close all windows before you
|
|
133
|
-
// continue" or "A prettier interface for reviewers" was force-capitalized to
|
|
134
|
-
// "Windows"/"Prettier" the moment the word appeared, lowercase, in ordinary
|
|
135
|
-
// prose. A follow-up audit applied the bar's own stated test -- "would the
|
|
136
|
-
// lowercase form appear as ordinary English in technical prose?" -- to EVERY
|
|
137
|
-
// entry, mechanically, via the real spelling dictionary (guard 1 above).
|
|
138
|
-
// Seven entries failed and were removed:
|
|
139
|
-
//
|
|
140
|
-
// | Entry | Why removed (real, attested lowercase English usage) |
|
|
141
|
-
// |------------|------------------------------------------------------------|
|
|
142
|
-
// | `Chrome` | "chrome plating", "a chrome bumper" -- the metal/finish |
|
|
143
|
-
// | `Markdown` | "a markdown of thirty percent" -- the retail/finance |
|
|
144
|
-
// | | term; `google/brand-capitalization` documents this exact |
|
|
145
|
-
// | | homograph for the same word (see config/presets/google.ts)|
|
|
146
|
-
// | `Postman` | "ask the postman for a receipt" -- the mail carrier |
|
|
147
|
-
// | `Prettier` | "a prettier interface" -- the ordinary comparative |
|
|
148
|
-
// | | adjective |
|
|
149
|
-
// | `Safari` | "plan a safari with the team" -- the trip |
|
|
150
|
-
// | `Swagger` | "he spoke with swagger" -- ordinary confidence/ |
|
|
151
|
-
// | | boastfulness |
|
|
152
|
-
// | `Windows` | "close all windows before you continue" -- plural of the |
|
|
153
|
-
// | | ordinary noun |
|
|
154
|
-
//
|
|
155
|
-
// Three more entries ALSO have a real, dictionary-attested lowercase English
|
|
156
|
-
// sense -- `Android` ("android" = a humanoid robot), `Docker` ("docker" = a
|
|
157
|
-
// dockworker, chiefly British/historical usage), `TypeScript` ("typescript"
|
|
158
|
-
// = a typed manuscript, an archaic sense) -- but were kept rather than
|
|
159
|
-
// removed after adjudication: unlike the seven above, the call here is
|
|
160
|
-
// genuinely debatable, not clear-cut. The ordinary sense of each is rare in
|
|
161
|
-
// practice (dockworker and typed-manuscript both read as dated; the robot
|
|
162
|
-
// sense is mostly genre fiction) and the proper-noun sense dominates current
|
|
163
|
-
// usage -- especially `TypeScript`, central to this very codebase. This is a
|
|
164
|
-
// deliberate, documented risk-acceptance, not an oversight: see the
|
|
165
|
-
// `ACCEPTED_RISK_ENTRIES` allowlist in proper-nouns.test.ts, which the
|
|
166
|
-
// mechanized dictionary guard consults so these three don't fail the suite.
|
|
167
|
-
// `Reunite` (below) has the same real-word tension ("reunite" is an ordinary
|
|
168
|
-
// verb) but predates this audit as an explicit, already-adjudicated
|
|
169
|
-
// project-owner decision (see the exclusion table above) and is left as is.
|
|
170
|
-
//
|
|
171
|
-
// None of the seven removed entries are silently lost either: a project that
|
|
172
|
-
// relies on one for its own brand or prose adds it back via its OWN rule's
|
|
173
|
-
// `exceptions`/`vocab`, exactly as with the three-class exclusions above.
|
|
174
|
-
//
|
|
175
|
-
// Final count: 31 entries. Alphabetized case-insensitively, duplicate-free.
|
|
1
|
+
// Technical and product names that `capitalization` and `spelling` protect by
|
|
2
|
+
// default, unioned with each rule's own `exceptions`/`vocab`. Opt out with
|
|
3
|
+
// `builtinVocabulary: false`.
|
|
4
|
+
//
|
|
5
|
+
// Before adding an entry, note that two tests in __tests__/proper-nouns.test.ts
|
|
6
|
+
// reject most candidates and say why on failure: pure ALL-CAPS acronyms are
|
|
7
|
+
// already handled structurally by isAllCapsWord, and a word whose lowercase
|
|
8
|
+
// form is ordinary English would force-case ordinary prose. `curl` is the one
|
|
9
|
+
// entry deliberately admitted against that second rule, and the only entry
|
|
10
|
+
// whose as-written form is lowercase -- so a false hit force-LOWERCASES a
|
|
11
|
+
// capitalized `Curl`, where every other entry would force-capitalize.
|
|
12
|
+
//
|
|
13
|
+
// Alphabetized case-insensitively, duplicate-free (both enforced by test).
|
|
176
14
|
export const TECHNICAL_PROPER_NOUNS = [
|
|
177
15
|
'Android',
|
|
178
16
|
'AsyncAPI',
|
|
179
17
|
'Azure DevOps',
|
|
180
18
|
'Bitbucket',
|
|
19
|
+
'curl',
|
|
181
20
|
'Docker',
|
|
182
21
|
'ESLint',
|
|
183
22
|
'Firefox',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proper-nouns.js","sourceRoot":"","sources":["../../src/data/proper-nouns.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"proper-nouns.js","sourceRoot":"","sources":["../../src/data/proper-nouns.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,8BAA8B;AAC9B,EAAE;AACF,gFAAgF;AAChF,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,0EAA0E;AAC1E,sEAAsE;AACtE,EAAE;AACF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,sBAAsB,GAAsB;IACvD,SAAS;IACT,UAAU;IACV,cAAc;IACd,WAAW;IACX,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,gBAAgB;IAChB,QAAQ;IACR,cAAc;IACd,UAAU;IACV,SAAS;IACT,KAAK;IACL,YAAY;IACZ,YAAY;IACZ,OAAO;IACP,OAAO;IACP,SAAS;IACT,SAAS;IACT,KAAK;IACL,OAAO;IACP,SAAS;IACT,MAAM;IACN,OAAO;IACP,SAAS;IACT,YAAY;IACZ,oBAAoB;IACpB,SAAS;IACT,SAAS;CACV,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capitalization.d.ts","sourceRoot":"","sources":["../../../src/rules/scope/capitalization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"capitalization.d.ts","sourceRoot":"","sources":["../../../src/rules/scope/capitalization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AAoM/D,eAAO,MAAM,cAAc,EAAE,SAAiE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { formatTemplate } from '../token/messages.js';
|
|
2
2
|
import { newLineRe } from '../../core/line-endings.js';
|
|
3
3
|
import { maskInlineCode, restoreInlineCode } from '../../core/inline-code.js';
|
|
4
|
-
import { apTitleCase, chicagoTitleCase,
|
|
4
|
+
import { apTitleCase, chicagoTitleCase, keepsOwnCasing, buildExceptionPlan, recaseWords, } from './title-case.js';
|
|
5
5
|
import { TECHNICAL_PROPER_NOUNS } from '../../data/proper-nouns.js';
|
|
6
6
|
// Fallback when a programmatically-built rule has no `message` (validate()
|
|
7
7
|
// requires one). %s slots: the segment's first line, then the `match` value.
|
|
@@ -30,15 +30,17 @@ const DOLLAR_STYLES = new Set(['$title', '$sentence', '$lower', '$upper']);
|
|
|
30
30
|
// treating it as a phrase), and `recaseWords` is the same tokenizer, which is
|
|
31
31
|
// what makes each phrase ONE token that counts toward word position. $sentence
|
|
32
32
|
// only supplies its own per-word casing rule below.
|
|
33
|
+
// Follows `startsSentence`, not `index === 0`: a heading can carry more than
|
|
34
|
+
// one sentence (`Step 1. Configure the project`). recaseWords decides where.
|
|
33
35
|
function sentenceCase(text, exceptions) {
|
|
34
36
|
const { wordMap, phrases } = buildExceptionPlan(exceptions);
|
|
35
|
-
return recaseWords(text, phrases, (word,
|
|
37
|
+
return recaseWords(text, phrases, (word, _index, _total, startsSentence) => {
|
|
36
38
|
const exceptionHit = wordMap.get(word.toLowerCase());
|
|
37
39
|
if (exceptionHit !== undefined)
|
|
38
40
|
return exceptionHit;
|
|
39
|
-
if (
|
|
41
|
+
if (keepsOwnCasing(word))
|
|
40
42
|
return word;
|
|
41
|
-
if (
|
|
43
|
+
if (startsSentence)
|
|
42
44
|
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
43
45
|
return word.toLowerCase();
|
|
44
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capitalization.js","sourceRoot":"","sources":["../../../src/rules/scope/capitalization.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"capitalization.js","sourceRoot":"","sources":["../../../src/rules/scope/capitalization.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,2EAA2E;AAC3E,6EAA6E;AAC7E,MAAM,gBAAgB,GAAG,oCAAoC,CAAC;AAE9D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAG3E,sEAAsE;AACtE,sEAAsE;AACtE,kEAAkE;AAClE,yEAAyE;AACzE,yEAAyE;AACzE,sEAAsE;AACtE,mEAAmE;AAEnE,YAAY;AACZ,EAAE;AACF,sE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AAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM;YACxC,UAAU,EAAE,IAAI,CAAC,SAAS;SAC3B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAc,EAAE,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -5,6 +5,15 @@
|
|
|
5
5
|
* don't count toward the length or case check.
|
|
6
6
|
*/
|
|
7
7
|
export declare function isAllCapsWord(word: string): boolean;
|
|
8
|
+
/** The `v2` of `v2.0`, or `v3`. The `v` must be the whole alphabetic part,
|
|
9
|
+
* so an ordinary word like `vector3` is untouched. */
|
|
10
|
+
export declare function isVersionToken(word: string): boolean;
|
|
11
|
+
/** `x-metadata`, `x-codeSamples`. Case-sensitive: matching `X-` too would
|
|
12
|
+
* freeze `X-ray` and AWS `X-Ray`. */
|
|
13
|
+
export declare function isVendorExtensionToken(word: string): boolean;
|
|
14
|
+
/** Tokens whose own casing is already correct. Must be checked before
|
|
15
|
+
* hyphen splitting -- an extension's `-` is part of its name. */
|
|
16
|
+
export declare function keepsOwnCasing(word: string): boolean;
|
|
8
17
|
export interface ExceptionPlan {
|
|
9
18
|
wordMap: Map<string, string>;
|
|
10
19
|
phrases: string[];
|
|
@@ -12,21 +21,16 @@ export interface ExceptionPlan {
|
|
|
12
21
|
export declare function buildExceptionPlan(exceptions: string[]): ExceptionPlan;
|
|
13
22
|
/**
|
|
14
23
|
* Rebuilds `text` with every word re-cased by `caseWord`, which receives the
|
|
15
|
-
* word
|
|
16
|
-
*
|
|
17
|
-
* the real last one. Separators between tokens are copied through verbatim.
|
|
24
|
+
* word, its `index`, the sequence `total`, and whether it opens a sentence.
|
|
25
|
+
* Separators are copied through verbatim.
|
|
18
26
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* or trailing phrase no longer hands its first/last position to a neighbour
|
|
22
|
-
* (#25610).
|
|
27
|
+
* Phrase-exception and mask tokens are emitted as-written but still OCCUPY an
|
|
28
|
+
* index, so a leading one cannot hand position 0 to a neighbour (#25610).
|
|
23
29
|
*
|
|
24
|
-
* Shared by
|
|
25
|
-
* capitalization.ts's sentenceCase, so all three `$`-styles agree on
|
|
26
|
-
* tokenization and phrase protection, not merely on the exception plan.
|
|
30
|
+
* Shared by apTitleCase/chicagoTitleCase and capitalization.ts's sentenceCase.
|
|
27
31
|
* Length-preserving whenever `caseWord` is.
|
|
28
32
|
*/
|
|
29
|
-
export declare function recaseWords(text: string, phrases: string[], caseWord: (word: string, index: number, total: number) => string): string;
|
|
33
|
+
export declare function recaseWords(text: string, phrases: string[], caseWord: (word: string, index: number, total: number, startsSentence: boolean) => string): string;
|
|
30
34
|
/**
|
|
31
35
|
* AP style: lowercases articles, coordinating conjunctions, and
|
|
32
36
|
* prepositions of 3 letters or fewer -- everything else is capitalized,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title-case.d.ts","sourceRoot":"","sources":["../../../src/rules/scope/title-case.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"title-case.d.ts","sourceRoot":"","sources":["../../../src/rules/scope/title-case.ts"],"names":[],"mappings":"AA4EA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED;uDACuD;AACvD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;sCACsC;AACtC,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;kEACkE;AAClE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAuBD,MAAM,WAAW,aAAa;IAG5B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAI7B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,aAAa,CAStE;AAmJD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,KAAK,MAAM,GACxF,MAAM,CAcR;AAuED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,GAAE,MAAM,EAAO,GAAG,MAAM,CAE3E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,GAAE,MAAM,EAAO,GAAG,MAAM,CAEhF"}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
// `capitalization` assertion's `$title` match (see ./capitalization.ts).
|
|
3
3
|
// Deliberately no markdown/Vale awareness here -- these functions operate
|
|
4
4
|
// on plain text only. Scope/segment handling, backtick-span freezing, and
|
|
5
|
-
// the problem/fix wiring all live in capitalization.ts.
|
|
5
|
+
// the problem/fix wiring all live in capitalization.ts. The one import below
|
|
6
|
+
// is the mask CHARACTER, not any markdown handling: masking happens in
|
|
7
|
+
// capitalization.ts, and the tokenizer here only has to recognize the result.
|
|
6
8
|
//
|
|
7
9
|
// Shared casing rules (both styles):
|
|
8
10
|
// - The FIRST and LAST word are ALWAYS capitalized, regardless of any
|
|
@@ -26,6 +28,8 @@
|
|
|
26
28
|
// - Chicago: articles, coordinating conjunctions, and EVERY preposition
|
|
27
29
|
// regardless of length -- via the fixed list below (JS has no built-in
|
|
28
30
|
// dictionary of "all English prepositions" to draw on).
|
|
31
|
+
import { INLINE_CODE_MASK_CHAR } from '../../core/inline-code.js';
|
|
32
|
+
import { ABBREVIATIONS, lastWordBefore } from '../../scopes/sentences.js';
|
|
29
33
|
const ARTICLES = ['a', 'an', 'the'];
|
|
30
34
|
const COORDINATING_CONJUNCTIONS = ['and', 'but', 'or', 'nor', 'for', 'so', 'yet'];
|
|
31
35
|
// Every entry here is <= 3 letters -- both AP and Chicago lowercase these.
|
|
@@ -63,17 +67,9 @@ const CHICAGO_STOPWORDS = new Set([
|
|
|
63
67
|
...LONG_PREPOSITIONS,
|
|
64
68
|
]);
|
|
65
69
|
// One "word" is a run of letters/digits, optionally joined by internal
|
|
66
|
-
// hyphens ('well-known') or apostrophes ("don't")
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
// invisible to this tokenizer: never capitalized, never counted toward
|
|
70
|
-
// first/last-word position.
|
|
71
|
-
//
|
|
72
|
-
// A PHRASE exception is deliberately never reached by this regex: phrase
|
|
73
|
-
// spans are carved out of the text before it runs, so a phrase is one token
|
|
74
|
-
// instead of the several this regex would split it into (it splits on exactly
|
|
75
|
-
// the whitespace and dots those entries contain). See tokenizeCasingWords.
|
|
76
|
-
const WORD_RE = /[A-Za-z0-9]+(?:['’-][A-Za-z0-9]+)*/g;
|
|
70
|
+
// hyphens ('well-known') or apostrophes ("don't"); anything else is a
|
|
71
|
+
// separator copied through verbatim. Phrase exceptions never reach the
|
|
72
|
+
// tokenizer -- tokenizeCasingWords carves them out first.
|
|
77
73
|
/**
|
|
78
74
|
* True for a word that's already an ALL-CAPS acronym (2+ letters, e.g.
|
|
79
75
|
* 'API', 'HTML5') -- both styles leave these exactly as written rather
|
|
@@ -84,6 +80,21 @@ export function isAllCapsWord(word) {
|
|
|
84
80
|
const letters = word.replace(/[^A-Za-z]/g, '');
|
|
85
81
|
return letters.length >= 2 && letters === letters.toUpperCase();
|
|
86
82
|
}
|
|
83
|
+
/** The `v2` of `v2.0`, or `v3`. The `v` must be the whole alphabetic part,
|
|
84
|
+
* so an ordinary word like `vector3` is untouched. */
|
|
85
|
+
export function isVersionToken(word) {
|
|
86
|
+
return /^v\d+$/i.test(word);
|
|
87
|
+
}
|
|
88
|
+
/** `x-metadata`, `x-codeSamples`. Case-sensitive: matching `X-` too would
|
|
89
|
+
* freeze `X-ray` and AWS `X-Ray`. */
|
|
90
|
+
export function isVendorExtensionToken(word) {
|
|
91
|
+
return /^x-./.test(word);
|
|
92
|
+
}
|
|
93
|
+
/** Tokens whose own casing is already correct. Must be checked before
|
|
94
|
+
* hyphen splitting -- an extension's `-` is part of its name. */
|
|
95
|
+
export function keepsOwnCasing(word) {
|
|
96
|
+
return isAllCapsWord(word) || isVersionToken(word) || isVendorExtensionToken(word);
|
|
97
|
+
}
|
|
87
98
|
function capitalizeWord(word) {
|
|
88
99
|
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
89
100
|
}
|
|
@@ -127,12 +138,24 @@ function findPhraseMatches(text, phrases) {
|
|
|
127
138
|
}
|
|
128
139
|
return matches.sort((a, b) => a.start - b.start);
|
|
129
140
|
}
|
|
141
|
+
// A mask run is one inline code span (core/inline-code.ts). It gets its own
|
|
142
|
+
// token so it OCCUPIES a position, like a phrase exception (#25610) -- a
|
|
143
|
+
// heading opening with a code span must not hand position 0 to the next word.
|
|
144
|
+
// `exception` is the run itself so it survives byte for byte; restoreInlineCode
|
|
145
|
+
// splices by offset.
|
|
146
|
+
const WORD_OR_MASK_RE = new RegExp(`${INLINE_CODE_MASK_CHAR}+|[A-Za-z0-9]+(?:['’-][A-Za-z0-9]+)*`, 'g');
|
|
130
147
|
function pushWordTokens(text, from, to, tokens) {
|
|
131
148
|
if (from >= to)
|
|
132
149
|
return;
|
|
133
|
-
for (const match of text.slice(from, to).matchAll(
|
|
150
|
+
for (const match of text.slice(from, to).matchAll(WORD_OR_MASK_RE)) {
|
|
134
151
|
const start = from + (match.index ?? 0);
|
|
135
|
-
|
|
152
|
+
const isMask = match[0].startsWith(INLINE_CODE_MASK_CHAR);
|
|
153
|
+
tokens.push({
|
|
154
|
+
text: match[0],
|
|
155
|
+
start,
|
|
156
|
+
end: start + match[0].length,
|
|
157
|
+
...(isMask ? { exception: match[0] } : {}),
|
|
158
|
+
});
|
|
136
159
|
}
|
|
137
160
|
}
|
|
138
161
|
/**
|
|
@@ -156,20 +179,30 @@ function tokenizeCasingWords(text, phrases) {
|
|
|
156
179
|
pushWordTokens(text, cursor, text.length, tokens);
|
|
157
180
|
return tokens;
|
|
158
181
|
}
|
|
182
|
+
// Trailing whitespace is required: a bare dot is usually a dotted identifier
|
|
183
|
+
// or version (`element.focus()`, `v2.0`), not a sentence end. No ':' -- both
|
|
184
|
+
// style guides lowercase after a colon unless a full sentence follows, which
|
|
185
|
+
// nothing here can detect.
|
|
186
|
+
const SENTENCE_BREAK_RE = /[.?!]["'’”)\]]*\s/;
|
|
187
|
+
// ABBREVIATIONS is the sentence splitter's own list, reused so the two cannot
|
|
188
|
+
// disagree about what ends a sentence (`Cost vs. value` is one sentence).
|
|
189
|
+
function gapEndsSentence(text, gapStart, gap) {
|
|
190
|
+
const match = SENTENCE_BREAK_RE.exec(gap);
|
|
191
|
+
if (!match)
|
|
192
|
+
return false;
|
|
193
|
+
if (match[0][0] !== '.')
|
|
194
|
+
return true; // '?' and '!' never abbreviate
|
|
195
|
+
return !ABBREVIATIONS.has(lastWordBefore(text, gapStart + (match.index ?? 0)));
|
|
196
|
+
}
|
|
159
197
|
/**
|
|
160
198
|
* Rebuilds `text` with every word re-cased by `caseWord`, which receives the
|
|
161
|
-
* word
|
|
162
|
-
*
|
|
163
|
-
* the real last one. Separators between tokens are copied through verbatim.
|
|
199
|
+
* word, its `index`, the sequence `total`, and whether it opens a sentence.
|
|
200
|
+
* Separators are copied through verbatim.
|
|
164
201
|
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* or trailing phrase no longer hands its first/last position to a neighbour
|
|
168
|
-
* (#25610).
|
|
202
|
+
* Phrase-exception and mask tokens are emitted as-written but still OCCUPY an
|
|
203
|
+
* index, so a leading one cannot hand position 0 to a neighbour (#25610).
|
|
169
204
|
*
|
|
170
|
-
* Shared by
|
|
171
|
-
* capitalization.ts's sentenceCase, so all three `$`-styles agree on
|
|
172
|
-
* tokenization and phrase protection, not merely on the exception plan.
|
|
205
|
+
* Shared by apTitleCase/chicagoTitleCase and capitalization.ts's sentenceCase.
|
|
173
206
|
* Length-preserving whenever `caseWord` is.
|
|
174
207
|
*/
|
|
175
208
|
export function recaseWords(text, phrases, caseWord) {
|
|
@@ -179,8 +212,10 @@ export function recaseWords(text, phrases, caseWord) {
|
|
|
179
212
|
let result = '';
|
|
180
213
|
let cursor = 0;
|
|
181
214
|
tokens.forEach((token, index) => {
|
|
182
|
-
|
|
183
|
-
|
|
215
|
+
const separator = text.slice(cursor, token.start);
|
|
216
|
+
const startsSentence = index === 0 || gapEndsSentence(text, cursor, separator);
|
|
217
|
+
result += separator;
|
|
218
|
+
result += token.exception ?? caseWord(token.text, index, tokens.length, startsSentence);
|
|
184
219
|
cursor = token.end;
|
|
185
220
|
});
|
|
186
221
|
return result + text.slice(cursor);
|
|
@@ -221,6 +256,10 @@ function transformWord(word, isFirstWord, isLastWord, stopwords, exceptionMap) {
|
|
|
221
256
|
const exceptionHit = exceptionMap.get(word.toLowerCase());
|
|
222
257
|
if (exceptionHit !== undefined)
|
|
223
258
|
return exceptionHit;
|
|
259
|
+
// Before the hyphen split: `x-codeSamples` split into parts became
|
|
260
|
+
// `X-codesamples`. An exceptions entry still wins, above.
|
|
261
|
+
if (keepsOwnCasing(word))
|
|
262
|
+
return word;
|
|
224
263
|
// Hyphenation check: with no whole-compound exception match, a hyphenated
|
|
225
264
|
// compound is stopword-tested part by part instead (the stopword lists
|
|
226
265
|
// only contain single words, so a whole-string lookup against them would
|
|
@@ -229,8 +268,6 @@ function transformWord(word, isFirstWord, isLastWord, stopwords, exceptionMap) {
|
|
|
229
268
|
if (word.includes('-')) {
|
|
230
269
|
return capitalizeHyphenated(word, isFirstWord, isLastWord, stopwords, exceptionMap);
|
|
231
270
|
}
|
|
232
|
-
if (isAllCapsWord(word))
|
|
233
|
-
return word;
|
|
234
271
|
if (isFirstWord || isLastWord)
|
|
235
272
|
return capitalizeWord(word);
|
|
236
273
|
if (stopwords.has(word.toLowerCase()))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title-case.js","sourceRoot":"","sources":["../../../src/rules/scope/title-case.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AACzE,0EAA0E;AAC1E,0EAA0E;AAC1E,
|
|
1
|
+
{"version":3,"file":"title-case.js","sourceRoot":"","sources":["../../../src/rules/scope/title-case.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AACzE,0EAA0E;AAC1E,0EAA0E;AAC1E,6EAA6E;AAC7E,uEAAuE;AACvE,8EAA8E;AAC9E,EAAE;AACF,qCAAqC;AACrC,sEAAsE;AACtE,yBAAyB;AACzB,kEAAkE;AAClE,yEAAyE;AACzE,wEAAwE;AACxE,qCAAqC;AACrC,2EAA2E;AAC3E,0EAA0E;AAC1E,wEAAwE;AACxE,2EAA2E;AAC3E,8BAA8B;AAC9B,wEAAwE;AACxE,yEAAyE;AACzE,oDAAoD;AACpD,EAAE;AACF,6DAA6D;AAC7D,uEAAuE;AACvE,sBAAsB;AACtB,wEAAwE;AACxE,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE1E,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACpC,MAAM,yBAAyB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAClF,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,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ACjE,OAAO,SAAS,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,UAAU,GAAa,EAAE;IACtE,OAAO,SAAS,CAAC,IAAI,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -3,5 +3,13 @@ export interface SentenceSpan {
|
|
|
3
3
|
start: number;
|
|
4
4
|
end: number;
|
|
5
5
|
}
|
|
6
|
+
export declare const ABBREVIATIONS: Set<string>;
|
|
7
|
+
/**
|
|
8
|
+
* The word immediately before `index`, lowercased, with a trailing dot
|
|
9
|
+
* removed -- so a dotted abbreviation like `e.g.` yields `e.g`, which is the
|
|
10
|
+
* form ABBREVIATIONS stores. Exported for title-case.ts, which asks the same
|
|
11
|
+
* question at the same kind of boundary.
|
|
12
|
+
*/
|
|
13
|
+
export declare function lastWordBefore(text: string, index: number): string;
|
|
6
14
|
export declare function splitSentences(text: string): SentenceSpan[];
|
|
7
15
|
//# sourceMappingURL=sentences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentences.d.ts","sourceRoot":"","sources":["../../src/scopes/sentences.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;
|
|
1
|
+
{"version":3,"file":"sentences.d.ts","sourceRoot":"","sources":["../../src/scopes/sentences.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAKD,eAAO,MAAM,aAAa,aAwBxB,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIlE;AA8BD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CA2C3D"}
|
package/dist/scopes/sentences.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// Shared with title-case.ts's sentence-break test, so the casing styles and
|
|
2
|
+
// the sentence splitter agree on what ends a sentence. One list, not two:
|
|
3
|
+
// `Cost vs. value` is a single sentence to both.
|
|
4
|
+
export const ABBREVIATIONS = new Set([
|
|
2
5
|
'e.g',
|
|
3
6
|
'i.e',
|
|
4
7
|
'etc',
|
|
@@ -23,7 +26,13 @@ const ABBREVIATIONS = new Set([
|
|
|
23
26
|
'inc',
|
|
24
27
|
'ltd',
|
|
25
28
|
]);
|
|
26
|
-
|
|
29
|
+
/**
|
|
30
|
+
* The word immediately before `index`, lowercased, with a trailing dot
|
|
31
|
+
* removed -- so a dotted abbreviation like `e.g.` yields `e.g`, which is the
|
|
32
|
+
* form ABBREVIATIONS stores. Exported for title-case.ts, which asks the same
|
|
33
|
+
* question at the same kind of boundary.
|
|
34
|
+
*/
|
|
35
|
+
export function lastWordBefore(text, index) {
|
|
27
36
|
const slice = text.slice(0, index);
|
|
28
37
|
const match = /([\w.]+)$/.exec(slice);
|
|
29
38
|
return (match ? match[1] : '').toLowerCase().replace(/\.$/, '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentences.js","sourceRoot":"","sources":["../../src/scopes/sentences.ts"],"names":[],"mappings":"AAMA,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"sentences.js","sourceRoot":"","sources":["../../src/scopes/sentences.ts"],"names":[],"mappings":"AAMA,4EAA4E;AAC5E,0EAA0E;AAC1E,iDAAiD;AACjD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IACnC,KAAK;IACL,KAAK;IACL,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ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AC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9F,KAAK,GAAG,GAAG,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAChB,KAAK,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YACjB,KAAK,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;YACtD,GAAG,EAAE,IAAI,CAAC,MAAM;SACjB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/recheck",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Content linting (configurable + built-in rules)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"typescript": "6.0.3",
|
|
60
60
|
"vitest": "4.1.10",
|
|
61
61
|
"@redocly/portal": "0.68.3",
|
|
62
|
-
"@redocly/theme": "0.68.0-next.
|
|
62
|
+
"@redocly/theme": "0.68.0-next.8"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "tsgo && tsgo --noEmit -p tsconfig.typecheck.json",
|