@lincy/eslint-config 3.1.0 → 3.2.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 +75 -21
- package/dist/index.cjs +717 -558
- package/dist/index.d.cts +63 -22
- package/dist/index.d.ts +63 -22
- package/dist/index.js +692 -554
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -135,8 +135,8 @@ export default lincy({
|
|
|
135
135
|
vue: true, // 默认值: 检测是否安装vue依赖
|
|
136
136
|
// 是否启用 jsonc 规则
|
|
137
137
|
jsonc: false, // 默认值: 检测是否安装typescript依赖
|
|
138
|
-
// 是否启用
|
|
139
|
-
|
|
138
|
+
// 是否启用 yaml 规则
|
|
139
|
+
yaml: false, // 默认值: true
|
|
140
140
|
// 是否启用 .gitignore 文件
|
|
141
141
|
gitignore: false, // 默认值: true
|
|
142
142
|
// 是否启用 test 规则
|
|
@@ -190,6 +190,7 @@ export default lincy(
|
|
|
190
190
|
},
|
|
191
191
|
// 你还可以继续配置多个 ESLint Flat Configs
|
|
192
192
|
{
|
|
193
|
+
files: ['**/*.ts'],
|
|
193
194
|
rules: {},
|
|
194
195
|
},
|
|
195
196
|
)
|
|
@@ -204,36 +205,34 @@ import {
|
|
|
204
205
|
ignores,
|
|
205
206
|
imports,
|
|
206
207
|
javascript,
|
|
207
|
-
javascriptStylistic,
|
|
208
208
|
jsdoc,
|
|
209
209
|
jsonc,
|
|
210
210
|
markdown,
|
|
211
211
|
node,
|
|
212
212
|
sortPackageJson,
|
|
213
213
|
sortTsconfig,
|
|
214
|
+
stylistic,
|
|
214
215
|
typescript,
|
|
215
|
-
typescriptStylistic,
|
|
216
216
|
unicorn,
|
|
217
217
|
vue,
|
|
218
|
-
|
|
218
|
+
yaml,
|
|
219
219
|
} from '@lincy/eslint-config'
|
|
220
220
|
|
|
221
221
|
export default [
|
|
222
|
-
...ignores,
|
|
222
|
+
...ignores(),
|
|
223
223
|
...javascript(),
|
|
224
|
-
...comments,
|
|
225
|
-
...node,
|
|
226
|
-
...jsdoc,
|
|
227
|
-
...imports,
|
|
228
|
-
...unicorn,
|
|
229
|
-
...javascriptStylistic,
|
|
224
|
+
...comments(),
|
|
225
|
+
...node(),
|
|
226
|
+
...jsdoc(),
|
|
227
|
+
...imports(),
|
|
228
|
+
...unicorn(),
|
|
230
229
|
|
|
231
230
|
...typescript(),
|
|
232
|
-
...
|
|
231
|
+
...stylistic(),
|
|
233
232
|
|
|
234
233
|
...vue(),
|
|
235
|
-
...jsonc,
|
|
236
|
-
...
|
|
234
|
+
...jsonc(),
|
|
235
|
+
...yaml(),
|
|
237
236
|
...markdown(),
|
|
238
237
|
]
|
|
239
238
|
```
|
|
@@ -246,12 +245,13 @@ export default [
|
|
|
246
245
|
|
|
247
246
|
由于平面配置支持显式提供了插件名称,因此我们重命名了一些插件以使它们更加一致并隐藏实现细节。
|
|
248
247
|
|
|
249
|
-
|
|
|
250
|
-
|
|
|
251
|
-
| `
|
|
252
|
-
| `
|
|
253
|
-
|
|
|
254
|
-
|
|
|
248
|
+
| New Prefix | Original Prefix | Source Plugin |
|
|
249
|
+
| --- | --- | --- |
|
|
250
|
+
| `import/*` | `i/*` | [eslint-plugin-i](https://github.com/un-es/eslint-plugin-i) |
|
|
251
|
+
| `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
|
|
252
|
+
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
|
|
253
|
+
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
|
|
254
|
+
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
|
|
255
255
|
|
|
256
256
|
当您想要覆盖规则或内联禁用它们时,您需要更新到新的前缀:
|
|
257
257
|
|
|
@@ -261,6 +261,60 @@ export default [
|
|
|
261
261
|
type foo = { bar: 2 }
|
|
262
262
|
```
|
|
263
263
|
|
|
264
|
+
### Rules Overrides
|
|
265
|
+
|
|
266
|
+
某些规则仅在特定文件中启用,例如,“ts/*”规则仅在“.ts”文件中启用,“vue/*”规则仅在“.vue”文件中启用。 如果要覆盖规则,则需要指定文件扩展名:
|
|
267
|
+
|
|
268
|
+
```js
|
|
269
|
+
// eslint.config.js
|
|
270
|
+
import antfu from '@antfu/eslint-config'
|
|
271
|
+
|
|
272
|
+
export default antfu(
|
|
273
|
+
{ vue: true, typescript: true },
|
|
274
|
+
{
|
|
275
|
+
// 记得在这里指定文件 glob,否则可能会导致 vue 插件处理非 vue 文件
|
|
276
|
+
files: ['**/*.vue'],
|
|
277
|
+
rules: {
|
|
278
|
+
'vue/operator-linebreak': ['error', 'before'],
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
// 如果没有 `files`,它们是所有文件的通用规则
|
|
283
|
+
rules: {
|
|
284
|
+
'style/semi': ['error', 'never'],
|
|
285
|
+
},
|
|
286
|
+
}
|
|
287
|
+
)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
还可以使用“overrides”选项以使其更容易:
|
|
291
|
+
|
|
292
|
+
```js
|
|
293
|
+
// eslint.config.js
|
|
294
|
+
import antfu from '@antfu/eslint-config'
|
|
295
|
+
|
|
296
|
+
export default antfu({
|
|
297
|
+
overrides: {
|
|
298
|
+
vue: {
|
|
299
|
+
'vue/operator-linebreak': ['error', 'before'],
|
|
300
|
+
},
|
|
301
|
+
typescript: {
|
|
302
|
+
'ts/consistent-type-definitions': ['error', 'interface'],
|
|
303
|
+
},
|
|
304
|
+
javascript: {},
|
|
305
|
+
stylistic: {
|
|
306
|
+
'antfu/consistent-list-newline': 'off',
|
|
307
|
+
},
|
|
308
|
+
yaml: {},
|
|
309
|
+
ignores: [
|
|
310
|
+
'**/assets',
|
|
311
|
+
'**/static',
|
|
312
|
+
]
|
|
313
|
+
// ...
|
|
314
|
+
}
|
|
315
|
+
})
|
|
316
|
+
```
|
|
317
|
+
|
|
264
318
|
### Type Aware Rules
|
|
265
319
|
|
|
266
320
|
您可以选择通过将选项对象传递给“typescript”配置来启用[类型感知规则](https://typescript-eslint.io/linting/typed-linting/):
|