@ntnyq/eslint-config 6.1.5 → 7.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.
Files changed (4) hide show
  1. package/README.md +159 -213
  2. package/dist/index.d.mts +1385 -276
  3. package/dist/index.mjs +145 -58
  4. package/package.json +52 -49
package/README.md CHANGED
@@ -1,126 +1,195 @@
1
1
  # @ntnyq/eslint-config
2
2
 
3
- > 🎨 ESLint config for JavaScript, TypeScript, Vue, JSON, Markdown, YAML, TOML, SVG, and more.
3
+ > ESLint flat config preset for modern frontend projects (TypeScript, Vue, JSON, Markdown, YAML, TOML, and more).
4
4
 
5
5
  [![CI](https://github.com/ntnyq/eslint-config/workflows/CI/badge.svg)](https://github.com/ntnyq/eslint-config/actions)
6
6
  [![NPM VERSION](https://img.shields.io/npm/v/@ntnyq/eslint-config/latest.svg)](https://www.npmjs.com/package/@ntnyq/eslint-config/v/latest)
7
+ [![NPM NEXT VERSION](https://img.shields.io/npm/v/@ntnyq/eslint-config/next.svg)](https://www.npmjs.com/package/@ntnyq/eslint-config/v/next)
7
8
  [![NPM DOWNLOADS](https://img.shields.io/npm/dy/@ntnyq/eslint-config)](https://www.npmjs.com/package/@ntnyq/eslint-config)
8
9
  [![LICENSE](https://img.shields.io/github/license/ntnyq/eslint-config.svg)](https://github.com/ntnyq/eslint-config/blob/main/LICENSE)
9
10
 
10
- <!-- [![NPM NEXT VERSION](https://img.shields.io/npm/v/@ntnyq/eslint-config/next.svg)](https://www.npmjs.com/package/@ntnyq/eslint-config/v/next) -->
11
+ ## Requirements
11
12
 
12
- > [!IMPORTANT]
13
- > Feel free to create and maintain your own fork if you think this is too opinionated.
14
-
15
- ## 📋 Requirements
16
-
17
- - Node.js ^20.19.0 || ^22.13.0 || >=24
18
- - ESLint ^9.38.0
13
+ - Node.js ^22.13.0 || >=24.11.0
14
+ - ESLint ^10.4.0
19
15
 
20
16
  > [!TIP]
21
- > For Node.js v18 support, please use [v4](https://github.com/ntnyq/eslint-config/tree/v4).
17
+ > Need legacy runtime support?
22
18
  >
23
- > For Node.js versions below 20.19.0, please use [v5](https://github.com/ntnyq/eslint-config/tree/v5).
19
+ > - Node.js v18: use [v4](https://github.com/ntnyq/eslint-config/tree/v4)
20
+ > - Node.js < 20.19.0: use [v5](https://github.com/ntnyq/eslint-config/tree/v5)
21
+ > - Node.js < 22.13.0: use [v6](https://github.com/ntnyq/eslint-config/tree/v6)
24
22
 
25
- ## Features
23
+ ## Why Frontend Teams Use It
26
24
 
27
- - Designed to work alongside formatters, e.g. [Prettier](https://prettier.io) or [oxfmt](https://oxc.rs/docs/guide/usage/formatter)
28
- - 🎯 Opinionated: single quote, no semi, trailing comma, etc
29
- - 🪄 Respect `.gitignore` via [eslint-config-flat-gitignore](https://github.com/antfu/eslint-config-flat-gitignore)
30
- - 📦 Out-of-the-box support for TypeScript, Vue, JSON, Markdown, YAML, TOML, SVG, Astro, Svelte, etc
31
- - 🛡️ Strict but provides useful rules to guard your codebase
32
- - 🔧 Custom ESLint commands for [eslint-plugin-command](https://github.com/antfu/eslint-plugin-command)
33
- - 🎪 [ESLint flat config](https://eslint.org/docs/latest/use/configure/configuration-files) for ESLint v9.38.0+
25
+ - Works out of the box with ESLint flat config.
26
+ - Auto-detects and enables configs by your dependencies and file types.
27
+ - Covers common frontend files: TS, Vue SFC, JSON, Markdown, YAML, TOML.
28
+ - Keeps formatting tool friendly (Prettier or oxfmt).
29
+ - Supports scaling from single apps to monorepos.
34
30
 
35
- ## 📦 Install
31
+ ## Install
36
32
 
37
33
  ```shell
38
- npm i eslint typescript @ntnyq/eslint-config -D
34
+ # pnpm
35
+ pnpm add -D eslint typescript @ntnyq/eslint-config
36
+
37
+ # npm
38
+ npm i -D eslint typescript @ntnyq/eslint-config
39
+
40
+ # yarn
41
+ yarn add -D eslint typescript @ntnyq/eslint-config
42
+
43
+ # bun
44
+ bun add -D eslint typescript @ntnyq/eslint-config
39
45
  ```
40
46
 
41
- ```shell
42
- yarn add eslint typescript @ntnyq/eslint-config -D
47
+ ## 60-Second Quick Start
48
+
49
+ 1. Create `eslint.config.mjs` in project root.
50
+ 2. Add npm scripts.
51
+ 3. Run lint.
52
+
53
+ ```js
54
+ // eslint.config.mjs
55
+ // @ts-check
56
+
57
+ import { defineESLintConfig } from '@ntnyq/eslint-config'
58
+
59
+ export default defineESLintConfig()
43
60
  ```
44
61
 
45
- ```shell
46
- pnpm add eslint typescript @ntnyq/eslint-config -D
62
+ ```json
63
+ {
64
+ "scripts": {
65
+ "lint": "eslint .",
66
+ "lint:fix": "eslint . --fix"
67
+ }
68
+ }
47
69
  ```
48
70
 
49
71
  ```shell
50
- bun add eslint typescript @ntnyq/eslint-config -D
72
+ pnpm lint
51
73
  ```
52
74
 
53
- ## 🚀 Usage
75
+ ## Common Frontend Setups
54
76
 
55
- Highly recommend using **`eslint.config.mjs`** as the config file:
77
+ ### Vite + Vue 3 + TypeScript
56
78
 
57
79
  ```js
58
- // @ts-check
80
+ // eslint.config.mjs
81
+ import { defineESLintConfig } from '@ntnyq/eslint-config'
82
+
83
+ export default defineESLintConfig({
84
+ vue: true,
85
+ typescript: {
86
+ tsconfigPath: './tsconfig.app.json',
87
+ },
88
+ })
89
+ ```
59
90
 
91
+ ### Vite + React + TypeScript
92
+
93
+ ```js
94
+ // eslint.config.mjs
95
+ import { defineESLintConfig } from '@ntnyq/eslint-config'
96
+
97
+ export default defineESLintConfig({
98
+ vue: false,
99
+ typescript: {
100
+ tsconfigPath: './tsconfig.json',
101
+ },
102
+ })
103
+ ```
104
+
105
+ ### Monorepo (apps + packages)
106
+
107
+ ```js
108
+ // eslint.config.mjs
60
109
  import { defineESLintConfig } from '@ntnyq/eslint-config'
61
110
 
62
111
  export default defineESLintConfig(
63
- // Options here
64
112
  {
65
- // Enable a config
66
- svgo: true,
67
- // Disable a config
68
- jsdoc: false,
69
- vue: {
70
- // Overrides built-in rules
71
- overrides: {
72
- 'vue/slot-name-casing': 'off',
73
- },
74
- },
113
+ typescript: true,
114
+ vue: true,
75
115
  },
76
- // Optional user configs here
77
116
  [
78
117
  {
79
- files: ['**/utils/*.ts'],
118
+ files: ['apps/web/**'],
80
119
  rules: {
81
- 'antfu/top-level-function': 'error',
120
+ 'no-console': 'warn',
121
+ },
122
+ },
123
+ {
124
+ files: ['packages/**'],
125
+ rules: {
126
+ 'no-console': 'off',
82
127
  },
83
128
  },
84
129
  ],
85
130
  )
86
131
  ```
87
132
 
88
- Add a `lint` script to `package.json`:
133
+ ## Configuration Patterns
89
134
 
90
- ```json
91
- {
92
- "scripts": {
93
- "lint": "eslint",
94
- "lint:fix": "eslint --fix"
95
- }
96
- }
135
+ ### Enable or disable modules
136
+
137
+ ```js
138
+ import { defineESLintConfig } from '@ntnyq/eslint-config'
139
+
140
+ export default defineESLintConfig({
141
+ svgo: true,
142
+ astro: true,
143
+ jsdoc: false,
144
+ unicorn: false,
145
+ })
97
146
  ```
98
147
 
99
- <details>
100
- <summary>💼 Integration: Prettier, VS Code, husky and nano-staged</summary>
148
+ ### Override built-in rules
101
149
 
102
- <br>
150
+ ```js
151
+ import { defineESLintConfig } from '@ntnyq/eslint-config'
103
152
 
104
- ## 🎨 Prettier config
153
+ export default defineESLintConfig({
154
+ vue: {
155
+ overrides: {
156
+ 'vue/slot-name-casing': 'off',
157
+ },
158
+ },
159
+ typescript: {
160
+ overrides: {
161
+ '@typescript-eslint/no-unused-vars': 'warn',
162
+ },
163
+ },
164
+ })
165
+ ```
105
166
 
106
- > Feel free to use your own prettier config.
167
+ ### Add project-specific flat config blocks
107
168
 
108
- Install `prettier` and set up your Prettier config:
169
+ ```js
170
+ import { defineESLintConfig } from '@ntnyq/eslint-config'
109
171
 
110
- ```shell
111
- npm i prettier @ntnyq/prettier-config -D
172
+ export default defineESLintConfig({}, [
173
+ {
174
+ files: ['**/scripts/**'],
175
+ rules: {
176
+ 'no-console': 'off',
177
+ },
178
+ },
179
+ ])
112
180
  ```
113
181
 
114
- ```shell
115
- yarn add prettier @ntnyq/prettier-config -D
116
- ```
182
+ ## Formatter Integration
117
183
 
118
- ```shell
119
- pnpm add prettier @ntnyq/prettier-config -D
120
- ```
184
+ Use one formatter strategy in a project:
185
+
186
+ - Prettier path: install `prettier` and optional `@ntnyq/prettier-config`
187
+ - Oxfmt path: install `oxfmt`
188
+
189
+ ### Prettier example
121
190
 
122
191
  ```shell
123
- bun add prettier @ntnyq/prettier-config -D
192
+ pnpm add -D prettier @ntnyq/prettier-config
124
193
  ```
125
194
 
126
195
  ```js
@@ -129,179 +198,56 @@ bun add prettier @ntnyq/prettier-config -D
129
198
 
130
199
  import { defineConfig } from '@ntnyq/prettier-config'
131
200
 
132
- export default defineConfig({
133
- // Custom options if needed
134
- printWidth: 100,
135
- trailingComma: 'none',
136
- overrides: [
137
- {
138
- files: ['**/*.html'],
139
- options: {
140
- singleAttributePerLine: false,
141
- },
142
- },
143
- {
144
- files: ['**/*.{css,scss,less}'],
145
- options: {
146
- singleQuote: false,
147
- },
148
- },
149
- ],
150
- })
201
+ export default defineConfig()
151
202
  ```
152
203
 
153
- ## 💻 VS Code config
204
+ ### VS Code example
154
205
 
155
206
  ```json
156
207
  {
157
208
  "eslint.enable": true,
158
- "prettier.enable": true,
159
- "editor.formatOnSave": true,
160
- "prettier.configPath": "./prettier.config.mjs",
161
- "editor.defaultFormatter": "esbenp.prettier-vscode",
162
209
  "editor.codeActionsOnSave": {
163
210
  "source.fixAll.eslint": "explicit",
164
211
  "source.organizeImports": "never",
165
212
  "source.sortImports": "never"
166
- },
167
- "eslint.validate": [
168
- "vue",
169
- "yaml",
170
- "toml",
171
- "json",
172
- "jsonc",
173
- "json5",
174
- "markdown",
175
- "javascript",
176
- "typescript",
177
- "javascriptreact",
178
- "typescriptreact"
179
- ]
180
- }
181
- ```
182
-
183
- ## 🎯 Lint changed files only
184
-
185
- ### 1. Add dependencies
186
-
187
- ```shell
188
- pnpm add husky nano-staged -D
189
- ```
190
-
191
- ### 2. Config in `package.json`
192
-
193
- ```json
194
- {
195
- "scripts": {
196
- "prepare": "husky"
197
- },
198
- "nano-staged": {
199
- "*.{js,ts,cjs,mjs,jsx,tsx,vue,md,svg,yml,yaml,toml,json}": "eslint --fix",
200
- "*.{css,scss,html}": "prettier -uw"
201
213
  }
202
214
  }
203
215
  ```
204
216
 
205
- ### 3. Add a Git hook
217
+ ## Optional Configs (Disabled by Default)
206
218
 
207
- ```shell
208
- echo "nano-staged" > .husky/pre-commit
209
- ```
219
+ - `astro`
220
+ - `eslintPlugin`
221
+ - `html`
222
+ - `pnpm`
223
+ - `svelte`
224
+ - `svgo`
225
+ - `unusedImports`
210
226
 
211
- </details>
212
-
213
- ## 🔍 View what rules are enabled
214
-
215
- Please check [eslint-config-inspector](https://eslint-config-inspector.ntnyq.com/) powered by [@eslint/config-inspector](https://github.com/eslint/config-inspector).
216
-
217
- ## ⚙️ Advanced config
218
-
219
- For details, see:
220
-
221
- - [./src/types/config.ts](https://github.com/ntnyq/eslint-config/blob/main/src/types/config.ts)
222
- - [./src/core.ts](https://github.com/ntnyq/eslint-config/blob/main/src/core.ts)
223
-
224
- ### 📝 Config interface
225
-
226
- ```ts
227
- export interface ConfigOptions {
228
- /**
229
- * Shareable options
230
- */
231
- shareable?: OptionsShareable
232
-
233
- /**
234
- * Configs enabled by default
235
- */
236
- command?: ConfigCommandOptions
237
- eslintComments?: ConfigESLintCommentsOptions
238
- ignores?: ConfigIgnoresOptions
239
- javascript?: ConfigJavaScriptOptions
240
- node?: ConfigNodeOptions
241
-
242
- /**
243
- * Configs below can be disabled
244
- */
245
- antfu?: boolean | ConfigAntfuOptions
246
- deMorgan?: boolean | ConfigDeMorganOptions
247
- depend?: boolean | ConfigDependOptions
248
- githubAction?: boolean | ConfigGitHubActionOptions
249
- gitignore?: boolean | ConfigGitIgnoreOptions
250
- importX?: boolean | ConfigImportXOptions
251
- jsdoc?: boolean | ConfigJsdocOptions
252
- jsonc?: boolean | ConfigJsoncOptions
253
- markdown?: boolean | ConfigMarkdownOptions
254
- ntnyq?: boolean | ConfigNtnyqOptions
255
- perfectionist?: boolean | ConfigPerfectionistOptions
256
- pinia?: boolean | ConfigPiniaOptions
257
- prettier?: boolean | ConfigPrettierOptions
258
- regexp?: boolean | ConfigRegexpOptions
259
- sort?: boolean | ConfigSortOptions
260
- specials?: boolean | ConfigSpecialsOptions
261
- test?: boolean | ConfigTestOptions
262
- toml?: boolean | ConfigTomlOptions
263
- typescript?: boolean | ConfigTypeScriptOptions
264
- unicorn?: boolean | ConfigUnicornOptions
265
- unocss?: boolean | ConfigUnoCSSOptions
266
- vue?: boolean | ConfigVueOptions
267
- yml?: boolean | ConfigYmlOptions
268
-
269
- /**
270
- * Configs below are disabled by default
271
- */
272
- astro?: boolean | ConfigAstroOptions
273
- html?: boolean | ConfigHtmlOptions
274
- pnpm?: boolean | ConfigPnpmOptions
275
- oxfmt?: boolean | ConfigOxfmtOptions
276
- svelte?: boolean | ConfigSvelteOptions
277
- svgo?: boolean | ConfigSVGOOptions
278
- eslintPlugin?: boolean | ConfigESLintPluginOptions
279
- unusedImports?: boolean | ConfigUnusedImportsOptions
280
- }
281
- ```
227
+ Enable them explicitly in `defineESLintConfig({ ... })` when needed.
228
+
229
+ ## Inspect Final Rules
282
230
 
283
- ## 📌 Versioning policy
231
+ - Online inspector: [eslint-config-inspector.ntnyq.com](https://eslint-config-inspector.ntnyq.com/)
232
+ - Local inspect: `npx eslint --inspect-config path/to/file.ts`
284
233
 
285
- This project aims to follow [Semantic Versioning](https://semver.org/) for releases.
234
+ ## Advanced API
286
235
 
287
- ### 🔴 Changes treated as Breaking Changes
236
+ - [Config options type](./src/types/config.ts)
237
+ - [Factory implementation](./src/core.ts)
288
238
 
289
- - Node.js version requirement changes
290
- - Huge refactors that might break the config
291
- - Plugins made major changes that might break the config
292
- - Changes that might affect most of the codebases
239
+ ## Versioning Policy
293
240
 
294
- ### 🟢 Changes treated as Non-Breaking Changes
241
+ This project follows Semantic Versioning with opinionated lint rules:
295
242
 
296
- - Enable/disable rules and plugins (that might become stricter)
297
- - Rule option changes
298
- - Version bumps of dependencies
243
+ - Treated as breaking: Node.js engine changes, major plugin incompatibility, broad refactors.
244
+ - Treated as non-breaking: enabling/disabling rules, rule option tuning, dependency bumps.
299
245
 
300
- ## 🙏 Credits
246
+ ## Credits
301
247
 
302
248
  - [@sxzz/eslint-config](https://github.com/sxzz/eslint-config)
303
249
  - [@antfu/eslint-config](https://github.com/antfu/eslint-config)
304
250
 
305
- ## 📄 License
251
+ ## License
306
252
 
307
253
  [MIT](./LICENSE) License © 2023-PRESENT [ntnyq](https://github.com/ntnyq)