# eslint-define-config

> Provide a defineConfig function for .eslintrc.js files

Latest version **2.1.0** (published 2023-12-27) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install eslint-define-config
pnpm add eslint-define-config
yarn add eslint-define-config
bun add eslint-define-config
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2023-12-27 |
| First published | 2021-03-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 0 |
| Unpacked size | 307.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 355 |
| Author | Christopher Quadflieg |
| Maintainers | shinigami92 |
| Keywords | config, configuration, define-config, eslint-config, eslint, eslintconfig, typed, typescript |

## Links

- npm: https://www.npmjs.com/package/eslint-define-config
- Repository: https://github.com/eslint-types/eslint-define-config
- Homepage: https://github.com/eslint-types/eslint-define-config#readme
- Issues: https://github.com/eslint-types/eslint-define-config/issues
- Funding: https://github.com/Shinigami92
- npm.io page: https://npm.io/package/eslint-define-config

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2023-12-27
- 2.0.0-beta.1 (beta) — 2023-10-24
- 2.0.0-alpha.4 (alpha) — 2023-10-09
- 2.0.0 — 2023-11-17
- 2.0.0-beta.0 — 2023-10-22
- 1.24.1 — 2023-10-09
- 2.0.0-alpha.3 — 2023-10-08
- 1.24.0 — 2023-10-08
- 2.0.0-alpha.2 — 2023-10-08
- 2.0.0-alpha.1 — 2023-10-06
- 2.0.0-alpha.0 — 2023-10-06
- 1.23.0 — 2023-08-05
- 1.22.0 — 2023-07-30
- 1.21.0 — 2023-06-20
- 1.20.0 — 2023-04-26
- … 47 more at https://npm.io/package/eslint-define-config/versions

## README

<p>
  <a href="https://www.npmjs.com/package/eslint-define-config" target="_blank">
    <img alt="NPM package" src="https://img.shields.io/npm/v/eslint-define-config.svg">
  </a>
  <a href="https://www.npmjs.com/package/eslint-define-config" target="_blank">
    <img alt="Downloads" src="https://img.shields.io/npm/dt/eslint-define-config.svg">
  </a>
  <a href="https://github.com/eslint-types/eslint-define-config/actions/workflows/ci.yml">
    <img alt="Build Status" src="https://github.com/eslint-types/eslint-define-config/actions/workflows/ci.yml/badge.svg?branch=main">
  </a>
  <a href="https://github.com/eslint-types/eslint-define-config/blob/main/LICENSE">
    <img alt="License: MIT" src="https://img.shields.io/github/license/eslint-types/eslint-define-config.svg">
  </a>
  <a href="https://prettier.io" target="_blank">
    <img alt="Code Style: Prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg">
  </a>
  <a href="https://www.paypal.com/donate?hosted_button_id=L7GY729FBKTZY" target="_blank">
    <img alt="Donate: PayPal" src="https://img.shields.io/badge/Donate-PayPal-blue.svg">
  </a>
</p>

# eslint-define-config

Provide a `defineConfig` function for `.eslintrc.js`, and a `defineFlatConfig` function for `eslint.config.js` files.

# Installation

```bash
# add eslint and eslint-define-config to project’s dev dependencies
npm add --save-dev eslint eslint-define-config
# or
yarn add --dev eslint eslint-define-config
# or
pnpm add --save-dev eslint eslint-define-config
```

# Usage

By default only `eslint`'s rules are supported. To activate auto-suggestions for Rules of specific plugins, you need to install the respective types for that plugin.  
Plugins can either support their own types, or they could be supported by the community in the [`@eslint-types`](https://github.com/eslint-types/define-config-plugin-types) repository.

A list of community supported plugins can be found [here](https://www.npmjs.com/org/eslint-types).

`.eslintrc.js`

```ts
// @ts-check
const { defineConfig } = require('eslint-define-config');

/// <reference types="@eslint-types/typescript-eslint" />

module.exports = defineConfig({
  root: true,
  rules: {
    // rules...
  },
});
```

## Flat Config

`eslint.config.js`

```ts
// @ts-check
const { defineFlatConfig } = require('eslint-define-config');

/// <reference types="@eslint-types/typescript-eslint" />

module.exports = defineFlatConfig([
  'eslint:recommended',
  {
    plugins: {
      // plugins...
    },
    rules: {
      // rules...
    },
  },
]);
```

# Why?

Improve your eslint configuration experience with:

- auto-suggestions
- type checking (Use `// @ts-check` at the first line in your `.eslintrc.js` or `eslint.config.js`)
- documentation
- deprecation warnings

<img src="https://user-images.githubusercontent.com/7195563/112484789-8a416480-8d7a-11eb-9337-d8b5bc16de17.png" alt="Image" width="600px"/>

## Video

_Click on the thumbnail to play the video_

<a href="https://user-images.githubusercontent.com/7195563/112726158-4a19e780-8f1c-11eb-8cc6-4ea6c100137f.mp4" target="_blank">
  <img src="https://user-images.githubusercontent.com/7195563/112726343-30c56b00-8f1d-11eb-9b92-260c530caf1b.png" alt="Video" width="600px"/>
</a>

## Want to support your own plugin?

:warning: **This feature is very new and requires the support of the respective plugin owners**

Add a `declare module` to your plugin package like this:

```ts
declare module 'eslint-define-config' {
  export interface CustomRuleOptions {
    /**
     * Require consistently using either `T[]` or `Array<T>` for arrays.
     *
     * @see [array-type](https://typescript-eslint.io/rules/array-type)
     */
    '@typescript-eslint/array-type': [
      {
        default?: 'array' | 'generic' | 'array-simple';
        readonly?: 'array' | 'generic' | 'array-simple';
      },
    ];

    // ... more Rules
  }
}
```

There are other interfaces that can be extended.

- `CustomExtends`
- `CustomParserOptions`
- `CustomParsers`
- `CustomPlugins`
- `CustomSettings`

# Credits

- [Proposal Idea](https://github.com/eslint/eslint/issues/14249)
- [Vite](https://github.com/vitejs/vite) and [Evan You](https://github.com/yyx990803) for the idea
- [@antfu](https://github.com/antfu) and his [tweet](https://twitter.com/antfu7/status/1365907188338753536)

---
_Source: https://npm.io/package/eslint-define-config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
