@coderwyd/eslint-config 1.1.0-beta.2 → 1.1.0-beta.3
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 +35 -5
- package/dist/index.cjs +348 -144
- package/dist/index.d.cts +78 -11
- package/dist/index.d.ts +78 -11
- package/dist/index.js +393 -190
- package/package.json +16 -11
package/README.md
CHANGED
|
@@ -26,6 +26,8 @@ pnpm i -D eslint @coderwyd/eslint-config
|
|
|
26
26
|
|
|
27
27
|
### Create config file
|
|
28
28
|
|
|
29
|
+
With [`"type": "module"`](https://nodejs.org/api/packages.html#type) in `package.json` (recommended):
|
|
30
|
+
|
|
29
31
|
```js
|
|
30
32
|
// eslint.config.js
|
|
31
33
|
import coderwyd from '@coderwyd/eslint-config'
|
|
@@ -33,6 +35,15 @@ import coderwyd from '@coderwyd/eslint-config'
|
|
|
33
35
|
export default coderwyd()
|
|
34
36
|
```
|
|
35
37
|
|
|
38
|
+
With CJS:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
// eslint.config.js
|
|
42
|
+
const coderwyd = require('@coderwyd/eslint-config').default
|
|
43
|
+
|
|
44
|
+
module.exports = coderwyd()
|
|
45
|
+
```
|
|
46
|
+
|
|
36
47
|
> Note that `.eslintignore` no longer works in Flat config, see [customization](#customization) for more details.
|
|
37
48
|
|
|
38
49
|
### Add script for package.json
|
|
@@ -100,7 +111,7 @@ Add the following settings to your `.vscode/settings.json`:
|
|
|
100
111
|
|
|
101
112
|
## Customization
|
|
102
113
|
|
|
103
|
-
Since v1.0, we migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
|
|
114
|
+
Since v1.0, we migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new). It provides a much better organization and composition.
|
|
104
115
|
|
|
105
116
|
Normally you only need to import the `coderwyd` preset:
|
|
106
117
|
|
|
@@ -132,7 +143,7 @@ export default coderwyd({
|
|
|
132
143
|
})
|
|
133
144
|
```
|
|
134
145
|
|
|
135
|
-
The `coderwyd` factory
|
|
146
|
+
The `coderwyd` factory function also accepts any number of arbitrary custom config overrides:
|
|
136
147
|
|
|
137
148
|
```js
|
|
138
149
|
// eslint.config.js
|
|
@@ -155,7 +166,7 @@ export default coderwyd(
|
|
|
155
166
|
)
|
|
156
167
|
```
|
|
157
168
|
|
|
158
|
-
Going more advanced, you can also import
|
|
169
|
+
Going more advanced, you can also import fine-grained configs and compose them as you wish:
|
|
159
170
|
|
|
160
171
|
```js
|
|
161
172
|
// eslint.config.js
|
|
@@ -211,8 +222,10 @@ Since flat config requires us to explicitly provide the plugin names (instead of
|
|
|
211
222
|
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
|
|
212
223
|
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
|
|
213
224
|
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
|
|
225
|
+
| `test/*` | `vitest/*` | [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) |
|
|
226
|
+
| `test/*` | `no-only-tests/*` | [eslint-plugin-no-only-tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests) |
|
|
214
227
|
|
|
215
|
-
When you want to
|
|
228
|
+
When you want to override rules, or disable them inline, you need to update to the new prefix:
|
|
216
229
|
|
|
217
230
|
```diff
|
|
218
231
|
-// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
@@ -229,7 +242,24 @@ Certain rules would only be enabled in specific files, for example, `ts/*` rules
|
|
|
229
242
|
import coderwyd from '@coderwyd/eslint-config'
|
|
230
243
|
|
|
231
244
|
export default coderwyd(
|
|
232
|
-
{
|
|
245
|
+
{
|
|
246
|
+
// Enable stylistic formatting rules
|
|
247
|
+
// stylistic: true,
|
|
248
|
+
|
|
249
|
+
// Or customize the stylistic rules
|
|
250
|
+
stylistic: {
|
|
251
|
+
indent: 2, // 4, or 'tab'
|
|
252
|
+
quotes: 'single', // or 'double'
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
// TypeScript and Vue are auto-detected, you can also explicitly enable them:
|
|
256
|
+
typescript: true,
|
|
257
|
+
vue: true,
|
|
258
|
+
|
|
259
|
+
// Disable jsonc and yaml support
|
|
260
|
+
jsonc: false,
|
|
261
|
+
yaml: false,
|
|
262
|
+
},
|
|
233
263
|
{
|
|
234
264
|
// Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files
|
|
235
265
|
files: ['**/*.vue'],
|