Skip to content

Commit b30d030

Browse files
committed
feat: add docs for oxlint.config.ts
1 parent f8269f3 commit b30d030

File tree

4 files changed

+53
-14
lines changed

4 files changed

+53
-14
lines changed

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

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
---
22
title: Configuration
3-
description: Configure Oxlint using a .oxlintrc.json file.
3+
description: Configure Oxlint using .oxlintrc.json or oxlint.config.ts.
44
---
55

66
# Configuration
77

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.
99

1010
This page focuses on project configuration: rules, categories, plugins, overrides, and shared settings.
1111

1212
## Create a config file
1313

14-
To generate a starter config in the current directory:
14+
To generate a starter config in the current directory (JSON):
1515

1616
```sh
1717
oxlint --init
1818
```
1919

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):
2121

2222
```sh
2323
oxlint -c ./oxlintrc.json
@@ -27,8 +27,9 @@ oxlint --config ./oxlintrc.json
2727

2828
Notes:
2929

30-
- Only `.json` config files are supported, but oxlint configuration files support comments (like jsonc).
30+
- `.oxlintrc.json` supports comments (like jsonc).
3131
- 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.
3233

3334
A minimal configuration looks like this:
3435

@@ -44,9 +45,33 @@ A minimal configuration looks like this:
4445
}
4546
```
4647

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+
export default defineConfig({
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+
4772
## Configuration file format
4873

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:
5075

5176
- `rules`: Enable or disable rules, set severity, and configure rule options.
5277
- `categories`: Enable groups of rules with similar intent.
@@ -259,6 +284,16 @@ Paths in `extends` are resolved relative to the configuration file that declares
259284
}
260285
```
261286

287+
```ts [oxlint.config.ts]
288+
import baseConfig from "./configs/base.ts";
289+
import frontendConfig from "./configs/frontend.ts";
290+
import { defineConfig } from "oxlint";
291+
292+
export default defineConfig({
293+
extends: [baseConfig, frontendConfig],
294+
});
295+
```
296+
262297
## Configure environments and globals
263298

264299
Use `env` to enable predefined globals for common environments such as browser or node.

src/docs/guide/usage/linter/ignore-files.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: Control which files Oxlint lints.
88
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.
99

1010
> [!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.
1212
1313
## Default ignores
1414

@@ -22,7 +22,7 @@ Hidden files are not automatically ignored.
2222

2323
## `ignorePatterns`
2424

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.
2626

2727
Patterns are resolved relative to the configuration file.
2828

@@ -39,7 +39,7 @@ In monorepos, nested configs can ignore package specific output without affectin
3939

4040
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.
4141

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.
4343

4444
## Ignore from the command line
4545

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
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.
44
---
55

66
# Nested configuration files
77

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.
99

1010
This is useful in monorepos where packages need their own settings, while still keeping a shared baseline.
1111

1212
If you only need to exclude files or folders, use [Ignores](./ignore-files) instead.
1313

1414
## How it works
1515

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.
1717

1818
Given the following structure:
1919

@@ -23,7 +23,7 @@ my-project/
2323
├── src/
2424
│ ├── index.js
2525
├── package1/
26-
│ ├── .oxlintrc.json
26+
│ ├── oxlint.config.ts
2727
│ └── index.js
2828
└── package2/
2929
├── .oxlintrc.json
@@ -33,7 +33,7 @@ my-project/
3333
Configuration resolution works as follows:
3434

3535
- `src/index.js` uses `my-project/.oxlintrc.json`
36-
- `package1/index.js` uses `my-project/package1/.oxlintrc.json`
36+
- `package1/index.js` uses `my-project/package1/oxlint.config.ts`
3737
- `package2/index.js` uses `my-project/package2/.oxlintrc.json`
3838

3939
## What to expect

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ Initialize the `.oxlintrc.json` config with default values:
8484
oxlint --init
8585
```
8686

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.
90+
8791
Then run Oxlint:
8892

8993
```sh

0 commit comments

Comments
 (0)