这是indexloc提供的服务,不要输入任何密码
Skip to content

docs: update ESLint package docs #9833

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

Merged
merged 1 commit into from
Jan 29, 2025
Merged
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
54 changes: 51 additions & 3 deletions docs/repo-docs/reference/eslint-config-turbo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,60 @@ Install `eslint-config-turbo` into the location where your ESLint configuration
</Tab>
</PackageManagerTabs>

## Usage
## Usage (Flat Config `eslint.config.js`)

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

```json title="./packages/config-eslint/index.js"
export default [
...turboConfig,
// Other configuration
];
```

You can also configure rules available in the configuration:

```js title="./packages/eslint-config/base.js"
import turboConfig from 'eslint-config-turbo/flat';

export default [
...turboConfig,
// Other configuration
{
rules: {
'turbo/no-undeclared-env-vars': [
'error',
{
allowList: ['^ENV_[A-Z]+$'],
},
],
},
},
];
```

## Usage (Legacy `eslintrc*`)

Add `turbo` to the extends section of your eslint configuration file. You can omit the `eslint-config-` prefix:

```json title="./packages/eslint-config/base.json"
{
"extends": ["turbo"]
}
```

You can also configure rules available in the configuration:

```json title="./packages/eslint-config/base.json"
{
"plugins": ["turbo"],
"rules": {
"turbo/no-undeclared-env-vars": [
"error",
{
"allowList": ["^ENV_[A-Z]+$"]
}
]
}
}
```
121 changes: 121 additions & 0 deletions docs/repo-docs/reference/eslint-plugin-turbo.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
title: eslint-plugin-turbo
description: Learn more about eslint-plugin-turbo.
---

import { PackageManagerTabs, Tab } from '#/components/tabs';

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

## Installation

Install `eslint-config-turbo` into the location where your ESLint configuration is held:

<PackageManagerTabs>
<Tab>

```bash title="Terminal"
npm i --save-dev eslint-config-turbo -w @acme/eslint-config
```

</Tab>
<Tab>

```bash title="Terminal"
yarn workspace @acme/eslint-config add eslint-config-turbo --dev
```

</Tab>
<Tab>

```bash title="Terminal"
pnpm add eslint-config-turbo --filter=@repo/eslint-config
```

</Tab>
</PackageManagerTabs>

## Usage (Flat Config `eslint.config.js`)

ESLint v9 uses the Flat Config format seen below:

```js title="./packages/eslint-config/base.js"
import turbo from 'eslint-plugin-turbo';

export default [turbo.configs['flat/recommended']];
```

Otherwise, you may configure the rules you want to use under the rules section.

```js title="./packages/eslint-config/base.js"
import turbo from 'eslint-plugin-turbo';

export default [
{
plugins: {
turbo,
},
rules: {
'turbo/no-undeclared-env-vars': 'error',
},
},
];
```

## Example (Flat Config `eslint.config.js`)

```js title="./packages/eslint-config/base.js"
import turbo from 'eslint-plugin-turbo';

export default [
{
plugins: {
turbo,
},
rules: {
'turbo/no-undeclared-env-vars': [
'error',
{
allowList: ['^ENV_[A-Z]+$'],
},
],
},
},
];
```

## Usage (Legacy `eslintrc*`)

Add `turbo` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:

```json title="./packages/eslint-config/base.json"
{
"plugins": ["turbo"]
}
```

Then configure the rules you want to use under the rules section.

```json title="./packages/eslint-config/base.json"
{
"rules": {
"turbo/no-undeclared-env-vars": "error"
}
}
```

## Example (Legacy `eslintrc*`)

```json title="./packages/eslint-config/base.json"
{
"plugins": ["turbo"],
"rules": {
"turbo/no-undeclared-env-vars": [
"error",
{
"allowList": ["^ENV_[A-Z]+$"]
}
]
}
}
```
1 change: 1 addition & 0 deletions docs/repo-docs/reference/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"---Packages---",
"create-turbo",
"eslint-config-turbo",
"eslint-plugin-turbo",
"turbo-ignore",
"turbo-codemod",
"turbo-gen"
Expand Down
Loading