Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

eslint-define-config

eslint-types331.7kMIT2.1.0TypeScript support: included

Provide a defineConfig function for .eslintrc.js files

config, configuration, define-config, eslint-config, eslint, eslintconfig, typed, typescript

readme

NPM package Downloads Build Status License: MIT Code Style: Prettier Donate: PayPal

eslint-define-config

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

Installation

# 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 repository.

A list of community supported plugins can be found here.

.eslintrc.js

// @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-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
Image

Video

Click on the thumbnail to play the video

Video

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:

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

changelog

Next

diff

2.1.0

diff

2.0.0

diff

BREAKING CHANGES

There is a whole new way to support plugins.
Please read the README for more information.

1.24.1

diff

Hotfix

  • Fix missing build files in package.json (#242)

1.24.0

diff

This will be the last v1 version.

We are working on a new custom plugin support for v2.
Read more about that here: Support augmented global properties #233

In preparation for this, the project was moved into a new GitHub organization called eslint-types.

The v2 version is already available via the npm dist-tag "alpha". So if you already want to advance custom support with your own plugin, don't hold back and start incorporating it into your plugin.

Other changes

  • Support for @typescript-eslint v6
  • Updated several rules (please see diff)
  • Deprecate predefined config of flat config (#227)

1.23.0

diff

  • Fix languageOptions.parser should be an object (#220)
  • Fix sourceType in flat config can be commonjs (#222)
  • Update rules for: [sonarjs]

1.22.0

diff

  • Add support for yml (#218)
  • Update rules for: [eslint, graphql-eslint, import, jsdoc, typescript-eslint, unicorn, vue]

1.21.0

diff

  • Use esm by default (#204)
  • Update rules for: [eslint, graphql-eslint, jsdoc, jsonc, testing-library, typescript-eslint, unicorn, vitest, vue]

1.20.0

diff

  • Patch types generated by jsonschema compiler (#190)
  • Add support for React (#193)
  • Add support for React Hooks (#194)
  • Add support for Testing Library (#195)
  • Add support for JSX A11y (#196)
  • Update rules for: [jsdoc]

1.19.0

diff

  • Patch types generated by jsonschema compiler (#190)
  • Add support for vitest (#191)
  • Update rules for: [typescript-eslint, jsdoc]

1.18.0

diff

  • Allow parserOptions.project to be true (#185)
  • Update rules for: [eslint, typescript-eslint, node, graphql, sonarjs, vue]

1.17.0

diff

  • Upgrade to TypeScript 5
  • Allow parserOptions.project to be null (#175)
  • Update rules for: [eslint, typescript-eslint]

1.16.0

diff

  • Fix and sync config.rule type to eslint Linter.Rule (#172)
  • Update rules for: [eslint, typescript-eslint, graphql, jsdoc, unicorn, vue-pug]

1.15.0

diff

  • Add support for graphql (#168)
  • Update rules for: [import, typescript-eslint, vue]

1.14.0

diff

  • Add settings for flat config (#164)

1.13.0

diff

  • Fix excludedFiles type to allow string[] (#159)
  • Add support for deprecation (8ca5721)
  • Add support for eslint-comments (#163)
  • Add support for jsonc (#160)
  • Add support for promise (#162)
  • Add support for sonarjs (#161)
  • Update rules for: [eslint, jsdoc, spellcheck, typescript-eslint, unicorn, vue]

1.12.0

diff

  • Add globals key to overrides (#153)
  • Update rules for: [eslint, jsdoc, n, typescript-eslint, vue]

1.11.0

diff

  • Improve type suggestions with specific defineFlatConfig (#150)
    (theoretically a breaking change)

1.10.0

diff

  • Add override for defining just one item of Flat Config (#148)
  • Export TS types (#149)

1.9.1

diff

  • Fix Flat ESLint Config (#147)

1.9.0

diff

  • Add PredefinedConfig for Flat ESLint Config (#146)

1.8.0

diff

  • Add support for Flat ESLint Config (#122)

1.7.0

diff

  • Add support for mdx (#121)

1.6.1

diff

  • Update rules for: [eslint, typescript-eslint, vue]

1.6.0

diff

  • Add override.excludedFiles (#120)
  • Update rules for: [eslint, import, node, typescript-eslint, unicorn, vue]

1.5.1

diff

  • Update ESLint config type (#111)
  • Update rules for: [eslint]

1.5.0

diff

  • overrides.files allows string (#108)
  • Update rules for: [typescript-eslint, vue]

1.4.1

diff

  • Update rules for: [eslint, typescript-eslint, vue]

1.4.0

diff

  • Generate rules for: [vue-pug]
  • Removed rules for: [vue-pug-sfc]
  • Update ParserOptions
  • Update rules for: [eslint, import, jsdoc, typescript-eslint, unicorn, vue]

1.3.0

diff

  • Generate rules for: [import]
  • Update ParserOptions
  • Update rules for: [eslint, jsdoc, typescript-eslint, unicorn, vue]

1.2.5

diff

  • Update rules for: [jsdoc, typescript-eslint, vue-i18n]

1.2.4

diff

  • Update rules for: [vue]

1.2.3

diff

  • Update rules for: [eslint, unicorn]

1.2.2

diff

  • Allow parser and parserOptions to get overridden (193593a)
  • Update rules for: [jsdoc, typescript-eslint, unicorn]

1.2.1

diff

  • Update rules for: [eslint, jsdoc, typescript-eslint, vue]

1.2.0

diff

  • Add support for: [vue-i18n, vue-pug-sfc]
  • Update rules for: [eslint, typescript-eslint, unicorn]

1.1.4

diff

  • Update rules for: [typescript-eslint, unicorn, vue]

1.1.3

diff

  • Update rules for: [typescript-eslint, vue]
  • Removed some manual JSDocs to simplify the automatic generation process

1.1.2

diff

  • Update some rules

1.1.1

diff

  • Automatically generate rule definitions for node
  • Fix rules JSDoc hovering

1.1.0

diff

  • Automatically generate rule definitions for: (#69)
    • eslint
    • @typescript-eslint
    • jsdoc
    • spellcheck
    • unicorn
    • vue

1.0.9

diff

  • Add processor (#35)

1.0.8

diff

  • Provide support for repo Vite

1.0.7

diff

  • Add more rules
  • Fix missing config definition for indent rule

1.0.6

diff

  • Add more rules
  • Add more settings
  • Mark id-blacklist as deprecated

1.0.5

diff

  • Add more rules

1.0.4

diff

1.0.3

diff

  • Add more rules

v1.0.2

diff

  • Add extends property to Override (708c811)

1.0.1

diff

  • Define globals property (aeeb3ec)

1.0.0

diff

Initial release

Not every eslint core rule is currently typed, but any unknown rule will just fall back to a basic typed rule.

If you miss a rule or some other type definitions, feel free to create an issue or PR.

1.0.0-alpha.4

diff

  • Add env property types (fa116b5)
  • Override can contain env property (d9a9c58)
  • Define extends (0549d94)
  • First tuple value can be optional and fallback to default (ef9eb71)

1.0.0-alpha.3

diff

  • Export commonjs

1.0.0-alpha.2

diff

  • Define basic structure

1.0.0-alpha.1

diff

  • Initial alpha release