@lincy/eslint-config 4.0.2 → 4.1.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 +101 -44
- package/dist/index.cjs +200 -97
- package/dist/index.d.cts +75 -35
- package/dist/index.d.ts +75 -35
- package/dist/index.js +196 -95
- package/package.json +38 -15
package/README.md
CHANGED
|
@@ -46,9 +46,9 @@ For example:
|
|
|
46
46
|
}
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
## VS Code support (
|
|
49
|
+
## VS Code support (自动修复)
|
|
50
50
|
|
|
51
|
-
安装[VS Code ESLint扩展](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
51
|
+
安装 [VS Code ESLint扩展](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
52
52
|
|
|
53
53
|
将以下设置添加到您的“settings.json”:
|
|
54
54
|
|
|
@@ -130,47 +130,75 @@ module.exports = lincy()
|
|
|
130
130
|
import lincy from '@lincy/eslint-config'
|
|
131
131
|
|
|
132
132
|
export default lincy({
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
/**
|
|
134
|
+
* 是否启用 stylistic 格式化规则
|
|
135
|
+
* @default 默认值: true
|
|
136
|
+
* @example 可选: false | { indent?: number | 'tab'; quotes?: 'single' | 'double'; jsx?: boolean; files?: string[]}
|
|
137
|
+
*/
|
|
136
138
|
stylistic: true,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
/**
|
|
140
|
+
* 是否启用 typescript 规则
|
|
141
|
+
* @default 默认值: 检测是否安装typescript依赖,
|
|
142
|
+
* @example 可选: false | true | { parserOptions: {}; files?: string[] }
|
|
143
|
+
*/
|
|
140
144
|
typescript: true,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
/**
|
|
146
|
+
* 是否启用 vue 规则
|
|
147
|
+
* @default 默认值: 检测是否安装vue依赖,
|
|
148
|
+
* @example 可选: false | true | { files?: string[] }
|
|
149
|
+
*/
|
|
144
150
|
vue: true,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
/**
|
|
152
|
+
* 是否启用 jsx 规则
|
|
153
|
+
* @default 默认值: true,
|
|
154
|
+
* @example 可选: false
|
|
155
|
+
*/
|
|
148
156
|
jsx: true,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
/**
|
|
158
|
+
* 是否启用 react 规则
|
|
159
|
+
* @default 默认值: 检测是否安装react依赖,
|
|
160
|
+
* @example 可选: false | true | { jsx?: boolean; version?: string; files?: string[] }
|
|
161
|
+
*/
|
|
152
162
|
react: true,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
163
|
+
/**
|
|
164
|
+
* 是否启用 unocss 规则
|
|
165
|
+
* @default 默认值: false,
|
|
166
|
+
* @example 可选: true | { attributify?: boolean; strict?: boolean }
|
|
167
|
+
*/
|
|
168
|
+
unocss: true,
|
|
169
|
+
/**
|
|
170
|
+
* 是否启用 jsonc 规则
|
|
171
|
+
* @default 默认值: true,
|
|
172
|
+
* @example 可选: false | { files?: string[] }
|
|
173
|
+
*/
|
|
156
174
|
jsonc: false,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
175
|
+
/**
|
|
176
|
+
* 是否启用 yaml 规则
|
|
177
|
+
* @default 默认值: true,
|
|
178
|
+
* @example 可选: false | { files?: string[] }
|
|
179
|
+
*/
|
|
160
180
|
yaml: false,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
181
|
+
/**
|
|
182
|
+
* 是否启用 .gitignore 文件
|
|
183
|
+
* @default 默认值: true,
|
|
184
|
+
* @example 可选: false | { ignores?: string[] }
|
|
185
|
+
*/
|
|
164
186
|
gitignore: false,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
187
|
+
/**
|
|
188
|
+
* 是否启用 test 规则
|
|
189
|
+
* @default 默认值: true,
|
|
190
|
+
* @example 可选: false | { files?: string[] }
|
|
191
|
+
*/
|
|
168
192
|
test: false,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
193
|
+
/**
|
|
194
|
+
* 是否启用 markdown 规则
|
|
195
|
+
* @default 默认值: true,
|
|
196
|
+
* @example 可选: false | { files?: string[] }
|
|
197
|
+
*/
|
|
172
198
|
markdown: false,
|
|
173
|
-
|
|
199
|
+
/**
|
|
200
|
+
* 覆盖规则
|
|
201
|
+
*/
|
|
174
202
|
overrides: {},
|
|
175
203
|
|
|
176
204
|
// 工厂函数第一个参数默认为各规则的开关, 但是也可以作为追加规则使用, 当包含以下键名将会自动整合到一个规则里
|
|
@@ -185,7 +213,8 @@ export default lincy({
|
|
|
185
213
|
})
|
|
186
214
|
```
|
|
187
215
|
|
|
188
|
-
`lincy`
|
|
216
|
+
`lincy` 工厂函数还接受任意数量的自定义配置覆盖
|
|
217
|
+
下面示例为添加`auto-import`生成的全局方法
|
|
189
218
|
|
|
190
219
|
```js
|
|
191
220
|
// eslint.config.js
|
|
@@ -200,16 +229,8 @@ const autoImport = JSON.parse(
|
|
|
200
229
|
export default lincy(
|
|
201
230
|
{
|
|
202
231
|
// 配置, 参考上一个代码块
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
{
|
|
206
|
-
plugins: {
|
|
207
|
-
'@unocss': plugin,
|
|
208
|
-
},
|
|
209
|
-
rules: {
|
|
210
|
-
...plugin.configs.recommended.rules,
|
|
211
|
-
'@unocss/order': 'off',
|
|
212
|
-
},
|
|
232
|
+
// 启用 unocss
|
|
233
|
+
unocss: true
|
|
213
234
|
},
|
|
214
235
|
// 启用 auto-import 生成的 .eslintrc-auto-import.json
|
|
215
236
|
{
|
|
@@ -251,6 +272,7 @@ import {
|
|
|
251
272
|
stylistic,
|
|
252
273
|
typescript,
|
|
253
274
|
unicorn,
|
|
275
|
+
unocss,
|
|
254
276
|
vue,
|
|
255
277
|
yaml,
|
|
256
278
|
} from '@lincy/eslint-config'
|
|
@@ -268,6 +290,7 @@ export default combine(
|
|
|
268
290
|
stylistic(/* Options */),
|
|
269
291
|
vue(),
|
|
270
292
|
react(/* Options */),
|
|
293
|
+
unocss(/* Options */),
|
|
271
294
|
jsonc(),
|
|
272
295
|
yaml(),
|
|
273
296
|
markdown(),
|
|
@@ -382,6 +405,40 @@ export default lincy({
|
|
|
382
405
|
})
|
|
383
406
|
```
|
|
384
407
|
|
|
408
|
+
### 可选配置
|
|
409
|
+
|
|
410
|
+
提供了一些可选配置,默认情况下不包含它们的依赖项
|
|
411
|
+
|
|
412
|
+
#### React
|
|
413
|
+
|
|
414
|
+
当检测到依赖安装了`react`, 则默认开启
|
|
415
|
+
|
|
416
|
+
运行“npx eslint”会提示您安装所需的依赖项,当然,您也可以手动安装它们:
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
pnpm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### UnoCSS
|
|
423
|
+
|
|
424
|
+
要启用 UnoCSS 支持,需要显式打开它
|
|
425
|
+
|
|
426
|
+
```js
|
|
427
|
+
// eslint.config.js
|
|
428
|
+
import lincy from '@lincy/eslint-config'
|
|
429
|
+
|
|
430
|
+
export default lincy({
|
|
431
|
+
unocss: true,
|
|
432
|
+
})
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
运行“npx eslint”会提示您安装所需的依赖项,当然,您也可以手动安装它们:
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
pnpm i -D @unocss/eslint-plugin
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
|
|
385
442
|
#### `perfectionist` (sorting)
|
|
386
443
|
|
|
387
444
|
这个插件 [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) 允许你排序对象键名,导入,自动修复等。
|