@isentinel/eslint-config 5.2.0 → 6.0.0-beta.10

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
@@ -347,6 +347,102 @@ the new prefix:
347
347
  type foo = { bar: 2 }
348
348
  ```
349
349
 
350
+ ### Rules Overrides
351
+
352
+ Certain rules would only be enabled in specific files, for example, `ts/*` rules
353
+ would only be enabled in `.ts` files and `vue/*` rules would only be enabled in
354
+ `.vue` files. If you want to override the rules, you need to specify the file
355
+ extension:
356
+
357
+ ```js
358
+ // eslint.config.js
359
+ import antfu from "@antfu/eslint-config";
360
+
361
+ export default antfu(
362
+ {
363
+ typescript: true,
364
+ vue: true,
365
+ },
366
+ {
367
+ // Remember to specify the file glob here, otherwise it might cause the
368
+ // vue plugin to handle non-vue files
369
+ files: ["**/*.vue"],
370
+ rules: {
371
+ "vue/operator-linebreak": ["error", "before"],
372
+ },
373
+ },
374
+ {
375
+ // Without `files`, they are general rules for all files (Markdown
376
+ // excluded — see note below)
377
+ rules: {
378
+ "style/semi": ["error", "never"],
379
+ },
380
+ },
381
+ );
382
+ ```
383
+
384
+ <!-- prettier-ignore -->
385
+ > [!NOTE]
386
+ > Rule overrides without an explicit `files` constraint are> automatically
387
+ > excluded from Markdown files, via
388
+ > [`composer.setDefaultIgnores`](https://github.com/antfu/eslint-flat-config-utils#composersetdefaultignores).
389
+ > This prevents JS-only rules (e.g. `no-irregular-whitespace`,
390
+ > `perfectionist/sort-imports`) from crashing on `@eslint/markdown`'s
391
+ > `SourceCode`, which doesn't expose JS-specific methods like
392
+ > `getAllComments()`. If you want a rule to apply to Markdown, scope it
393
+ > explicitly with `files: ['**/*.md']`.
394
+
395
+ We also provided the `overrides` options in each integration to make it easier:
396
+
397
+ ```js
398
+ // eslint.config.ts
399
+ import isentinel from "@isentinel/eslint-config";
400
+
401
+ export default isentinel({
402
+ typescript: {
403
+ overrides: {
404
+ "ts/consistent-type-definitions": ["error", "interface"],
405
+ },
406
+ },
407
+ yaml: {
408
+ overrides: {
409
+ // ...
410
+ },
411
+ },
412
+ });
413
+ ```
414
+
415
+ #### Redundant Override Detection
416
+
417
+ Overrides that re-state what the preset already resolves to by default fail to
418
+ typecheck, so you learn immediately (in-editor, no lint run needed) when a
419
+ preset update makes one of your overrides redundant:
420
+
421
+ ```ts
422
+ export default isentinel({
423
+ rules: {
424
+ // Type error: 'no-alert' already defaults to this value in the preset;
425
+ // remove the override, or set `redundancyCheck: false` to disable this
426
+ // check
427
+ "no-alert": "error",
428
+ },
429
+ });
430
+ ```
431
+
432
+ The check understands severity aliases (`2` ≙ `"error"`), option tuples (flagged
433
+ only on an exact match), flat-config merge semantics (a bare severity keeps the
434
+ previous options, so it is redundant whenever the severity matches), and the
435
+ `type`/`roblox` variants — a rule that only defaults to `"error"` for
436
+ `type: "package"` is not flagged in a game config. It applies to the top-level
437
+ `rules`, every per-integration `overrides`, and un-scoped extra configs; both
438
+ the ESLint and oxlint factories are covered.
439
+
440
+ Compared defaults are the canonical (CI, non-editor) ones: editor/agent
441
+ downgrades, `defaultSeverity` promotion and oxlint hybrid rule-dropping are
442
+ intentionally ignored. `files`-scoped configs and composer `.override()` calls
443
+ are not checked. Opt out entirely with `redundancyCheck: false`, or per line
444
+ with `// @ts-expect-error`.
445
+
350
446
  ### Spell Checker
351
447
 
352
448
  This config includes the [CSpell](https://cspell.org/) plugin by default, which
@@ -427,9 +523,52 @@ Running `npx eslint` should prompt you to install the required dependencies,
427
523
  otherwise, you can install them manually:
428
524
 
429
525
  ```bash
430
- pnpm i -D eslint-plugin-react-x eslint-plugin-react-hooks eslint-plugin-react-naming-convention eslint-plugin-jest
526
+ pnpm i -D eslint-plugin-react-x eslint-plugin-react-jsx eslint-plugin-react-naming-convention eslint-plugin-jest
527
+ ```
528
+
529
+ #### Oxlint
530
+
531
+ The config can run alongside (or be replaced by)
532
+ [oxlint](https://oxc.rs/docs/guide/usage/linter/) in three modes: ESLint-only
533
+ (the default), hybrid (`oxlint && eslint`), and oxlint standalone via the
534
+ `@isentinel/eslint-config/oxlint` export.
535
+
536
+ ```ts
537
+ // eslint.config.ts - hybrid mode: ESLint drops every rule oxlint covers
538
+ import isentinel from "@isentinel/eslint-config";
539
+
540
+ export default isentinel({
541
+ oxlint: true,
542
+ });
543
+ ```
544
+
545
+ ```ts
546
+ // oxlint.config.ts
547
+ import { isentinel } from "@isentinel/eslint-config/oxlint";
548
+
549
+ export default isentinel({
550
+ name: "project/options",
551
+ });
552
+ ```
553
+
554
+ Requires the optional peer dependencies:
555
+
556
+ ```bash
557
+ pnpm i -D oxlint oxlint-tsgolint
431
558
  ```
432
559
 
560
+ See [docs/oxlint.md](./docs/oxlint.md) for the per-rule mapping, what stays in
561
+ ESLint and why, and migration notes.
562
+
563
+ #### Type-Aware Split
564
+
565
+ On large projects the type-aware rules dominate ESLint wall time; an explicit
566
+ numeric `--concurrency` is the biggest single win. The `typeAware` option
567
+ additionally splits the config into two complementary passes: a non-type-aware
568
+ pass (`typeAware: false`) that never builds a TypeScript program and a
569
+ type-aware-only pass (`typeAware: "only"`). Together they cover exactly the full
570
+ config. See [docs/type-aware-split.md](./docs/type-aware-split.md).
571
+
433
572
  #### ESLint Plugin Development
434
573
 
435
574
  If you're developing an ESLint plugin, you can enable specialized rules to help
@@ -451,26 +590,33 @@ otherwise, you can install them manually:
451
590
  pnpm i -D eslint-plugin-eslint-plugin
452
591
  ```
453
592
 
454
- ### Lint Staged
593
+ ### Git hooks
455
594
 
456
- If you want to apply lint and auto-fix before every commit, you can add the
457
- following to your `package.json`:
595
+ If you want to apply lint and auto-fix before every commit, use
596
+ [hk](https://hk.jdx.dev). Create `hk.pkl` in your project root:
458
597
 
459
- ```json
460
- {
461
- "simple-git-hooks": {
462
- "pre-commit": "pnpm lint-staged"
463
- },
464
- "lint-staged": {
465
- "*": "eslint --fix"
598
+ ```pkl
599
+ amends "package://github.com/jdx/hk/releases/download/v1.48.0/hk@1.48.0#/Config.pkl"
600
+
601
+ hooks {
602
+ ["pre-commit"] {
603
+ fix = true
604
+ steps {
605
+ ["eslint"] {
606
+ glob = List("*")
607
+ check = "eslint --no-warn-ignored {{files}}"
608
+ fix = "eslint --fix --no-warn-ignored {{files}}"
609
+ }
610
+ }
466
611
  }
467
612
  }
468
613
  ```
469
614
 
470
- and then
615
+ and then install hk and activate the hooks:
471
616
 
472
617
  ```bash
473
- pnpm i -D lint-staged simple-git-hooks
618
+ mise use hk pkl # or see https://hk.jdx.dev for other install methods
619
+ hk install
474
620
  ```
475
621
 
476
622
  ## View what rules are enabled
package/dist/cli.d.mts CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {}
package/dist/cli.mjs CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {};