Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/robinloeffel/esbuild-plugin-eslint

Lint your esbuild bundles with eslint. 🧐
https://github.com/robinloeffel/esbuild-plugin-eslint

esbuild esbuild-plugin eslint

Last synced: 7 days ago
JSON representation

Lint your esbuild bundles with eslint. 🧐

Awesome Lists containing this project

README

        

# `esbuild-plugin-eslint`

[![latest version on npm](https://img.shields.io/npm/v/esbuild-plugin-eslint)](https://www.npmjs.com/package/esbuild-plugin-eslint)
[![npm downloads a week](https://img.shields.io/npm/dw/esbuild-plugin-eslint)](https://www.npmjs.com/package/esbuild-plugin-eslint)
[![required node version](https://img.shields.io/node/v/esbuild-plugin-eslint)](https://github.com/nodejs/Release)
[![esbuild peer dep](https://img.shields.io/npm/dependency-version/esbuild-plugin-eslint/peer/esbuild?label=esbuild%20peer%20dep)](https://github.com/evanw/esbuild)
[![eslint peer dep](https://img.shields.io/npm/dependency-version/esbuild-plugin-eslint/peer/eslint?label=eslint%20peer%20dep)](https://github.com/eslint/eslint)
[![package license](https://img.shields.io/npm/l/esbuild-plugin-eslint)](license)

> Lint your [`esbuild`](https://github.com/evanw/esbuild) bundles with [`eslint`](https://github.com/eslint/eslint). 🧐

Nicely integrates the most recent version of [`eslint`](https://github.com/eslint/eslint) into an [`esbuild`](https://github.com/evanw/esbuild) plugin.

## How

```bash
npm i esbuild-plugin-eslint eslint --save-dev
```

```js
import { build } from 'esbuild';
import eslint from 'esbuild-plugin-eslint';

await build({
// ...
plugins: [
eslint({ /* config */ })
]
});
```

```bash
node esbuild.config.js
```

## Config

This plugin respects your [ESLint configuration](https://eslint.org/docs/user-guide/configuring) as per default. It also takes a configuration object intended for the [ESLint constructor](https://eslint.org/docs/latest/developer-guide/nodejs-api#parameters) with the addition of a `filter`, `throwOnError`, and `throwOnWarning` property. The most important options are:

### `filter`

Type: `RegExp`

Default: `/\.(?:jsx?|tsx?|mts|cts|mjs|cjs|vue|svelte)$/`

Used by: [`esbuild`](https://github.com/evanw/esbuild)

Reference: [esbuild.github.io](https://esbuild.github.io/plugins/#on-load-options)

Tells esbuild what files to look at. Only files matching this pattern will be handled by the plugin.

### `throwOnError`

Type: `boolean`

Default: `false`

Used by: [The plugin itself](https://github.com/robinloeffel/esbuild-plugin-eslint)

Instructs the plugin to forward errors found by ESLint to esbuild and throw an error.

### `throwOnWarning`

Type: `boolean`

Default: `false`

Used by: [The plugin itself](https://github.com/robinloeffel/esbuild-plugin-eslint)

Instructs the plugin to forward warnings found by ESLint to esbuild and throw an error.

### `fix`

Type: `boolean`

Default: `false`

Used by: [`eslint`](https://github.com/eslint/eslint)

Reference: [eslint.org (`options.fix`)](https://eslint.org/docs/latest/developer-guide/nodejs-api#parameters)

Controls whether to enable or disable the autofix feature of ESLint.

### `useEslintrc`

Type: `boolean`

Default: `true`

Used by: [`eslint`](https://github.com/eslint/eslint)

Reference: [eslint.org (`options.useEslintrc`)](https://eslint.org/docs/latest/developer-guide/nodejs-api#parameters)

If set to `false`, ESLint will not respect any configuration files it finds.

## License

MIT