Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork26
Provide a defineConfig function for .eslintrc.js files
License
eslint-types/eslint-define-config
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Provide adefineConfig function for.eslintrc.js, and adefineFlatConfig function foreslint.config.js files.
# 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
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...},});
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...},},]);
Improve your eslint configuration experience with:
- auto-suggestions
- type checking (Use
// @ts-checkat the first line in your.eslintrc.jsoreslint.config.js) - documentation
- deprecation warnings
Click on the thumbnail to play the video

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.
CustomExtendsCustomParserOptionsCustomParsersCustomPluginsCustomSettings
- Proposal Idea
- Vite andEvan You for the idea
- @antfu and histweet
About
Provide a defineConfig function for .eslintrc.js files
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
