Skip to content

docs: mention ESLint's defineConfig() #11335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions docs/getting-started/Quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,29 @@ export default tseslint.config(

This code will enable our [recommended configuration](../users/Shared_Configurations.mdx) for linting.

#### Details

- `tseslint.config(...)` is an **_optional_** helper function — see [`typescript-eslint`'s `config(...)`](../packages/TypeScript_ESLint.mdx#config).
- `'@eslint/js'` / `eslint.configs.recommended` turns on [eslint's recommended config](https://www.npmjs.com/package/@eslint/js).
- `tseslint.configs.recommended` turns on [our recommended config](../users/Shared_Configurations.mdx#recommended).

<details>
<summary>Aside on file extensions</summary>
<summary>Aside on ESLint's `defineConfig()`</summary>

The `.mjs` extension makes the file use the [ES modules (ESM)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) format. Node interprets `.js` files in the [CommonJS (CJS)](https://nodejs.org/api/modules.html) format by default, but if you have `"type": "module"` in your `package.json`, you can also use `eslint.config.js`.
ESLint also provides a `defineConfig()` helper similar to `tseslint.config()`.
However, there is a types incompatibility issue that causes type errors to incorrectly be reported when mixing typescript-eslint's configs and `defineConfig()`.
For now we recommend using `tseslint.config()` for use with typescript-eslint's configs.

See [typescript-eslint#10899](https://github.com/typescript-eslint/typescript-eslint/issues/10899) for more details.

</details>

#### Details
<details>
<summary>Aside on file extensions</summary>

- `tseslint.config(...)` is an **_optional_** helper function — see [`typescript-eslint`'s `config(...)`](../packages/TypeScript_ESLint.mdx#config).
- `'@eslint/js'` / `eslint.configs.recommended` turns on [eslint's recommended config](https://www.npmjs.com/package/@eslint/js).
- `tseslint.configs.recommended` turns on [our recommended config](../users/Shared_Configurations.mdx#recommended).
The `.mjs` extension makes the file use the [ES modules (ESM)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) format. Node interprets `.js` files in the [CommonJS (CJS)](https://nodejs.org/api/modules.html) format by default, but if you have `"type": "module"` in your `package.json`, you can also use `eslint.config.js`.

</details>

### Step 3: Running ESLint

Expand Down
13 changes: 11 additions & 2 deletions docs/packages/TypeScript_ESLint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npm i typescript-eslint

## Usage

We recommend getting started by using `tseslint.config` helper function in your ESLint config:
We recommend getting started by using the `tseslint.config()` helper function in your ESLint config:

```js title="eslint.config.mjs"
// @ts-check
Expand All @@ -47,6 +47,15 @@ export default tseslint.config(

This config file exports a flat config that enables both the [core ESLint recommended config](https://www.npmjs.com/package/@eslint/js) and [our recommended config](../users/Shared_Configurations.mdx#recommended).

:::note
ESLint also provides a `defineConfig()` helper similar to `tseslint.config()`.
However, there is a types incompatibility issue that causes type errors to incorrectly be reported when mixing typescript-eslint's configs and `defineConfig()`.
For now we recommend using `tseslint.config()` for use with typescript-eslint configs.

See [typescript-eslint#10899](https://github.com/typescript-eslint/typescript-eslint/issues/10899) for more details.

:::

### `config(...)`

`tseslint.config(...)` takes in any number of ESLint config objects, each of which may additionally include an `extends` array of configs to extend.
Expand Down Expand Up @@ -105,7 +114,7 @@ Otherwise it _will not_ impact your ability to use our tooling.

#### Flat config `extends`

The `tseslint.config` utility function also adds handling for the `extends` property on flat config objects.
The `tseslint.config()` utility function also adds handling for the `extends` property on flat config objects.
This allows you to more easily extend shared configs for specific file patterns whilst also overriding rules/options provided by those configs:

```js
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy