@lincy/eslint-config 4.1.0 → 4.2.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 +26 -20
- package/dist/index.cjs +963 -856
- package/dist/index.d.cts +175 -29
- package/dist/index.d.ts +175 -29
- package/dist/index.js +960 -857
- package/package.json +24 -17
package/README.md
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
> Thanks to [sxzz/eslint-config](https://github.com/sxzz/eslint-config) and [antfu/eslint-config](https://github.com/antfu/eslint-config) for the inspiration and reference.
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
7
|
+
- 单引号,无结尾分号
|
|
8
|
+
- 自动格式化
|
|
9
|
+
- 专为与 TypeScript、Vue(2/3)、React 一起使用而设计,开箱即用
|
|
10
|
+
- 也适用于 json、yaml、markdown
|
|
11
|
+
- import导入排序, 对象字⾯量项尾逗号
|
|
12
|
+
- 合理的默认值,最佳实践,只需一行配置
|
|
13
|
+
- [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
|
|
14
|
+
- 使用 [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
15
|
+
- **风格原则**: 读取最小,差异稳定
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
@@ -101,6 +101,7 @@ For example:
|
|
|
101
101
|
通常你只需要导入 `lincy` 预设:
|
|
102
102
|
|
|
103
103
|
#### esm
|
|
104
|
+
|
|
104
105
|
如果 package.json 中开启了`"type": "module",`
|
|
105
106
|
|
|
106
107
|
```js
|
|
@@ -114,6 +115,7 @@ export default lincy()
|
|
|
114
115
|
```
|
|
115
116
|
|
|
116
117
|
#### cjs
|
|
118
|
+
|
|
117
119
|
如果 package.json 中没有开启`"type": "module",`
|
|
118
120
|
|
|
119
121
|
```js
|
|
@@ -133,7 +135,7 @@ export default lincy({
|
|
|
133
135
|
/**
|
|
134
136
|
* 是否启用 stylistic 格式化规则
|
|
135
137
|
* @default 默认值: true
|
|
136
|
-
* @example 可选: false | { indent?: number | 'tab'; quotes?: 'single' | 'double'; jsx?: boolean;
|
|
138
|
+
* @example 可选: false | { indent?: number | 'tab'; quotes?: 'single' | 'double'; jsx?: boolean; semi?: boolean}
|
|
137
139
|
*/
|
|
138
140
|
stylistic: true,
|
|
139
141
|
/**
|
|
@@ -196,6 +198,12 @@ export default lincy({
|
|
|
196
198
|
* @example 可选: false | { files?: string[] }
|
|
197
199
|
*/
|
|
198
200
|
markdown: false,
|
|
201
|
+
/**
|
|
202
|
+
* 是否启用 formatters 规则
|
|
203
|
+
* @default 默认值: false,
|
|
204
|
+
* @example 可选: true | { css?: 'prettier' | boolean; html?: 'prettier' | boolean; toml?: 'dprint' | boolean; markdown?: 'prettier' | 'dprint' | boolean }
|
|
205
|
+
*/
|
|
206
|
+
formatters: false,
|
|
199
207
|
/**
|
|
200
208
|
* 覆盖规则
|
|
201
209
|
*/
|
|
@@ -299,18 +307,17 @@ export default combine(
|
|
|
299
307
|
|
|
300
308
|
查看 [configs](https://github.com/lincenying/eslint-config/blob/main/src/configs) 和 [factory](https://github.com/lincenying/eslint-config/blob/main/src/factory.ts)了解更多详细信息。
|
|
301
309
|
|
|
302
|
-
|
|
303
310
|
### 插件重命名
|
|
304
311
|
|
|
305
312
|
由于扁平化配置支持显式提供了插件名称,因此我们重命名了一些插件以使它们更加一致并隐藏实现细节。
|
|
306
313
|
|
|
307
|
-
| New Prefix | Original Prefix
|
|
308
|
-
|
|
|
309
|
-
| `import/*` | `i/*`
|
|
310
|
-
| `node/*`
|
|
311
|
-
| `yaml/*`
|
|
312
|
-
| `ts/*`
|
|
313
|
-
| `style/*`
|
|
314
|
+
| New Prefix | Original Prefix | Source Plugin |
|
|
315
|
+
| ---------- | ---------------------- | ------------------------------------------------------------------------------------------ |
|
|
316
|
+
| `import/*` | `i/*` | [eslint-plugin-i](https://github.com/un-es/eslint-plugin-i) |
|
|
317
|
+
| `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
|
|
318
|
+
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
|
|
319
|
+
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
|
|
320
|
+
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
|
|
314
321
|
|
|
315
322
|
当您想要覆盖规则或内联禁用它们时,您需要更新到新的前缀:
|
|
316
323
|
|
|
@@ -322,7 +329,7 @@ type foo = { bar: 2 }
|
|
|
322
329
|
|
|
323
330
|
### 规则覆盖
|
|
324
331
|
|
|
325
|
-
某些规则仅在特定文件中启用,例如,“ts
|
|
332
|
+
某些规则仅在特定文件中启用,例如,“ts/_”规则仅在“.ts”文件中启用,“vue/_”规则仅在“.vue”文件中启用。 如果要覆盖规则,则需要指定文件扩展名:
|
|
326
333
|
|
|
327
334
|
```js
|
|
328
335
|
// eslint.config.js
|
|
@@ -438,7 +445,6 @@ export default lincy({
|
|
|
438
445
|
pnpm i -D @unocss/eslint-plugin
|
|
439
446
|
```
|
|
440
447
|
|
|
441
|
-
|
|
442
448
|
#### `perfectionist` (sorting)
|
|
443
449
|
|
|
444
450
|
这个插件 [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) 允许你排序对象键名,导入,自动修复等。
|