You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Silent the stylistic rules in you IDE, but still auto fix them
73
+
"eslint.rules.customizations": [
74
+
{ "rule":"style/*", "severity":"off" },
75
+
{ "rule":"*-indent", "severity":"off" },
76
+
{ "rule":"*-spacing", "severity":"off" },
77
+
{ "rule":"*-spaces", "severity":"off" },
78
+
{ "rule":"*-order", "severity":"off" },
79
+
{ "rule":"*-dangle", "severity":"off" },
80
+
{ "rule":"*-newline", "severity":"off" },
81
+
{ "rule":"*quotes", "severity":"off" },
82
+
{ "rule":"*semi", "severity":"off" }
83
+
],
84
+
85
+
// Enable eslint for all supported languages
86
+
"eslint.validate": [
87
+
"javascript",
88
+
"javascriptreact",
89
+
"typescript",
90
+
"typescriptreact",
91
+
"vue",
92
+
"html",
93
+
"markdown",
94
+
"json",
95
+
"jsonc",
96
+
"yaml"
97
+
]
70
98
}
71
99
```
72
100
73
-
### TypeScript Aware Rules
101
+
##Customization
74
102
75
-
Type aware rules are enabled when a `tsconfig.eslint.json` is found in the project root, which will introduce some stricter rules into your project. If you want to enable it while have no `tsconfig.eslint.json` in the project root, you can change tsconfig name by modifying `ESLINT_TSCONFIG` env.
103
+
Since v1.0, we migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), provides a much better organization and composition.
104
+
105
+
Normally you only need to import the `coderwyd` preset:
76
106
77
107
```js
78
-
// .eslintrc.js
79
-
constprocess=require('node:process')
108
+
// eslint.config.js
109
+
importcoderwydfrom'@coderwyd/eslint-config'
110
+
111
+
exportdefaultcoderwyd()
112
+
```
80
113
81
-
process.env.ESLINT_TSCONFIG='tsconfig.json'
114
+
And that's it! Or you can configure each integration individually, for example:
// `.eslintignore` is no longer supported in Flat config, use `ignores` instead
128
+
ignores: [
129
+
'./fixtures',
130
+
// ...globs
131
+
]
132
+
})
133
+
```
134
+
135
+
The `coderwyd` factory functions also accepts arbitrary numbers of constom configs overrides:
136
+
137
+
```js
138
+
// eslint.config.js
139
+
importcoderwydfrom'@coderwyd/eslint-config'
140
+
141
+
exportdefaultcoderwyd(
142
+
{
143
+
// Configures for coderwyd's config
144
+
},
145
+
146
+
// From the second arguments they are ESLint Flat Configs
147
+
// you can have multiple configs
148
+
{
149
+
files: ['**/*.ts'],
150
+
rules: {},
151
+
},
152
+
{
153
+
rules: {},
154
+
},
155
+
)
156
+
```
157
+
158
+
Going more advanced, you can also import the very fine-grained configs and compose them as you wish:
159
+
160
+
```js
161
+
// eslint.config.js
162
+
import {
163
+
astro,
164
+
comments,
165
+
ignores,
166
+
imports,
167
+
javascript,
168
+
jsdoc,
169
+
jsonc,
170
+
markdown,
171
+
node,
172
+
react,
173
+
sortPackageJson,
174
+
sortTsconfig,
175
+
stylistic,
176
+
typescript,
177
+
unicorn,
178
+
vue,
179
+
yml,
180
+
} from'@coderwyd/eslint-config'
181
+
182
+
exportdefault [
183
+
...astro(),
184
+
...react(),
185
+
...ignores(),
186
+
...javascript(),
187
+
...comments(),
188
+
...node(),
189
+
...jsdoc(),
190
+
...imports(),
191
+
...unicorn(),
192
+
...typescript(),
193
+
...stylistic(),
194
+
...vue(),
195
+
...jsonc(),
196
+
...yml(),
197
+
...markdown(),
198
+
]
199
+
```
200
+
201
+
Check out the [configs](https://github.com/coderwyd/eslint-config/blob/main/src/configs) and [factory](https://github.com/coderwyd/eslint-config/blob/main/src/factory.ts) for more details.
202
+
203
+
## Plugins Renaming
204
+
205
+
Since flat config requires us to explicitly provide the plugin names (instead of mandatory convention from npm package name), we renamed some plugins to make overall scope more consistent and easier to write.
Certain rules would only be enabled in specific files, for example, `ts/*` rules would only be enabled in `.ts` files and `vue/*` rules would only be enabled in `.vue` files. If you want to override the rules, you need to specify the file extension:
226
+
227
+
```js
228
+
// eslint.config.js
229
+
importcoderwydfrom'@coderwyd/eslint-config'
230
+
231
+
exportdefaultcoderwyd(
232
+
{ vue:true, typescript:true },
233
+
{
234
+
// Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files
235
+
files: ['**/*.vue'],
236
+
rules: {
237
+
'vue/operator-linebreak': ['error', 'before'],
238
+
},
239
+
},
240
+
{
241
+
// Without `files`, they are general rules for all files
242
+
rules: {
243
+
'style/semi': ['error', 'never'],
244
+
},
245
+
}
246
+
)
247
+
```
248
+
249
+
We also provided an `overrides` options to make it easier:
You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the options object to the `typescript` config:
272
+
273
+
```js
274
+
// eslint.config.js
275
+
importcoderwydfrom'@coderwyd/eslint-config'
276
+
277
+
exportdefaultcoderwyd({
278
+
typescript: {
279
+
tsconfigPath:'tsconfig.json',
280
+
},
281
+
})
86
282
```
87
283
88
284
### Lint Staged
@@ -106,27 +302,10 @@ and then
106
302
npm i -D lint-staged simple-git-hooks
107
303
```
108
304
109
-
## FAQ
110
-
111
-
### Customization rules
112
-
113
-
add you like rules to your .eslintrc file.
114
-
115
-
<!-- eslint-skip -->
116
-
117
-
```jsonc
118
-
{
119
-
"extends":"@coderwyd",
120
-
"rules": {
121
-
// your rules...
122
-
}
123
-
}
124
-
```
125
-
126
305
## Thanks
127
306
128
307
This project is based on [@antfu/eslint-config](https://github.com/antfu/eslint-config)
0 commit comments