@cldmv/fix-headers 2.1.3 → 2.1.4

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 CHANGED
@@ -1,50 +1,83 @@
1
1
  # @cldmv/fix-headers
2
2
 
3
- Multi-language source header normalizer for Node.js projects.
3
+ **@cldmv/fix-headers** is a multi-language source header normalizer for Node.js projects. It scans a project's files, works out which project each file belongs to from the manifests around it (`package.json`, `pyproject.toml`, `composer.json`, `Cargo.toml`, `go.mod`, …), detects the author from git, and inserts or updates a standard header at the top of every file in that file's own comment syntax.
4
4
 
5
- `@cldmv/fix-headers` scans project files, auto-detects project metadata (language, root, project name, git author/email), and inserts or updates standard file headers.
5
+ Headers stay correct without hand-editing: `@Date` follows the file's real creation time, `@Last modified time` only moves when the header changes, the `@Copyright` holder and years come from the manifest and the file's history, and `--check` validates existing headers in CI without writing anything. It runs as a `fix-headers` command line tool or as a library from ESM and CommonJS, and one shared config can serve every repository in an organisation.
6
+
7
+ > _One header format for every file in every repository, detected from the project itself and kept current by a single command._
6
8
 
7
9
  [![npm version]][npm_version_url] [![npm downloads]][npm_downloads_url] <!-- [![GitHub release]][github_release_url] -->[![GitHub downloads]][github_downloads_url] [![Last commit]][last_commit_url] <!-- [![Release date]][release_date_url] -->[![npm last update]][npm_last_update_url] [![Coverage]][coverage_url]
8
10
 
9
11
  [![Contributors]][contributors_url] [![Sponsor shinrai]][sponsor_url]
10
12
 
13
+ ---
14
+
11
15
  ## ✨ What's New
12
16
 
13
- ### Latest: v2.1.3 (October 2026)
17
+ ### Latest: v2.1.4 (October 2026)
14
18
 
15
- - **CI and development-dependency maintenance, no runtime change** — the `✅ Required PR Check` mirror job in `ci.yml` no longer carries the required name while it is skipped, so a skipped `pull_request` run can no longer satisfy the branch ruleset and let an in-repo PR merge before the push run's tests have finished ([#111](https://github.com/CLDMV/fix-headers/pull/111)). Four development dependencies move to their current releases in the lockfile: `@cldmv/jsonv` 1.1.1, `@cldmv/eslint-plugin-jsonv` 1.0.13, `@cldmv/prettier-plugin-jsonv` 1.1.0 and `@cldmv/vitest-runner` 1.5.1 ([#109](https://github.com/CLDMV/fix-headers/pull/109), [#114](https://github.com/CLDMV/fix-headers/pull/114)). `ignore`, the only runtime dependency, is unchanged, and `dist/`, `bin/` and the API are the same as in v2.1.2.
16
- - [View full v2.1.3 Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.1.3.md)
19
+ - **`require()` fails clearly where Node.js cannot load ES modules synchronously** — the CommonJS entry point (`dist/index.cjs`, a small wrapper around the ES module build) now checks `process.features.require_module` first. On a Node.js version without `require(esm)` it throws an `ERR_REQUIRE_ESM` error that names the package, the versions `require()` needs (^20.19.0 or >=22.12.0) and the running version, and points at `import()`, instead of Node's bare error from inside the package ([#117](https://github.com/CLDMV/fix-headers/pull/117)). New `node:test` checks run the built CommonJS entry point on every `npm test` and coverage run. On supported Node.js versions (`engines.node` is `>=22.12.0`) nothing changes.
20
+ - **Never breaks files it can't stamp** — strict JSON (`package.json` included), Markdown named with `--input`, and files with no or an unhandled extension are now skipped and reported instead of getting a JavaScript comment that broke them. Markdown gets a header only when forced with `--force-detector markdown`, as an HTML comment ([#124](https://github.com/CLDMV/fix-headers/pull/124)).
21
+ - **Repeatable `--input` and no more dependency folders** — every `--input` value is processed, not just the last ([#125](https://github.com/CLDMV/fix-headers/pull/125)), and `node_modules`, `bower_components`, `jspm_packages`, `.pnpm-store` and `.yarn` are never walked, at any depth, even without a `.gitignore` ([#126](https://github.com/CLDMV/fix-headers/pull/126)).
22
+ - [View full v2.1.4 Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.1.4.md)
17
23
 
18
24
  ### Recent Releases
19
25
 
20
- - **v2.1.2** (October 2026) — no runtime change: the repository adopts the shared CLDMV fix-headers config (`.configs/fix-headers.json` extending `@cldmv/configs/fix-headers.json`, run with `npm run fix:headers`) and stamps uniform file headers across its own sources ([#107](https://github.com/CLDMV/fix-headers/pull/107)) ([Release](https://github.com/CLDMV/fix-headers/releases/tag/v2.1.2))
21
- - **v2.1.1** (October 2026) — a file that holds only a header now ends with the header instead of trailing `margin` blank lines ([#105](https://github.com/CLDMV/fix-headers/pull/105), fixes [#104](https://github.com/CLDMV/fix-headers/issues/104)); `esbuild` bumped to 0.28.2 to clear GHSA-g7r4-m6w7-qqqr ([#103](https://github.com/CLDMV/fix-headers/pull/103)) ([Release](https://github.com/CLDMV/fix-headers/releases/tag/v2.1.1))
22
- - **v2.1.0** (September 2026) — `spacing` and `margin` header layout options: every header is framed with empty comment lines and followed by two blank lines, and YAML and Python headers keep their padded `#` lines on the first run ([#101](https://github.com/CLDMV/fix-headers/pull/101)) ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.1.0.md))
23
- - **v2.0.0** (September 2026) — built package (`dist/` and `bin/` instead of `src/`), discovery without name-based skips, `@Project` and the copyright holder from the project manifest, `--check` date validation, `--diff`, `--timezone` and config `extends` ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.0.0.md))
26
+ - **v2.1.3** (October 2026) — CI and development-dependency maintenance with no runtime change: a skipped PR run can no longer satisfy `✅ Required PR Check` and let a pull request merge before its tests finish ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.1.3.md))
27
+ - **v2.1.2** (October 2026) — no runtime change: the repository adopts the shared CLDMV fix-headers config from `@cldmv/configs` and stamps uniform file headers across its own sources ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.1.2.md))
28
+ - **v2.1.1** (October 2026) — a file that holds only a header now ends with the header instead of trailing `margin` blank lines; `esbuild` 0.28.2 clears GHSA-g7r4-m6w7-qqqr ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.1.1.md))
29
+ - **v2.1.0** (September 2026) — `spacing` and `margin` header layout options: every header is framed with empty comment lines and followed by two blank lines ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.1.0.md))
30
+
31
+ 📚 For complete release notes, see the [docs/changelog/](https://github.com/CLDMV/fix-headers/tree/master/docs/changelog/) folder.
24
32
 
25
- 📚 For complete release notes, see the [docs/changelog/](https://github.com/CLDMV/fix-headers/tree/master/docs/changelog/) folder and the [GitHub Releases](https://github.com/CLDMV/fix-headers/releases).
33
+ ---
26
34
 
27
- ## Features
35
+ ## 🚀 Key Features
28
36
 
29
37
  - Finds the project each file belongs to from its manifest (`package.json`, `pyproject.toml` / `setup.cfg` / `setup.py`, `composer.json`, `Cargo.toml`, `go.mod`), whatever the file's type
30
- - `@Project` is the name from that project's manifest, so a CSS, HTML, YAML or JSON file in a Python, PHP, Rust or Go project gets that project's name too; the folder name is used only when no manifest provides one. Override it with `projectName`. See [Project name and root](#project-name-and-root)
38
+ - `@Project` is the name from that project's manifest, so a CSS, HTML, YAML or JSONC file in a Python, PHP, Rust or Go project gets that project's name too; the folder name is used only when no manifest provides one. Override it with `projectName`. See [Project name and root](#-project-name-and-root)
31
39
  - Auto-detects author and email from git config/commit history
32
40
  - Supports per-run overrides for every detected value
33
41
  - Supports folder inclusion and exclusion configuration; skips only what the project's ignore files (everything git honours) or your own exclusions say
34
42
  - Supports monorepos: every file resolves its own project from the nearest manifest in its parent tree
43
+ - Writes each header in the file's own comment syntax, and skips files that cannot carry one (strict JSON, plain text); Markdown gets a header only when you force it. See [Supported file types](#-supported-file-types)
35
44
  - Supports per-detector syntax overrides for line and block comment tokens
36
- - Config files can use `extends` to build on a shared config (an https URL, an npm package path or a file path), so one organisation-wide config serves every repository. See [Shared configs](#shared-configs)
45
+ - Config files can use `extends` to build on a shared config (an https URL, an npm package path or a file path), so one organisation-wide config serves every repository. See [Shared configs](#-shared-configs)
37
46
  - Supports both ESM and CJS consumers
38
47
 
39
- ## Install
48
+ ---
49
+
50
+ ## 📦 Installation
51
+
52
+ ### Requirements
53
+
54
+ - **Node.js 22.12.0 or later** (`engines.node` is `>=22.12.0`).
55
+ - The package is an ES module and loads with `import` on every supported version. `require("@cldmv/fix-headers")` loads the ES module build synchronously, which needs Node.js ^20.19.0 or >=22.12.0; on older Node.js, use `import()` instead.
56
+
57
+ ### Install
40
58
 
41
59
  ```bash
42
60
  npm i @cldmv/fix-headers
43
61
  ```
44
62
 
45
- ## Usage
63
+ As a development dependency, for the CLI in `package.json` scripts:
46
64
 
47
- ### ESM
65
+ ```bash
66
+ npm i -D @cldmv/fix-headers
67
+ ```
68
+
69
+ ---
70
+
71
+ ## 🚀 Quick Start
72
+
73
+ Preview what would change, then write it:
74
+
75
+ ```bash
76
+ fix-headers --dry-run --verbose
77
+ fix-headers
78
+ ```
79
+
80
+ From ESM:
48
81
 
49
82
  ```js
50
83
  import fixHeaders from "@cldmv/fix-headers";
@@ -52,7 +85,19 @@ import fixHeaders from "@cldmv/fix-headers";
52
85
  const result = await fixHeaders({ dryRun: true });
53
86
  ```
54
87
 
55
- ## CLI
88
+ From CommonJS:
89
+
90
+ ```js
91
+ const fixHeaders = require("@cldmv/fix-headers");
92
+
93
+ const result = await fixHeaders({ dryRun: true });
94
+ ```
95
+
96
+ `result` lists every scanned file and the changes a writing run makes; see [API](#-api) for the options and [Sample output](#-sample-output) for per-file detail.
97
+
98
+ ---
99
+
100
+ ## 💻 CLI
56
101
 
57
102
  After install, use the package binary:
58
103
 
@@ -69,11 +114,11 @@ npm run cli -- --dry-run --json
69
114
  Common CLI options:
70
115
 
71
116
  - `--dry-run`
72
- - `--check` - validate header dates without writing; exits `1` on date drift (see [Date checks](#date-checks))
117
+ - `--check` - validate header dates without writing; exits `1` on date drift (see [Date checks](#-date-checks))
73
118
  - `--fix-created-date`
74
119
  - `--strict-created-date`
75
120
  - `--normalize-date-format`
76
- - `--timezone <name>` - write new header dates in an IANA time zone (see [Time zone](#time-zone))
121
+ - `--timezone <name>` - write new header dates in an IANA time zone (see [Time zone](#-time-zone))
77
122
  - `--convert-timezone` - with `--timezone`, also rewrite existing header dates into that zone
78
123
  - `--json`
79
124
  - `--verbose` - list updated files; together with `--sample-output` or `--diff`, also list each file's field differences (`authorName: found "X", expected "Y"`)
@@ -83,28 +128,23 @@ Common CLI options:
83
128
  - `--force-last-modified-author-update`
84
129
  - `--use-gpg-signer-author` (the signing key's UID name, with the OpenPGP UID comment dropped)
85
130
  - `--cwd <path>`
86
- - `--input <path>`
87
- - `--include-folder <path>` (repeatable)
131
+ - `--input <path>` (repeatable) - process these files and folders instead of the whole project: the union of every value, each file once (`--input src/a.mjs --input src/b.mjs --input scripts`). A named file whose type cannot carry a header (see [Supported file types](#-supported-file-types)) is reported as `skipped: <file> (<reason>)` and left unchanged
132
+ - `--include-folder <path>` (repeatable) - naming a folder inside a dependency folder (`--include-folder node_modules/pkg`) processes it, although discovery otherwise skips dependency folders (see [Which files are processed](#-which-files-are-processed))
88
133
  - `--include-folder-non-recursive <path>` (repeatable) - include only that folder's own files, not its subfolders
89
134
  - `--exclude-folder <path>` (repeatable)
90
135
  - `--include-extension <ext>` (repeatable)
91
136
  - `--enable-detector <id>` / `--disable-detector <id>` (repeatable)
137
+ - `--force-detector <id>` (repeatable) - turn on a force-only detector; `--force-detector markdown` gives `.md` / `.markdown` files an HTML-comment header (see [Supported file types](#-supported-file-types))
92
138
  - `--project-name <name>`
93
139
  - `--author-name <name>` / `--author-email <email>`
94
- - `--company-name <name>` - the `@Copyright` holder for every file, instead of the one the manifests provide (see [Copyright holder](#copyright-holder))
140
+ - `--company-name <name>` - the `@Copyright` holder for every file, instead of the one the manifests provide (see [Copyright holder](#-copyright-holder))
95
141
  - `--copyright-start-year <year>` - the `@Copyright` start year for every file (default: the year of each file's `@Date`)
96
- - `--spacing <n>` / `--margin <n>` - the header's layout: empty comment lines inside the header's edges (default `1`) and blank lines after it (default `2`), see [Header layout](#header-layout)
97
- - `--config <json-file>` - load options from a JSON file, which may use `extends` to build on shared configs (see [Shared configs](#shared-configs)); flags on the command line win over the file
142
+ - `--spacing <n>` / `--margin <n>` - the header's layout: empty comment lines inside the header's edges (default `1`) and blank lines after it (default `2`), see [Header layout](#-header-layout)
143
+ - `--config <json-file>` - load options from a JSON file, which may use `extends` to build on shared configs (see [Shared configs](#-shared-configs)); flags on the command line win over the file
98
144
 
99
- ### CommonJS
145
+ ---
100
146
 
101
- ```js
102
- const fixHeaders = require("@cldmv/fix-headers");
103
-
104
- const result = await fixHeaders({ dryRun: true });
105
- ```
106
-
107
- ## API
147
+ ## 🔧 API
108
148
 
109
149
  ### `fixHeaders(options?)`
110
150
 
@@ -113,23 +153,24 @@ Runs header normalization. Project/language/author/email metadata is auto-detect
113
153
  Important options:
114
154
 
115
155
  - `cwd?: string` - start directory for project detection
116
- - `input?: string` - explicit single file or folder path to process
156
+ - `input?: string | string[]` - file or folder paths to process instead of the whole project. Every path is processed: the files named plus the files discovered under the folders named, each file once, in the order given. A path that does not exist throws; an empty list means no input. A file whose type cannot carry a header is listed in the result's `skipped` instead of being changed (see [Supported file types](#-supported-file-types))
117
157
  - `dryRun?: boolean` - compute changes without writing files
118
- - `check?: boolean` - validate each existing header's dates and write nothing (implies `dryRun`). Each result entry gets `dateIssues`, and the result gets `filesWithDateDrift` and `dateAdvisories`. See [Date checks](#date-checks)
119
- - `fixCreatedDate?: boolean` - move an existing `@Date` back to the oldest of itself, the file's git first commit, and its filesystem creation time (see [Creation date](#creation-date)). It only ever moves `@Date` earlier. Off by default: an existing `@Date` is kept as written
158
+ - `check?: boolean` - validate each existing header's dates and write nothing (implies `dryRun`). Each result entry gets `dateIssues`, and the result gets `filesWithDateDrift` and `dateAdvisories`. See [Date checks](#-date-checks)
159
+ - `fixCreatedDate?: boolean` - move an existing `@Date` back to the oldest of itself, the file's git first commit, and its filesystem creation time (see [Creation date](#-creation-date)). It only ever moves `@Date` earlier. Off by default: an existing `@Date` is kept as written
120
160
  - `strictCreatedDate?: boolean` - with `check`, count a `@Date` later than the file's git first commit or filesystem creation time as drift (fails the run). Off by default, where it is an advisory
121
161
  - `normalizeDateFormat?: boolean` - write every header date in the git `%aI` form (`2026-03-01T17:59:32-08:00`), keeping each date's offset and instant. Off by default; the first run rewrites (and restamps) every managed file whose dates use the space form (`2026-03-01 17:59:32 -08:00`)
122
- - `timezone?: string` - an IANA time zone name (`America/Los_Angeles`, `UTC`, `Asia/Kolkata`, ...). Every date fix-headers writes (a new header's `@Date`, and `@Last modified time`) is expressed in that zone; the instant and its epoch never change. Unset (the default): dates are written as today. An unknown zone name throws. See [Time zone](#time-zone)
123
- - `convertTimezone?: boolean` - with `timezone`, also rewrite the existing `@Date` and `@Last modified time` values of every header into that zone, keeping each instant. Throws when `timezone` is not set. See [Time zone](#time-zone)
124
- - `sampleOutput?: boolean` - include a `sample` for each changed file: previous/new header text, a unified `diff`, per-field `issues`, and `detectedValues` (see [Sample output](#sample-output))
125
- - `configFile?: string` - load JSON options from file (resolved from `cwd`). The file may use `extends` to build on shared configs by URL, npm package path or file path (see [Shared configs](#shared-configs)); options passed in the call win over everything from files
162
+ - `timezone?: string` - an IANA time zone name (`America/Los_Angeles`, `UTC`, `Asia/Kolkata`, ...). Every date fix-headers writes (a new header's `@Date`, and `@Last modified time`) is expressed in that zone; the instant and its epoch never change. Unset (the default): dates are written as today. An unknown zone name throws. See [Time zone](#-time-zone)
163
+ - `convertTimezone?: boolean` - with `timezone`, also rewrite the existing `@Date` and `@Last modified time` values of every header into that zone, keeping each instant. Throws when `timezone` is not set. See [Time zone](#-time-zone)
164
+ - `sampleOutput?: boolean` - include a `sample` for each changed file: previous/new header text, a unified `diff`, per-field `issues`, and `detectedValues` (see [Sample output](#-sample-output))
165
+ - `configFile?: string` - load JSON options from file (resolved from `cwd`). The file may use `extends` to build on shared configs by URL, npm package path or file path (see [Shared configs](#-shared-configs)); options passed in the call win over everything from files
126
166
  - `includeExtensions?: string[]` - file extensions to process
127
- - `enabledDetectors?: string[]` - detector ids to enable (defaults to all)
167
+ - `enabledDetectors?: string[]` - detector ids to enable (defaults to every detector that is not force-only)
128
168
  - `disabledDetectors?: string[]` - detector ids to disable
169
+ - `forcedDetectors?: string[]` - force-only detector ids to turn on (currently only `"markdown"`). A forced detector is used for `input` and for discovery alike, even when `enabledDetectors` does not list it; `disabledDetectors` still turns it off. An id that is unknown or does not need forcing throws. See [Supported file types](#-supported-file-types)
129
170
  - `detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }>` - override detector comment syntax tokens
130
171
  - `includeFolders?: Array<string | { path: string, recursive?: boolean }>` - project-relative folders to scan. A string entry is scanned recursively; `{ path, recursive: false }` includes only that folder's own files (for example `{ path: ".", recursive: false }` for the project-root files without the whole tree). Overlapping entries are collapsed, so every file is scanned once however the folders nest or are spelled (`"."` next to `"src"`, `"src"` next to `"src/core"`, `"./src"` next to `"src/"`)
131
- - `excludeFolders?: string[]` - folder names or relative paths to exclude, on top of what the ignore files exclude
132
- - `gitignore?: boolean | string | string[]` - which ignore files decide what discovery skips. Omitted (or `true`): every ignore file git honours (see [Which files are processed](#which-files-are-processed)). `false`: no ignore files, every file is processed. A path or array of paths (relative to the project root): exactly those files, parsed with `.gitignore` syntax, without asking git.
172
+ - `excludeFolders?: string[]` - folder names or relative paths to exclude, on top of what the ignore files exclude. Dependency folders are always excluded: `node_modules`, `bower_components`, `jspm_packages`, `.pnpm-store` and `.yarn` at any depth, and a `vendor` folder holding Composer's `autoload.php` or Go's `modules.txt` (see [Which files are processed](#-which-files-are-processed)); list a path inside one in `includeFolders` (or pass it as `input`) to process it anyway
173
+ - `gitignore?: boolean | string | string[]` - which ignore files decide what discovery skips. Omitted (or `true`): every ignore file git honours (see [Which files are processed](#-which-files-are-processed)). `false`: no ignore files, every file is processed except those in dependency folders. A path or array of paths (relative to the project root): exactly those files, parsed with `.gitignore` syntax, without asking git.
133
174
  - `projectName?: string` - the `@Project` value for every file, instead of the manifest name
134
175
  - `language?: string` - the reported `language` for every file (does not change comment syntax or project resolution)
135
176
  - `projectRoot?: string` - the project root for every file (the base of `@Filename` and of git history lookups) and the scan root
@@ -140,10 +181,10 @@ Important options:
140
181
  - `forceAuthorUpdate?: boolean` - force update `@Author`/`@Email` to detected or overridden current values
141
182
  - `forceLastModifiedAuthorUpdate?: boolean` - force update `@Last modified by` to detected or overridden current values. Without this, an existing header's recorded `@Last modified by` identity is preserved and does not by itself trigger an update just because the running author differs (e.g. a different `git config user.name` than whoever last touched the file)
142
183
  - `useGpgSignerAuthor?: boolean` - take the detected `@Author` name from the user ID of the OpenPGP key git signs commits with (`user.signingkey`, read through `gpg.openpgp.program` / `gpg.program` / `gpg`; the first user ID that is not revoked or expired). The OpenPGP UID comment is dropped, so `Nate Corcoran (2023 PC) <nate@example.com>` becomes `Nate Corcoran` (with `company: "CLDMV"`: `Nate Corcoran <CLDMV>`). It describes whoever runs the tool, whatever the last commit is — a squash merge made by GitHub or a bot has no locally verifiable signer. With no readable OpenPGP signing key (none configured, `gpg.format` is `ssh`/`x509`, or gpg is unavailable) it falls back to the last commit's signer (`%GS`), then `git config user.name`, then the last commit's author
143
- - `companyName?: string` - the `@Copyright` holder for every file, instead of the one the project's manifests provide. There is no built-in default: unset, the holder comes from the manifests, and with none it is left out of the line (see [Copyright holder](#copyright-holder))
144
- - `copyrightStartYear?: number` - the `@Copyright` start year for every file. Unset (the default): each file's start year is the year of its own `@Date`, see [Copyright years](#copyright-years)
145
- - `spacing?: number` - empty comment lines just inside the header's opening and just before its closing. Default `1`, see [Header layout](#header-layout)
146
- - `margin?: number` - blank lines between the header and the file's next content. Default `2`, see [Header layout](#header-layout)
184
+ - `companyName?: string` - the `@Copyright` holder for every file, instead of the one the project's manifests provide. There is no built-in default: unset, the holder comes from the manifests, and with none it is left out of the line (see [Copyright holder](#-copyright-holder))
185
+ - `copyrightStartYear?: number` - the `@Copyright` start year for every file. Unset (the default): each file's start year is the year of its own `@Date`, see [Copyright years](#-copyright-years)
186
+ - `spacing?: number` - empty comment lines just inside the header's opening and just before its closing. Default `1`, see [Header layout](#-header-layout)
187
+ - `margin?: number` - blank lines between the header and the file's next content. Default `2`, see [Header layout](#-header-layout)
147
188
 
148
189
  Example:
149
190
 
@@ -171,7 +212,9 @@ const result = await fixHeaders({
171
212
  });
172
213
  ```
173
214
 
174
- ## Shared configs
215
+ ---
216
+
217
+ ## 🧩 Shared configs
175
218
 
176
219
  A config file (`--config <path>` on the CLI, `configFile` in the API) can extend other configs with `extends`, so an organisation keeps its header settings in one place instead of copying them into every repository. `extends` is a string or an array of strings, and each entry is one of:
177
220
 
@@ -210,7 +253,9 @@ A shared config can also be served from a URL, and mixed with local files:
210
253
  }
211
254
  ```
212
255
 
213
- ## Project name and root
256
+ ---
257
+
258
+ ## 🔎 Project name and root
214
259
 
215
260
  Which project a file belongs to depends on the manifests around it, not on the file's type. Comment syntax is the only thing the file's type decides.
216
261
 
@@ -229,14 +274,14 @@ A manifest claims its folder as soon as it exists and can be read, even when it
229
274
  For each file:
230
275
 
231
276
  1. **Project root.** Walk up from the file's folder. The nearest folder that at least one driver claims is the project root. `@Filename` is the file's path relative to it, and git history (`@Date`, `@Last modified time`) is looked up from it.
232
- 2. **Order.** When several drivers claim that folder, the file's native driver is read first (a `.py` file reads `python` first), then the fixed order `node`, `python`, `php`, `rust`, `go`. Language-neutral files (CSS, HTML, YAML, JSON, …) use the fixed order.
277
+ 2. **Order.** When several drivers claim that folder, the file's native driver is read first (a `.py` file reads `python` first), then the fixed order `node`, `python`, `php`, `rust`, `go`. Language-neutral files (CSS, HTML, YAML, JSONC, …) use the fixed order.
233
278
  3. **Per-field fallback.** Each value is taken from the first driver in that order whose manifest provides it. In a folder with a nameless `package.json` and a named `pyproject.toml`, every file gets the `pyproject.toml` name.
234
279
  4. **Climbing.** A value no driver at the project root provides is looked up the same way in each ancestor folder a driver claims, up to and including the scan root (`projectRoot`, else `cwd`), never above it. A nameless sub-package therefore takes the name of the repository around it. Only values climb: the project root, and with it `@Filename` and the git lookups, stays the nearest claimed folder.
235
280
  5. **Folder name.** When nothing up to the scan root provides a name, `@Project` is the project root's folder name.
236
281
 
237
282
  A folder holding `.git` is a repository boundary: neither the root search nor the climb goes past it, so a nested repository without a manifest is a project of its own. With no manifest up to the repository root, that repository root is the project root and its folder name is the name. With neither a manifest nor a repository anywhere above the file, the file's own folder is the project root: `@Project` is that folder's name and `@Filename` is `/<file name>`.
238
283
 
239
- `projectName`, `projectRoot`, `language` and `marker` override the detected values for every file. The copyright holder is resolved from the same manifests by the same rules, see [Copyright holder](#copyright-holder).
284
+ `projectName`, `projectRoot`, `language` and `marker` override the detected values for every file. The copyright holder is resolved from the same manifests by the same rules, see [Copyright holder](#-copyright-holder).
240
285
 
241
286
  For example, scanning `repo/`:
242
287
 
@@ -257,7 +302,9 @@ repo/
257
302
 
258
303
  To support another ecosystem, add a module to `src/drivers/` that exports a `driver` with `id`, `languages` (the file-type detector ids native to it), `manifests` (filenames that claim a folder, in reading order), `detect(dirPath)` (returns `detectManifests(dirPath, manifests)` from `src/drivers/shared.mjs`) and `read(detection)` (returns `{ name, company }`, each `undefined` when the manifest has none), then add it to `MANIFEST_DRIVERS` in `src/drivers/index.mjs` at its place in the fixed order.
259
304
 
260
- ## Copyright holder
305
+ ---
306
+
307
+ ## 📜 Copyright holder
261
308
 
262
309
  The holder on the `@Copyright` line (`companyName`) comes from the manifest of the project the file belongs to, read by the same drivers and with the same rules as the project name: the nearest claimed folder, the file's native driver first, the per-field fallback, and climbing up to the scan root (never past a `.git` folder). The holder climbs on its own, so a sub-package whose `package.json` has a name but no author takes the repository's author while keeping its own `@Project`. The field each driver reads is in the table above.
263
310
 
@@ -283,7 +330,9 @@ With `companyName: "Example Co"` every file gets `Copyright (c) 2026-2026 Exampl
283
330
 
284
331
  With `sampleOutput`, `detectedValues.companyName` is the resolved holder (`null` when there is none) and `detectedValues.companyNameSource` says where it came from: `{ from: "manifest", driver, manifest, dir }`, `{ from: "option" }` (`companyName`) or `{ from: "none" }`. `result.metadata` carries the same two values for the scan root. The `@Author` suffix set by `company` (`Name <Company>`) is a separate option and does not affect the holder.
285
332
 
286
- ## Creation date
333
+ ---
334
+
335
+ ## 📅 Creation date
287
336
 
288
337
  `@Date` is "oldest wins": a file cannot have been created later than its first commit or than the time the filesystem first saw it, and an `@Date` older than both (a file brought in from elsewhere, or dated before it was committed) is kept.
289
338
 
@@ -293,7 +342,9 @@ With `sampleOutput`, `detectedValues.companyName` is the resolved holder (`null`
293
342
 
294
343
  The filesystem creation time is the earlier of the file's birth time and its modification time. Content last written at the modification time existed by then, so it bounds creation even when the birth time is later (an extracted archive or a `cp -p` copy keeps the source's modification time). Where the platform reports no birth time, the modification time is used. A fresh clone or CI checkout gives every file a current filesystem time, so there the git first commit decides.
295
344
 
296
- ## Copyright years
345
+ ---
346
+
347
+ ## 📆 Copyright years
297
348
 
298
349
  `@Copyright: Copyright (c) <start>-<end> <companyName> All rights reserved.`
299
350
 
@@ -302,7 +353,9 @@ The filesystem creation time is the earlier of the file's birth time and its mod
302
353
 
303
354
  A file created in 2019 therefore gets `2019-2026` when fix-headers runs in 2026, not `2026-2026`.
304
355
 
305
- ## Header layout
356
+ ---
357
+
358
+ ## 📐 Header layout
306
359
 
307
360
  Two options set the shape of the header, and both apply to every file type.
308
361
 
@@ -341,7 +394,9 @@ With `spacing: 0, margin: 1` the header is compact, with no empty comment lines
341
394
 
342
395
  An existing header is restyled in place to match, so changing either option rewrites the layout of every header on the next run, and a run with unchanged options finds nothing to update. A line-comment header always keeps at least one blank line after it, even with `margin: 0`, so a comment that follows the file's header is not read as part of it.
343
396
 
344
- ## Date checks
397
+ ---
398
+
399
+ ## ✅ Date checks
345
400
 
346
401
  `check: true` / `--check` validates the `@Date` and `@Last modified time` values of every existing header and writes nothing. It compares instants, not strings, so the same moment written with another offset or in the space/`T` form is not drift. It is independent of the rendered-header diff: an author, identity, copyright, or other content difference never fails the check. Files without a header are skipped.
347
402
 
@@ -374,11 +429,13 @@ Advisories are counted in the summary and listed with `--verbose`; `--json` prin
374
429
 
375
430
  In a normal (writing) run, an epoch that disagrees with its datetime text is recomputed from the text; the datetime text itself is left as written. `created-newer-than-source` is corrected only with `fixCreatedDate` / `--fix-created-date`.
376
431
 
377
- ## Time zone
432
+ ---
433
+
434
+ ## 🌍 Time zone
378
435
 
379
436
  A header date is correct in any zone: the offset is only how the instant is shown, and the epoch in parentheses is the instant. So nothing is converted by default. `timezone` / `--timezone <name>` is for projects that want every date shown in one zone:
380
437
 
381
- - **Dates fix-headers writes** are expressed in the zone: a new header's `@Date` (from the git first commit or the filesystem, see [Creation date](#creation-date)), an `@Date` moved by `fixCreatedDate`, and the `@Last modified time` stamped on every changed file.
438
+ - **Dates fix-headers writes** are expressed in the zone: a new header's `@Date` (from the git first commit or the filesystem, see [Creation date](#-creation-date)), an `@Date` moved by `fixCreatedDate`, and the `@Last modified time` stamped on every changed file.
382
439
  - **Dates already in a header** are kept as written, unless `convertTimezone` / `--convert-timezone` is also set. That sweep rewrites existing `@Date` and `@Last modified time` values into the zone. A value whose datetime is not recognised is left alone, and so is one already in the zone's offset at that instant.
383
440
 
384
441
  Only the wall-clock time and the offset change; the instant and the epoch stay the same. The offset is the zone's offset at that instant, from the time zone data built into Node (`Intl`), so daylight saving time is applied per date: with `America/Los_Angeles`, a January date is written at `-08:00` and a July date at `-07:00`. Half-hour and other zones work the same way (`Asia/Kolkata` is `+05:30`, `Pacific/Kiritimati` is `+14:00`). The zone name is validated with `Intl`, and an unknown name fails the run.
@@ -403,14 +460,55 @@ $ fix-headers --timezone America/Los_Angeles --convert-timezone
403
460
 
404
461
  The `@Date` instant is unchanged; `@Last modified time` is restamped with the time of the run, in the zone.
405
462
 
406
- ## Which files are processed
463
+ ---
464
+
465
+ ## 📑 Supported file types
466
+
467
+ Each file type is handled by a detector, which decides the header's comment syntax. A file is given a header only when an enabled detector handles its extension:
468
+
469
+ | Detector | Extensions | Header comment | Default |
470
+ | ---------- | ----------------------------- | -------------- | ------------------------------------------ |
471
+ | `node` | `.js .mjs .cjs .ts .tsx .jsx` | `/** … */` | on |
472
+ | `json` | `.jsonc .json5 .jsonv` | `/** … */` | on |
473
+ | `css` | `.css` | `/* … */` | on |
474
+ | `html` | `.html .htm` | `<!-- … -->` | on |
475
+ | `yaml` | `.yaml .yml` | `# …` | on |
476
+ | `python` | `.py` | `# …` | on |
477
+ | `php` | `.php` | `/** … */` | on |
478
+ | `rust` | `.rs` | `/** … */` | on |
479
+ | `go` | `.go` | `/** … */` | on |
480
+ | `markdown` | `.md .markdown` | `<!-- … -->` | off; only with `--force-detector markdown` |
481
+
482
+ Every other file is skipped and left byte-for-byte unchanged, including when you name it with `--input` or add its extension with `includeExtensions`:
407
483
 
408
- By default every file with a supported extension is processed. Nothing is skipped because of its name: `node_modules`, `dist`, `build`, `coverage`, `tmp` and the like are processed unless something excludes them. Files are skipped only when:
484
+ - **Strict JSON (`.json`)** has no comment syntax, so it never gets a header. A comment would make `package.json` and every other JSON file invalid.
485
+ - **Files with no extension, or an extension no enabled detector handles** (`.txt`, `.toml`, a disabled detector's extensions, …) are skipped instead of being given a guessed comment.
486
+ - **Markdown** is skipped unless the `markdown` detector is forced with `--force-detector markdown` (`forcedDetectors: ["markdown"]` in the API or a config file). Naming a `.md` file with `--input` does not force it. A forced header is an HTML comment, which Markdown renderers do not display; it goes below any YAML front matter (`---` … `---`), and later runs update it in place. Forcing applies to discovery too, so a repo-wide run with the option also stamps `README.md` and changelogs; to stamp one file, pass the option together with `--input <file>`. `.mdx` is not covered, because MDX does not accept HTML comments.
409
487
 
488
+ A skipped file is listed in the result's `skipped` array as `{ file, reason }` and counted in `filesSkipped`, not in `filesScanned` or `changes`. The CLI adds `skipped=<n>` to its summary and prints one `skipped: <file> (<reason>)` line per file:
489
+
490
+ ```sh
491
+ $ fix-headers --input package.json
492
+ fix-headers complete: scanned=0, updated=0, skipped=1, dryRun=false
493
+ skipped: package.json (no enabled detector handles .json files)
494
+ ```
495
+
496
+ ---
497
+
498
+ ## 📁 Which files are processed
499
+
500
+ By default every file with a supported extension (see [Supported file types](#-supported-file-types)) is processed. Build output is not skipped by name: `dist`, `build`, `coverage`, `tmp` and the like are processed unless something excludes them. Files are skipped only when:
501
+
502
+ - they are inside a dependency folder (below),
410
503
  - the project's ignore files ignore them, or
411
504
  - you exclude them with `excludeFolders` / `--exclude-folder`.
412
505
 
413
- The one exception is `.git`, git's own storage, which is never walked.
506
+ `.git`, git's own storage, is never walked. Neither are dependency folders, which hold installed third-party code and never the project's own source. They are skipped at any depth (a sub-package's own `node_modules` included) and whatever the ignore files say, so a project with no `.gitignore`, a tracked dependency folder or `gitignore: false` does not stamp headers into them:
507
+
508
+ - `node_modules`, `bower_components`, `jspm_packages`, `.pnpm-store` and `.yarn`
509
+ - `vendor`, but only when it holds Composer's `vendor/autoload.php` or Go's `vendor/modules.txt`. Any other `vendor` folder is processed, because the name is also used for code the project maintains itself (front-end `vendor/` scripts, Laravel's published `resources/views/vendor`). Exclude such a folder with `excludeFolders` if it holds third-party code.
510
+
511
+ A path inside a dependency folder that you name explicitly is still processed: an `includeFolders` / `--include-folder` entry such as `node_modules/pkg`, or an `input` / `--input` file or folder.
414
512
 
415
513
  "Ignore files" means everything git itself honours: the root `.gitignore`, `.gitignore` files in subfolders (each applying to its own folder), `.git/info/exclude`, and the global excludes file (`core.excludesFile`), including negation patterns.
416
514
 
@@ -421,15 +519,19 @@ The one exception is `.git`, git's own storage, which is never walked.
421
519
 
422
520
  `gitignore: false` turns all of this off, and `gitignore: "<file>"` / `["<file>", ...]` replaces it with exactly the listed files.
423
521
 
424
- ## Notes
522
+ ---
523
+
524
+ ## 📝 Notes
425
525
 
426
526
  - `excludeFolders` supports both folder-name and nested path matching.
427
- - `includeFolders` entries never double-count a file. A folder that lies inside another recursive include is not walked a second time; the exception is a folder the outer walk never enters because `excludeFolders` excludes it (for example `node_modules/pkg` listed explicitly while `node_modules` is excluded), which keeps being walked on its own because it was named explicitly. An `includeFolders` entry does not override the ignore files: a folder they ignore contributes no files.
428
- - File discovery is described in [Which files are processed](#which-files-are-processed).
429
- - For monorepos, each file resolves its project from the nearest manifest in its parent tree (see [Project name and root](#project-name-and-root)).
527
+ - `includeFolders` entries never double-count a file. A folder that lies inside another recursive include is not walked a second time; the exception is a folder the outer walk never enters because it is a dependency folder or `excludeFolders` excludes it (for example `node_modules/pkg` listed explicitly), which keeps being walked on its own because it was named explicitly. An `includeFolders` entry does not override the ignore files: a folder they ignore contributes no files.
528
+ - File discovery is described in [Which files are processed](#-which-files-are-processed).
529
+ - For monorepos, each file resolves its project from the nearest manifest in its parent tree (see [Project name and root](#-project-name-and-root)).
430
530
  - With `sampleOutput` enabled, each changed file includes `previousValue`, `newValue`, `diff`, `issues`, and `detectedValues` in results.
431
531
 
432
- ## Sample output
532
+ ---
533
+
534
+ ## 🔍 Sample output
433
535
 
434
536
  With `sampleOutput: true` (CLI: `--sample-output` or `--diff`), every changed entry in `result.changes` carries a `sample` object. It costs nothing when the option is off.
435
537
 
@@ -437,7 +539,7 @@ With `sampleOutput: true` (CLI: `--sample-output` or `--diff`), every changed en
437
539
  - `newValue` - the header block this run writes.
438
540
  - `diff` - a ready-to-print unified diff of the header block. The `---`/`+++` lines name the file (`a/<file>` / `b/<file>`, or `/dev/null` when there was no previous header, in which case the whole new header shows as added), and hunk line numbers are file line numbers.
439
541
  - `issues` - one `{ field, previous, detected }` entry per header field whose written value differs from the existing header, in header order. Fields: `projectName`, `filename`, `createdAt`, `authorName`, `authorEmail`, `lastModifiedByName`, `lastModifiedByEmail`, `lastModifiedAt`, `copyrightStartYear`, `copyrightEndYear`, `companyName`. Values are the field text as written in the header (dates keep their `date (timestamp)` form); `previous` is `null` when the field was missing.
440
- - `detectedValues` - the metadata resolved for the file. `projectNameSource` says where `projectName` came from: `{ from: "manifest", driver, manifest, dir }` (the driver, its manifest and the folder it sits in), `{ from: "folder", dir }` (the project root's folder name) or `{ from: "option" }` (`projectName`). `copyrightStartYear` is the start year written for the file, and `copyrightStartYearSource` says where it came from: `"option"` (`copyrightStartYear`) or `"created-date"` (the year of the file's `@Date`, see [Copyright years](#copyright-years)). The run-level `result.metadata.copyrightStartYear` is the `copyrightStartYear` option, or `null` when it is not set.
542
+ - `detectedValues` - the metadata resolved for the file. `projectNameSource` says where `projectName` came from: `{ from: "manifest", driver, manifest, dir }` (the driver, its manifest and the folder it sits in), `{ from: "folder", dir }` (the project root's folder name) or `{ from: "option" }` (`projectName`). `copyrightStartYear` is the start year written for the file, and `copyrightStartYearSource` says where it came from: `"option"` (`copyrightStartYear`) or `"created-date"` (the year of the file's `@Date`, see [Copyright years](#-copyright-years)). The run-level `result.metadata.copyrightStartYear` is the `copyrightStartYear` option, or `null` when it is not set.
441
543
 
442
544
  `issues` compares the existing header against what is actually written, not against the raw detected metadata. fix-headers preserves an existing `@Author`/`@Email` and `@Last modified by` identity unless `forceAuthorUpdate` / `forceLastModifiedAuthorUpdate` is set, so those fields only appear when they really change. An updated file always gets a fresh `@Last modified time`, so `lastModifiedAt` is listed for every changed file that already had a header.
443
545
 
@@ -472,9 +574,40 @@ issues: src/cli.mjs
472
574
  */
473
575
  ```
474
576
 
475
- ## License
577
+ ---
578
+
579
+ ## 📚 Documentation
580
+
581
+ - **[Changelog](https://github.com/CLDMV/fix-headers/tree/master/docs/changelog/)** — release notes for every version (v1 and v2)
582
+ - **[Release notes on GitHub](https://github.com/CLDMV/fix-headers/releases)** — the same notes attached to each release tag
583
+
584
+ [![CodeFactor]][codefactor_url] [![OpenSSF Scorecard]][ossf_scorecard_url] [![npms.io score]][npms_url] [![npm unpacked size]][npm_size_url] [![Repo size]][repo_size_url]
585
+
586
+ ---
587
+
588
+ ## 🤝 Contributing
589
+
590
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/CLDMV/fix-headers/issues). Pull requests target the `next` branch; releases ship from `next` to `master`.
591
+
592
+ [![Contributors]][contributors_url] [![Sponsor shinrai]][sponsor_url]
593
+
594
+ ---
595
+
596
+ ## 🔗 Links
597
+
598
+ - **npm**: [@cldmv/fix-headers](https://www.npmjs.com/package/@cldmv/fix-headers)
599
+ - **GitHub**: [CLDMV/fix-headers](https://github.com/CLDMV/fix-headers)
600
+ - **Issues**: [GitHub Issues](https://github.com/CLDMV/fix-headers/issues)
601
+ - **Changelog**: [docs/changelog/](https://github.com/CLDMV/fix-headers/tree/master/docs/changelog/)
602
+ - **Releases**: [GitHub Releases](https://github.com/CLDMV/fix-headers/releases)
603
+
604
+ ---
605
+
606
+ ## 📄 License
607
+
608
+ [![GitHub license]][github_license_url] [![npm license]][npm_license_url]
476
609
 
477
- Apache-2.0
610
+ Apache-2.0 © Shinrai / CLDMV
478
611
 
479
612
  <!-- Badge definitions -->
480
613
  <!-- [github release]: https://img.shields.io/github/v/release/CLDMV/fix-headers?style=for-the-badge&logo=github&logoColor=white&labelColor=181717 -->
@@ -498,3 +631,17 @@ Apache-2.0
498
631
  [contributors_url]: https://github.com/CLDMV/fix-headers/graphs/contributors
499
632
  [sponsor shinrai]: https://img.shields.io/github/sponsors/shinrai?style=for-the-badge&logo=githubsponsors&logoColor=white&labelColor=EA4AAA&label=Sponsor
500
633
  [sponsor_url]: https://github.com/sponsors/shinrai
634
+ [codefactor]: https://img.shields.io/codefactor/grade/github/CLDMV/fix-headers?style=for-the-badge&logo=codefactor&logoColor=white&labelColor=F44A6A
635
+ [codefactor_url]: https://www.codefactor.io/repository/github/cldmv/fix-headers
636
+ [openssf scorecard]: https://img.shields.io/ossf-scorecard/github.com/CLDMV/fix-headers?style=for-the-badge&label=OpenSSF%20Scorecard
637
+ [ossf_scorecard_url]: https://scorecard.dev/viewer/?uri=github.com/CLDMV/fix-headers
638
+ [npms.io score]: https://img.shields.io/npms-io/final-score/%40cldmv%2Ffix-headers?style=for-the-badge&logo=npms&logoColor=white&labelColor=0B5D57
639
+ [npms_url]: https://npms.io/search?q=%40cldmv%2Ffix-headers
640
+ [npm unpacked size]: https://img.shields.io/npm/unpacked-size/%40cldmv%2Ffix-headers.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
641
+ [npm_size_url]: https://www.npmjs.com/package/@cldmv/fix-headers
642
+ [repo size]: https://img.shields.io/github/repo-size/CLDMV/fix-headers?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
643
+ [repo_size_url]: https://github.com/CLDMV/fix-headers
644
+ [github license]: https://img.shields.io/github/license/CLDMV/fix-headers.svg?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
645
+ [github_license_url]: https://github.com/CLDMV/fix-headers/blob/HEAD/LICENSE
646
+ [npm license]: https://img.shields.io/npm/l/%40cldmv%2Ffix-headers.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
647
+ [npm_license_url]: https://www.npmjs.com/package/@cldmv/fix-headers