Skip to content

Commit 983af33

Browse files
authored
docs: update ESLint package docs (#9833)
### Description Copies the READMEs of the packages up into docs. In the future, we should find a way to automate this (or stub the npm doc to point at our docs). ### Testing Instructions 👀
1 parent ebf2170 commit 983af33

File tree

3 files changed

+173
-3
lines changed

3 files changed

+173
-3
lines changed

docs/repo-docs/reference/eslint-config-turbo.mdx

+51-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,60 @@ Install `eslint-config-turbo` into the location where your ESLint configuration
3535
</Tab>
3636
</PackageManagerTabs>
3737

38-
## Usage
38+
## Usage (Flat Config `eslint.config.js`)
3939

40-
In your ESLint configuration file, add the package:
40+
```js title="./packages/eslint-config/base.js"
41+
import turboConfig from 'eslint-config-turbo/flat';
4142

42-
```json title="./packages/config-eslint/index.js"
43+
export default [
44+
...turboConfig,
45+
// Other configuration
46+
];
47+
```
48+
49+
You can also configure rules available in the configuration:
50+
51+
```js title="./packages/eslint-config/base.js"
52+
import turboConfig from 'eslint-config-turbo/flat';
53+
54+
export default [
55+
...turboConfig,
56+
// Other configuration
57+
{
58+
rules: {
59+
'turbo/no-undeclared-env-vars': [
60+
'error',
61+
{
62+
allowList: ['^ENV_[A-Z]+$'],
63+
},
64+
],
65+
},
66+
},
67+
];
68+
```
69+
70+
## Usage (Legacy `eslintrc*`)
71+
72+
Add `turbo` to the extends section of your eslint configuration file. You can omit the `eslint-config-` prefix:
73+
74+
```json title="./packages/eslint-config/base.json"
4375
{
4476
"extends": ["turbo"]
4577
}
4678
```
79+
80+
You can also configure rules available in the configuration:
81+
82+
```json title="./packages/eslint-config/base.json"
83+
{
84+
"plugins": ["turbo"],
85+
"rules": {
86+
"turbo/no-undeclared-env-vars": [
87+
"error",
88+
{
89+
"allowList": ["^ENV_[A-Z]+$"]
90+
}
91+
]
92+
}
93+
}
94+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
title: eslint-plugin-turbo
3+
description: Learn more about eslint-plugin-turbo.
4+
---
5+
6+
import { PackageManagerTabs, Tab } from '#/components/tabs';
7+
8+
[The `eslint-plugin-turbo` package](https://www.npmjs.com/package/eslint-plugin-turbo) helps you find environment variables that are used in your code that are not a part of Turborepo's hashing. Environment variables used in your source code that are not accounted for in `turbo.json` will be highlighted in your editor and errors will show as ESLint output.
9+
10+
## Installation
11+
12+
Install `eslint-config-turbo` into the location where your ESLint configuration is held:
13+
14+
<PackageManagerTabs>
15+
<Tab>
16+
17+
```bash title="Terminal"
18+
npm i --save-dev eslint-config-turbo -w @acme/eslint-config
19+
```
20+
21+
</Tab>
22+
<Tab>
23+
24+
```bash title="Terminal"
25+
yarn workspace @acme/eslint-config add eslint-config-turbo --dev
26+
```
27+
28+
</Tab>
29+
<Tab>
30+
31+
```bash title="Terminal"
32+
pnpm add eslint-config-turbo --filter=@repo/eslint-config
33+
```
34+
35+
</Tab>
36+
</PackageManagerTabs>
37+
38+
## Usage (Flat Config `eslint.config.js`)
39+
40+
ESLint v9 uses the Flat Config format seen below:
41+
42+
```js title="./packages/eslint-config/base.js"
43+
import turbo from 'eslint-plugin-turbo';
44+
45+
export default [turbo.configs['flat/recommended']];
46+
```
47+
48+
Otherwise, you may configure the rules you want to use under the rules section.
49+
50+
```js title="./packages/eslint-config/base.js"
51+
import turbo from 'eslint-plugin-turbo';
52+
53+
export default [
54+
{
55+
plugins: {
56+
turbo,
57+
},
58+
rules: {
59+
'turbo/no-undeclared-env-vars': 'error',
60+
},
61+
},
62+
];
63+
```
64+
65+
## Example (Flat Config `eslint.config.js`)
66+
67+
```js title="./packages/eslint-config/base.js"
68+
import turbo from 'eslint-plugin-turbo';
69+
70+
export default [
71+
{
72+
plugins: {
73+
turbo,
74+
},
75+
rules: {
76+
'turbo/no-undeclared-env-vars': [
77+
'error',
78+
{
79+
allowList: ['^ENV_[A-Z]+$'],
80+
},
81+
],
82+
},
83+
},
84+
];
85+
```
86+
87+
## Usage (Legacy `eslintrc*`)
88+
89+
Add `turbo` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
90+
91+
```json title="./packages/eslint-config/base.json"
92+
{
93+
"plugins": ["turbo"]
94+
}
95+
```
96+
97+
Then configure the rules you want to use under the rules section.
98+
99+
```json title="./packages/eslint-config/base.json"
100+
{
101+
"rules": {
102+
"turbo/no-undeclared-env-vars": "error"
103+
}
104+
}
105+
```
106+
107+
## Example (Legacy `eslintrc*`)
108+
109+
```json title="./packages/eslint-config/base.json"
110+
{
111+
"plugins": ["turbo"],
112+
"rules": {
113+
"turbo/no-undeclared-env-vars": [
114+
"error",
115+
{
116+
"allowList": ["^ENV_[A-Z]+$"]
117+
}
118+
]
119+
}
120+
}
121+
```

docs/repo-docs/reference/meta.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"---Packages---",
2626
"create-turbo",
2727
"eslint-config-turbo",
28+
"eslint-plugin-turbo",
2829
"turbo-ignore",
2930
"turbo-codemod",
3031
"turbo-gen"

0 commit comments

Comments
 (0)