Skip to content

Commit a9af992

Browse files
committed
docs: split out linter/nested-config.md
1 parent cb8c3ab commit a9af992

File tree

4 files changed

+69
-59
lines changed

4 files changed

+69
-59
lines changed

.vitepress/config/en.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export const enConfig = defineLocaleConfig("root", {
4949
link: "/docs/guide/usage/linter/config",
5050
},
5151
{
52-
text: "Command-line Interface",
53-
link: "/docs/guide/usage/linter/cli",
52+
text: "Nested Configs",
53+
link: "/docs/guide/usage/linter/nested-config",
5454
},
5555
{
5656
text: "Rules",
@@ -64,6 +64,10 @@ export const enConfig = defineLocaleConfig("root", {
6464
text: "Automatic Fixes",
6565
link: "/docs/guide/usage/linter/automatic-fixes",
6666
},
67+
{
68+
text: "CLI reference",
69+
link: "/docs/guide/usage/linter/cli",
70+
},
6771
{
6872
text: "Configuration file reference",
6973
link: "/docs/guide/usage/linter/config-file-reference",

src/docs/guide/usage/linter/config.md

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -249,60 +249,3 @@ You can ignore certain patterns of files by configuring the `ignorePatterns` pro
249249
"ignorePatterns": ["vendor", "test/snapshots/**", "test.js"],
250250
}
251251
```
252-
253-
## Nesting configuration files
254-
255-
> [!WARNING]
256-
> This is currently an experimental feature and may have bugs. To enable it, pass the `--experimental-nested-config` option in the command-line.
257-
258-
It is possible to have multiple configuration files within the same project, and Oxlint will automatically detect the presence of these files and use them in addition to the top-level configuration file. The files must be named `.oxlintrc.json` for this to work.
259-
260-
For example, consider the following project structure:
261-
262-
```
263-
my-project/
264-
├── .oxlintrc.json
265-
├── src/
266-
│ ├── index.js
267-
├── package1/
268-
│ ├── .oxlintrc.json
269-
│ └── index.js
270-
└── package2/
271-
├── .oxlintrc.json
272-
└── index.js
273-
```
274-
275-
Oxlint will always use the nearest configuration file to the file currently being processed and use that for linting. In the example hierarchy above, that means:
276-
277-
- `src/index.js` will be linted using `my-project/.oxlintrc.json`
278-
- `package1/index.js` will be linted using `my-project/package1/.oxlintrc.json`
279-
- `package2/index.js` will be linted using `my-project/package2/.oxlintrc.json`
280-
281-
Configuration files are not automatically merged, and the configuration in a child configuration file will not affect the parent configuration. However, options passed in the command-line will override any configuration file, regardless of whether it is in the parent or child directory. In addition, using the `--config` option to specify a singular file for configuration will disable the use of nested configuration files.
282-
283-
## Extending configuration files
284-
285-
Files can use configuration from other files by using the `extends` property in a configuration file. The value of the `extends` property is an array of file paths to other configuration files, which are resolved relative to the location of the configuration file. Files may be called anything and do not need to be called `.oxlintrc.json`, but still need to be valid JSON configuration files.
286-
287-
```jsonc
288-
// oxlint-typescript.json
289-
{
290-
"plugins": ["typescript"],
291-
"rules": {
292-
"typescript/no-explicit-any": "error"
293-
}
294-
}
295-
// .oxlintrc.json
296-
{
297-
"extends": ["oxlint-typescript.json"],
298-
"rules": {
299-
"no-unused-vars": "warn"
300-
}
301-
}
302-
```
303-
304-
Not all properties can be extended, but the following properties are supported:
305-
306-
- `rules`
307-
- `plugins`
308-
- `overrides`
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
outline: [2, 3]
3+
editLink: false
4+
---
5+
6+
# Nested Configs
7+
8+
## Nesting configuration files
9+
10+
> [!WARNING]
11+
> This is currently an experimental feature and may have bugs. To enable it, pass the `--experimental-nested-config` option in the command-line.
12+
13+
It is possible to have multiple configuration files within the same project, and Oxlint will automatically detect the presence of these files and use them in addition to the top-level configuration file. The files must be named `.oxlintrc.json` for this to work.
14+
15+
For example, consider the following project structure:
16+
17+
```
18+
my-project/
19+
├── .oxlintrc.json
20+
├── src/
21+
│ ├── index.js
22+
├── package1/
23+
│ ├── .oxlintrc.json
24+
│ └── index.js
25+
└── package2/
26+
├── .oxlintrc.json
27+
└── index.js
28+
```
29+
30+
Oxlint will always use the nearest configuration file to the file currently being processed and use that for linting. In the example hierarchy above, that means:
31+
32+
- `src/index.js` will be linted using `my-project/.oxlintrc.json`
33+
- `package1/index.js` will be linted using `my-project/package1/.oxlintrc.json`
34+
- `package2/index.js` will be linted using `my-project/package2/.oxlintrc.json`
35+
36+
Configuration files are not automatically merged, and the configuration in a child configuration file will not affect the parent configuration. However, options passed in the command-line will override any configuration file, regardless of whether it is in the parent or child directory. In addition, using the `--config` option to specify a singular file for configuration will disable the use of nested configuration files.
37+
38+
## Extending configuration files
39+
40+
Files can use configuration from other files by using the `extends` property in a configuration file. The value of the `extends` property is an array of file paths to other configuration files, which are resolved relative to the location of the configuration file. Files may be called anything and do not need to be called `.oxlintrc.json`, but still need to be valid JSON configuration files.
41+
42+
```jsonc
43+
// oxlint-typescript.json
44+
{
45+
"plugins": ["typescript"],
46+
"rules": {
47+
"typescript/no-explicit-any": "error"
48+
}
49+
}
50+
// .oxlintrc.json
51+
{
52+
"extends": ["oxlint-typescript.json"],
53+
"rules": {
54+
"no-unused-vars": "warn"
55+
}
56+
}
57+
```
58+
59+
Not all properties can be extended, but the following properties are supported:
60+
61+
- `rules`
62+
- `plugins`
63+
- `overrides`

src/docs/guide/usage/linter/rules/nested-config.md

Whitespace-only changes.

0 commit comments

Comments
 (0)