@lincy/eslint-config 3.0.10 → 3.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 CHANGED
@@ -24,9 +24,9 @@ pnpm add -D eslint @lincy/eslint-config
24
24
 
25
25
  ```js
26
26
  // eslint.config.js
27
- import eslintConfig from '@lincy/eslint-config'
27
+ import lincy from '@lincy/eslint-config'
28
28
 
29
- export default eslintConfig()
29
+ export default lincy()
30
30
  ```
31
31
 
32
32
  > 通常您不需要`.eslintignore`,因为它已由预设提供。
@@ -99,46 +99,96 @@ For example:
99
99
 
100
100
  ## 定制化
101
101
 
102
- 通常你只需要导入 `eslintConfig` 预设:
102
+ 通常你只需要导入 `lincy` 预设:
103
103
 
104
+ #### esm
104
105
  ```js
105
106
  // eslint.config.js
106
- import eslintConfig from '@lincy/eslint-config'
107
+ import lincy from '@lincy/eslint-config'
107
108
 
108
- export default eslintConfig()
109
+ // or
110
+ // import { lincy } from '@lincy/eslint-config'
111
+
112
+ export default lincy()
113
+ ```
114
+
115
+ #### cjs
116
+ ```js
117
+ // eslint.config.js
118
+ const lincy = require('@lincy/eslint-config').lincy
119
+
120
+ module.exports = lincy()
109
121
  ```
110
122
 
111
123
  您可以单独配置每个功能,例如:
112
124
 
113
125
  ```js
114
126
  // eslint.config.js
115
- import eslintConfig from '@lincy/eslint-config'
116
-
117
- export default eslintConfig({
118
- stylistic: true, // enable stylistic formatting rules
119
- typescript: true,
120
- vue: true,
121
- jsonc: false,
122
- yml: false,
127
+ import lincy from '@lincy/eslint-config'
128
+
129
+ export default lincy({
130
+ // 是否启用 stylistic 格式化规则
131
+ stylistic: true, // 默认值: true
132
+ // 是否启用 typescript 规则
133
+ typescript: true, // 默认值: 检测是否安装typescript依赖
134
+ // 是否启用 vue 规则
135
+ vue: true, // 默认值: 检测是否安装vue依赖
136
+ // 是否启用 jsonc 规则
137
+ jsonc: false, // 默认值: 检测是否安装typescript依赖
138
+ // 是否启用 yml 规则
139
+ yml: false, // 默认值: true
140
+ // 是否启用 .gitignore 文件
141
+ gitignore: false, // 默认值: true
142
+ // 是否启用 test 规则
143
+ test: false, // 默认值: true
144
+ // 是否启用 markdown 规则
145
+ markdown: false, // 默认值: true
123
146
  })
124
147
  ```
125
148
 
126
- `eslintConfig` 工厂函数还接受任意数量的自定义配置覆盖:
149
+ `lincy` 工厂函数还接受任意数量的自定义配置覆盖:
127
150
 
128
151
  ```js
129
152
  // eslint.config.js
130
- import eslintConfig from '@lincy/eslint-config'
153
+ import { readFile } from 'node:fs/promises'
154
+ import lincy from '@lincy/eslint-config'
155
+ import plugin from '@unocss/eslint-plugin'
156
+
157
+ const autoImport = JSON.parse(
158
+ await readFile(new URL('./.eslintrc-auto-import.json', import.meta.url)),
159
+ )
131
160
 
132
- export default eslintConfig(
161
+ export default lincy(
133
162
  {
134
163
  // Configures for config
135
164
  },
136
-
137
- // From the second arguments they are ESLint Flat Configs
138
- // you can have multiple configs
165
+ // 启用 unocss
139
166
  {
140
- rules: {},
167
+ plugins: {
168
+ '@unocss': plugin,
169
+ },
170
+ rules: {
171
+ ...plugin.configs.recommended.rules,
172
+ '@unocss/order': 'off',
173
+ },
174
+ },
175
+ // 启用 auto-import 生成的 .eslintrc-auto-import.json
176
+ {
177
+ languageOptions: {
178
+ globals: {
179
+ ...autoImport.globals,
180
+ // 其他 globals
181
+ },
182
+ },
183
+ },
184
+ // 自定义排除文件(夹)
185
+ {
186
+ ignores: [
187
+ '**/assets',
188
+ '**/static',
189
+ ],
141
190
  },
191
+ // 你还可以继续配置多个 ESLint Flat Configs
142
192
  {
143
193
  rules: {},
144
194
  },
@@ -202,7 +252,6 @@ export default [
202
252
  | `n/*` | `node` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n)
203
253
  | `@typescript-eslint/*` | `ts/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
204
254
  | `@stylistic/js` | `style/*` | [@stylistic/eslint-plugin-js](https://github.com/eslint-stylistic/eslint-stylistic) |
205
- | `@stylistic/ts` | `style-ts/` | [@stylistic/eslint-plugin-ts](https://github.com/eslint-stylistic/eslint-stylistic) |
206
255
 
207
256
  当您想要覆盖规则或内联禁用它们时,您需要更新到新的前缀:
208
257
 
@@ -218,9 +267,9 @@ type foo = { bar: 2 }
218
267
 
219
268
  ```js
220
269
  // eslint.config.js
221
- import eslintConfig from '@lincy/eslint-config'
270
+ import lincy from '@lincy/eslint-config'
222
271
 
223
- export default eslintConfig({
272
+ export default lincy({
224
273
  typescript: {
225
274
  tsconfigPath: 'tsconfig.json',
226
275
  },