98 lines
4.7 KiB
Markdown
98 lines
4.7 KiB
Markdown
# @eslint/config-helpers
|
|
|
|
## Description
|
|
|
|
Helper utilities for creating ESLint configuration.
|
|
|
|
## Installation
|
|
|
|
For Node.js and compatible runtimes:
|
|
|
|
```shell
|
|
npm install @eslint/config-helpers
|
|
# or
|
|
yarn add @eslint/config-helpers
|
|
# or
|
|
pnpm install @eslint/config-helpers
|
|
# or
|
|
bun install @eslint/config-helpers
|
|
```
|
|
|
|
For Deno:
|
|
|
|
```shell
|
|
deno add @eslint/config-helpers
|
|
```
|
|
|
|
## Usage
|
|
|
|
### `defineConfig()`
|
|
|
|
The `defineConfig()` function allows you to specify an ESLint configuration with full type checking and additional capabilities, such as `extends`. Here's an example:
|
|
|
|
```js
|
|
// eslint.config.js
|
|
import { defineConfig } from "@eslint/config-helpers";
|
|
import js from "@eslint/js";
|
|
|
|
export default defineConfig([
|
|
{
|
|
files: ["src/**/*.js"],
|
|
plugins: { js },
|
|
extends: ["js/recommended"],
|
|
rules: {
|
|
semi: "error",
|
|
"prefer-const": "error",
|
|
},
|
|
},
|
|
{
|
|
files: ["test/**/*.js"],
|
|
rules: {
|
|
"no-console": "off",
|
|
},
|
|
},
|
|
]);
|
|
```
|
|
|
|
### `globalIgnores()`
|
|
|
|
The `globalIgnores()` function allows you to specify patterns for files and directories that should be globally ignored by ESLint. This is useful for excluding files that you don't want to lint, such as build directories or third-party libraries. Here's an example:
|
|
|
|
```js
|
|
// eslint.config.js
|
|
import { defineConfig, globalIgnores } from "@eslint/config-helpers";
|
|
|
|
export default defineConfig([
|
|
{
|
|
files: ["src/**/*.js"],
|
|
rules: {
|
|
semi: "error",
|
|
"prefer-const": "error",
|
|
},
|
|
},
|
|
globalIgnores(["node_modules/", "dist/", "coverage/"]),
|
|
]);
|
|
```
|
|
|
|
## License
|
|
|
|
Apache 2.0
|
|
|
|
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
|
<!--sponsorsstart-->
|
|
|
|
## Sponsors
|
|
|
|
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
|
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
|
|
|
<h3>Platinum Sponsors</h3>
|
|
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
|
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a></p><h3>Silver Sponsors</h3>
|
|
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
|
|
<p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nolebase.ayaka.io"><img src="https://avatars.githubusercontent.com/u/11081491" alt="Neko" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
|
|
<h3>Technology Sponsors</h3>
|
|
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
|
|
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
|
|
<!--sponsorsend-->
|