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

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,71 @@ 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
+
350
415
  ### Spell Checker
351
416
 
352
417
  This config includes the [CSpell](https://cspell.org/) plugin by default, which
@@ -427,7 +492,7 @@ Running `npx eslint` should prompt you to install the required dependencies,
427
492
  otherwise, you can install them manually:
428
493
 
429
494
  ```bash
430
- pnpm i -D eslint-plugin-react-x eslint-plugin-react-hooks eslint-plugin-react-naming-convention eslint-plugin-jest
495
+ pnpm i -D eslint-plugin-react-x eslint-plugin-react-jsx eslint-plugin-react-naming-convention eslint-plugin-jest
431
496
  ```
432
497
 
433
498
  #### ESLint Plugin Development
@@ -451,26 +516,33 @@ otherwise, you can install them manually:
451
516
  pnpm i -D eslint-plugin-eslint-plugin
452
517
  ```
453
518
 
454
- ### Lint Staged
519
+ ### Git hooks
455
520
 
456
- If you want to apply lint and auto-fix before every commit, you can add the
457
- following to your `package.json`:
521
+ If you want to apply lint and auto-fix before every commit, use
522
+ [hk](https://hk.jdx.dev). Create `hk.pkl` in your project root:
458
523
 
459
- ```json
460
- {
461
- "simple-git-hooks": {
462
- "pre-commit": "pnpm lint-staged"
463
- },
464
- "lint-staged": {
465
- "*": "eslint --fix"
524
+ ```pkl
525
+ amends "package://github.com/jdx/hk/releases/download/v1.48.0/hk@1.48.0#/Config.pkl"
526
+
527
+ hooks {
528
+ ["pre-commit"] {
529
+ fix = true
530
+ steps {
531
+ ["eslint"] {
532
+ glob = List("*")
533
+ check = "eslint --no-warn-ignored {{files}}"
534
+ fix = "eslint --fix --no-warn-ignored {{files}}"
535
+ }
536
+ }
466
537
  }
467
538
  }
468
539
  ```
469
540
 
470
- and then
541
+ and then install hk and activate the hooks:
471
542
 
472
543
  ```bash
473
- pnpm i -D lint-staged simple-git-hooks
544
+ mise use hk pkl # or see https://hk.jdx.dev for other install methods
545
+ hk install
474
546
  ```
475
547
 
476
548
  ## View what rules are enabled
package/dist/cli.mjs CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {};