@infernodesign/eslint-config 2.14.3 → 2.15.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
@@ -1,12 +1,16 @@
1
1
  # @infernodesign/eslint-config
2
2
 
3
- Shared ESLint flat config presets for Inferno Design projects. Orignally forked from [Antfu's eslint-config](https://github.com/antfu/eslint-config).
3
+ Shared ESLint flat config presets for Inferno Design projects. Orignally forked from [Antfu's
4
+ eslint-config](https://github.com/antfu/eslint-config).
4
5
 
5
6
  - Autofix for formatting (aimed to be used standalone **without** Prettier)
6
7
  - Reasonable best practices and only one line of config.
7
8
  - Designed to work with TypeScript, JSX, Vue, JSON, YAML, Toml, Markdown, etc. Out-of-box.
8
- - Uses the [ESLint Flat Config](https://eslint.org/docs/latest/use/configure/configuration-files-new) for easy compilation.
9
- - Optional [React](#react), [Medusa](#medusa), [Next.js](#nextjs), [Sanity](#sanity), [Svelte](#svelte), [UnoCSS](#unocss), [Astro](#astro), [Storybook](#storybook), [Solid](#solid) support, [TailwindCSS](#tailwindcss) support.
9
+ - Uses the [ESLint Flat Config](https://eslint.org/docs/latest/use/configure/configuration-files-new) for easy
10
+ compilation.
11
+ - Optional [React](#react), [Medusa](#medusa), [Next.js](#nextjs), [Sanity](#sanity), [shadcn](#shadcn),
12
+ [Svelte](#svelte), [UnoCSS](#unocss), [Astro](#astro), [Storybook](#storybook), [Solid](#solid) support,
13
+ [TailwindCSS](#tailwindcss) support.
10
14
  - Optional [formatters](#formatters) support for formatting CSS, HTML, XML, etc.
11
15
  - **Style principle**: Minimal for reading, stable for diff, consistent
12
16
  - Sorted imports, dangling commas
@@ -19,7 +23,8 @@ Shared ESLint flat config presets for Inferno Design projects. Orignally forked
19
23
 
20
24
  ### Starter Wizard
21
25
 
22
- We provided a CLI tool to help you set up your project, or migrate from the legacy config to the new flat config with one command.
26
+ We provided a CLI tool to help you set up your project, or migrate from the legacy config to the new flat config with
27
+ one command.
23
28
 
24
29
  ```bash
25
30
  npx @infernodesign/eslint-config@latest
@@ -47,7 +52,8 @@ export default config()
47
52
  Combined with legacy config:
48
53
  </summary>
49
54
 
50
- If you still use some configs from the legacy eslintrc format, you can use the [`@eslint/eslintrc`](https://www.npmjs.com/package/@eslint/eslintrc) package to convert them to the flat config.
55
+ If you still use some configs from the legacy eslintrc format, you can use the
56
+ [`@eslint/eslintrc`](https://www.npmjs.com/package/@eslint/eslintrc) package to convert them to the flat config.
51
57
 
52
58
  ```js
53
59
  // eslint.config.mjs
@@ -153,7 +159,8 @@ Add the following settings to your `.vscode/settings.json`:
153
159
 
154
160
  ## Customization
155
161
 
156
- Since v1.0, we migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new). It provides much better organization and composition.
162
+ Since v1.0, we migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new).
163
+ It provides much better organization and composition.
157
164
 
158
165
  Normally you only need to import the `antfu` preset:
159
166
 
@@ -243,7 +250,8 @@ Going more advanced, you can also import fine-grained configs and compose them a
243
250
  <details>
244
251
  <summary>Advanced Example</summary>
245
252
 
246
- We wouldn't recommend using this style in general unless you know exactly what they are doing, as there are shared options between configs and might need extra care to make them consistent.
253
+ We wouldn't recommend using this style in general unless you know exactly what they are doing, as there are shared
254
+ options between configs and might need extra care to make them consistent.
247
255
 
248
256
  ```js
249
257
  // eslint.config.js
@@ -291,13 +299,15 @@ export default combine(
291
299
 
292
300
  </details>
293
301
 
294
- Check out the [configs](https://github.com/antfu/eslint-config/blob/main/src/configs) and [factory](https://github.com/antfu/eslint-config/blob/main/src/factory.ts) for more details.
302
+ Check out the [configs](https://github.com/antfu/eslint-config/blob/main/src/configs) and
303
+ [factory](https://github.com/antfu/eslint-config/blob/main/src/factory.ts) for more details.
295
304
 
296
305
  > Thanks to [sxzz/eslint-config](https://github.com/sxzz/eslint-config) for the inspiration and reference.
297
306
 
298
307
  ### Plugins Renaming
299
308
 
300
- Since flat config requires us to explicitly provide the plugin names (instead of the mandatory convention from npm package name), we renamed some plugins to make the overall scope more consistent and easier to write.
309
+ Since flat config requires us to explicitly provide the plugin names (instead of the mandatory convention from npm
310
+ package name), we renamed some plugins to make the overall scope more consistent and easier to write.
301
311
 
302
312
  | New Prefix | Original Prefix | Source Plugin |
303
313
  | ------------------------- | --------------------------------- | ----------------------------------------------------------------------------------------------------- |
@@ -340,7 +350,9 @@ export default config()
340
350
 
341
351
  ### Rules Overrides
342
352
 
343
- Certain rules would only be enabled in specific files, for example, `ts/*` rules would only be enabled in `.ts` files and `vue/*` rules would only be enabled in `.vue` files. If you want to override the rules, you need to specify the file extension:
353
+ Certain rules would only be enabled in specific files, for example, `ts/*` rules would only be enabled in `.ts` files
354
+ and `vue/*` rules would only be enabled in `.vue` files. If you want to override the rules, you need to specify the file
355
+ extension:
344
356
 
345
357
  ```js
346
358
  // eslint.config.js
@@ -394,7 +406,9 @@ export default config({
394
406
 
395
407
  ### Config Composer
396
408
 
397
- Since v2.10.0, the factory function `config()` returns a [`FlatConfigComposer` object from `eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils#composer) where you can chain the methods to compose the config even more flexibly.
409
+ Since v2.10.0, the factory function `config()` returns a [`FlatConfigComposer` object from
410
+ `eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils#composer) where you can chain the methods
411
+ to compose the config even more flexibly.
398
412
 
399
413
  ```js
400
414
  // eslint.config.js
@@ -446,7 +460,8 @@ npm i -D eslint-plugin-astro
446
460
 
447
461
  #### Formatters
448
462
 
449
- Use external formatters to format files that ESLint cannot handle yet (`.css`, `.html`, etc). Powered by [`eslint-plugin-format`](https://github.com/antfu/eslint-plugin-format).
463
+ Use external formatters to format files that ESLint cannot handle yet (`.css`, `.html`, etc). Powered by
464
+ [`eslint-plugin-format`](https://github.com/antfu/eslint-plugin-format).
450
465
 
451
466
  ```js
452
467
  // eslint.config.js
@@ -512,7 +527,8 @@ export default config({
512
527
  })
513
528
  ```
514
529
 
515
- Medusa support is powered by [`@medusajs/eslint-plugin`](https://docs.medusajs.com/resources/lint). It is an optional peer dependency, so projects that enable `medusa` must install it:
530
+ Medusa support is powered by [`@medusajs/eslint-plugin`](https://docs.medusajs.com/resources/lint). It is an optional
531
+ peer dependency, so projects that enable `medusa` must install it:
516
532
 
517
533
  ```bash
518
534
  npm i -D @medusajs/eslint-plugin
@@ -535,7 +551,8 @@ export default config({
535
551
  })
536
552
  ```
537
553
 
538
- The `strict` preset requires a TypeScript config that includes every linted TypeScript file. Rule overrides retain the file scopes defined by the selected Medusa preset:
554
+ The `strict` preset requires a TypeScript config that includes every linted TypeScript file. Rule overrides retain the
555
+ file scopes defined by the selected Medusa preset:
539
556
 
540
557
  ```js
541
558
  // eslint.config.js
@@ -596,7 +613,9 @@ export default config({
596
613
  })
597
614
  ```
598
615
 
599
- Sanity support is powered by [`@sanity-labs/eslint-plugin`](https://github.com/sanity-labs/sanity-lint/tree/main/packages/eslint-plugin). It is an optional peer dependency, so projects that enable `sanity` must install it:
616
+ Sanity support is powered by
617
+ [`@sanity-labs/eslint-plugin`](https://github.com/sanity-labs/sanity-lint/tree/main/packages/eslint-plugin). It is an
618
+ optional peer dependency, so projects that enable `sanity` must install it:
600
619
 
601
620
  ```bash
602
621
  npm i -D @sanity-labs/eslint-plugin
@@ -640,9 +659,11 @@ export default config({
640
659
  })
641
660
  ```
642
661
 
643
- Other available presets are `performance` for performance-focused GROQ rules and `strict` for enabling every Sanity rule as an error.
662
+ Other available presets are `performance` for performance-focused GROQ rules and `strict` for enabling every Sanity rule
663
+ as an error.
644
664
 
645
- For schema-aware GROQ rules like `sanity/groq-invalid-type-filter` and `sanity/groq-unknown-field`, provide an extracted schema file. In monorepos, use `cwd` to resolve `schemaPath` from the nested Studio or app directory:
665
+ For schema-aware GROQ rules like `sanity/groq-invalid-type-filter` and `sanity/groq-unknown-field`, provide an extracted
666
+ schema file. In monorepos, use `cwd` to resolve `schemaPath` from the nested Studio or app directory:
646
667
 
647
668
  ```js
648
669
  // eslint.config.js
@@ -663,6 +684,126 @@ Generate `schema.json` with the Sanity CLI:
663
684
  npx sanity schema extract
664
685
  ```
665
686
 
687
+ #### shadcn
688
+
689
+ To enable shadcn design system linting with the default recommended rules, explicitly turn it on:
690
+
691
+ ```js
692
+ // eslint.config.js
693
+ import { config } from '@infernodesign/eslint-config'
694
+
695
+ export default config({
696
+ shadcn: true,
697
+ })
698
+ ```
699
+
700
+ shadcn support is powered by [`@shadcn/lint`](https://github.com/shadcn-ui/lint). It is an optional peer dependency, so
701
+ projects that enable `shadcn` must install it. It requires Tailwind CSS v4 and ESLint v9.30.0+:
702
+
703
+ ```bash
704
+ npm i -D @shadcn/lint
705
+ ```
706
+
707
+ The `preset` option selects the rule set:
708
+
709
+ - `recommended` (default): `shadcn/no-restyle`, `shadcn/no-raw-colors`, `shadcn/no-arbitrary-values`,
710
+ `shadcn/no-inline-styles`, and `shadcn/require-static-classes` as errors (`no-restyle` and `no-arbitrary-values` allow
711
+ `layout` classes), plus `shadcn/no-unknown-classes` as a warning.
712
+ - `warn`: the same rules and options, all as warnings. Useful when adopting the rules in an existing project.
713
+ - `none`: registers the plugin and settings only, so you can enable rules yourself.
714
+
715
+ ```js
716
+ // eslint.config.js
717
+ import { config } from '@infernodesign/eslint-config'
718
+
719
+ export default config({
720
+ shadcn: {
721
+ preset: 'warn',
722
+ },
723
+ })
724
+ ```
725
+
726
+ Use `settings` to pass [plugin settings](https://github.com/shadcn-ui/lint#settings) through to `settings.shadcn`, for
727
+ example to tell the rules where your components are imported from:
728
+
729
+ ```js
730
+ // eslint.config.js
731
+ import { config } from '@infernodesign/eslint-config'
732
+
733
+ export default config({
734
+ shadcn: {
735
+ settings: {
736
+ componentImports: ['^@repo/ui(/|$)'],
737
+ ui: '@/components/ui',
738
+ },
739
+ },
740
+ })
741
+ ```
742
+
743
+ Files matching `componentFiles` (default `['**/components/ui/**']`) are where the components themselves live, so
744
+ `shadcn/no-restyle`, `shadcn/no-arbitrary-values`, and `shadcn/require-static-classes` are turned off there. Set
745
+ `componentFiles: []` to disable this override. Globs are relative to the ESLint config root.
746
+
747
+ In a monorepo, point `settings.ui` at the workspace UI package and move the component override to that package. These
748
+ paths assume the ESLint config sits at the workspace root:
749
+
750
+ ```js
751
+ // eslint.config.js
752
+ import { config } from '@infernodesign/eslint-config'
753
+
754
+ export default config({
755
+ shadcn: {
756
+ componentFiles: ['packages/ui/src/components/**'],
757
+ settings: {
758
+ ui: '@workspace/ui/components',
759
+ },
760
+ },
761
+ })
762
+ ```
763
+
764
+ To share rules through a `design-system.lint.json` policy file, set `policy`. Relative paths are resolved from `cwd`
765
+ (default `process.cwd()`). The policy file is only loaded when `policy` is set:
766
+
767
+ ```js
768
+ // eslint.config.js
769
+ import { config } from '@infernodesign/eslint-config'
770
+
771
+ export default config({
772
+ shadcn: {
773
+ cwd: 'packages/ui',
774
+ policy: 'design-system.lint.json',
775
+ },
776
+ })
777
+ ```
778
+
779
+ ```json
780
+ {
781
+ "rules": {
782
+ "shadcn/no-raw-colors": "warn"
783
+ },
784
+ "overrides": [
785
+ {
786
+ "files": [ "packages/ui/src/components/**" ],
787
+ "rules": {
788
+ "shadcn/no-arbitrary-values": "off",
789
+ "shadcn/no-restyle": "off",
790
+ "shadcn/require-static-classes": "off"
791
+ }
792
+ }
793
+ ]
794
+ }
795
+ ```
796
+
797
+ Rules are layered as preset < policy `rules` < `overrides`, so your `overrides` always win. A few details to note:
798
+
799
+ - When the policy defines `overrides`, they replace the built-in `componentFiles` override. An explicit `"overrides":
800
+ []` also removes the built-in override without adding any.
801
+ - Policy override `files` globs are used as-is and are relative to the ESLint config root, not to the policy file. A
802
+ policy at `packages/ui/design-system.lint.json` must therefore use globs like `packages/ui/src/components/**`.
803
+ - `cwd` only locates a relative `policy` path. It does not affect how any glob is matched.
804
+ - A missing policy file logs a warning and is ignored. A policy file with invalid JSON or an invalid shape throws an
805
+ error.
806
+
666
807
  #### Storybook
667
808
 
668
809
  To enable storybook support, you need to explicitly turn it on:
@@ -780,7 +921,8 @@ npm i -D @unocss/eslint-plugin
780
921
 
781
922
  ### Vue
782
923
 
783
- Vue support is detected automatically by checking if `vue` is installed in your project. You can also explicitly enable/disable it:
924
+ Vue support is detected automatically by checking if `vue` is installed in your project. You can also explicitly
925
+ enable/disable it:
784
926
 
785
927
  ```js
786
928
  // eslint.config.js
@@ -793,7 +935,8 @@ export default config({
793
935
 
794
936
  #### Vue 2
795
937
 
796
- We have limited support for Vue 2 (as it's already [reached EOL](https://v2.vuejs.org/eol/)). If you are still using Vue 2, you can configure it manually by setting `vueVersion` to `2`:
938
+ We have limited support for Vue 2 (as it's already [reached EOL](https://v2.vuejs.org/eol/)). If you are still using Vue
939
+ 2, you can configure it manually by setting `vueVersion` to `2`:
797
940
 
798
941
  ```js
799
942
  // eslint.config.js
@@ -806,7 +949,8 @@ export default config({
806
949
  })
807
950
  ```
808
951
 
809
- As it's in maintenance mode, we only accept bug fixes for Vue 2. It might also be removed in the future when `eslint-plugin-vue` drops support for Vue 2. We recommend upgrading to Vue 3 if possible.
952
+ As it's in maintenance mode, we only accept bug fixes for Vue 2. It might also be removed in the future when
953
+ `eslint-plugin-vue` drops support for Vue 2. We recommend upgrading to Vue 3 if possible.
810
954
 
811
955
  #### Vue Accessibility
812
956
 
@@ -835,7 +979,8 @@ This config also provides some optional plugins/rules for extended usage.
835
979
 
836
980
  #### `command`
837
981
 
838
- Powered by [`eslint-plugin-command`](https://github.com/antfu/eslint-plugin-command). It is not a typical rule for linting, but an on-demand micro-codemod tool that triggers by specific comments.
982
+ Powered by [`eslint-plugin-command`](https://github.com/antfu/eslint-plugin-command). It is not a typical rule for
983
+ linting, but an on-demand micro-codemod tool that triggers by specific comments.
839
984
 
840
985
  For a few triggers, for example:
841
986
 
@@ -869,7 +1014,8 @@ The command comments are usually one-off and will be removed along with the tran
869
1014
 
870
1015
  ### Type Aware Rules
871
1016
 
872
- You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the options object to the `typescript` config:
1017
+ You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the
1018
+ options object to the `typescript` config:
873
1019
 
874
1020
  ```js
875
1021
  // eslint.config.js
@@ -890,9 +1036,12 @@ Auto-fixing for the following rules are disabled when ESLint is running in a cod
890
1036
  - [`test/no-only-tests`](https://github.com/levibuzolic/eslint-plugin-no-only-tests)
891
1037
  - [`unused-imports/no-unused-imports`](https://www.npmjs.com/package/eslint-plugin-unused-imports)
892
1038
 
893
- Since v3.16.0, they are no longer disabled, but made non-fixable using [this helper](https://github.com/antfu/eslint-flat-config-utils#composerdisablerulesfix).
1039
+ Since v3.16.0, they are no longer disabled, but made non-fixable using [this
1040
+ helper](https://github.com/antfu/eslint-flat-config-utils#composerdisablerulesfix).
894
1041
 
895
- This is to prevent unused imports from getting removed by the editor during refactoring to get a better developer experience. Those rules will be applied when you run ESLint in the terminal or [Lint Staged](#lint-staged). If you don't want this behavior, you can disable them:
1042
+ This is to prevent unused imports from getting removed by the editor during refactoring to get a better developer
1043
+ experience. Those rules will be applied when you run ESLint in the terminal or [Lint Staged](#lint-staged). If you don't
1044
+ want this behavior, you can disable them:
896
1045
 
897
1046
  ```js
898
1047
  // eslint.config.js
@@ -929,7 +1078,8 @@ npx simple-git-hooks
929
1078
 
930
1079
  ## View what rules are enabled
931
1080
 
932
- I built a visual tool to help you view what rules are enabled in your project and apply them to what files, [@eslint/config-inspector](https://github.com/eslint/config-inspector)
1081
+ I built a visual tool to help you view what rules are enabled in your project and apply them to what files,
1082
+ [@eslint/config-inspector](https://github.com/eslint/config-inspector)
933
1083
 
934
1084
  Go to your project root that contains `eslint.config.mjs` and run:
935
1085
 
@@ -939,7 +1089,8 @@ npx @eslint/config-inspector
939
1089
 
940
1090
  ## Versioning Policy
941
1091
 
942
- This project follows [Semantic Versioning](https://semver.org/) for releases. However, since this is just a config and involves opinions and many moving parts, we don't treat rules changes as breaking changes.
1092
+ This project follows [Semantic Versioning](https://semver.org/) for releases. However, since this is just a config and
1093
+ involves opinions and many moving parts, we don't treat rules changes as breaking changes.
943
1094
 
944
1095
  ### Changes Considered as Breaking Changes
945
1096
 
@@ -958,7 +1109,8 @@ This project follows [Semantic Versioning](https://semver.org/) for releases. Ho
958
1109
 
959
1110
  ### How to format CSS?
960
1111
 
961
- You can opt-in to the [`formatters`](#formatters) feature to format your CSS. Note that it's only doing formatting, but not linting. If you want proper linting support, give [`stylelint`](https://stylelint.io/) a try.
1112
+ You can opt-in to the [`formatters`](#formatters) feature to format your CSS. Note that it's only doing formatting, but
1113
+ not linting. If you want proper linting support, give [`stylelint`](https://stylelint.io/) a try.
962
1114
 
963
1115
  ## License
964
1116
 
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import { cac } from "cac";
8
8
  import parse from "parse-gitignore";
9
9
  import { execSync } from "node:child_process";
10
10
  //#region package.json
11
- var version = "2.14.3";
11
+ var version = "2.15.0";
12
12
  //#endregion
13
13
  //#region src/cli/constants.ts
14
14
  const vscodeSettingsString = `
@@ -89,6 +89,11 @@ const frameworkOptions = [
89
89
  label: c.red("Sanity"),
90
90
  value: "sanity"
91
91
  },
92
+ {
93
+ hint: "Design system rules via @shadcn/lint (requires Tailwind CSS v4)",
94
+ label: c.white("shadcn"),
95
+ value: "shadcn"
96
+ },
92
97
  {
93
98
  label: c.blue("Slidev"),
94
99
  value: "slidev"
@@ -133,6 +138,7 @@ const dependenciesMap = {
133
138
  node: [],
134
139
  react: ["@eslint-react/eslint-plugin", "eslint-plugin-react-refresh"],
135
140
  sanity: ["@sanity-labs/eslint-plugin"],
141
+ shadcn: ["@shadcn/lint"],
136
142
  slidev: ["prettier-plugin-slidev"],
137
143
  solid: ["eslint-plugin-solid"],
138
144
  storybook: ["eslint-plugin-storybook"],
@@ -196,23 +202,24 @@ async function updateEslintFiles(result) {
196
202
  //#endregion
197
203
  //#region src/cli/constants-generated.ts
198
204
  const versionsMap = {
199
- "@eslint-react/eslint-plugin": "^5.24.4",
205
+ "@eslint-react/eslint-plugin": "^5.26.5",
200
206
  "@medusajs/eslint-plugin": "^2.21.2",
201
- "@next/eslint-plugin-next": "^16.3.8",
202
- "@sanity-labs/eslint-plugin": "^1.0.1",
203
- "@unocss/eslint-plugin": "^66.10.5",
207
+ "@next/eslint-plugin-next": "^16.4.0",
208
+ "@sanity-labs/eslint-plugin": "^1.0.2",
209
+ "@shadcn/lint": "^0.2.1",
210
+ "@unocss/eslint-plugin": "^66.11.0",
204
211
  "astro-eslint-parser": "^3.2.0",
205
212
  "eslint": "^10.12.0",
206
213
  "eslint-plugin-astro": "^3.2.1",
207
- "eslint-plugin-better-tailwindcss": "^4.8.0",
214
+ "eslint-plugin-better-tailwindcss": "^4.9.0",
208
215
  "eslint-plugin-format": "^2.0.1",
209
216
  "eslint-plugin-react-refresh": "^0.5.7",
210
217
  "eslint-plugin-solid": "^0.18.1",
211
- "eslint-plugin-storybook": "^10.6.1",
212
- "eslint-plugin-svelte": "^3.23.0",
213
- "prettier-plugin-astro": "^1.1.0",
218
+ "eslint-plugin-storybook": "^10.6.2",
219
+ "eslint-plugin-svelte": "^3.23.1",
220
+ "prettier-plugin-astro": "^1.1.1",
214
221
  "prettier-plugin-slidev": "^1.0.5",
215
- "svelte-eslint-parser": "^1.8.1"
222
+ "svelte-eslint-parser": "^1.9.0"
216
223
  };
217
224
  //#endregion
218
225
  //#region src/cli/stages/update-package-json.ts