eslint-config-un 
Grown out of the personal collection of rules, an ESLint config aspiring to cover as many rules as possible, be reasonably strict and easily configurable.
Features
- Every major plugin is included (50+ in total):
Vanilla JS rules,
typescript-eslint,
π¦unicorn,
βregexp,
node,
vue,
angular
react and 4 sister plugins,
solid,
tailwind,
css,
yaml
and many more;
- Every single rule was evaluated and given a reasonable default severity and options;
- Extremely configurable: you can easily override any rule's severity and granularly alter the default options;
- Zero configuration by default: exporting
eslintConfig()
from eslint.config.ts
is enough to get started;
- Strictly typed: all the options and rule names exist in TypeScript types;
- Well documented: every single config, sub-config and their options are documented in JSDoc format;
- Respects your
.gitignore
: those files are not linted by default.
- Provides the ability to disable autofix on a per-rule basis.
- Works great with Prettier: conflicting rules are disabled if you use Prettier.
- Rename plugin prefixes easily if you would like to.
Installation
Minimum supported versions:
- NodeJS: ^20.10 or >=21.2
- ESLint: ^9.15.0 (peer dependency)
npm i -D eslint-config-un eslint@latest
pnpm i -D eslint-config-un eslint@latest
yarn add -D eslint-config-un eslint@latest
Almost all the used plugins are direct dependencies of this package, you don't need to install them separately. We aim to update the dependencies within 1 month after their release.
Certain plugins are optional peer dependencies, which means that you need to install them manually if they are end up being used.
Optional peer dependencies & reason
The reason for making these plugins not coming with this package is because they have heavy non-optional peer dependencies, such as graphql
, storybook
and tailwindcss
. Not only that they're heavy, but having those peer dependencies installed would make this package think that the corresponding config is used.
graphql | @graphql-eslint/eslint-plugin | Heavy dependency graphql |
betterTailwindcss | eslint-plugin-better-tailwindcss | Heavy dependency tailwindcss |
storybook | eslint-plugin-storybook | Heavy dependency storybook |
tailwindcss | eslint-plugin-tailwindcss | Heavy dependency tailwindcss |
turbo | eslint-plugin-turbo | Heavy dependency turbo |
eslintPlugin | eslint-plugin-eslint-plugin | Very specific plugin |
Usage
In your eslint.config.ts
:
import {eslintConfig} from 'eslint-config-un';
export default eslintConfig({
});
[!NOTE]
We highly recommend using TypeScript config file, which is supported since ESLint v9.18.0, or @ts-check
directive at the start of the file otherwise.
List of configs
eslint-config-un has a concept of Configs and Sub-configs. They are similar to ESLint flat config objects, but not the quite the same.
You can enable any Config by setting it to true
or an object with the Config's options. Passing false
disables the Config.
Config interface & docs
The Config has the following interface (exact types are simplified for docs):
type UnConfig =
| boolean
| {
files?: string[];
ignores?: string[];
[RuleName in ('overrides' | 'overridesAny')]?: {
[RuleName in string]:
| Severity
| [Severity, RuleOptions[RuleName]]
| ((
ourSeverity: Severity,
ourOptions?: RuleOptions[RuleName],
) => Severity | [Severity, RuleOptions[RuleName]]);
};
forceSeverity?: '2' | 'error' | '1' | 'warn';
[`config${string}`]: UnConfig;
[customOptions: string]: unknown;
};
type Severity = 0 | 1 | 2 | 'off' | 'warn' | 'error';
- The Config is usually tied to a one or more ESLint plugins and produces one or more ESLint flat config objects.
- Sub-configs are the same as Configs, but configured within Config options. All Sub-configs use
configXXX
naming convention.
- After evaluating all the flat configs, eslint-config-un will load only those plugins that were actually used, unless
loadPluginsOnDemand
option is set to false
.
files
is an array of file globs to which this Config will be applied. If you specify an empty array []
, the Config will be disabled, but not its Sub-configs.
ignores
is exactly the same as ESLint's ignores
.
overrides
/overridesAny
is similar to ESLint's rules
, but with a very important advantage: you can provide a function that will be called with the rule severity and options set by eslint-config-un, which allows you to granularly override the options or change the severity of each rule.
- The only difference between
overrides
and overridesAny
is that overridesAny
will allow any rule to be overridden (from TypeScript's stand point; technically you can pass any rule to overrides
too), while overrides
will only allow those rules which are tied to the config.
overridesAny
will be applied after overrides
.
forceSeverity
allows to bulk override the severity of all the rules not overridden via overrides
or overridesAny
.
Sub-config is a Config located within Config's options. If the parent config is disabled, all its Sub-configs are disabled too. In the following table, Sub-configs have /
in their names.
Most popular and well known
Web frameworks & related
Runtimes & related
Languages
JS/TS - Miscellaneous
Libraries
Miscellaneous
How to use
Rules configuration (configs
and extraConfigs
option)
Example of configuration:
import {eslintConfig} from 'eslint-config-un';
export default eslintConfig({
configs: {
node: {
files: ['backend/**'],
},
vue: {
files: [],
configPinia: {
ignores: ['./path/to/pinia/store/with-many-error.ts'],
},
},
perfectionist: {
files: ['src/big-list-of-something.ts'],
overrides: {
'perfectionist/sort-objects': 2,
},
},
jsdoc: false,
security: true,
},
});
Providing user defined flag configs
You can provide your own configs by using extraConfigs
option. The provided configs will be placed after all the eslint-config-un's configs, and before the config which disables Prettier incompatible rules for all files.
Example:
import {eslintConfig} from 'eslint-config-un';
export default eslintConfig({
configs: {
},
extraConfigs: [
{
files: ['src/big-list-of-something.ts'],
rules: {
'perfectionist/sort-objects': 2,
'perfectionist/sort-object-types': 2,
},
},
],
});
Plugin prefixes (pluginRenames
option)
ESLint plugins are registered with an arbitrary user-provided prefix, such as unicorn
or vue
. Then the rule name are formed by combining the prefix with the rule name, for example unicorn/no-useless-undefined
.
eslint-config-un provides the ability to change any registered plugin prefix. Additionally, some plugins are registered with a different prefix than their documentation suggests. If you would like to rename them back or rename some other plugins, you can use pluginRenames
option, which is a map from the "canonical" prefixes to the user defined ones.
Default renames
[!NOTE]
If you rename a plugin, you still have to use the original prefix within overrides
, overridesAny
and extraConfigs
. eslint-config-un will rename the rules accordingly for you.
[!WARNING] Renaming plugins and eslint-disable
directives
If you rename a plugin, you will have to manually rename the rules within eslint-disable-*
directives.
Disabling rule autofix
ESLint doesn't (yet?) have the ability to disable autofix for a rule by the user on per-rule basis. Our config attempts to provide this missing functionality by providing the limited ability to disable autofix for a rule as a whole or per-file and per-rule basis, but with a caveat that the rule will have disable-autofix
prefix in its name. Additionally, we disable autofix for some rules by default, the list of which is available below.
To disable autofix for a rule, use an object notation for the rule entry:
import {eslintConfig} from 'eslint-config-un';
export default eslintConfig({
configs: {
unicorn: {
overrides: {
'unicorn/better-regex': {
severity: 2,
disableAutofix: 'prefixed',
},
},
},
},
});
unprefixed
: will disable autofix without changing the name of the rule, but it will be disabled for all files.
prefixed
: will create a plugin with disable-autofix
prefix and copy this rule into it. The final rule is going to be disable-autofix/<rule-name>
and <rule-name>
will be disabled in the resulting flat config.
true
: use the default autofix disabling method, determined in disableAutofixMethod.default
root option, which defaults to unprefixed
.
false
: re-enable autofix for the rule (does nothing if autofix for this rule is disabled anywhere else with unprefixed
method).
Configs notes
TypeScript
Rules requiring type information, which are known to be performance-demanding, are enabled by default, and will be applied to the same files as ts
config is applied to. It's just a little heads up; you should make your own decision whether to keep them enabled. Use configTypeAware
to control to which files such rules will be applied to, if any.
Frontend frameworks
We detect the version of the used frontend framework (Angular, Vue, Svelte, etc.) and apply the appropriate rules depending on the version. You can always manually specify the version using an appropriate option. Consult JSDoc of each config for more details.
Vue
By default, TypeScript rules will be enabled in .vue
files if enforceTypescriptInScriptSection
is set to true in vue's config options which in turn is automatically set to true if ts
config is enabled. If you have .vue
files authored in both TypeScript and JavaScript, use enforceTypescriptInScriptSection.{files,ignores}
to manually specify TS & JS Vue components respectively. It is not currently possible to apply different ESLint rules depending on the value of lang
attribute of <script>
SFC section.
Angular
We support Angular versions from 13 to 19, all at once. This is achieved by generating an ESLint plugin specifically for the detected Angular version. Internally, @angular-eslint/eslint-plugin
of versions 19 and 18, and @angular-eslint/eslint-plugin-template
of versions 17 and 19 are used. We smartly enable the appropriate rules for each Angular version.
With this approach, we offer a unique ability to port the rules added in newer versions of @angular-eslint/eslint-plugin*
and use them with older rules on older Angular codebases. Use portRules
option to control which rules will be ported.
React
We use rules from several plugins to lint your React code. You will be able to choose whether you would like to use only eslint-plugin-react
or @eslint-react/eslint-plugin
, or both, which is the default.
Markdown
If markdown
config is enabled (which is the default), the same rules provided by other configs will be applied to code blocks (```lang ... ```) inside Markdown files. This works because under the hood the plugin @eslint/markdown
that provides that functionality will create virtual files for each code block with the same extension as specified after ```.
But applying certain rules for code blocks might not be desirable because some of them are too strict for the code that won't be executed anyway or even unfixable (like missing imports). You can find the full list of disabled rules in src/configs/markdown.ts
file.
Other root options
ignores
Specifies a list of globally ignored files. By default will be merged with our ignore patterns, unless overrideIgnores
is set to true
.
overrideIgnores
Set to true
if you don't want ignores
to be merged with our ignore patterns, which are ['**/dist']
.
gitignore
By default .gitignore
d files will be added to ignores
list. Set to false
to disable this behavior. You may also provide an object which configures eslint-config-flat-gitignore, which provides this functionality in the first place.
mode
Type of your project, either application (app
, default) or library (lib
). Will affect certain rules, actual list of which is written in JSDoc of this option.
disablePrettierIncompatibleRules
Disables rules that are potentially conflicting with Prettier. eslint-config-prettier
is used under the hood, with a few exceptions. Defaults to true
if prettier
package is installed.
forceSeverity
Globally forces non-zero severity of all the rules configured by eslint-config-un (i.e. not within overrides
, overridesAny
or extraConfigs
). This can also be configured per-config.
FAQ
How do I add my own flat configs?
Use extraConfigs
option. The configs provided there will be placed after all the eslint-config-un's configs, and before the config which disables Prettier incompatible rules for all files. These configs have a richer rules
option, which allows you to apply more settings like overrides
option does.
Alternatively, you can await
the eslintConfig()
function and then add your own flat configs to whatever place you like (we recommend use flat config composer from eslint-flat-config-utils
package) for this purpose.
Do I have to install any of the used plugins?
No! All the used plugins are direct dependencies of this package, you don't need to install them separately. We aim to update the dependencies within 1 month after their release. If anything, you can always override the dependency version using your package manager settings. Although, this might not be safe because we generate types for specific versions of the plugins, so the actual options of the rules might be different.
How do I know how eslint-config-un configures rules?
It's too much to document, so please have a look at the source code of our config. All the configs are placed inside src/configs
directory.
How does exactly eslint-config-un knows if some package is installed?
We use local-pkg
package to detect if a package is installed.
How can I know which configs will be enabled, for which rules autofix will be disabled, etc.?
You can enable the debug mode by setting DEBUG=eslint-config-un
environment variable when running ESLint command.
Alternatively, you can use @eslint/config-inspector
to inspect the final config.
Troubleshooting & caveats
TypeError: Key languageOptions
: Key globals
: Global AudioWorkletGlobalScope
has leading or trailing whitespace.
Install globals
package as a dev dependency.
If you would like not to wait until the dependencies of eslint-config-un
are updated or by whatever other reason you need to install a different version of a dependency, you can do that using your package manager's settings for all but the following packages: