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
Copy file name to clipboardExpand all lines: src/docs/guide/usage/linter/config.md
+41-6Lines changed: 41 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,23 @@
1
1
---
2
2
title: Configuration
3
-
description: Configure Oxlint using a .oxlintrc.json file.
3
+
description: Configure Oxlint using .oxlintrc.json or oxlint.config.ts.
4
4
---
5
5
6
6
# Configuration
7
7
8
-
Oxlint works out of the box, but most teams commit a configuration file to keep linting consistent across local runs, editors, and CI.
8
+
Oxlint works out of the box, but most teams commit a configuration file (`.oxlintrc.json` or `oxlint.config.ts`) to keep linting consistent across local runs, editors, and CI.
9
9
10
10
This page focuses on project configuration: rules, categories, plugins, overrides, and shared settings.
11
11
12
12
## Create a config file
13
13
14
-
To generate a starter config in the current directory:
14
+
To generate a starter config in the current directory (JSON):
15
15
16
16
```sh
17
17
oxlint --init
18
18
```
19
19
20
-
Oxlint automatically looks for a `.oxlintrc.json` in the current working directory. You can also pass a config explicitly (note that this will disable nested config lookup):
20
+
Oxlint automatically looks for a `.oxlintrc.json`or `oxlint.config.ts`in the current working directory. You can also pass a config explicitly (note that this will disable nested config lookup):
21
21
22
22
```sh
23
23
oxlint -c ./oxlintrc.json
@@ -27,8 +27,9 @@ oxlint --config ./oxlintrc.json
27
27
28
28
Notes:
29
29
30
-
-Only `.json`config files are supported, but oxlint configuration files support comments (like jsonc).
30
+
-`.oxlintrc.json`supports comments (like jsonc).
31
31
- The configuration format aims to be compatible with ESLint v8's format (`eslintrc.json`).
32
+
- You can use either `.oxlintrc.json` or `oxlint.config.ts` in a directory, but not both.
32
33
33
34
A minimal configuration looks like this:
34
35
@@ -44,9 +45,33 @@ A minimal configuration looks like this:
44
45
}
45
46
```
46
47
48
+
### TypeScript config file (`oxlint.config.ts`)
49
+
50
+
Oxlint also supports a TypeScript configuration file named `oxlint.config.ts`.
51
+
52
+
```ts [oxlint.config.ts]
53
+
import { defineConfig } from"oxlint";
54
+
55
+
exportdefaultdefineConfig({
56
+
categories: {
57
+
correctness: "warn",
58
+
},
59
+
rules: {
60
+
"eslint/no-unused-vars": "error",
61
+
},
62
+
});
63
+
```
64
+
65
+
Notes:
66
+
67
+
- The file must be named `oxlint.config.ts` (including when passed via `--config`).
68
+
- The default export must be an object and should be wrapped with `defineConfig` for typing.
69
+
- TypeScript configs require the Node-based `oxlint` package (JS runtime). If you're using a standalone binary, use `.oxlintrc.json` instead.
70
+
- TypeScript configs require a Node runtime that can execute TypeScript.
71
+
47
72
## Configuration file format
48
73
49
-
A configuration file is a JSON object. The most common top-level fields are:
74
+
A configuration file is either a JSON object (`.oxlintrc.json`) or a TypeScript module that default-exports a config object (`oxlint.config.ts`). The most common top-level fields are:
50
75
51
76
-`rules`: Enable or disable rules, set severity, and configure rule options.
52
77
-`categories`: Enable groups of rules with similar intent.
@@ -259,6 +284,16 @@ Paths in `extends` are resolved relative to the configuration file that declares
259
284
}
260
285
```
261
286
287
+
```ts [oxlint.config.ts]
288
+
importbaseConfigfrom"./configs/base.ts";
289
+
importfrontendConfigfrom"./configs/frontend.ts";
290
+
import { defineConfig } from"oxlint";
291
+
292
+
exportdefaultdefineConfig({
293
+
extends: [baseConfig, frontendConfig],
294
+
});
295
+
```
296
+
262
297
## Configure environments and globals
263
298
264
299
Use `env` to enable predefined globals for common environments such as browser or node.
Copy file name to clipboardExpand all lines: src/docs/guide/usage/linter/ignore-files.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ description: Control which files Oxlint lints.
8
8
Large repositories contain files that should not be linted, such as build output, vendored code, snapshots, or generated artifacts. Oxlint provides a predictable ignore model that works well in monorepos and CI.
9
9
10
10
> [!TIP]
11
-
> It is strongly recommended to use `"ignorePatterns"` in `.oxlintrc.json` for ignoring files rather than a separate ignore file. This ensures that every developer will have the same ignores across all tools and commands running oxlint, especially IDE/editor integrations. It also keeps your configuration centralized to one file.
11
+
> It is strongly recommended to use `"ignorePatterns"` in your Oxlint config file (`.oxlintrc.json`or `oxlint.config.ts`) for ignoring files rather than a separate ignore file. This ensures that every developer will have the same ignores across all tools and commands running Oxlint, especially IDE/editor integrations. It also keeps your configuration centralized to one file.
12
12
13
13
## Default ignores
14
14
@@ -22,7 +22,7 @@ Hidden files are not automatically ignored.
22
22
23
23
## `ignorePatterns`
24
24
25
-
The recommended approach is to define ignores in `.oxlintrc.json` using `ignorePatterns`. This keeps ignores close to the configuration they belong to and works naturally with nested configs.
25
+
The recommended approach is to define ignores in your config file using `ignorePatterns`. This keeps ignores close to the configuration they belong to and works naturally with nested configs.
26
26
27
27
Patterns are resolved relative to the configuration file.
28
28
@@ -39,7 +39,7 @@ In monorepos, nested configs can ignore package specific output without affectin
39
39
40
40
Oxlint also supports `.eslintignore` for compatibility with existing ESLint setups. Existing `.eslintignore` files can remain in place during migration. The syntax is compatible with `.gitignore`, including comments and negation patterns.
41
41
42
-
New projects should prefer `"ignorePatterns"` in `.oxlintrc.json`, and we strongly recommend moving over to `"ignorePatterns"` soon after migrating, if not during migration.
42
+
New projects should prefer `"ignorePatterns"` in their config file, and we strongly recommend moving over to `"ignorePatterns"` soon after migrating, if not during migration.
Copy file name to clipboardExpand all lines: src/docs/guide/usage/linter/nested-config.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,19 @@
1
1
---
2
2
title: Nested configuration files
3
-
description: Use multiple .oxlintrc.json files to apply different Oxlint settings to different parts of a repository.
3
+
description: Use multiple configuration files to apply different Oxlint settings to different parts of a repository.
4
4
---
5
5
6
6
# Nested configuration files
7
7
8
-
Oxlint can use multiple configuration files in the same repository. It automatically detects configuration files named `.oxlintrc.json` and applies them based on where files live in the directory tree.
8
+
Oxlint can use multiple configuration files in the same repository. It automatically detects configuration files named `.oxlintrc.json`or `oxlint.config.ts`and applies them based on where files live in the directory tree.
9
9
10
10
This is useful in monorepos where packages need their own settings, while still keeping a shared baseline.
11
11
12
12
If you only need to exclude files or folders, use [Ignores](./ignore-files) instead.
13
13
14
14
## How it works
15
15
16
-
For each file being linted, Oxlint uses the nearest `.oxlintrc.json` relative to that file.
16
+
For each file being linted, Oxlint uses the nearest config file (`.oxlintrc.json` or `oxlint.config.ts`) relative to that file.
Copy file name to clipboardExpand all lines: src/docs/guide/usage/linter/quickstart.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,10 @@ Initialize the `.oxlintrc.json` config with default values:
84
84
oxlint --init
85
85
```
86
86
87
+
Then customize `.oxlintrc.json` as needed. See [Configuration](/docs/guide/usage/linter/config).
88
+
89
+
Alternatively, Oxlint supports a TypeScript config file named `oxlint.config.ts`. See [Configuration](/docs/guide/usage/linter/config#typescript-config) for details.
0 commit comments