Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Provide a defineConfig function for .eslintrc.js files

License

NotificationsYou must be signed in to change notification settings

eslint-types/eslint-define-config

Repository files navigation

NPM packageDownloadsBuild StatusLicense: MITCode Style: PrettierDonate: PayPal

eslint-define-config

Provide adefineConfig function for.eslintrc.js, and adefineFlatConfig function foreslint.config.js files.

Installation

# add eslint and eslint-define-config to project’s dev dependenciesnpm add --save-dev eslint eslint-define-config# oryarn add --dev eslint eslint-define-config# orpnpm add --save-dev eslint eslint-define-config

Usage

By default onlyeslint'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 foundhere.

.eslintrc.js

//@ts-checkconst{ defineConfig}=require('eslint-define-config');/// <reference types="@eslint-types/typescript-eslint" />module.exports=defineConfig({root:true,rules:{// rules...},});

Flat Config

eslint.config.js

//@ts-checkconst{ defineFlatConfig}=require('eslint-define-config');constjs=require('@eslint/js');constcustomConfig=require('./custom-config.js');/// <reference types="@eslint-types/typescript-eslint" />module.exports=defineFlatConfig([js.configs.recommended,customConfig,{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 oreslint.config.js)
  • documentation
  • deprecation warnings

Image

Video

Click on the thumbnail to play the video

Video

Want to support your own plugin?

⚠️This feature is very new and requires the support of the respective plugin owners

Add adeclare module to your plugin package like this:

declare module'eslint-define-config'{exportinterfaceCustomRuleOptions{/**     * 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


[8]ページ先頭

©2009-2025 Movatter.jp