@clipboard-health/oxlint-config 5.2.1 → 5.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
CHANGED
|
@@ -9,6 +9,7 @@ Shared [Oxlint](https://oxc.rs/docs/guide/usage/linter) configuration for Clipbo
|
|
|
9
9
|
- [Fast runs](#fast-runs)
|
|
10
10
|
- [Strict presets](#strict-presets)
|
|
11
11
|
- [Suppression policy](#suppression-policy)
|
|
12
|
+
- [Lint ceilings](#lint-ceilings)
|
|
12
13
|
- [Categories](#categories)
|
|
13
14
|
- [What is shared](#what-is-shared)
|
|
14
15
|
- [Intentionally disabled rules](#intentionally-disabled-rules)
|
|
@@ -294,6 +295,121 @@ override disables it for that file. It does not detect overrides that match only
|
|
|
294
295
|
extensions, such as `*.tsx`, or other paths. Call it for each directory that must enforce the
|
|
295
296
|
policy.
|
|
296
297
|
|
|
298
|
+
## Lint ceilings
|
|
299
|
+
|
|
300
|
+
`lint-ceilings.json` holds per-file upper bounds for count rules such as `max-lines` and
|
|
301
|
+
`complexity`, so a repository can keep strict defaults while existing large or complex files stay
|
|
302
|
+
as they are. A listed file may shrink but not grow. Pull requests don't edit the file: the
|
|
303
|
+
`cbh-lint-ceilings check` CLI blocks growth, and a weekly bot PR lowers stale values. This avoids
|
|
304
|
+
the merge conflicts of exact-count baselines.
|
|
305
|
+
|
|
306
|
+
```json
|
|
307
|
+
{
|
|
308
|
+
"version": 1,
|
|
309
|
+
"rules": {
|
|
310
|
+
"complexity": {
|
|
311
|
+
"src/modules/users/user-manipulation.service.ts": 58
|
|
312
|
+
},
|
|
313
|
+
|
|
314
|
+
"max-lines": {
|
|
315
|
+
"src/app/lib/analytics/events.ts": 2802,
|
|
316
|
+
|
|
317
|
+
"src/app/redesign/Login/Login.tsx": 3264
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
- Keys under `rules` are canonical Oxlint rule names: `complexity`, `import/max-dependencies`,
|
|
324
|
+
`max-depth`, `max-lines`, `max-lines-per-function`, `max-nested-callbacks`, `max-params` and
|
|
325
|
+
`max-statements`. Aliases such as `eslint/max-lines` are rejected. JavaScript plugin rules
|
|
326
|
+
aren't supported yet: `oxlint --print-config` omits their options, so the CLI can't measure
|
|
327
|
+
them against the configured default.
|
|
328
|
+
- Paths are relative to the repository root. For per-function rules such as `complexity`, the
|
|
329
|
+
value is the file's largest function value, because Oxlint overrides apply to whole files.
|
|
330
|
+
- The layout is canonical: rules and paths sorted, a blank line between entries. `init` and
|
|
331
|
+
`tighten` write it, and `check` fails on any other layout.
|
|
332
|
+
|
|
333
|
+
### Configure
|
|
334
|
+
|
|
335
|
+
Pass the parsed file to `createOxlintConfig`:
|
|
336
|
+
|
|
337
|
+
```ts
|
|
338
|
+
import { base, createOxlintConfig, typeAware, vitest } from "@clipboard-health/oxlint-config";
|
|
339
|
+
import { defineConfig } from "oxlint";
|
|
340
|
+
|
|
341
|
+
import ceilings from "./lint-ceilings.json" with { type: "json" };
|
|
342
|
+
|
|
343
|
+
export default defineConfig(createOxlintConfig({ ceilings, presets: [base, typeAware, vitest] }));
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
The factory appends one override per listed file after every preset and local override. Oxlint
|
|
347
|
+
applies the last matching override, so a ceiling listed before a later glob override, such as a
|
|
348
|
+
higher `max-lines` for test files, would be ignored. Each ceiling override also carries the severity and
|
|
349
|
+
options the file otherwise gets, such as `skipComments`, because an override replaces a rule's
|
|
350
|
+
options. It skips files where the rule is off, so a ceiling never turns a rule back on. The factory
|
|
351
|
+
assumes `oxlint.config.ts` and `lint-ceilings.json` both sit in the repository root.
|
|
352
|
+
|
|
353
|
+
### Commands
|
|
354
|
+
|
|
355
|
+
`cbh-lint-ceilings` ships in `@clipboard-health/oxlint-plugin`, a dependency of this package. It
|
|
356
|
+
measures with the repository's own Oxlint and configuration, with ceilings ignored, so its numbers
|
|
357
|
+
match the linter's. It reads the root configuration through `oxlint --print-config`, which drops
|
|
358
|
+
rule options inherited through `extends` (Oxlint 1.91). Build the root `oxlint.config.ts` with
|
|
359
|
+
`createOxlintConfig`, not `extends`, so options such as `max` survive.
|
|
360
|
+
|
|
361
|
+
```sh
|
|
362
|
+
npx cbh-lint-ceilings init # one entry per file above its default, all supported rules
|
|
363
|
+
npx cbh-lint-ceilings init --rule complexity
|
|
364
|
+
npx cbh-lint-ceilings check # in CI; locally compares with the merge base of origin/HEAD
|
|
365
|
+
npx cbh-lint-ceilings check --base origin/main
|
|
366
|
+
npx cbh-lint-ceilings tighten # weekly, on the default branch
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
`check` looks at changed files that have a ceiling and lints their base and current versions. It
|
|
370
|
+
fails when:
|
|
371
|
+
|
|
372
|
+
- a listed file's value grew, even if it is still under its ceiling. For per-function rules, it
|
|
373
|
+
fails when the file's largest value grew or the total excess over the default grew. Splitting a
|
|
374
|
+
function at 40 into two at 25 passes (excess 20 → 10), while a new function at 22 in a listed
|
|
375
|
+
file fails even though the file's largest value is unchanged.
|
|
376
|
+
- an entry was added or raised. An entry that follows its file's rename at the same or a lower
|
|
377
|
+
value is not an addition.
|
|
378
|
+
|
|
379
|
+
Stale-high values, entries for deleted files or files now within the default, and lowered or
|
|
380
|
+
removed entries all pass. `--allow-increases` reports increases without failing: pass it from CI
|
|
381
|
+
only when an increase is approved.
|
|
382
|
+
|
|
383
|
+
### CI
|
|
384
|
+
|
|
385
|
+
Run `check` as its own small job, on an ephemeral runner, with the default merge-commit checkout.
|
|
386
|
+
In GitHub Actions, `check` compares a pull request's merge commit with its first parent and a
|
|
387
|
+
merge-queue commit with the queue's base (`merge_group.base_sha`). `fetch-depth: 2` covers pull
|
|
388
|
+
requests and merge or squash queues; a rebase queue needs depth of at least the pull request's
|
|
389
|
+
commit count plus one. Any other checkout, such as the pull request head, falls back to the merge
|
|
390
|
+
base with the pull request base and needs that history:
|
|
391
|
+
|
|
392
|
+
```yaml
|
|
393
|
+
lint-ceilings:
|
|
394
|
+
runs-on: [self-hosted, cb-ephemeral-8-cores]
|
|
395
|
+
steps:
|
|
396
|
+
- uses: actions/checkout@v6
|
|
397
|
+
with:
|
|
398
|
+
fetch-depth: 2
|
|
399
|
+
persist-credentials: false
|
|
400
|
+
# Install the repository's dependencies, then:
|
|
401
|
+
- run: npx cbh-lint-ceilings check
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
There is no shared approval workflow yet. A repository that wants a reviewed path for raises can
|
|
405
|
+
compute approval in its own workflow, for example from a review by a named team, and then pass
|
|
406
|
+
`--allow-increases`.
|
|
407
|
+
|
|
408
|
+
Copy the [weekly tighten workflow template](../oxlint-plugin/templates/tighten-lint-ceilings.yml)
|
|
409
|
+
to keep values current. It runs `tighten` on the default branch, opens or updates a `chore/tighten-lint-ceilings`
|
|
410
|
+
PR, enables auto-merge and requests reviewers. The job that installs dependencies holds no write
|
|
411
|
+
token, and the job that pushes installs nothing.
|
|
412
|
+
|
|
297
413
|
## Categories
|
|
298
414
|
|
|
299
415
|
This config is tuned for agent-written code: enforce rules that prevent bugs or help agents work faster, ignore rules that only encode human style preferences. Categories are applied as a denylist (enable the category, then disable individual rules that are noise) rather than an allowlist, so new bug-catching rules in a category are adopted automatically as oxlint ships them.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clipboard-health/oxlint-config",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "Shared Oxlint configuration for Clipboard Health repositories.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@clipboard-health/oxlint-plugin": "1.
|
|
23
|
+
"@clipboard-health/oxlint-plugin": "1.10.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"oxlint": ">=1.68.0",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createOxlintConfig = createOxlintConfig;
|
|
4
|
+
const oxlint_plugin_1 = require("@clipboard-health/oxlint-plugin");
|
|
4
5
|
function createOxlintConfig(request) {
|
|
5
|
-
const { localConfig, presets = [] } = request;
|
|
6
|
+
const { ceilings, localConfig, presets = [] } = request;
|
|
6
7
|
const configChain = localConfig === undefined ? [...presets] : [...presets, localConfig];
|
|
7
8
|
let config = {};
|
|
8
9
|
for (const preset of configChain) {
|
|
@@ -11,7 +12,13 @@ function createOxlintConfig(request) {
|
|
|
11
12
|
next: preset,
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
if (ceilings === undefined) {
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
const { overrides } = (0, oxlint_plugin_1.createLintCeilingOverrides)({ ceilings, config });
|
|
19
|
+
return overrides.length === 0
|
|
20
|
+
? config
|
|
21
|
+
: mergeOxlintPreset({ current: config, next: { overrides } });
|
|
15
22
|
}
|
|
16
23
|
function mergeOxlintPreset(request) {
|
|
17
24
|
const { current, next } = request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOxlintConfig.js","sourceRoot":"","sources":["../../../../../packages/oxlint-config/src/internal/createOxlintConfig.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"createOxlintConfig.js","sourceRoot":"","sources":["../../../../../packages/oxlint-config/src/internal/createOxlintConfig.ts"],"names":[],"mappings":";;;AAAA,mEAA6E;AAK7E,4BAAmC,OAAkC;IACnE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,WAAW,GAAG,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAA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C,IAAI,aAAa,CAAC,SAAS,CAAC;gBACrD,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,GAAG,SAAS,EAAE;gBACnC,CAAC,CAAC,SAAS,CAAC;IAClB,CAAC;IAED,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,wDAAwD;AACxD,SAAS,UAAU,CAAQ,KAAY;IACrC,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,iBAAiB,CAAmC,OAI5D;IACC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEzC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IACxB,CAAC;AACH,CAAC"}
|
package/src/internal/types.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { OxlintConfig } from "oxlint";
|
|
2
2
|
export type OxlintPreset = Omit<OxlintConfig, "extends">;
|
|
3
3
|
export interface CreateOxlintConfigRequest {
|
|
4
|
+
/**
|
|
5
|
+
* Parsed lint-ceilings.json. Its per-file overrides go after every preset and local override,
|
|
6
|
+
* so a later glob such as a test preset's `max-lines` cannot override a file's ceiling.
|
|
7
|
+
*/
|
|
8
|
+
ceilings?: unknown;
|
|
4
9
|
localConfig?: OxlintPreset;
|
|
5
10
|
presets?: readonly OxlintPreset[];
|
|
6
11
|
}
|