Commit fc74849
committed
feat(linter): inherit
- part of #9307
This gives the `extends` keyword some functionality: specifically to allow inheriting rules from other configuration files. Rules that are in the extended configuration will be used as the base, and then files in the config doing the extending will override the extended rules.
So, you can, for example, specify a base configuration that defines rules that you generally want to be enabled. Then, in each nested configuration file, you could disable rules depending on the directory:
```text
.oxlintrc.json // { "rules: { "no-useless-escape": "error" } }
package1/
.oxlintrc.json // { "extends": ["../.oxlintrc.json"], "rules": { "no-useless-escape": "off" } }
package2/
src // uses ../.oxlintrc.json with `no-useless-escape` enabled
```
As a side effect of this, building a config from a `.oxlintrc.json` file can result in config errors, even if all of the syntax and rules are configured correctly, because an extended configuration file might be incorrect or unparseable. For now, we simply raise an error if this occurs and stop execution, but in the future we could make this more graceful if we wanted and just ignore that file.
We will also need to revisit performance here, as I think a global cache config might be necessary so that we never load a file more than once and parse it more than once.rules via the extended config files (#9308)1 parent 3fce826 commit fc74849
File tree
14 files changed
+324
-15
lines changed- apps/oxlint
- fixtures/extends_config
- rules_multiple
- src
- snapshots
- crates
- oxc_language_server/src
- oxc_linter/src
- config
14 files changed
+324
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
203 | 223 | | |
204 | | - | |
205 | | - | |
| 224 | + | |
206 | 225 | | |
207 | 226 | | |
208 | 227 | | |
| |||
230 | 249 | | |
231 | 250 | | |
232 | 251 | | |
233 | | - | |
234 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
235 | 268 | | |
236 | 269 | | |
237 | 270 | | |
| |||
982 | 1015 | | |
983 | 1016 | | |
984 | 1017 | | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
985 | 1025 | | |
0 commit comments