@isentinel/eslint-config 6.0.0-beta.2 → 6.0.0-beta.20

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
@@ -38,6 +38,16 @@ import isentinel from "@isentinel/eslint-config";
38
38
  export default isentinel();
39
39
  ```
40
40
 
41
+ `@isentinel/eslint-config/eslint` is an explicit alias of the root export, for
42
+ symmetry with `@isentinel/eslint-config/oxlint`:
43
+
44
+ ```ts
45
+ // eslint.config.ts
46
+ import { isentinel } from "@isentinel/eslint-config/eslint";
47
+
48
+ export default isentinel();
49
+ ```
50
+
41
51
  #### Optional: TypeScript Config Support
42
52
 
43
53
  If you want to use `eslint.config.ts` instead of `.js`, install `jiti` v2.0.0 or
@@ -91,17 +101,20 @@ export default isentinel(
91
101
 
92
102
  ### Add script for package.json
93
103
 
94
- For example:
104
+ The package ships an `isentinel-lint` bin that runs oxlint and ESLint together.
105
+ The starter wizard adds these for you; to wire them up manually:
95
106
 
96
107
  ```json
97
108
  {
98
109
  "scripts": {
99
- "lint": "eslint",
100
- "lint:fix": "eslint --fix"
110
+ "lint": "isentinel-lint",
111
+ "lint:fix": "isentinel-lint --fix"
101
112
  }
102
113
  }
103
114
  ```
104
115
 
116
+ See [`isentinel-lint`](#isentinel-lint) for what it does and every flag.
117
+
105
118
  ## Recommended Settings
106
119
 
107
120
  ### TSConfig
@@ -194,6 +207,207 @@ Add the following settings to your `.vscode/settings.json`:
194
207
  }
195
208
  ```
196
209
 
210
+ ## isentinel-lint
211
+
212
+ The package ships a second bin, `isentinel-lint`, a hybrid runner that drives
213
+ [oxlint](https://oxc.rs/docs/guide/usage/linter/) and ESLint together. Point
214
+ your `lint` script at it and forget the wiring (the starter wizard does this for
215
+ you):
216
+
217
+ ```json
218
+ {
219
+ "scripts": {
220
+ "lint": "isentinel-lint",
221
+ "lint:fix": "isentinel-lint --fix"
222
+ }
223
+ }
224
+ ```
225
+
226
+ It resolves the `eslint` and `oxlint` binaries from your project's
227
+ `node_modules`, so both must be installed locally.
228
+
229
+ ### What it does
230
+
231
+ By default (a local run, no `--type-aware`, no `--fix`) it runs **three**
232
+ children concurrently via
233
+ [`concurrently`](https://www.npmjs.com/package/concurrently), grouping their
234
+ output:
235
+
236
+ - **oxlint** — the full oxlint pass (including its type-aware rules).
237
+ - **fast pass** — ESLint with only the syntactic (non-type-aware) rules, over
238
+ every lintable file (TS/JS, JSON, YAML, TOML, Markdown, Lua). This is where
239
+ non-TS files are linted.
240
+ - **type-aware pass** — ESLint with only the type-aware rules, over the TS/JS
241
+ family. The preset's config splits exactly in two, so `fast ∪ type-aware`
242
+ reproduces the full config rule-for-rule.
243
+
244
+ The type-aware pass is the expensive one (it builds a TypeScript program), so
245
+ the runner **skips it entirely when nothing type-relevant changed** since the
246
+ last run — it uses the TypeScript builder to find the files whose type-aware
247
+ results could have changed, and if that set is empty it prints a short note to
248
+ stderr and does not start the pass. The fast pass and oxlint always run.
249
+
250
+ Other behaviours:
251
+
252
+ - Sizes each ESLint pass's `--concurrency` from how many files it will actually
253
+ re-lint (its own dirty count), rather than eagerly spinning up a worker per
254
+ CPU. The fast pass is cheap per file, so it packs far more files per worker
255
+ (see `FAST_FILES_PER_WORKER`) than the type-aware pass.
256
+ - Keeps a separate ESLint cache per pass so they never invalidate one another:
257
+ `.eslintcache-fast-<key>` (fast pass), `.eslintcache-typeaware-<key>`
258
+ (type-aware pass), and `.eslintcache-<key>` (the full single-pass config used
259
+ by `--fix`, CI and `--type-aware=full`). A change to an
260
+ ESLint/oxlint/Prettier/tsconfig file or a lockfile clears each cache that is
261
+ actually older than that change; a change to the root `package.json`
262
+ resolution surface (`exports`, `imports`, `main`, `module`, `types`,
263
+ `typesVersions`, `dependencies`, `devDependencies`, `peerDependencies`) clears
264
+ only the type-aware caches (a syntactic lint cannot be affected by
265
+ resolution). Add `.eslintcache*` to `.gitignore` — a bare `.eslintcache` entry
266
+ does not match the suffixed names.
267
+ - Splits every cache by **config variant**. ESLint stores a config hash per
268
+ cache entry, so two runs that resolve even slightly different configs wipe
269
+ each other's entries when they share one cache file — an agent session and a
270
+ human session alternating against one cache re-lint the whole project in both
271
+ directions, every time. The `<key>` above is an 8-character hash of the inputs
272
+ that make this preset resolve a different config: agent session, editor
273
+ session and CI. Each variant gets its own cache (and its own builder /
274
+ `package.json`-hash state), so nothing is invalidated; the variants simply
275
+ stop overwriting each other. Git-hook runs deliberately share the plain
276
+ no-agent variant.
277
+
278
+ If your own `eslint.config.*` branches on something the runner cannot see —
279
+ your own agent/editor check, a feature flag, or an explicit `isAgent`,
280
+ `isInEditor` or `defaultSeverity` option — set `ISENTINEL_LINT_CACHE_KEY` to a
281
+ value naming that branch. It is folded into the key, giving those configs
282
+ separate caches too.
283
+
284
+ - Runs `--fix` sequentially (`oxlint --fix`, then `eslint --fix`) so two writers
285
+ never race on the same files.
286
+ - Lets every child run to completion and returns non-zero if any failed — an
287
+ ordinary lint error in one tool no longer kills the others mid-run.
288
+
289
+ > **Unused eslint-disable directives.** The default two-pass mode does **not**
290
+ > report unused `eslint-disable` directives: a directive naming a rule that
291
+ > lives in the _other_ pass would look unused to the pass that runs it and
292
+ > produce a false positive. `--fix`, CI and `--type-aware=full` runs use the
293
+ > single full config and still report unused directives.
294
+
295
+ ### Hybrid detection
296
+
297
+ Running both engines only makes sense when the ESLint config is in **hybrid
298
+ mode** (`oxlint: true`), which drops every oxlint-covered rule from the ESLint
299
+ side so the two engines never overlap. A config that omits `oxlint: true` runs
300
+ every mapped rule in _both_ engines — duplicate diagnostics, and under `--fix` a
301
+ tug-of-war as each rewrites toward its own option resolution. So whenever both
302
+ engines would run (default mode or `--fix`), the runner checks whether the
303
+ resolved config is hybrid; if it is not, it **runs ESLint only, skips oxlint,
304
+ and prints one stderr warning** (enable hybrid mode, or pass `--oxlint` to run
305
+ oxlint explicitly). The check is cheap: the factory records the hybrid status in
306
+ `node_modules/.cache/isentinel-lint/` on every config evaluation, and the runner
307
+ trusts that cache unless your ESLint config is newer, in which case it probes
308
+ `eslint --print-config` once and caches the result. If the status cannot be
309
+ determined it fails open and runs both engines as before. Explicit `--eslint` /
310
+ `--oxlint` runs skip the check entirely.
311
+
312
+ Any trailing positional arguments are treated as paths to lint (default `.`).
313
+
314
+ ### Flags
315
+
316
+ | Flag | Description |
317
+ | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
318
+ | `--eslint` | Run only ESLint. |
319
+ | `--oxlint` | Run only oxlint. |
320
+ | `--fix` | Apply fixes: `oxlint --fix` then `eslint --fix` (sequential). |
321
+ | `--agents`, `--no-agents` | Force agent-friendly output from both linters on or off (default: on in an agent session). |
322
+ | `--type-aware=off\|only\|full` | Force a single ESLint pass: `off` fast-only, `only` type-aware-only, `full` the whole config in one pass. Cannot mix with `--fix`. |
323
+ | `--no-oxlint-type-aware` | Skip oxlint's type-aware rules (no `oxlint-tsgolint` needed). |
324
+ | `--no-cache` | Disable ESLint's on-disk cache. |
325
+ | `--concurrency <n\|off>` | Override the concurrency heuristic with a fixed worker count. |
326
+ | `--eslint-args "<args>"` | Extra arguments forwarded verbatim to ESLint. |
327
+ | `--oxlint-args "<args>"` | Extra arguments forwarded verbatim to oxlint. |
328
+ | `--print` | Print the composed commands without running them. |
329
+ | `-- <args>` | Forward args to the single selected tool (needs `--eslint`/`--oxlint`). |
330
+ | `-h`, `--help` | Show help. |
331
+ | `-v`, `--version` | Show the version. |
332
+
333
+ ### Environment
334
+
335
+ | Variable | Effect |
336
+ | ----------------------- | -------------------------------------------------------------------------------------------------------------------- |
337
+ | `FILES_PER_WORKER` | Target files a single type-aware ESLint worker handles before adding another (default `350`). |
338
+ | `FAST_FILES_PER_WORKER` | Same, for the fast (syntactic) pass, which packs far more files per worker (default `800`). |
339
+ | `LINT_MAX_WORKERS` | Upper bound on ESLint workers (default a quarter of available CPUs). |
340
+ | `ESLINT_TYPE_AWARE` | `off` or `only`; the type-aware mode `--type-aware` sets for the ESLint child (`false` is a legacy alias for `off`). |
341
+ | `CI` | When set, the runner uses the single full pass with `--cache-strategy content` (see below). |
342
+
343
+ ### Type-aware oxlint and tsgolint
344
+
345
+ By default the runner passes `--type-aware` to oxlint, which needs
346
+ [`oxlint-tsgolint`](https://www.npmjs.com/package/oxlint-tsgolint). If it is not
347
+ installed the runner errors out rather than silently skipping type-aware rules.
348
+ Install it, or pass `--no-oxlint-type-aware` to run oxlint without them:
349
+
350
+ ```bash
351
+ pnpm i -D oxlint oxlint-tsgolint
352
+ ```
353
+
354
+ `--type-aware=off` also drops oxlint's type-aware pass, since the fast mode
355
+ skips type-aware linting entirely.
356
+
357
+ ### CI
358
+
359
+ When a `CI` environment variable is set the runner skips the two-pass split and
360
+ runs a single full-config ESLint pass (alongside oxlint). CI cores are few, so
361
+ the two-pass parallelism does not pay off, and the full config is the only one
362
+ that reports unused `eslint-disable` directives — which you want enforced in CI.
363
+ The pass also switches to `--cache-strategy content` so caches key on file
364
+ contents rather than timestamps, which are unreliable across fresh checkouts.
365
+
366
+ ### Agent output
367
+
368
+ `--agents` emits machine-readable output for AI agents: oxlint runs with
369
+ `--format agent`, and ESLint uses the formatter shipped at
370
+ `@isentinel/eslint-config/formatter-agents`, which the runner resolves and
371
+ passes to `eslint --format` for you.
372
+
373
+ It is on by default whenever an AI coding agent session is detected, so agents
374
+ get agent-shaped output without passing the flag. Detection follows
375
+ [`std-env`](https://github.com/unjs/std-env)'s agent table (Claude Code, Codex,
376
+ Cursor, Gemini CLI, opencode, replit, auggie, goose, junie, devin, kiro, pi),
377
+ plus the `AI_AGENT` variable as an explicit override. Git hook and lint-staged
378
+ runs are excluded — those are human-initiated. Pass `--no-agents` to force human
379
+ output, or set `AI_AGENT` to force detection on.
380
+
381
+ ### Known limitations
382
+
383
+ The incremental machinery favours speed, and a few edges are deliberately left
384
+ to self-heal or need a one-off nudge:
385
+
386
+ - **Config changes reached through an imported module are invisible to a
387
+ _skipped_ typed pass.** The runner busts caches on the mtime of your
388
+ `eslint.config.*`, tsconfigs and lockfiles, but not on files those configs
389
+ `import`. ESLint's own per-entry config hash would still catch such a change
390
+ once the pass runs — but if the typed pass was auto-skipped (nothing
391
+ type-relevant looked dirty), it never runs to notice. Touch your
392
+ `eslint.config.*` (or run once with `--no-cache`) after editing a module it
393
+ imports.
394
+ - **mtime granularity.** Cache freshness is compared by modification time, so
395
+ the usual coarse-filesystem-timestamp race that affects ESLint's own cache
396
+ applies here too (edits within the same clock tick as the last run can be
397
+ missed). CI uses `--cache-strategy content` to sidestep it; locally, a second
398
+ run settles it.
399
+ - **Solution-style / project-reference tsconfigs.** The TypeScript builder used
400
+ to find type-affected files does not follow project references, so in a
401
+ solution-style setup builder invalidation silently becomes a no-op and the
402
+ runner falls back to plain mtime dirtiness. Type-aware results stay correct
403
+ (ESLint still lints the dirty files); only the cross-file "an imported type
404
+ changed" invalidation is skipped.
405
+ - **Hybrid status tracks `eslint.config.*` mtimes only.** If you toggle hybrid
406
+ mode (`oxlint: true`) from a module the config _imports_ rather than the
407
+ config file itself, the runner trusts its cached hybrid decision for one more
408
+ run before the factory's passive write corrects it — it self-heals on the next
409
+ invocation.
410
+
197
411
  ## Customization
198
412
 
199
413
  Normally you only need to import the `isentinel` preset:
@@ -412,6 +626,37 @@ export default isentinel({
412
626
  });
413
627
  ```
414
628
 
629
+ #### Redundant Override Detection
630
+
631
+ Overrides that re-state what the preset already resolves to by default fail to
632
+ typecheck, so you learn immediately (in-editor, no lint run needed) when a
633
+ preset update makes one of your overrides redundant:
634
+
635
+ ```ts
636
+ export default isentinel({
637
+ rules: {
638
+ // Type error: 'no-alert' already defaults to this value in the preset;
639
+ // remove the override, or set `redundancyCheck: false` to disable this
640
+ // check
641
+ "no-alert": "error",
642
+ },
643
+ });
644
+ ```
645
+
646
+ The check understands severity aliases (`2` ≙ `"error"`), option tuples (flagged
647
+ only on an exact match), flat-config merge semantics (a bare severity keeps the
648
+ previous options, so it is redundant whenever the severity matches), and the
649
+ `type`/`roblox` variants — a rule that only defaults to `"error"` for
650
+ `type: "package"` is not flagged in a game config. It applies to the top-level
651
+ `rules`, every per-integration `overrides`, and un-scoped extra configs; both
652
+ the ESLint and oxlint factories are covered.
653
+
654
+ Compared defaults are the canonical (CI, non-editor) ones: editor/agent
655
+ downgrades, `defaultSeverity` promotion and oxlint hybrid rule-dropping are
656
+ intentionally ignored. `files`-scoped configs and composer `.override()` calls
657
+ are not checked. Opt out entirely with `redundancyCheck: false`, or per line
658
+ with `// @ts-expect-error`.
659
+
415
660
  ### Spell Checker
416
661
 
417
662
  This config includes the [CSpell](https://cspell.org/) plugin by default, which
@@ -495,6 +740,80 @@ otherwise, you can install them manually:
495
740
  pnpm i -D eslint-plugin-react-x eslint-plugin-react-jsx eslint-plugin-react-naming-convention eslint-plugin-jest
496
741
  ```
497
742
 
743
+ #### Naming Conventions
744
+
745
+ Enable the opinionated `flawless/naming-convention` rules with `naming: true`,
746
+ or pass an object to add new selector entries or override the built-in defaults:
747
+
748
+ ```ts
749
+ // eslint.config.ts
750
+ import isentinel from "@isentinel/eslint-config";
751
+
752
+ export default isentinel({
753
+ naming: {
754
+ selectors: [
755
+ // Override the default variable format
756
+ { format: ["snake_case"], selector: "variable" },
757
+ // Add a new selector not covered by the defaults
758
+ { format: ["PascalCase"], prefix: ["I"], selector: "interface" },
759
+ ],
760
+ // Applied only to .tsx files, before `selectors`
761
+ selectorsTsx: [{ format: ["StrictPascalCase"], selector: "function" }],
762
+ },
763
+ });
764
+ ```
765
+
766
+ Entries in `selectors` apply to both the TS and TSX configs; `selectorsTsx`
767
+ applies to the TSX config only. User entries are prepended before the defaults,
768
+ and the rule applies the first matching entry after sorting by specificity — so
769
+ an entry with the same specificity as a default overrides it, while new
770
+ selectors are simply added. A less specific entry cannot override a more
771
+ specific default. The `overridesTypeAware` escape hatch still replaces the whole
772
+ rule if you need full control.
773
+
774
+ #### Oxlint
775
+
776
+ The config can run alongside (or be replaced by)
777
+ [oxlint](https://oxc.rs/docs/guide/usage/linter/) in three modes: ESLint-only
778
+ (the default), hybrid (`oxlint && eslint`), and oxlint standalone via the
779
+ `@isentinel/eslint-config/oxlint` export.
780
+
781
+ ```ts
782
+ // eslint.config.ts - hybrid mode: ESLint drops every rule oxlint covers
783
+ import isentinel from "@isentinel/eslint-config";
784
+
785
+ export default isentinel({
786
+ oxlint: true,
787
+ });
788
+ ```
789
+
790
+ ```ts
791
+ // oxlint.config.ts
792
+ import { isentinel } from "@isentinel/eslint-config/oxlint";
793
+
794
+ export default isentinel({
795
+ name: "project/options",
796
+ });
797
+ ```
798
+
799
+ Requires the optional peer dependencies:
800
+
801
+ ```bash
802
+ pnpm i -D oxlint oxlint-tsgolint
803
+ ```
804
+
805
+ See [docs/oxlint.md](./docs/oxlint.md) for the per-rule mapping, what stays in
806
+ ESLint and why, and migration notes.
807
+
808
+ #### Type-Aware Split
809
+
810
+ On large projects the type-aware rules dominate ESLint wall time; an explicit
811
+ numeric `--concurrency` is the biggest single win. The `typeAware` option
812
+ additionally splits the config into two complementary passes: a non-type-aware
813
+ pass (`typeAware: false`) that never builds a TypeScript program and a
814
+ type-aware-only pass (`typeAware: "only"`). Together they cover exactly the full
815
+ config. See [docs/type-aware-split.md](./docs/type-aware-split.md).
816
+
498
817
  #### ESLint Plugin Development
499
818
 
500
819
  If you're developing an ESLint plugin, you can enable specialized rules to help
package/bin/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import "../dist/cli.js";
3
+ import "../dist/cli.mjs";
package/bin/lint.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ import "../dist/lint-cli.mjs";
package/dist/cli.d.mts CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {}