@rm-industries/oxlint-plugin-headstamp 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +73 -11
  2. package/package.json +14 -3
package/README.md CHANGED
@@ -14,24 +14,32 @@ input.
14
14
 
15
15
  Headstamp uses oxlint's `createOnce` API with a `Program` visitor. JavaScript plugins
16
16
  are still an alpha oxlint feature. CI verifies the lockfile's exact versions,
17
- currently oxlint 1.88.0. No benchmarked performance improvement is claimed.
17
+ currently oxlint 1.93.0. No benchmarked performance improvement is claimed.
18
18
 
19
19
  Development and peer dependencies use caret ranges. The committed lockfile and
20
20
  `npm ci` keep installs reproducible; dependency updates must pass the same checks.
21
21
 
22
- ## Try the local package
22
+ ## Tested source formats
23
23
 
24
- The npm package has not been published. Build this checkout first:
24
+ Real CLI tests verify `.js`, `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`, `.jsx`, and
25
+ `.tsx`, using module, CommonJS, typed, and JSX syntax as appropriate. For every
26
+ extension, tests require missing-header diagnostics, exact header insertion,
27
+ valid-header acceptance, unchanged source bodies, and repeated-fix convergence.
28
+ They also cover LF/CRLF, BOM-only and shebang-only prefixes, and mixed-file
29
+ configuration overrides, disabled rules, and ignores.
25
30
 
26
- ```sh
27
- npm ci
28
- npm run build
29
- ```
31
+ Use oxlint's existing file discovery, overrides, and ignores; Headstamp adds no
32
+ file selector or parser. Physical-file headers in Vue, Svelte, and Astro are
33
+ deferred on oxlint 1.88.0: scriptless files do not invoke the plugin, and scripts
34
+ expose separate source/edit regions. Enabling the rule there can insert per-script
35
+ banners rather than one physical-file header. Exclude those formats with oxlint
36
+ overrides/ignores when enforcing physical headers. See the [framework investigation](docs/framework-upstream-research.md)
37
+ for separate decisions, reproducible CLI probes, and pinned upstream references.
30
38
 
31
- Then install it in your consuming project:
39
+ ## Install
32
40
 
33
41
  ```sh
34
- npm install --save-dev /path/to/headstamp oxlint@1.88.0
42
+ npm install --save-dev @rm-industries/oxlint-plugin-headstamp oxlint@^1.88.0
35
43
  ```
36
44
 
37
45
  ## Configure
@@ -83,6 +91,61 @@ property when reading from a file. Configuration can compute replacement values
83
91
  import shared options, but the rule receives strings, not executable functions.
84
92
  JSON oxlint configuration also works with inline template and value strings.
85
93
 
94
+ ## SPDX header example
95
+
96
+ Use this in `oxlint.config.ts`. Change `MIT` and `Acme` to your project's
97
+ license identifier and copyright holder.
98
+
99
+ ```ts
100
+ import { defineConfig } from 'oxlint';
101
+
102
+ const year = String(new Date().getUTCFullYear());
103
+
104
+ export default defineConfig({
105
+ jsPlugins: [{ name: 'headstamp', specifier: '@rm-industries/oxlint-plugin-headstamp' }],
106
+ overrides: [
107
+ {
108
+ files: ['src/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
109
+ rules: {
110
+ 'headstamp/header': [
111
+ 'error',
112
+ {
113
+ template: '// SPDX-License-Identifier: {{license}}\n// SPDX-FileCopyrightText: {{years}} Acme',
114
+ values: {
115
+ license: { pattern: 'MIT', replacement: 'MIT' },
116
+ years: { pattern: '\\d{4}(?:-\\d{4})?', replacement: year },
117
+ },
118
+ },
119
+ ],
120
+ },
121
+ },
122
+ ],
123
+ });
124
+ ```
125
+
126
+ With `oxlint --fix`, a missing header gets the configured license and year.
127
+ An existing header with the wrong license identifier can be repaired without
128
+ changing a valid year or year range.
129
+
130
+ ### Optional Git-derived year
131
+
132
+ To use the latest commit's year as the default, replace the `year` declaration
133
+ above with this snippet. This runs Git once when the config loads. It uses the
134
+ same year for every file; it does not infer per-file history. If Git is missing
135
+ or the checkout has no commits, it falls back to the current UTC year.
136
+
137
+ ```ts
138
+ import { spawnSync } from 'node:child_process';
139
+
140
+ const commitDate = spawnSync('git', ['log', '-1', '--format=%cs'], {
141
+ cwd: new URL('.', import.meta.url),
142
+ encoding: 'utf8',
143
+ timeout: 10000,
144
+ });
145
+ const gitYear = commitDate.status === 0 ? /^(\d{4})-/.exec(commitDate.stdout)?.[1] : undefined;
146
+ const year = gitYear ?? String(new Date().getUTCFullYear());
147
+ ```
148
+
86
149
  ## Placeholders
87
150
 
88
151
  Use `{{name}}` and define each name once in `values`, with a regex `pattern` string
@@ -264,8 +327,7 @@ all tests, and package-content inspection. CI checks formatting without rewritin
264
327
  files. Publishing a GitHub release triggers a separate npm release workflow after
265
328
  those same checks; manual release-workflow runs prepare an artifact without
266
329
  publishing. See [RELEASING.md](RELEASING.md) for bootstrap, trusted-publisher setup,
267
- and version/tag requirements. No npm package has been published as part of adding
268
- this workflow.
330
+ and version/tag requirements.
269
331
 
270
332
  Tests use oxlint's public rule-testing API and real CLI runs. CLI tests exercise
271
333
  TypeScript configuration and exported types, external templates, supported source
package/package.json CHANGED
@@ -1,7 +1,18 @@
1
1
  {
2
2
  "name": "@rm-industries/oxlint-plugin-headstamp",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Oxlint-first header templates, regex validation, and safe insertion.",
5
+ "keywords": [
6
+ "autofix",
7
+ "copyright-header",
8
+ "file-header",
9
+ "header-template",
10
+ "javascript",
11
+ "license-header",
12
+ "oxlint",
13
+ "oxlint-plugin",
14
+ "typescript"
15
+ ],
5
16
  "license": "MIT",
6
17
  "repository": {
7
18
  "type": "git",
@@ -34,8 +45,8 @@
34
45
  },
35
46
  "devDependencies": {
36
47
  "@types/node": "^22.20.5",
37
- "oxfmt": "^0.73.0",
38
- "oxlint": "^1.88.0",
48
+ "oxfmt": "^0.78.0",
49
+ "oxlint": "^1.93.0",
39
50
  "typescript": "^7.0.2"
40
51
  },
41
52
  "peerDependencies": {