Skip to content

Commit 7c77b1b

Browse files
authored
docs: rework structure and improve flat config docs (typescript-eslint#8507)
1 parent 677e7cc commit 7c77b1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+720
-277
lines changed

docs/Developers.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ title: Developers
66
These are the developer guides to working with the typescript-eslint tooling.
77
It's intended for use by third-parties who want to use our tools to build great things.
88

9-
> If you're reading this as a new developer: welcome to the community!
10-
> We're happy to have you! ❤️‍🔥
9+
:::info Welcome!
10+
If you're reading this as a new developer: welcome to the community!
11+
We're happy to have you! ❤️‍🔥
12+
:::

docs/Packages.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ As of v7 and ESLint 9, most users should be using the **[`typescript-eslint`](./
1212
It exports configurations for ESLint and brings along the corresponding versions of other packages as dependencies.
1313

1414
:::tip
15-
See [Getting Started](./Getting_Started.mdx) for guidance on setting up typescript-eslint on a project.
15+
See [Getting Started](./getting-started/Quickstart.mdx) for guidance on setting up typescript-eslint on a project.
1616
:::
1717

1818
## Other Packages

docs/linting/Legacy_ESLint_Setup.mdx renamed to docs/getting-started/Legacy_ESLint_Setup.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ id: legacy-eslint-setup
33
title: Legacy ESLint Setup
44
---
55

6+
import Tabs from '@theme/Tabs';
7+
import TabItem from '@theme/TabItem';
8+
69
## Quickstart
710

811
These steps will get you running ESLint with our recommended rules on your TypeScript code as quickly as possible.
912

1013
:::note
1114
This page is for [ESLint's legacy config format](https://eslint.org/docs/latest/use/configure/configuration-files).
12-
See [Getting Started](../Getting_Started.mdx) for [ESLint's new "flat" configuration format](https://eslint.org/docs/latest/use/configure/configuration-files-new).
15+
See [Getting Started](../getting-started/Quickstart.mdx) for [ESLint's new "flat" configuration format](https://eslint.org/docs/latest/use/configure/configuration-files-new).
1316
:::
1417

1518
### Step 1: Installation
@@ -83,7 +86,7 @@ ESLint will lint all TypeScript compatible files within the current folder, and
8386

8487
We provide a plethora of powerful rules that utilize the power of TypeScript's type information. [Visit _Typed Rules_ for a setup guide](./Typed_Linting.mdx).
8588

86-
If you're having problems getting this working, please have a look at our [Troubleshooting & FAQs](./Troubleshooting.mdx).
89+
If you're having problems getting this working, please have a look at our [Troubleshooting & FAQs](../troubleshooting/FAQ.mdx).
8790

8891
### Documentation Resources
8992

docs/Getting_Started.mdx renamed to docs/getting-started/Quickstart.mdx

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
---
2-
id: getting-started
2+
id: quickstart
33
title: Getting Started
4+
slug: /getting-started/
5+
pagination_next: getting-started/typed-linting
46
---
57

6-
## Quickstart
7-
8-
These steps will get you running ESLint with our recommended rules on your TypeScript code as quickly as possible.
8+
import Tabs from '@theme/Tabs';
9+
import TabItem from '@theme/TabItem';
910

1011
:::note
11-
This page is for [ESLint's new "flat" config format](https://eslint.org/docs/latest/use/configure/configuration-files-new).
12-
See [Legacy ESLint Setup](./linting/Legacy_ESLint_Setup.mdx) for [ESLint's legacy format](https://eslint.org/docs/latest/use/configure/configuration-files).
12+
This page is a quick-start guide for [ESLint's new "flat" config format](https://eslint.org/docs/latest/use/configure/configuration-files-new) to help you go from zero to linting as quick as possible.
13+
14+
- For the same guide but for [ESLint's legacy format](https://eslint.org/docs/latest/use/configure/configuration-files) — see [Legacy ESLint Setup](./Legacy_ESLint_Setup.mdx).
15+
- For quickstart information on linting with type information — see [Typed Linting](./Typed_Linting.mdx).
16+
1317
:::
1418

19+
## Quickstart
20+
21+
These steps will get you running ESLint with our recommended rules on your TypeScript code as quickly as possible.
22+
1523
### Step 1: Installation
1624

17-
First, install the required packages for [ESLint](https://eslint.org), [TypeScript](https://typescriptlang.org), and this plugin:
25+
First, install the required packages for [ESLint](https://eslint.org), [TypeScript](https://typescriptlang.org), and [our tooling](../packages/TypeScript_ESLint.mdx):
1826

1927
```bash npm2yarn
2028
npm install --save-dev eslint typescript typescript-eslint
2129
```
2230

2331
### Step 2: Configuration
2432

25-
Next, create a `eslint.config.js` config file in the root of your project, and populate it with the following:
33+
Next, create an `eslint.config.js` config file in the root of your project, and populate it with the following:
2634

2735
```js title="eslint.config.js"
2836
// @ts-check
@@ -36,6 +44,8 @@ export default tseslint.config(
3644
);
3745
```
3846

47+
This code will enable our [recommended configuration](../users/Shared_Configurations.mdx) for linting.
48+
3949
### Step 3: Running ESLint
4050

4151
Open a terminal to the root of your project and run the following command:
@@ -68,19 +78,19 @@ ESLint will lint all TypeScript compatible files within the current folder, and
6878

6979
## Details
7080

71-
The [`config`](./packages/TypeScript_ESLint.mdx) helper sets three parts of ESLint:
72-
73-
- [Parser](https://eslint.org/docs/latest/use/configure/parser): set to [`@typescript-eslint/parser`](./packages/Parser.mdx) so ESLint knows how to parse the new pieces of TypeScript syntax.
74-
- [Plugins](https://eslint.org/docs/latest/use/configure/plugins): set to [`@typescript-eslint/eslint-plugin`](./packages/ESLint_Plugin.mdx) to load [rules listed in our _Rules_ page](/rules).
75-
- [Rules](https://eslint.org/docs/latest/use/configure/rules): extends from our [recommended configuration](./linting/Configurations.mdx#recommended) to enable our most commonly useful lint rules.
81+
- `tseslint.config(...)` is an _optional_ helper function — [read more about it here](../packages/TypeScript_ESLint.mdx#config).
82+
- `'@eslint/js'` / `eslint.configs.recommended` turns on [eslint's recommended config](https://www.npmjs.com/package/@eslint/js).
83+
- `...tseslint.configs.recommended` turns on [our recommended config](../users/Shared_Configurations.mdx#recommended).
7684

77-
See [ESLint's Configuration Files docs](https://eslint.org/docs/user-guide/configuring/configuration-files) for more details on configuring ESLint.
85+
See [ESLint's Configuration Files docs](https://eslint.org/docs/user-guide/configuring/configuration-files-new) for more details on configuring ESLint.
7886

7987
## Next Steps
8088

81-
We provide a plethora of powerful rules that utilize the power of TypeScript's type information. [Visit the next page for a setup guide](./linting/Typed_Linting.mdx 'Visit the next page for a typed rules setup guide').
89+
We provide a plethora of powerful rules that utilize the power of TypeScript's type information.
90+
91+
[Visit the next page for a setup guide](./Typed_Linting.mdx 'Visit the next page for a typed rules setup guide').
8292

83-
If you're having problems getting this working, please have a look at our [Troubleshooting & FAQs](./linting/Troubleshooting.mdx).
93+
If you're having problems getting this working, please have a look at our [Troubleshooting & FAQs](../troubleshooting/FAQ.mdx).
8494

8595
### Documentation Resources
8696

docs/linting/Typed_Linting.mdx renamed to docs/getting-started/Typed_Linting.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
id: typed-linting
33
title: Linting with Type Information
4+
pagination_next: getting-started/typed-linting/monorepos
45
---
56

67
import Tabs from '@theme/Tabs';
@@ -38,7 +39,7 @@ For CommonJS modules and/or older versions of Node.js, [use `__dirname` or an al
3839

3940
In more detail:
4041

41-
- `tseslint.configs.recommendedTypeChecked` is another [recommended configuration](./Configurations.mdx) we provide. This one contains recommended rules that additionally require type information.
42+
- `tseslint.configs.recommendedTypeChecked` is another [recommended configuration](../users/Shared_Configurations.mdx) we provide. This one contains recommended rules that additionally require type information.
4243
- `parserOption.project` tells our parser how to find the TSConfig for each source file (`true` indicates to find the closest `tsconfig.json` for each source file)
4344
- If your project is a multi-package monorepo, see [our docs on configuring a monorepo](./typed-linting/Monorepos.mdx).
4445

@@ -69,7 +70,7 @@ module.exports = {
6970

7071
In more detail:
7172

72-
- `plugin:@typescript-eslint/recommended-type-checked` is another [recommended configuration](./Configurations.mdx) we provide. This one contains recommended rules that additionally require type information.
73+
- `plugin:@typescript-eslint/recommended-type-checked` is another [recommended configuration](../users/Shared_Configurations.mdx) we provide. This one contains recommended rules that additionally require type information.
7374
- `parserOptions.project` tells our parser how to find the TSConfig for each source file (`true` indicates to find the closest `tsconfig.json` for each source file)
7475
- If your project is a multi-package monorepo, see [our docs on configuring a monorepo](./typed-linting/Monorepos.mdx).
7576
- `parserOptions.tsconfigRootDir` tells our parser the absolute path of your project's root directory (see [Parser#tsconfigRootDir](../packages/Parser.mdx#tsconfigrootdir)).
@@ -79,7 +80,7 @@ In more detail:
7980

8081
:::caution
8182
Your ESLint config file may start receiving a parsing error about type information.
82-
See [our TSConfig inclusion FAQ](./Troubleshooting.mdx#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file).
83+
See [our TSConfig inclusion FAQ](../troubleshooting/FAQ.mdx#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file).
8384
:::
8485

8586
With that done, run the same lint command you ran before.
@@ -137,7 +138,7 @@ If your project is a multi-package monorepo, see [our docs on configuring a mono
137138

138139
### How can I disable type-aware linting for a subset of files?
139140

140-
You can combine ESLint's [overrides](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-based-on-glob-patterns) config in conjunction with our [`disable-type-checked`](./Configurations.mdx#disable-type-checked) config to turn off type-aware linting on specific subsets of files.
141+
You can combine ESLint's [overrides](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-based-on-glob-patterns) config in conjunction with our [`disable-type-checked`](../users/Shared_Configurations.mdx#disable-type-checked) config to turn off type-aware linting on specific subsets of files.
141142

142143
<Tabs groupId="eslint-config">
143144
<TabItem value="Flat Config">
@@ -211,8 +212,8 @@ This means that generally they usually only run a complete lint before a push, o
211212
### I get errors telling me "The file must be included in at least one of the projects provided"
212213

213214
You're using an outdated version of `@typescript-eslint/parser`.
214-
Update to the latest version to see a more informative version of this error message, explained in our [Troubleshooting and FAQs page](./Troubleshooting.mdx#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file).
215+
Update to the latest version to see a more informative version of this error message, explained in our [Troubleshooting and FAQs page](../troubleshooting/FAQ.mdx#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file).
215216

216217
## Troubleshooting
217218

218-
If you're having problems getting this working, please have a look at our [Troubleshooting and FAQs page](./Troubleshooting.mdx).
219+
If you're having problems getting this working, please have a look at our [Troubleshooting and FAQs page](../troubleshooting/FAQ.mdx).

docs/linting/typed-linting/Monorepos.mdx renamed to docs/getting-started/typed-linting/Monorepos.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
id: monorepos
33
title: Monorepo Configuration
4+
pagination_next: null
45
---
56

67
import Tabs from '@theme/Tabs';
@@ -158,4 +159,4 @@ As an interim workaround, consider one of the following:
158159

159160
## Troubleshooting
160161

161-
If you're having problems getting this working, please have a look at our [Troubleshooting FAQ](../Troubleshooting.mdx).
162+
If you're having problems getting this working, please have a look at our [Troubleshooting FAQ](../../troubleshooting/FAQ.mdx).

docs/maintenance/Issues.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ We avoid features that:
141141
- Are only relevant for a minority of users, as they aren't likely worth the maintenance burden
142142
- Aren't TypeScript-specific (e.g. should be in ESLint core instead)
143143
- Are only relevant with specific userland frameworks or libraries, such as Jest or React
144-
- Are for "formatting" functionality (we [strongly recommend users use a separate dedicated formatter](../linting/troubleshooting/Formatting.mdx))
144+
- Are for "formatting" functionality (we [strongly recommend users use a separate dedicated formatter](../troubleshooting/Formatting.mdx))
145145

146146
#### ✨ Rule Enhancements
147147

docs/maintenance/Team.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,5 @@ We're eternally grateful to every individual and organization able to help us ke
9494

9595
See [`.github/SPONSORSHIPS.md`](https://github.com/typescript-eslint/typescript-eslint/blob/main/.github/SPONSORSHIPS.md) for documentation on how and why to sponsor us.
9696

97-
You can find our biggest sponsors on [typescript-eslint.io > Financial Contributors](https://typescript-eslint.io/#financial-contributors).
97+
You can find our biggest sponsors on [typescript-eslint.io > Financial Contributors](/#financial-contributors).
9898
More can be found on [our Open Collective](https://opencollective.com/typescript-eslint).

docs/packages/ESLint_Plugin.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sidebar_label: eslint-plugin
88
> The TypeScript plugin for ESLint. ✨
99
1010
:::info
11-
See [Getting Started](../Getting_Started.mdx) for documentation on how to lint your TypeScript code with ESLint.
11+
See [Getting Started](../getting-started/Quickstart.mdx) for documentation on how to lint your TypeScript code with ESLint.
1212
:::
1313

1414
`@typescript-eslint/eslint-plugin` is an ESLint plugin used to load in custom rules and rule configurations lists from typescript-eslint.

docs/packages/ESLint_Plugin_TSLint.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ sidebar_label: eslint-plugin-tslint
88
> ESLint plugin that allows running TSLint rules within ESLint to help you migrate from TSLint to ESLint. ✨
99
1010
:::caution
11-
Per [What About TSLint?](../linting/troubleshooting/TSLint.mdx), we highly recommend migrating off TSLint.
12-
See [Getting Started](../Getting_Started.mdx) for documentation on how to lint your TypeScript code with ESLint.
11+
Per [What About TSLint?](../troubleshooting/TSLint.mdx), we highly recommend migrating off TSLint.
12+
See [Getting Started](../getting-started/Quickstart.mdx) for documentation on how to lint your TypeScript code with ESLint.
1313
:::
1414

1515
## Installation

docs/packages/Parser.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ interface ParserOptions {
6060
6161
Whether to use common heuristics to infer whether ESLint is being used as part of a single run (as opposed to `--fix` mode or in a persistent session such as an editor extension).
6262

63-
When typescript-eslint handles TypeScript Program management behind the scenes for [linting with type information](../linting/Typed_Linting.mdx), this distinction is important for performance.
63+
When typescript-eslint handles TypeScript Program management behind the scenes for [linting with type information](../getting-started/Typed_Linting.mdx), this distinction is important for performance.
6464
There is significant overhead to managing TypeScript "Watch" Programs needed for the long-running use-case.
6565
Being able to assume the single run case allows typescript-eslint to faster immutable Programs instead.
6666

@@ -126,7 +126,7 @@ Specifies the version of ECMAScript syntax you want to use. This is used by the
126126

127127
> Default `undefined`.
128128
129-
This option allow you to tell parser to act as if `emitDecoratorMetadata: true` is set in `tsconfig.json`, but without [type-aware linting](../linting/Typed_Linting.mdx). In other words, you don't have to specify `parserOptions.project` in this case, making the linting process faster.
129+
This option allow you to tell parser to act as if `emitDecoratorMetadata: true` is set in `tsconfig.json`, but without [type-aware linting](../getting-started/Typed_Linting.mdx). In other words, you don't have to specify `parserOptions.project` in this case, making the linting process faster.
130130

131131
### `extraFileExtensions`
132132

0 commit comments

Comments
 (0)