@lincy/eslint-config 5.2.7 → 5.3.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 +97 -20
- package/dist/index.cjs +124 -99
- package/dist/index.d.cts +788 -605
- package/dist/index.d.ts +788 -605
- package/dist/index.js +121 -98
- package/package.json +37 -35
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
|
|
|
@@ -44,7 +44,7 @@ export default lincy()
|
|
|
44
44
|
}
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
### VS Code support (保存时自动修复)
|
|
48
48
|
|
|
49
49
|
安装 [VS Code ESLint扩展](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
50
50
|
|
|
@@ -101,6 +101,16 @@ export default lincy()
|
|
|
101
101
|
}
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
### 使用.ts文件作为配置文件
|
|
105
|
+
|
|
106
|
+
1. 将`eslint`更新至最新版本
|
|
107
|
+
2. 在`package.json`中的`eslint .`后面添加参数`--flag unstable_ts_config`, 包括`scripts`、`lint-staged`中
|
|
108
|
+
3. 在`.vscode/settings.json`文件添加`"eslint.options": {
|
|
109
|
+
"flags": [
|
|
110
|
+
"unstable_ts_config"
|
|
111
|
+
]
|
|
112
|
+
}`
|
|
113
|
+
|
|
104
114
|
## 定制化
|
|
105
115
|
|
|
106
116
|
通常你只需要导入 `lincy` 预设:
|
|
@@ -140,19 +150,41 @@ export default lincy({
|
|
|
140
150
|
/**
|
|
141
151
|
* 是否启用 stylistic 格式化规则
|
|
142
152
|
* @default 默认值: true
|
|
143
|
-
* @example 可选: false |
|
|
153
|
+
* @example 可选: false |
|
|
154
|
+
* {
|
|
155
|
+
* indent?: number | 'tab';
|
|
156
|
+
* quotes?: 'single' | 'double';
|
|
157
|
+
* jsx?: boolean;
|
|
158
|
+
* semi?: boolean;
|
|
159
|
+
* lessOpinionated?: boolean;
|
|
160
|
+
* }
|
|
144
161
|
*/
|
|
145
162
|
stylistic: true,
|
|
146
163
|
/**
|
|
147
164
|
* 是否启用 typescript 规则
|
|
148
165
|
* @default 默认值: 检测是否安装typescript依赖,
|
|
149
|
-
* @example 可选: false | true |
|
|
166
|
+
* @example 可选: false | true |
|
|
167
|
+
* {
|
|
168
|
+
* files?: string[], // 自定义 glob 覆盖 “files” 选项
|
|
169
|
+
* componentExts: string[], // 组件的附加扩展
|
|
170
|
+
* parserOptions: {};
|
|
171
|
+
* filesTypeAware: string[],
|
|
172
|
+
* ignoresTypeAware?: string[],
|
|
173
|
+
* tsconfigPath?: string,
|
|
174
|
+
* type: 'app' | 'lib'
|
|
175
|
+
* }
|
|
150
176
|
*/
|
|
151
177
|
typescript: true,
|
|
152
178
|
/**
|
|
153
179
|
* 是否启用 vue 规则
|
|
154
180
|
* @default 默认值: 检测是否安装vue依赖,
|
|
155
|
-
* @example 可选: false | true |
|
|
181
|
+
* @example 可选: false | true |
|
|
182
|
+
* {
|
|
183
|
+
* files?: string[]; // 自定义 glob 覆盖 “files” 选项
|
|
184
|
+
* stylistic: boolean; // 是否开启 stylistic
|
|
185
|
+
* sfcBlocks: boolean; // 为 Vue SFC 创建虚拟文件以启用 linting
|
|
186
|
+
* typescript: boolean; // 是否开启 typescript
|
|
187
|
+
* }
|
|
156
188
|
*/
|
|
157
189
|
vue: true,
|
|
158
190
|
/**
|
|
@@ -164,31 +196,53 @@ export default lincy({
|
|
|
164
196
|
/**
|
|
165
197
|
* 是否启用 react 规则
|
|
166
198
|
* @default 默认值: 检测是否安装react依赖,
|
|
167
|
-
* @example 可选: false | true |
|
|
199
|
+
* @example 可选: false | true |
|
|
200
|
+
* {
|
|
201
|
+
* files?: string[], // 自定义 glob 覆盖 “files” 选项
|
|
202
|
+
* filesTypeAware?: string[], // 应该识别类型的文件的全局模式.
|
|
203
|
+
* ignoresTypeAware?: string[], // 不应具有类型感知的文件的 Glob 模式
|
|
204
|
+
* tsconfigPath?: string, // 提供此选项后,将启用类型感知规则
|
|
205
|
+
* }
|
|
168
206
|
*/
|
|
169
207
|
react: true,
|
|
170
208
|
/**
|
|
171
209
|
* 是否启用 unocss 规则
|
|
172
210
|
* @default 默认值: false,
|
|
173
|
-
* @example 可选: true |
|
|
211
|
+
* @example 可选: true |
|
|
212
|
+
* {
|
|
213
|
+
* attributify?: boolean; // 启用 attributify 支持.
|
|
214
|
+
* strict?: boolean; // 启用严格模式,抛出有关阻止列表类的错误
|
|
215
|
+
* }
|
|
174
216
|
*/
|
|
175
217
|
unocss: true,
|
|
176
218
|
/**
|
|
177
219
|
* 是否启用 jsonc 规则
|
|
178
220
|
* @default 默认值: true,
|
|
179
|
-
* @example 可选: false |
|
|
221
|
+
* @example 可选: false |
|
|
222
|
+
* {
|
|
223
|
+
* files?: string[]; // 自定义 glob 覆盖 “files” 选项
|
|
224
|
+
* stylistic: boolean; // 是否开启 stylistic
|
|
225
|
+
* }
|
|
180
226
|
*/
|
|
181
227
|
jsonc: false,
|
|
182
228
|
/**
|
|
183
229
|
* 是否启用 yaml 规则
|
|
184
230
|
* @default 默认值: true,
|
|
185
|
-
* @example 可选: false |
|
|
231
|
+
* @example 可选: false |
|
|
232
|
+
* {
|
|
233
|
+
* files?: string[]; // 自定义 glob 覆盖 “files” 选项
|
|
234
|
+
* stylistic: boolean; // 是否开启 stylistic
|
|
235
|
+
* }
|
|
186
236
|
*/
|
|
187
237
|
yaml: false,
|
|
188
238
|
/**
|
|
189
239
|
* 是否启用 toml 规则
|
|
190
240
|
* @default 默认值: false,
|
|
191
|
-
* @example 可选: true
|
|
241
|
+
* @example 可选: true |
|
|
242
|
+
* {
|
|
243
|
+
* files?: string[]; // 自定义 glob 覆盖 “files” 选项
|
|
244
|
+
* stylistic: boolean; // 是否开启 stylistic
|
|
245
|
+
* }
|
|
192
246
|
*/
|
|
193
247
|
toml: false,
|
|
194
248
|
/**
|
|
@@ -218,7 +272,13 @@ export default lincy({
|
|
|
218
272
|
/**
|
|
219
273
|
* 是否启用 formatters 规则
|
|
220
274
|
* @default 默认值: false,
|
|
221
|
-
* @example 可选: true |
|
|
275
|
+
* @example 可选: true |
|
|
276
|
+
* {
|
|
277
|
+
* css?: 'prettier' | boolean;
|
|
278
|
+
* html?: 'prettier' | boolean;
|
|
279
|
+
* graphql?: 'prettier' | boolean;
|
|
280
|
+
* markdown?: 'prettier' | 'dprint' | boolean
|
|
281
|
+
* }
|
|
222
282
|
*/
|
|
223
283
|
formatters: false,
|
|
224
284
|
/**
|
|
@@ -524,6 +584,11 @@ export default lincy({
|
|
|
524
584
|
* 默认使用 Prettier
|
|
525
585
|
*/
|
|
526
586
|
css: true,
|
|
587
|
+
/**
|
|
588
|
+
* 格式化 graphql 文件
|
|
589
|
+
* 默认使用 Prettier
|
|
590
|
+
*/
|
|
591
|
+
graphql: true,
|
|
527
592
|
/**
|
|
528
593
|
* 格式化 HTML 文件
|
|
529
594
|
* 默认使用 Prettier
|
|
@@ -534,7 +599,19 @@ export default lincy({
|
|
|
534
599
|
* 支持 Prettier 和 dprint
|
|
535
600
|
* 默认使用 Prettier
|
|
536
601
|
*/
|
|
537
|
-
markdown: 'prettier'
|
|
602
|
+
markdown: 'prettier',
|
|
603
|
+
/**
|
|
604
|
+
* 格式化 svg 文件
|
|
605
|
+
* 需要安装 @prettier/plugin-xml 插件
|
|
606
|
+
* 默认使用 Prettier
|
|
607
|
+
*/
|
|
608
|
+
svg: 'prettier',
|
|
609
|
+
/**
|
|
610
|
+
* 格式化 xml 文件
|
|
611
|
+
* 需要安装 @prettier/plugin-xml 插件
|
|
612
|
+
* 默认使用 Prettier
|
|
613
|
+
*/
|
|
614
|
+
xml: 'prettier'
|
|
538
615
|
}
|
|
539
616
|
})
|
|
540
617
|
```
|