@chanyuxi/eslint-waltz 1.1.1 → 1.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
@@ -1,82 +1,106 @@
1
- # Introduction
1
+ # @chanyuxi/eslint-waltz
2
2
 
3
- 👋 A composable ESLint flat config for JavaScript, TypeScript, JSONC, imports, React, Tailwind CSS, and Perfectionist.
3
+ Composable ESLint flat config for JavaScript, TypeScript, JSONC, React, Tailwind CSS, Perfectionist, and Vitest.
4
4
 
5
- Inspired by [@antfu/eslint-config](https://github.com/antfu/eslint-config).
5
+ Requires Node.js `>=20.19.0`.
6
6
 
7
- # Features
7
+ ## Install
8
8
 
9
- The following configuration modules are available:
9
+ Install the package, ESLint, and the peer dependencies used by the default configuration:
10
10
 
11
- - ✅ Javascript
12
- - ✅ Typescript
13
- - ✅ Stylistic
14
- - ✅ Perfectionist
15
- - ✅ Json
16
- - ✅ Import
17
- - ✅ React
18
- - ✅ Tailwind CSS
19
- - JSONC and imports are enabled by default and can be disabled with `json: false` and `imports: false`.
20
- - TypeScript, React, Tailwind CSS, and gitignore support are opt-in.
21
-
22
- The `stylistic` configuration is always enabled. Perfectionist is enabled by default with the `recommended-alphabetical` preset.
23
-
24
- # Usage
11
+ ```bash
12
+ pnpm add -D @chanyuxi/eslint-waltz eslint eslint-plugin-jsonc eslint-plugin-import-x eslint-plugin-perfectionist jsonc-eslint-parser
13
+ ```
25
14
 
26
- #### Install
15
+ `@eslint/js`, `@stylistic/eslint-plugin`, `globals`, and `jsonc-parser` are included automatically.
27
16
 
28
- Install the core package and its core ESLint peers:
17
+ Install peers only for the optional modules you enable:
29
18
 
30
19
  ```bash
31
- pnpm add -D @chanyuxi/eslint-waltz eslint @eslint/js @stylistic/eslint-plugin eslint-plugin-jsonc eslint-plugin-import-x eslint-plugin-perfectionist jsonc-eslint-parser globals
32
- ```
20
+ # TypeScript
21
+ pnpm add -D typescript-eslint
33
22
 
34
- Install the peer packages for any optional modules you enable, such as `typescript-eslint`, `eslint-plugin-tailwindcss`, `tailwindcss`, or the React ESLint plugins.
35
-
36
- Perfectionist uses the `recommended-alphabetical` preset by default. Use `perfectionist: { preset: 'recommended-custom' }`, `recommended-line-length`, or `recommended-natural` to select another recommended preset. ESLint 10 and the current integrations require Node.js `>=20.19.0`.
23
+ # React
24
+ pnpm add -D eslint-plugin-react-x eslint-plugin-react-debug eslint-plugin-react-dom eslint-plugin-react-hooks-extra eslint-plugin-react-naming-convention eslint-plugin-react-web-api
37
25
 
38
- Tailwind CSS support targets `eslint-plugin-tailwindcss` 4.x and Tailwind CSS 4.x. Node.js `>=20.19.0` is required when the Tailwind CSS module is enabled.
26
+ # Tailwind CSS
27
+ pnpm add -D eslint-plugin-tailwindcss tailwindcss
39
28
 
40
- #### Configuration
29
+ # .gitignore support
30
+ pnpm add -D eslint-config-flat-gitignore
31
+
32
+ # Vitest
33
+ pnpm add -D @vitest/eslint-plugin vitest
34
+ ```
41
35
 
42
- Create a `eslint.config.ts` file in the project root directory and configure it as follows:
36
+ ## Usage
43
37
 
44
38
  ```ts
39
+ // eslint.config.ts
45
40
  import waltz from '@chanyuxi/eslint-waltz'
46
41
 
47
42
  export default waltz({
48
- // JSONC and imports are enabled by default
49
- json: true,
50
43
  ts: true,
51
44
  react: true,
52
- tailwindcss: {
53
- settings: {
54
- tailwindcss: { cssConfigPath: './src/styles.css' },
55
- },
56
- },
57
- js: { globals: ['browser'] },
58
45
  })
59
46
  ```
60
47
 
61
- Every module accepts `files` and `overrides` where applicable. Custom flat configs can be appended after the options:
48
+ Enabled by default:
62
49
 
63
- ```ts
64
- export default waltz({}, {
65
- files: ['src/**/*.js'],
66
- rules: {
67
- 'no-console': 'off',
68
- },
69
- })
70
- ```
50
+ - JavaScript and stylistic rules
51
+ - JSONC rules
52
+ - import validation
53
+ - Perfectionist with `recommended-alphabetical`
71
54
 
72
- Run `pnpm run check` before committing. `pnpm pack` and `npm publish` build the package automatically through the `prepack` lifecycle.
55
+ Optional: `ts`, `react`, `tailwindcss`, `gitignore`, and `vitest`.
73
56
 
74
- #### VS Code synchronization
75
-
76
- After installing the package, run this command from your project root:
77
-
78
- ```bash
79
- npx eslint-waltz sync-vscode
80
- ```
81
-
82
- It creates or updates `.vscode/settings.json` with ESLint fix-on-save settings while preserving other settings and JSONC comments.
57
+ More options are documented in the exported TypeScript types.
58
+
59
+ The potentially expensive module-resolution rules are disabled by default. Enable
60
+ them explicitly when your project needs them:
61
+
62
+ ```ts
63
+ export default waltz({
64
+ imports: {
65
+ overrides: {
66
+ 'imports/named': 'error',
67
+ 'imports/namespace': 'error',
68
+ },
69
+ },
70
+ })
71
+ ```
72
+
73
+ ## TypeScript file scope
74
+
75
+ When `ts.files` is provided, it is the maximum TypeScript scope used by the
76
+ other modules that automatically include TypeScript files. JavaScript files
77
+ keep their normal scope, and a module's own `files` option can override this
78
+ limit. Vitest additionally intersects its test-file patterns with this scope.
79
+
80
+ ```ts
81
+ export default waltz({
82
+ ts: { files: ['src/**/*.ts'] },
83
+ react: true,
84
+ })
85
+ ```
86
+
87
+ ## VS Code synchronization
88
+
89
+ Run this command from your project root to enable ESLint fix-on-save settings
90
+ while preserving existing `.vscode/settings.json` values and comments:
91
+
92
+ ```bash
93
+ npx eslint-waltz sync-vscode
94
+ ```
95
+
96
+ React plugin settings can be customized when needed:
97
+
98
+ ```ts
99
+ export default waltz({
100
+ react: {
101
+ settings: {
102
+ 'react-x': { importSource: 'preact' },
103
+ },
104
+ },
105
+ })
106
+ ```
package/dist/cli.js CHANGED
File without changes