eslint-config-un 1.0.0-beta.0 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +229 -87
- package/dist/config-un/cache.mjs +133 -0
- package/dist/config-un/config-utils.mjs +76 -0
- package/dist/config-un/config.mjs +467 -0
- package/dist/config-un/fast-import.d.mts +14 -0
- package/dist/config-un/fast-import.mjs +35 -0
- package/dist/config-un/is-module-loaded.mjs +21 -0
- package/dist/config-un/resolve-config-async-data.mjs +198 -0
- package/dist/config-un/shared.d.mts +250 -0
- package/dist/config-un/shared.mjs +23 -0
- package/dist/configs/angular.d.mts +151 -0
- package/dist/{angular.mjs → configs/angular.mjs} +7 -5
- package/dist/configs/antfu.d.mts +8 -0
- package/dist/configs/antfu.mjs +20 -0
- package/dist/configs/astro.d.mts +20 -0
- package/dist/{astro.mjs → configs/astro.mjs} +6 -4
- package/dist/configs/ava.d.mts +26 -0
- package/dist/{ava.mjs → configs/ava.mjs} +4 -4
- package/dist/configs/better-tailwind.d.mts +67 -0
- package/dist/{better-tailwind.mjs → configs/better-tailwind.mjs} +3 -3
- package/dist/configs/boundaries.d.mts +18 -0
- package/dist/configs/boundaries.mjs +18 -0
- package/dist/configs/case-police.d.mts +8 -0
- package/dist/{case-police.mjs → configs/case-police.mjs} +3 -3
- package/dist/configs/check-file.d.mts +31 -0
- package/dist/configs/check-file.mjs +22 -0
- package/dist/configs/command.d.mts +8 -0
- package/dist/configs/command.mjs +17 -0
- package/dist/configs/compat.d.mts +24 -0
- package/dist/{compat.mjs → configs/compat.mjs} +3 -3
- package/dist/configs/cspell.d.mts +13 -0
- package/dist/{cspell.mjs → configs/cspell.mjs} +3 -3
- package/dist/configs/css-in-js.d.mts +49 -0
- package/dist/{css-in-js.mjs → configs/css-in-js.mjs} +3 -3
- package/dist/configs/css.d.mts +40 -0
- package/dist/{css.mjs → configs/css.mjs} +5 -4
- package/dist/configs/cypress.d.mts +9 -0
- package/dist/{cypress.mjs → configs/cypress.mjs} +4 -4
- package/dist/configs/de-morgan.d.mts +8 -0
- package/dist/{de-morgan.mjs → configs/de-morgan.mjs} +3 -3
- package/dist/configs/depend.d.mts +13 -0
- package/dist/{depend.mjs → configs/depend.mjs} +3 -3
- package/dist/configs/docusaurus.d.mts +8 -0
- package/dist/configs/docusaurus.mjs +20 -0
- package/dist/configs/ember.d.mts +25 -0
- package/dist/{ember.mjs → configs/ember.mjs} +4 -4
- package/dist/configs/erasable-syntax-only.d.mts +19 -0
- package/dist/{erasable-syntax-only.mjs → configs/erasable-syntax-only.mjs} +3 -3
- package/dist/configs/es.d.mts +59 -0
- package/dist/{es2.mjs → configs/es.mjs} +5 -4
- package/dist/configs/eslint-comments.d.mts +8 -0
- package/dist/{eslint-comments.mjs → configs/eslint-comments.mjs} +3 -3
- package/dist/configs/eslint-plugin.d.mts +34 -0
- package/dist/{eslint-plugin.mjs → configs/eslint-plugin.mjs} +4 -4
- package/dist/configs/expect-type.d.mts +13 -0
- package/dist/configs/expect-type.mjs +21 -0
- package/dist/configs/extra/cli.d.mts +14 -0
- package/dist/{cli.mjs → configs/extra/cli.mjs} +3 -3
- package/dist/configs/extra/cloudfront-functions.d.mts +14 -0
- package/dist/{cloudfront-functions.mjs → configs/extra/cloudfront-functions.mjs} +4 -4
- package/dist/configs/extra/no-stylistic-rules.d.mts +782 -0
- package/dist/configs/extra/no-stylistic-rules.mjs +758 -0
- package/dist/configs/fast-import.d.mts +27 -0
- package/dist/{fast-import.mjs → configs/fast-import.mjs} +3 -3
- package/dist/configs/file-progress.d.mts +29 -0
- package/dist/{file-progress.mjs → configs/file-progress.mjs} +4 -3
- package/dist/configs/formatjs.d.mts +67 -0
- package/dist/{formatjs.mjs → configs/formatjs.mjs} +3 -3
- package/dist/configs/graphql.d.mts +46 -0
- package/dist/{graphql.mjs → configs/graphql.mjs} +6 -4
- package/dist/configs/header.d.mts +33 -0
- package/dist/{header.mjs → configs/header.mjs} +3 -3
- package/dist/configs/headers.d.mts +38 -0
- package/dist/{headers.mjs → configs/headers.mjs} +3 -3
- package/dist/configs/html.d.mts +43 -0
- package/dist/{html.mjs → configs/html.mjs} +4 -4
- package/dist/configs/import-zod.d.mts +8 -0
- package/dist/{import-zod.mjs → configs/import-zod.mjs} +3 -3
- package/dist/configs/import.d.mts +62 -0
- package/dist/{import.mjs → configs/import.mjs} +6 -7
- package/dist/configs/index.d.mts +1116 -0
- package/dist/configs/index.mjs +3 -0
- package/dist/configs/jest-dom.d.mts +8 -0
- package/dist/configs/jest-dom.mjs +22 -0
- package/dist/configs/jest.d.mts +125 -0
- package/dist/{jest.mjs → configs/jest.mjs} +6 -5
- package/dist/configs/js-inline.d.mts +81 -0
- package/dist/{js-inline.mjs → configs/js-inline.mjs} +5 -4
- package/dist/configs/js.d.mts +14 -0
- package/dist/{js.mjs → configs/js.mjs} +3 -3
- package/dist/configs/jsdoc.d.mts +160 -0
- package/dist/{jsdoc.mjs → configs/jsdoc.mjs} +3 -3
- package/dist/configs/json-schema-validator.d.mts +26 -0
- package/dist/{json-schema-validator.mjs → configs/json-schema-validator.mjs} +4 -4
- package/dist/configs/jsonc.d.mts +30 -0
- package/dist/{jsonc.mjs → configs/jsonc.mjs} +4 -4
- package/dist/configs/jsx-a11y.d.mts +206 -0
- package/dist/{jsx-a11y.mjs → configs/jsx-a11y.mjs} +3 -3
- package/dist/configs/lit.d.mts +51 -0
- package/dist/{lit.mjs → configs/lit.mjs} +3 -3
- package/dist/configs/markdown-links.d.mts +24 -0
- package/dist/{markdown-links.mjs → configs/markdown-links.mjs} +3 -3
- package/dist/configs/markdown-preferences.d.mts +138 -0
- package/dist/configs/markdown-preferences.mjs +66 -0
- package/dist/configs/markdown.d.mts +96 -0
- package/dist/{markdown.mjs → configs/markdown.mjs} +23 -10
- package/dist/configs/math.d.mts +14 -0
- package/dist/{math.mjs → configs/math.mjs} +3 -3
- package/dist/configs/mdx.d.mts +25 -0
- package/dist/{mdx.mjs → configs/mdx.mjs} +6 -5
- package/dist/configs/mocha.d.mts +35 -0
- package/dist/{mocha.mjs → configs/mocha.mjs} +4 -4
- package/dist/configs/module-interop.d.mts +8 -0
- package/dist/configs/module-interop.mjs +17 -0
- package/dist/configs/nest-js.d.mts +8 -0
- package/dist/configs/nest-js.mjs +20 -0
- package/dist/configs/nextjs.d.mts +22 -0
- package/dist/{nextjs.mjs → configs/nextjs.mjs} +3 -3
- package/dist/configs/no-only-tests.d.mts +8 -0
- package/dist/{no-only-tests.mjs → configs/no-only-tests.mjs} +4 -4
- package/dist/configs/no-secrets.d.mts +24 -0
- package/dist/configs/no-secrets.mjs +33 -0
- package/dist/configs/no-unsanitized.d.mts +8 -0
- package/dist/{no-unsanitized.mjs → configs/no-unsanitized.mjs} +3 -3
- package/dist/configs/node-dependencies.d.mts +19 -0
- package/dist/{node-dependencies.mjs → configs/node-dependencies.mjs} +3 -3
- package/dist/configs/node.d.mts +157 -0
- package/dist/{node.mjs → configs/node.mjs} +3 -3
- package/dist/configs/nx.d.mts +13 -0
- package/dist/{nx.mjs → configs/nx.mjs} +3 -3
- package/dist/configs/package-json.d.mts +80 -0
- package/dist/{package-json.mjs → configs/package-json.mjs} +3 -3
- package/dist/configs/perfectionist.d.mts +101 -0
- package/dist/{perfectionist.mjs → configs/perfectionist.mjs} +3 -3
- package/dist/configs/playwright.d.mts +44 -0
- package/dist/{playwright.mjs → configs/playwright.mjs} +4 -4
- package/dist/configs/pnpm.d.mts +56 -0
- package/dist/{pnpm.mjs → configs/pnpm.mjs} +10 -7
- package/dist/configs/prefer-arrow-functions.d.mts +8 -0
- package/dist/{prefer-arrow-functions.mjs → configs/prefer-arrow-functions.mjs} +3 -3
- package/dist/configs/promise.d.mts +8 -0
- package/dist/{promise.mjs → configs/promise.mjs} +3 -3
- package/dist/configs/qunit.d.mts +9 -0
- package/dist/{qunit.mjs → configs/qunit.mjs} +4 -4
- package/dist/configs/qwik.d.mts +10 -0
- package/dist/{qwik.mjs → configs/qwik.mjs} +3 -3
- package/dist/configs/react.d.mts +330 -0
- package/dist/{react.mjs → configs/react.mjs} +4 -4
- package/dist/configs/regexp.d.mts +8 -0
- package/dist/{regexp.mjs → configs/regexp.mjs} +3 -3
- package/dist/configs/rxjs.d.mts +34 -0
- package/dist/{rxjs.mjs → configs/rxjs.mjs} +3 -3
- package/dist/configs/security.d.mts +8 -0
- package/dist/{security.mjs → configs/security.mjs} +3 -3
- package/dist/configs/shared.d.mts +42 -0
- package/dist/{shared.mjs → configs/shared.mjs} +8 -3
- package/dist/configs/solid.d.mts +8 -0
- package/dist/{solid.mjs → configs/solid.mjs} +3 -3
- package/dist/configs/sonar.d.mts +24 -0
- package/dist/{sonar.mjs → configs/sonar.mjs} +3 -3
- package/dist/configs/storybook.d.mts +8 -0
- package/dist/{storybook.mjs → configs/storybook.mjs} +3 -3
- package/dist/configs/stylistic.d.mts +17 -0
- package/dist/{stylistic.mjs → configs/stylistic.mjs} +5 -4
- package/dist/configs/svelte.d.mts +81 -0
- package/dist/{svelte.mjs → configs/svelte.mjs} +7 -5
- package/dist/configs/tailwind.d.mts +29 -0
- package/dist/{tailwind.mjs → configs/tailwind.mjs} +3 -3
- package/dist/configs/tanstack-query.d.mts +8 -0
- package/dist/{tanstack-query.mjs → configs/tanstack-query.mjs} +3 -3
- package/dist/configs/testing-library.d.mts +76 -0
- package/dist/{testing-library.mjs → configs/testing-library.mjs} +4 -4
- package/dist/configs/toml.d.mts +34 -0
- package/dist/{toml.mjs → configs/toml.mjs} +6 -6
- package/dist/configs/tree-shaking.d.mts +13 -0
- package/dist/configs/tree-shaking.mjs +21 -0
- package/dist/configs/ts.d.mts +136 -0
- package/dist/{ts.mjs → configs/ts.mjs} +6 -5
- package/dist/configs/turbo.d.mts +14 -0
- package/dist/{turbo.mjs → configs/turbo.mjs} +3 -3
- package/dist/configs/un.d.mts +8 -0
- package/dist/configs/un.mjs +17 -0
- package/dist/configs/unicorn.d.mts +21 -0
- package/dist/{unicorn.mjs → configs/unicorn.mjs} +3 -3
- package/dist/configs/unnecessary-abstractions.d.mts +8 -0
- package/dist/{unnecessary-abstractions.mjs → configs/unnecessary-abstractions.mjs} +3 -3
- package/dist/configs/unocss.d.mts +8 -0
- package/dist/{unocss.mjs → configs/unocss.mjs} +3 -3
- package/dist/configs/unused-imports.d.mts +17 -0
- package/dist/{unused-imports.mjs → configs/unused-imports.mjs} +3 -3
- package/dist/configs/vitest.d.mts +65 -0
- package/dist/configs/vitest.mjs +61 -0
- package/dist/configs/vue.d.mts +225 -0
- package/dist/{vue.mjs → configs/vue.mjs} +7 -6
- package/dist/configs/web-components.d.mts +21 -0
- package/dist/{web-components.mjs → configs/web-components.mjs} +3 -3
- package/dist/configs/yaml.d.mts +36 -0
- package/dist/{yaml.mjs → configs/yaml.mjs} +6 -6
- package/dist/configs/you-dont-need-lodash-underscore.d.mts +15 -0
- package/dist/{you-dont-need-lodash-underscore.mjs → configs/you-dont-need-lodash-underscore.mjs} +3 -3
- package/dist/configs/zod.d.mts +46 -0
- package/dist/configs/zod.mjs +32 -0
- package/dist/constants.d.mts +12 -0
- package/dist/constants.mjs +8 -75
- package/dist/{no-stylistic-rules.mjs → eslint-rules.gen.mjs} +182 -833
- package/dist/eslint-types-fixable-only.gen.d.mts +4 -0
- package/dist/eslint-types-per-plugin.gen.d.mts +33537 -0
- package/dist/eslint-types.gen.d.mts +33076 -0
- package/dist/eslint.d.mts +35 -74262
- package/dist/eslint.mjs +67 -44
- package/dist/index.d.mts +5 -1
- package/dist/index.mjs +5 -889
- package/dist/loaders/index.d.mts +3 -0
- package/dist/loaders/index.mjs +5 -0
- package/dist/loaders/packages.d.mts +54 -0
- package/dist/loaders/packages.mjs +34 -0
- package/dist/loaders/parsers.d.mts +28 -0
- package/dist/loaders/parsers.mjs +19 -0
- package/dist/loaders/plugins.d.mts +3720 -0
- package/dist/{loaders.mjs → loaders/plugins.mjs} +15 -80
- package/dist/loaders/shared.d.mts +15 -0
- package/dist/loaders/shared.mjs +34 -0
- package/dist/node_modules/import-meta-resolve/index.mjs +34 -0
- package/dist/node_modules/import-meta-resolve/lib/errors.mjs +342 -0
- package/dist/node_modules/import-meta-resolve/lib/get-format.mjs +109 -0
- package/dist/node_modules/import-meta-resolve/lib/package-json-reader.mjs +102 -0
- package/dist/node_modules/import-meta-resolve/lib/resolve.mjs +681 -0
- package/dist/node_modules/import-meta-resolve/lib/utils.mjs +32 -0
- package/dist/node_modules/is-in-editor/dist/index.mjs +192 -0
- package/dist/package.mjs +82 -0
- package/dist/plugin-un/index.mjs +17 -0
- package/dist/plugin-un/rules/no-multiple-consecutive-spaces.mjs +50 -0
- package/dist/plugin-un/rules/no-typeof-like-comparisons.mjs +72 -0
- package/dist/plugin-un/rules/prefer-early-return.mjs +58 -0
- package/dist/snippets.d.mts +7 -3
- package/dist/snippets.mjs +4 -3
- package/dist/types.d.mts +9 -0
- package/dist/utils.d.mts +27 -0
- package/dist/utils.mjs +13 -1471
- package/package.json +123 -70
- package/dist/check-file.mjs +0 -21
- package/dist/configs.mjs +0 -1
- package/dist/es.mjs +0 -6
- package/dist/markdown-preferences.mjs +0 -57
- package/dist/plugin-un.mjs +0 -181
- package/dist/un.mjs +0 -20
- package/dist/vitest.mjs +0 -53
- package/dist/zod.mjs +0 -23
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Grown out of the personal collection of rules, an ESLint config aspiring to cove
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **Every major plugin** is included (
|
|
7
|
+
- **Every major plugin** is included (100+ in total):
|
|
8
8
|
[ Vanilla JS rules](https://eslint.org/docs/latest/rules),
|
|
9
9
|
[![TypeScript] typescript-eslint](https://typescript-eslint.io/rules),
|
|
10
10
|
[🦄unicorn](https://npmjs.com/eslint-plugin-unicorn),
|
|
@@ -42,14 +42,19 @@ pnpm i -D eslint-config-un eslint@latest
|
|
|
42
42
|
yarn add -D eslint-config-un eslint@latest # Yarn Berry only (v2+)
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
Commonly used plugins are direct dependencies of this package, you don't need to install them separately.
|
|
45
|
+
Commonly used plugins are direct dependencies of this package, you don't need to install them separately.
|
|
46
|
+
We aim to update the dependencies within 1 month after their release.
|
|
47
|
+
You can always override plugins' implementation with [`pluginOverrides` option](#pluginoverrides) or using your package manager's overrides functionality.
|
|
46
48
|
|
|
47
|
-
Certain plugins (usually framework/library specific ones) are optional peer dependencies, which means that you need to install them manually if they are end up being used.
|
|
49
|
+
Certain plugins (usually framework/library specific ones) are optional peer dependencies, which means that you need to install them manually if they are end up being used.
|
|
50
|
+
You need to run ESLint with our config once to find out which plugins should be installed manually.
|
|
48
51
|
|
|
49
52
|
<details>
|
|
50
53
|
<summary>Installation with Yarn Classic (v1)</summary>
|
|
51
54
|
|
|
52
|
-
Yarn Classic (v1) does not support installing packages by npm name that have dependencies referenced by `file:` protocol - which we're using in this package.
|
|
55
|
+
Yarn Classic (v1) does not support installing packages by npm name that have dependencies referenced by `file:` protocol - which we're using in this package.
|
|
56
|
+
It fails with "Tarball is not in network and can not be located in cache" error.
|
|
57
|
+
Installing directly from the tarball does work:
|
|
53
58
|
|
|
54
59
|
```sh
|
|
55
60
|
yarn add -D https://registry.npmjs.org/eslint-config-un/-/eslint-config-un-<VERSION>.tgz eslint@latest
|
|
@@ -67,6 +72,8 @@ Note that if you're using custom registry, the URL should be changed accordingly
|
|
|
67
72
|
| `@angular-eslint/eslint-plugin-template` | `@angular-eslint/template` |
|
|
68
73
|
| `@angular-eslint/eslint-plugin` | `@angular-eslint` |
|
|
69
74
|
| `@cspell/eslint-plugin` | `@cspell` |
|
|
75
|
+
| `@darraghor/eslint-plugin-nestjs-typed` | `nestjs` |
|
|
76
|
+
| `@docusaurus/eslint-plugin` | `docusaurus` |
|
|
70
77
|
| `@eslint-react/eslint-plugin` | `@eslint-react` |
|
|
71
78
|
| `@intlify/eslint-plugin-vue-i18n` | `@intlify/vue-i18n` |
|
|
72
79
|
| `@next/eslint-plugin-next` | `@next/next` |
|
|
@@ -74,13 +81,16 @@ Note that if you're using custom registry, the URL should be changed accordingly
|
|
|
74
81
|
| `eslint-plugin-astro` | `astro` |
|
|
75
82
|
| `eslint-plugin-ava` | `ava` |
|
|
76
83
|
| `eslint-plugin-better-tailwindcss` | `better-tailwindcss` |
|
|
84
|
+
| `eslint-plugin-boundaries` | `boundaries` |
|
|
77
85
|
| `eslint-plugin-case-police` | `case-police` |
|
|
78
86
|
| `eslint-plugin-check-file` | `check-file` |
|
|
87
|
+
| `eslint-plugin-command` | `command` |
|
|
79
88
|
| `eslint-plugin-de-morgan` | `de-morgan` |
|
|
80
89
|
| `eslint-plugin-ember` | `ember` |
|
|
81
90
|
| `eslint-plugin-erasable-syntax-only` | `erasable-syntax-only` |
|
|
82
91
|
| `eslint-plugin-es-x` | `es` |
|
|
83
92
|
| `eslint-plugin-eslint-plugin` | `eslint-plugin` |
|
|
93
|
+
| `eslint-plugin-expect-type` | `expect-type` |
|
|
84
94
|
| `eslint-plugin-fast-import` | `fast-import` |
|
|
85
95
|
| `@graphql-eslint/eslint-plugin` | `graphql` |
|
|
86
96
|
| `eslint-plugin-header` | `header` |
|
|
@@ -128,18 +138,39 @@ export default eslintConfig({
|
|
|
128
138
|
> [!NOTE]
|
|
129
139
|
> We highly recommend using TypeScript config file, which is supported since ESLint v9.18.0, or [`@ts-check` directive](https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html#ts-check) at the start of the file otherwise.
|
|
130
140
|
|
|
131
|
-
|
|
141
|
+
<!-- eslint-disable-next-line markdown-preferences/heading-casing -->
|
|
142
|
+
## Configs and Sub-configs
|
|
132
143
|
|
|
133
|
-
eslint-config-un has a concept of Configs and Sub-configs, further referred to as Configs.
|
|
144
|
+
eslint-config-un has a concept of Configs and Sub-configs, further referred to as Configs.
|
|
145
|
+
They are similar to ESLint flat config objects, but with some useful extensions.
|
|
146
|
+
Every Config is *usually* tied to a one or more ESLint plugins produces one or more ESLint flat config items.
|
|
134
147
|
|
|
135
|
-
You can enable any Config by setting it to `true` or an object with the Config's options.
|
|
148
|
+
You can enable any Config by setting it to `true` or an object with the Config's options.
|
|
149
|
+
Passing `false` disables the Config.
|
|
150
|
+
Passing an empty array to `files` disables the Config, but not its' Sub-configs.
|
|
136
151
|
|
|
137
|
-
|
|
138
|
-
|
|
152
|
+
Sub-config is a Config located within Config's options.
|
|
153
|
+
If the parent config is disabled by passing `false`, all its' Sub-configs are disabled too.
|
|
154
|
+
|
|
155
|
+
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`.
|
|
156
|
+
|
|
157
|
+
### Config (`UnConfig`) interface
|
|
139
158
|
|
|
140
159
|
The Config has the following interface (exact types are simplified for docs):
|
|
141
160
|
|
|
142
161
|
```ts
|
|
162
|
+
type Severity = 0 | 1 | 2 | 'off' | 'warn' | 'error';
|
|
163
|
+
|
|
164
|
+
type RuleOptions = { /* ... pre-generated all rules' options */ };
|
|
165
|
+
|
|
166
|
+
type UnRuleEntry<RuleName extends string> = Severity | [Severity, RuleOptions[RuleName]] | {
|
|
167
|
+
severity: Severity;
|
|
168
|
+
options?: RuleOptions[RuleName];
|
|
169
|
+
disableAutofix?: boolean;
|
|
170
|
+
files?: string[];
|
|
171
|
+
ignores?: string[];
|
|
172
|
+
}
|
|
173
|
+
|
|
143
174
|
type UnConfig =
|
|
144
175
|
| boolean
|
|
145
176
|
| {
|
|
@@ -148,41 +179,74 @@ type UnConfig =
|
|
|
148
179
|
|
|
149
180
|
[RuleName in ('overrides' | 'overridesAny')]?: {
|
|
150
181
|
[RuleName in string]:
|
|
151
|
-
|
|
|
152
|
-
| [Severity, RuleOptions[RuleName]]
|
|
182
|
+
| UnRuleEntry<RuleName>
|
|
153
183
|
| ((
|
|
154
184
|
// These are severity and options *maybe* set by eslint-config-un
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
) =>
|
|
185
|
+
unRuleSeverity: Severity,
|
|
186
|
+
unRuleOptions?: RuleOptions[RuleName],
|
|
187
|
+
) => UnRuleEntry<RuleName>);
|
|
158
188
|
};
|
|
159
189
|
|
|
160
190
|
forceSeverity?: '2' | 'error' | '1' | 'warn';
|
|
161
|
-
|
|
162
191
|
[`config${string}`]: UnConfig; // These are Sub-configs
|
|
163
|
-
|
|
164
192
|
[customOptions: string]: unknown; // Custom options, individual for each Config
|
|
165
193
|
};
|
|
166
|
-
|
|
167
|
-
type Severity = 0 | 1 | 2 | 'off' | 'warn' | 'error';
|
|
168
194
|
```
|
|
169
195
|
|
|
170
|
-
|
|
196
|
+
#### `files` and `ignores`
|
|
197
|
+
|
|
198
|
+
They have exactly the same meaning as the corresponding ESLint flat config item properties, with the only difference being an empty array `[]` handling:
|
|
199
|
+
|
|
200
|
+
- If you specify an empty array for `files`, the Config **will be disabled**, but of its' Sub-configs remain unaffected.
|
|
201
|
+
- If you specify an empty array for `ignores`, the default ignore list won't be used.
|
|
202
|
+
|
|
203
|
+
#### `overrides` and `overridesAny`
|
|
204
|
+
|
|
205
|
+
These are 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.
|
|
171
206
|
|
|
172
|
-
|
|
207
|
+
- The 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.
|
|
208
|
+
- `overridesAny` will be applied **after** `overrides`.
|
|
173
209
|
|
|
174
|
-
|
|
175
|
-
- 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`.
|
|
176
|
-
- `files` and `ignores` have exactly the same meaning as the corresponding ESLint flat config item properties, with the only difference being an empty array `[]` handling:
|
|
177
|
-
- If you specify an empty array for `files`, the Config **will be disabled**, but of its' Sub-configs remain unaffected.
|
|
178
|
-
- If you specify an empty array for `ignores`, the default ignore list won't be used.
|
|
179
|
-
- `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.
|
|
180
|
-
- The 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.
|
|
181
|
-
- `overridesAny` will be applied **after** `overrides`.
|
|
182
|
-
- `forceSeverity` allows to bulk override the severity of all the rules not overridden via `overrides` or `overridesAny`.
|
|
183
|
-
- Custom options are individual for each Config and are documented in JSDoc format.
|
|
210
|
+
#### Sub-configs
|
|
184
211
|
|
|
185
|
-
Sub-
|
|
212
|
+
Sub-configs are the same as Configs, but configured within Config options.
|
|
213
|
+
All Sub-configs use `configXXX` naming convention.
|
|
214
|
+
|
|
215
|
+
#### `forceSeverity`
|
|
216
|
+
|
|
217
|
+
Allows to bulk override the severity of all the rules not overridden via `overrides` or `overridesAny`.
|
|
218
|
+
|
|
219
|
+
#### Custom options
|
|
220
|
+
|
|
221
|
+
Custom options are individual for each Config and are documented in JSDoc format.
|
|
222
|
+
|
|
223
|
+
### Rule entry (`UnRuleEntry`) interface
|
|
224
|
+
|
|
225
|
+
#### `severity` and `options`
|
|
226
|
+
|
|
227
|
+
Normal ESLint severity and rule options.
|
|
228
|
+
|
|
229
|
+
#### `disableAutofix`
|
|
230
|
+
|
|
231
|
+
Apply a copy of the rule with `disable-autofix/` prefix and all autofixes disabled.
|
|
232
|
+
|
|
233
|
+
#### `files` and `ignores`
|
|
234
|
+
|
|
235
|
+
Allows to limit to which files only the current rule will be applied.
|
|
236
|
+
Only works if:
|
|
237
|
+
|
|
238
|
+
- At least one of `files` or `ignores` is provided and non-empty;
|
|
239
|
+
- `files` or the current Config is not an empty array.
|
|
240
|
+
|
|
241
|
+
If these conditions are met, a separate Config will be created with:
|
|
242
|
+
|
|
243
|
+
- `name` being the current Config's name with `/@rule/<rule name with prefix>` postfix;
|
|
244
|
+
- `files` [intersected with the parent's `files`](https://eslint.org/docs/latest/use/configure/configuration-files#specifying-files-with-an-and-operation);
|
|
245
|
+
- `ignores` merged with the parent's `ignores`.
|
|
246
|
+
|
|
247
|
+
## List of configs
|
|
248
|
+
|
|
249
|
+
In the following table, Sub-configs have `/` in their names.
|
|
186
250
|
|
|
187
251
|
### Most popular and well known
|
|
188
252
|
|
|
@@ -233,6 +297,7 @@ Sub-config is a Config located within Config's options. If the parent config is
|
|
|
233
297
|
|  `lit/a11y` | ✅ | [eslint-plugin-lit-a11y](https://npmjs.com/eslint-plugin-lit-a11y) (`lit-a11y`) | Since v1.0.0 |
|
|
234
298
|
| ![TailwindCSS] `betterTailwind` | ✅ (`tailwindcss` is installed) | [eslint-plugin-better-tailwindcss](https://npmjs.com/eslint-plugin-better-tailwindcss) (`better-tailwindcss`) | Since v1.0.0<br>Supports v4 and v3 |
|
|
235
299
|
| ![TailwindCSS] `tailwind` | ❌ | [eslint-plugin-tailwindcss](https://npmjs.com/eslint-plugin-tailwindcss) (`tailwindcss`) | Only supports v3 |
|
|
300
|
+
|  `nestJs` | ✅ (`@nestjs/core` is installed) | [@darraghor/eslint-plugin-nestjs-typed](https://npmjs.com/@darraghor/eslint-plugin-nestjs-typed) (`nestjs`) | Since v1.0.0 |
|
|
236
301
|
|
|
237
302
|
### Runtimes & related
|
|
238
303
|
|
|
@@ -254,6 +319,7 @@ Sub-config is a Config located within Config's options. If the parent config is
|
|
|
254
319
|
| ----------------------------------------------------- | ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
255
320
|
| ![Markdown] `markdown` | ✅ | [@eslint/markdown](https://npmjs.com/@eslint/markdown) (`markdown`) | Since v0.7.0<br>Configured to also lint fenced code blocks inside .md files |
|
|
256
321
|
| ![Markdown] `markdown/formatFencedCodeBlocks` | ✅ (`prettier` is installed) | [eslint-plugin-prettier](https://npmjs.com/eslint-plugin-prettier) (`prettier`) | Since v1.0.0<br>Format fenced code blocks inside Markdown files using Prettier |
|
|
322
|
+
| ![Markdown] `markdown/sentencesPerLine` | ❌ | [eslint-plugin-sentences-per-line](https://npmjs.com/eslint-plugin-sentences-per-line) (`sentences-per-line`) | Since v1.0.0 |
|
|
257
323
|
| ![Markdown] `markdownPreferences` | ✅ | [eslint-plugin-markdown-preferences](https://npmjs.com/eslint-plugin-markdown-preferences) (`markdownPreferences`) | Since v1.0.0 |
|
|
258
324
|
| ![Markdown] `markdownLinks` | ✅ | [eslint-plugin-markdown-links](https://npmjs.com/eslint-plugin-markdown-links) (`markdownLinks`) | Since v1.0.0 |
|
|
259
325
|
|  `mdx` | ✅ | [eslint-plugin-mdx](https://npmjs.com/eslint-plugin-mdx) (`mdx`) | Since v1.0.0<br>Configured to also lint fenced code blocks inside .mdx files |
|
|
@@ -286,6 +352,8 @@ Sub-config is a Config located within Config's options. If the parent config is
|
|
|
286
352
|
| `erasableSyntaxOnly` | ❌ | [eslint-plugin-erasable-syntax-only](https://npmjs.com/eslint-plugin-erasable-syntax-only) (`erasable-syntax-only`) | Since v1.0.0 |
|
|
287
353
|
| `noUnnecessaryAbstractions` | ✅ | [eslint-plugin-unnecessary-abstractions](https://npmjs.com/eslint-plugin-unnecessary-abstractions) (`unnecessary-abstractions`) | Since v1.0.0 |
|
|
288
354
|
| `fastImport` | ❌ | [eslint-plugin-fast-import](https://npmjs.com/eslint-plugin-fast-import) (`fast-import`) | Since v1.0.0<br>Faster `eslint-plugin-import(-x)` alternative |
|
|
355
|
+
| `moduleInterop` | ✅ | [eslint-plugin-module-interop](https://npmjs.com/eslint-plugin-module-interop) (`module-interop`) | Since v1.0.0 |
|
|
356
|
+
| `treeShaking` | ❌ | [eslint-plugin-tree-shaking](https://npmjs.com/eslint-plugin-tree-shaking) (`tree-shaking`) | Since v1.0.0 |
|
|
289
357
|
|
|
290
358
|
### Libraries
|
|
291
359
|
|
|
@@ -297,6 +365,7 @@ Sub-config is a Config located within Config's options. If the parent config is
|
|
|
297
365
|
| `jest/noOnlyTests` | ❌ | [eslint-plugin-no-only-tests] (`no-only-tests`) | Since v1.0.0 |
|
|
298
366
|
| `vitest` | ✅ (`vitest` is installed) | [@vitest/eslint-plugin](https://npmjs.com/@vitest/eslint-plugin) (`vitest`) | Since v0.3.0 |
|
|
299
367
|
| `vitest/noOnlyTests` | ❌ | [eslint-plugin-no-only-tests] (`no-only-tests`) | Since v1.0.0 |
|
|
368
|
+
| `jestDom` | ✅ (`@testing-library/jest-dom` is installed) | [eslint-plugin-jest-dom](https://npmjs.com/eslint-plugin-jest-dom) (`jest-dom`) | Since v1.0.0 |
|
|
300
369
|
| `ava` | ✅ (`ava` is installed) | [eslint-plugin-ava](https://npmjs.com/eslint-plugin-ava) (`ava`) | Since v1.0.0 |
|
|
301
370
|
| `ava/noOnlyTests` | ❌ | [eslint-plugin-no-only-tests] (`no-only-tests`) | Since v1.0.0 |
|
|
302
371
|
| `qunit` | ✅ (`qunit` is installed) | [eslint-plugin-qunit](https://npmjs.com/eslint-plugin-qunit) (`qunit`) | Since v1.0.0 |
|
|
@@ -325,6 +394,7 @@ Sub-config is a Config located within Config's options. If the parent config is
|
|
|
325
394
|
|  `unocss` | ✅ (`unocss` is installed) | [@unocss/eslint-plugin](https://npmjs.com/@unocss/eslint-plugin) (`unocss`) | Since v1.0.0 |
|
|
326
395
|
|  `zod` | ✅ (`zod@>=4` is installed) | [eslint-plugin-zod-x](https://npmjs.com/eslint-plugin-zod-x) (`zod`) | Since v1.0.0 |
|
|
327
396
|
|  `formatJs` | ✅ (`@formatjs/icu-messageformat-parser` is installed) | [eslint-plugin-formatjs](https://npmjs.com/eslint-plugin-formatjs) (`formatjs`) | Since v1.0.0 |
|
|
397
|
+
|  `docusaurus` | ✅ (`@docusaurus/core` is installed) | [@docusaurus/eslint-plugin](https://npmjs.com/@docusaurus/eslint-plugin) (`docusaurus`) | Since v1.0.0 |
|
|
328
398
|
|
|
329
399
|
### Miscellaneous
|
|
330
400
|
|
|
@@ -341,6 +411,12 @@ Sub-config is a Config located within Config's options. If the parent config is
|
|
|
341
411
|
| `header` | ❌ | [eslint-plugin-header](https://npmjs.com/eslint-plugin-header) (`header`) | Since v1.0.0 |
|
|
342
412
|
| `headers` | ❌ | [eslint-plugin-headers](https://npmjs.com/eslint-plugin-headers) (`headers`) | Since v1.0.0 |
|
|
343
413
|
| `checkFile` | ❌ | [eslint-plugin-check-file](https://npmjs.com/eslint-plugin-check-file) (`check-file`) | Since v1.0.0 |
|
|
414
|
+
| `boundaries` | ❌ | [eslint-plugin-boundaries](https://npmjs.com/eslint-plugin-boundaries) (`boundaries`) | Since v1.0.0 |
|
|
415
|
+
| `noSecrets` | ✅ | [eslint-plugin-no-secrets](https://npmjs.com/eslint-plugin-no-secrets) (`no-secrets`) | Since v1.0.0 |
|
|
416
|
+
| `noSecrets/json` | ✅ | ^ | Applied only to `.json` files by default |
|
|
417
|
+
| `expectType` | ❌ | [eslint-plugin-expect-type](https://npmjs.com/eslint-plugin-expect-type) (`expect-type`) | Since v1.0.0 |
|
|
418
|
+
| `command` | ❌ | [eslint-plugin-command](https://npmjs.com/eslint-plugin-command) (`command`) | Since v1.0.0 |
|
|
419
|
+
| `antfu` | ❌ | [eslint-plugin-antfu](https://npmjs.com/eslint-plugin-antfu) (`antfu`) | Since v1.0.0<br>[Anthony Fu](https://antfu.me)'s personal collection of rules. |
|
|
344
420
|
|
|
345
421
|
## How to use
|
|
346
422
|
|
|
@@ -383,7 +459,8 @@ export default eslintConfig({
|
|
|
383
459
|
|
|
384
460
|
#### Providing user defined flag configs
|
|
385
461
|
|
|
386
|
-
You can provide your own configs by using `extraConfigs` option.
|
|
462
|
+
You can provide your own configs by using `extraConfigs` option.
|
|
463
|
+
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.
|
|
387
464
|
|
|
388
465
|
Example:
|
|
389
466
|
|
|
@@ -411,20 +488,25 @@ export default eslintConfig({
|
|
|
411
488
|
|
|
412
489
|
### Plugin prefixes (`pluginRenames` option)
|
|
413
490
|
|
|
414
|
-
ESLint plugins are registered with an arbitrary user-provided prefix, such as `unicorn` or `vue`.
|
|
491
|
+
ESLint plugins are registered with an arbitrary user-provided prefix, such as `unicorn` or `vue`.
|
|
492
|
+
Then the rule name are formed by combining the prefix with the rule name, for example `unicorn/no-useless-undefined`.
|
|
415
493
|
|
|
416
|
-
eslint-config-un provides the ability to change any registered plugin prefix.
|
|
494
|
+
eslint-config-un provides the ability to change any registered plugin prefix.
|
|
495
|
+
Additionally, some plugins are registered with a different prefix than their documentation suggests.
|
|
496
|
+
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.
|
|
417
497
|
|
|
418
498
|
#### Default renames
|
|
419
499
|
|
|
420
|
-
| Plugin
|
|
421
|
-
|
|
|
422
|
-
| [`typescript-eslint`](https://npmjs.com/typescript-eslint)
|
|
423
|
-
| [`eslint-plugin-import-x`]
|
|
424
|
-
| [`eslint-plugin-n`](https://npmjs.com/eslint-plugin-n)
|
|
425
|
-
| [`eslint-plugin-css`](https://npmjs.com/eslint-plugin-css)
|
|
426
|
-
| [`eslint-plugin-jsx-a11y-x`](https://npmjs.com/eslint-plugin-jsx-a11y-x)
|
|
427
|
-
| [`eslint-plugin-zod-x`](https://npmjs.com/eslint-plugin-zod-x)
|
|
500
|
+
| Plugin | Suggested prefix | Our prefix | Reason |
|
|
501
|
+
| -------------------------------------------------------------------------------------------------- | ------------------------- | ------------ | -------------------------------------------------------------------------------------------------------------------- |
|
|
502
|
+
| [`typescript-eslint`](https://npmjs.com/typescript-eslint) | `@typescript-eslint` | `ts` | More concise and convenient to use |
|
|
503
|
+
| [`eslint-plugin-import-x`] | `import-x` | `import` | This plugin is a fork and is meant to replace the original plugin with `import` prefix |
|
|
504
|
+
| [`eslint-plugin-n`](https://npmjs.com/eslint-plugin-n) | `n` | `node` | Same ^ |
|
|
505
|
+
| [`eslint-plugin-css`](https://npmjs.com/eslint-plugin-css) | `css` | `css-in-js` | Conflicts with [`@eslint/css`](https://npmjs.com/@eslint/css) and our name better captures the essence of the plugin |
|
|
506
|
+
| [`eslint-plugin-jsx-a11y-x`](https://npmjs.com/eslint-plugin-jsx-a11y-x) | `jsx-a11y-x` | `jsx-a11y` | This plugin is a fork and is meant to replace the original plugin with `jsx-a11y` prefix |
|
|
507
|
+
| [`eslint-plugin-zod-x`](https://npmjs.com/eslint-plugin-zod-x) | `zod-x` | `zod` | Better replacement for an existing `eslint-plugin-zod` plugin |
|
|
508
|
+
| [`@docusaurus/eslint-plugin`](https://npmjs.com/@docusaurus/eslint-plugin) | `@docusaurus` | `docusaurus` | `@` feels unnecessary |
|
|
509
|
+
| [`@darraghor/eslint-plugin-nestjs-typed`](https://npmjs.com/@darraghor/eslint-plugin-nestjs-typed) | `@darraghor/nestjs-typed` | `nestjs` | More concise and convenient to use |
|
|
428
510
|
|
|
429
511
|
> [!NOTE]
|
|
430
512
|
> 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.
|
|
@@ -434,7 +516,8 @@ eslint-config-un provides the ability to change any registered plugin prefix. Ad
|
|
|
434
516
|
|
|
435
517
|
### Disabling rule autofix
|
|
436
518
|
|
|
437
|
-
ESLint [doesn't (yet?) have the ability to disable autofix](https://github.com/eslint/rfcs/pull/125) for a rule by the user on per-rule basis.
|
|
519
|
+
ESLint [doesn't (yet?) have the ability to disable autofix](https://github.com/eslint/rfcs/pull/125) for a rule by the user on per-rule basis.
|
|
520
|
+
Our config attempts to provide this missing functionality by giving the ability to disable autofix for a rule as a whole ("globally") or per-file and per-rule basis, but in the latter case with a caveat that the rule will have `disable-autofix/` prefix in its name.
|
|
438
521
|
|
|
439
522
|
#### Globally disabling rule autofix
|
|
440
523
|
|
|
@@ -490,35 +573,47 @@ export default eslintConfig({
|
|
|
490
573
|
});
|
|
491
574
|
```
|
|
492
575
|
|
|
493
|
-
This will technically create a plugin with `disable-autofix` prefix and copy this rule into it.
|
|
576
|
+
This will technically create a plugin with `disable-autofix` prefix and copy this rule into it.
|
|
577
|
+
The final rule is going to be given a name `disable-autofix/<rule-name>` which would replace `<rule-name>` entry in the resulting config.
|
|
494
578
|
|
|
495
579
|
## Configs notes
|
|
496
580
|
|
|
497
581
|
### TypeScript
|
|
498
582
|
|
|
499
|
-
Rules [requiring type information](https://typescript-eslint.io/rules/?=typeInformation), which are [known to be performance-demanding](https://typescript-eslint.io/getting-started/typed-linting/#performance), are *enabled* by default, and will be applied to the same files as `ts` config is applied to.
|
|
583
|
+
Rules [requiring type information](https://typescript-eslint.io/rules/?=typeInformation), which are [known to be performance-demanding](https://typescript-eslint.io/getting-started/typed-linting/#performance), are *enabled* by default, and will be applied to the same files as `ts` config is applied to.
|
|
584
|
+
It's just a little heads up; you should make your own decision whether to keep them enabled.
|
|
585
|
+
Use `configTypeAware` to control to which files such rules will be applied to, if any.
|
|
500
586
|
|
|
501
587
|
### Frontend frameworks
|
|
502
588
|
|
|
503
|
-
We detect the version of the used frontend framework (Angular, Vue, Svelte, etc.) and apply the appropriate rules depending on the version.
|
|
589
|
+
We detect the version of the used frontend framework (Angular, Vue, Svelte, etc.) and apply the appropriate rules depending on the version.
|
|
590
|
+
You can always manually specify the version using an appropriate option.
|
|
591
|
+
Consult JSDoc of each config for more details.
|
|
504
592
|
|
|
505
593
|
#### Vue
|
|
506
594
|
|
|
507
|
-
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.
|
|
595
|
+
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.
|
|
596
|
+
If you have `.vue` files authored in both TypeScript and JavaScript, use `enforceTypescriptInScriptSection.{files,ignores}` to manually specify TS & JS Vue components respectively.
|
|
597
|
+
It is not currently possible to apply different ESLint rules depending on the value of `lang` attribute of `<script>` SFC section.
|
|
508
598
|
|
|
509
599
|
#### Angular
|
|
510
600
|
|
|
511
|
-
We support Angular versions from 13 to 20, all at once.
|
|
601
|
+
We support Angular versions from 13 to 20, all at once.
|
|
602
|
+
You are expected to install `@angular-eslint/eslint-plugin` and `@angular-eslint/eslint-plugin-template` packages of the same major version as your Angular version, but installing a greater version would also likely work.
|
|
603
|
+
With the latter, you can use the rules added in newer versions of `@angular-eslint/eslint-plugin*` on older Angular codebases.
|
|
512
604
|
|
|
513
605
|
#### React
|
|
514
606
|
|
|
515
|
-
We use rules from several plugins to lint your React code.
|
|
607
|
+
We use rules from several plugins to lint your React code.
|
|
608
|
+
You will be able to choose whether you would like to use only `@eslint-react/eslint-plugin` or `eslint-plugin-react`, or both, which is the default.
|
|
516
609
|
|
|
517
610
|
### Markdown
|
|
518
611
|
|
|
519
|
-
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.
|
|
612
|
+
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.
|
|
613
|
+
This works because under the hood the plugin [`@eslint/markdown`](https://npmjs.com/@eslint/markdown) that provides that functionality will create virtual files for each code block with the same extension as specified after ```.
|
|
520
614
|
|
|
521
|
-
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).
|
|
615
|
+
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).
|
|
616
|
+
You can find the full list of disabled rules in `src/configs/markdown.ts` file.
|
|
522
617
|
|
|
523
618
|
### Tailwind CSS
|
|
524
619
|
|
|
@@ -542,11 +637,14 @@ See [Rules configuration](#rules-configuration-configs-and-extraconfigs-option).
|
|
|
542
637
|
|
|
543
638
|
### `ignores`
|
|
544
639
|
|
|
545
|
-
Specifies a list of globally ignored files.
|
|
640
|
+
Specifies a list of globally ignored files.
|
|
641
|
+
By default will be merged with our ignore patterns (also exported as [`DEFAULT_GLOBAL_IGNORES`](#default_global_ignores)), unless the object notation is used and the `override` property is set to `true`.
|
|
546
642
|
|
|
547
643
|
### `extraPlugins`
|
|
548
644
|
|
|
549
|
-
Allows to provide additional ESLint plugins.
|
|
645
|
+
Allows to provide additional ESLint plugins.
|
|
646
|
+
Their prefixes and possibly rule names will appear in configs' `rules` property type.
|
|
647
|
+
They, like all the built-in plugins, by default will be loaded only if used.
|
|
550
648
|
|
|
551
649
|
Note that their prefixes must not match the built-it/known ones (like `ts` or `unicorn`) or even prefixes you've set via [`pluginRenames`](#pluginrenames).
|
|
552
650
|
|
|
@@ -556,18 +654,21 @@ Sets [`linterOptions.{noInlineConfig,reportUnusedDisableDirectives,reportUnusedI
|
|
|
556
654
|
|
|
557
655
|
### `defaultConfigsStatus`
|
|
558
656
|
|
|
559
|
-
Quickly enable multiple configs at once.
|
|
657
|
+
Quickly enable multiple configs at once.
|
|
658
|
+
Possible options:
|
|
560
659
|
|
|
561
660
|
- `all-disabled`: consider all top level configs disabled unless explicitly enabled.
|
|
562
661
|
- `misc-enabled`: consider some configs disabled by default (see the list in JSDoc).
|
|
563
662
|
|
|
564
663
|
### `mode`
|
|
565
664
|
|
|
566
|
-
Type of your project, either application (`app`, default) or library (`lib`).
|
|
665
|
+
Type of your project, either application (`app`, default) or library (`lib`).
|
|
666
|
+
Will affect certain rules, actual list of which is written in JSDoc of this option.
|
|
567
667
|
|
|
568
668
|
### `forceSeverity`
|
|
569
669
|
|
|
570
|
-
Globally forces non-zero severity of all the rules configured by eslint-config-un (i.e. not within `overrides`, `overridesAny` or [`extraConfigs`](#extraconfigs)).
|
|
670
|
+
Globally forces non-zero severity of all the rules configured by eslint-config-un (i.e. not within `overrides`, `overridesAny` or [`extraConfigs`](#extraconfigs)).
|
|
671
|
+
This can also be configured per-config.
|
|
571
672
|
|
|
572
673
|
### `pluginRenames`
|
|
573
674
|
|
|
@@ -575,13 +676,15 @@ See [Plugin prefixes](#plugin-prefixes-pluginrenames-option).
|
|
|
575
676
|
|
|
576
677
|
### `pluginOverrides`
|
|
577
678
|
|
|
578
|
-
Override implementation of some of the plugins.
|
|
679
|
+
Override implementation of some of the plugins.
|
|
680
|
+
This can be useful when this config is used to lint a repository of one of the built-in plugins to provide development version of that plugin.
|
|
579
681
|
|
|
580
682
|
### `loadPluginsOnDemand`
|
|
581
683
|
|
|
582
684
|
This option allows to decide whether whether ESLint plugins will be loaded if they are actually used (`true` by default).
|
|
583
685
|
|
|
584
|
-
Using object notation, you can also specify concrete plugins that will be loaded.
|
|
686
|
+
Using object notation, you can also specify concrete plugins that will be loaded.
|
|
687
|
+
This can be useful if you enable certain plugin rules only be using [configuration comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments).
|
|
585
688
|
|
|
586
689
|
### `autofixDisabledGloballyFor`
|
|
587
690
|
|
|
@@ -589,7 +692,9 @@ See [Globally disabling rule autofix](#globally-disabling-rule-autofix).
|
|
|
589
692
|
|
|
590
693
|
### `gitignore`
|
|
591
694
|
|
|
592
|
-
By default files from `.gitignore` (read from [the current working directory](https://nodejs.org/api/process.html#processcwd)) in the will be automatically added to the global [`ignores`](#ignores) list.
|
|
695
|
+
By default files from `.gitignore` (read from [the current working directory](https://nodejs.org/api/process.html#processcwd)) in the will be automatically added to the global [`ignores`](#ignores) list.
|
|
696
|
+
Set this option to `false` to disable this behavior.
|
|
697
|
+
You may also provide an object which configures [eslint-config-flat-gitignore](https://npmjs.com/eslint-config-flat-gitignore), which actually provides this functionality.
|
|
593
698
|
|
|
594
699
|
### `offlineMode`
|
|
595
700
|
|
|
@@ -599,12 +704,16 @@ It can also be enabled by setting `ESLINT_CONFIG_UN_OFFLINE_MODE` environment va
|
|
|
599
704
|
|
|
600
705
|
### `cacheConfigs`
|
|
601
706
|
|
|
602
|
-
Enables flat config caching.
|
|
707
|
+
Enables flat config caching.
|
|
708
|
+
This option is enabled by default when running in editor (detected by [`is-in-editor`](https://npmjs.com/is-in-editor)).
|
|
709
|
+
It can also be enabled by setting `ESLINT_CONFIG_UN_CACHE_CONFIGS` environment variable to non-empty string, but the explicitly passed value takes precedence.
|
|
603
710
|
|
|
604
711
|
There are 2 layers of caching:
|
|
605
712
|
|
|
606
|
-
- In memory: the cache will be stored in a global variable, and if it's preserved between ESLint extension process re-runs (it does at least in VSCode), it will be preferred over FS cache.
|
|
607
|
-
|
|
713
|
+
- In memory: the cache will be stored in a global variable, and if it's preserved between ESLint extension process re-runs (it does at least in VSCode), it will be preferred over FS cache.
|
|
714
|
+
This is an **extremely fast** caching option.
|
|
715
|
+
- In file system: the cache will be stored in `node_modules/.cache/eslint-config-un/config.json`.
|
|
716
|
+
Note that in this case caching might fail if the config contains unserializable data, such as functions.
|
|
608
717
|
|
|
609
718
|
The cache, regardless of the storage, is considered fresh for 1 hour, unless one of the following is changed:
|
|
610
719
|
|
|
@@ -615,7 +724,8 @@ The cache, regardless of the storage, is considered fresh for 1 hour, unless one
|
|
|
615
724
|
|
|
616
725
|
### `disablePrettierIncompatibleRules`
|
|
617
726
|
|
|
618
|
-
Disables rules that are potentially conflicting with Prettier. [`eslint-config-prettier`](https://npmjs.com/eslint-config-prettier) is used under the hood, with a few exceptions.
|
|
727
|
+
Disables rules that are potentially conflicting with Prettier. [`eslint-config-prettier`](https://npmjs.com/eslint-config-prettier) is used under the hood, with a few exceptions.
|
|
728
|
+
Defaults to `true` if `prettier` package is installed.
|
|
619
729
|
|
|
620
730
|
### `useFastImport`
|
|
621
731
|
|
|
@@ -631,22 +741,27 @@ Re-exported default export from [`globals` package](https://npmjs.com/globals),
|
|
|
631
741
|
|
|
632
742
|
#### `isInCi`
|
|
633
743
|
|
|
634
|
-
The constant showing if the current process is *likely* running in CI.
|
|
744
|
+
The constant showing if the current process is *likely* running in CI.
|
|
745
|
+
Info provided by [`ci-info` package](https://npmjs.com/ci-info).
|
|
635
746
|
|
|
636
|
-
Use case: disable or enable certain rules or features in CI.
|
|
747
|
+
Use case: disable or enable certain rules or features in CI.
|
|
748
|
+
Use with caution!
|
|
637
749
|
|
|
638
750
|
#### `isInEditor`
|
|
639
751
|
|
|
640
|
-
The constant showing if the current process is *likely* running within editor.
|
|
752
|
+
The constant showing if the current process is *likely* running within editor.
|
|
753
|
+
Info provided by [`is-in-editor` package](https://npmjs.com/is-in-editor).
|
|
641
754
|
|
|
642
755
|
Use case: disable or enable certain rules or features in editor, likely to improve performance.
|
|
643
756
|
|
|
644
757
|
> [!WARNING]
|
|
645
|
-
> Use this option sparingly as disabling certain rules only in editor might cause false positive reports on unused directives, which are subject to removal with autofix.
|
|
758
|
+
> Use this option sparingly as disabling certain rules only in editor might cause false positive reports on unused directives, which are subject to removal with autofix.
|
|
759
|
+
> We recommend also setting [`linterOptions.reportUnusedDisableDirectives`](https://eslint.org/docs/latest/use/configure/configuration-files#:~:text=reportUnusedDisableDirectives) to `!isInEditor()` for files affected by this option.
|
|
646
760
|
|
|
647
761
|
#### `DEFAULT_GLOBAL_IGNORES`
|
|
648
762
|
|
|
649
|
-
Default list of global `ignores` values set by eslint-config-un.
|
|
763
|
+
Default list of global `ignores` values set by eslint-config-un.
|
|
764
|
+
See also [`ignores` option](#ignores)
|
|
650
765
|
|
|
651
766
|
#### `RuleOptions`
|
|
652
767
|
|
|
@@ -665,23 +780,28 @@ Please refer to JSDoc of exported symbols for proper documentation.
|
|
|
665
780
|
|
|
666
781
|
#### `createNoRestricted*Rule`
|
|
667
782
|
|
|
668
|
-
Utility functions re-exported from [`eslint-no-restricted` package](https://npmjs.com/eslint-no-restricted) which generate `no-restricted-*` rules.
|
|
783
|
+
Utility functions re-exported from [`eslint-no-restricted` package](https://npmjs.com/eslint-no-restricted) which generate `no-restricted-*` rules.
|
|
784
|
+
Please refer to [the package documentation](https://github.com/bradzacher/eslint-no-restricted#readme) for more info.
|
|
669
785
|
|
|
670
786
|
## FAQ
|
|
671
787
|
|
|
672
788
|
### How do I add my own flat configs?
|
|
673
789
|
|
|
674
|
-
Use `extraConfigs` option.
|
|
790
|
+
Use `extraConfigs` option.
|
|
791
|
+
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.
|
|
792
|
+
These configs have a richer `rules` option, which allows you to apply more settings like `overrides` option does.
|
|
675
793
|
|
|
676
794
|
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](https://npmjs.com/eslint-flat-config-utils)) for this purpose.
|
|
677
795
|
|
|
678
796
|
### Do I have to install any of the used plugins?
|
|
679
797
|
|
|
680
|
-
Many plugins are direct dependencies on this package, but the rest (the majority) are optional peer dependencies which means you're responsible for making sure they're installed. eslint-config-un will refuse to work if a plugin is used but not installed.
|
|
798
|
+
Many plugins are direct dependencies on this package, but the rest (the majority) are optional peer dependencies which means you're responsible for making sure they're installed. eslint-config-un will refuse to work if a plugin is used but not installed.
|
|
799
|
+
Please run ESLint with our config once to get the list of dependencies to be installed manually.
|
|
681
800
|
|
|
682
801
|
### How do I know how eslint-config-un configures rules?
|
|
683
802
|
|
|
684
|
-
It's too much to document, so please have a look at the source code of our config.
|
|
803
|
+
It's too much to document, so please have a look at the source code of our config.
|
|
804
|
+
All the configs are placed inside `src/configs` directory.
|
|
685
805
|
|
|
686
806
|
### How does exactly eslint-config-un knows if some package is installed?
|
|
687
807
|
|
|
@@ -689,7 +809,8 @@ We use [`import-meta-resolve`](https://npmjs.com/import-meta-resolve) package to
|
|
|
689
809
|
|
|
690
810
|
### How can I know which configs will be enabled, for which rules autofix will be disabled, etc.?
|
|
691
811
|
|
|
692
|
-
You can enable the debug mode by setting `DEBUG=eslint-config-un` environment variable when running ESLint command.
|
|
812
|
+
You can enable the debug mode by setting `DEBUG=eslint-config-un` environment variable when running ESLint command.
|
|
813
|
+
We use [`obug` package](https://npmjs.com/obug) ([`debug`](https://npmjs.com/debug) alternative with compatible API) to print debug messages, so please refer to its documentation for more info.
|
|
693
814
|
|
|
694
815
|
Alternatively, you can use [`@eslint/config-inspector`](https://npmjs.com/@eslint/config-inspector) to inspect the final config.
|
|
695
816
|
|
|
@@ -697,36 +818,56 @@ Alternatively, you can use [`@eslint/config-inspector`](https://npmjs.com/@eslin
|
|
|
697
818
|
|
|
698
819
|
### Prerequisites
|
|
699
820
|
|
|
700
|
-
Node.JS and ESLint satisfy [minimum required versions](#installation).
|
|
821
|
+
Node.JS and ESLint satisfy [minimum required versions](#installation).
|
|
822
|
+
Please don't attempt to migrate to ESLint 9 and eslint-config-un at the same time.
|
|
701
823
|
|
|
702
824
|
### Migration guide
|
|
703
825
|
|
|
704
|
-
We recommend that every step and sub-step below is done in a separate commit and on a separate git branch.
|
|
826
|
+
We recommend that every step and sub-step below is done in a separate commit and on a separate git branch.
|
|
827
|
+
If necessary, any step should be additionally split into multiple commits.
|
|
828
|
+
Before committing, please do also run tests, formatter, other linters and tools to ensure that nothing became broken, if you have any.
|
|
705
829
|
|
|
706
|
-
1.
|
|
707
|
-
|
|
830
|
+
1. Dependencies:
|
|
831
|
+
1. Remove **ALL** ESLint related *dev* dependencies - be it plugins, parsers, whatever else or `eslint` itself.
|
|
832
|
+
This ensures correct versions of plugins will be resolved by eslint-config-un and saves you from other weird and hard to debug problems.
|
|
833
|
+
2. Install `eslint-config-un` following [the installation instructions](#installation).
|
|
834
|
+
2. If you're using `.js` config file, we highly recommend that you migrate to `.ts` one, or at least add `@ts-check` TypeScript directive to the former.
|
|
835
|
+
Please don't forget install [`jiti`](https://npmjs.com/jiti) for ESLint to able be to read your TypeScript config file.
|
|
708
836
|
3. Following your intuition or/and configs' options JSDoc documentation, migrate the existing config to the closest eslint-config-un equivalent.
|
|
709
|
-
1. Run ESLint for the first time (without `--fix`!).
|
|
837
|
+
1. Run ESLint for the first time (without `--fix`!).
|
|
838
|
+
The list of dependencies to be installed might be shown to you.
|
|
839
|
+
Please review whether those plugins are actually used/needed and act accordingly: install necessary plugins and disable configs which require packages you do not wish to install.
|
|
710
840
|
2. Rename rules on existing [`eslint` configuration comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments) if they have different plugin prefixes (the most common case is that `typescript-eslint` plugin has `ts` prefix in eslint-config-un instead of `@typescript-eslint`) **OR** change prefixes using [`pluginRenames` option](#plugin-prefixes-pluginrenames-option).
|
|
841
|
+
Look for `Definition for rule '<rule name>' was not found` comments
|
|
711
842
|
4. Perform the following two steps in any order:
|
|
712
843
|
1. Enable stylistic rules only and fix them automatically (if you wish to do so) by running ESLint with `--fix --fix-type problem,suggestion,layout` (the latter flag ensures auto removal of "unused" `eslint-disable` comments will not happen):
|
|
713
844
|
|
|
714
845
|
```ts
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
846
|
+
// ...
|
|
847
|
+
configs: {
|
|
848
|
+
// ...
|
|
849
|
+
noStylisticRules: {
|
|
850
|
+
enableRules: {
|
|
851
|
+
rules: true,
|
|
852
|
+
disableAllOtherRules: true,
|
|
853
|
+
},
|
|
719
854
|
},
|
|
720
|
-
|
|
855
|
+
// ...
|
|
856
|
+
},
|
|
857
|
+
// ...
|
|
721
858
|
```
|
|
722
859
|
|
|
723
860
|
**Note:** not every stylistic rule is auto-fixable and not all auto-fixes are safe to apply automatically (although we already maintain a list of rules for which we've disabled autofixes by default for these reasons).
|
|
724
861
|
|
|
725
862
|
Please carefully review automatically applied fixes and do not forget about problems requiring manual intervention.
|
|
726
|
-
|
|
863
|
+
It might be worth to fix stylistic issues in two stages: auto and manually fixable problems.
|
|
864
|
+
2. Now set `configs.noStylisticRules` to `true` to disable purely stylistic rules and run ESLint for the first time with the new config.
|
|
865
|
+
Please don't use `--fix` option - this may complicate things as you will have less idea of what's changed (plus some autofixes may be unsafe to automatically apply).
|
|
866
|
+
Thoroughly go through the report and:
|
|
727
867
|
- Decide which rules need to be disabled, enabled or changed the options of;
|
|
728
868
|
- Decide which `eslint-ignore` comments are no longer relevant and should be removed;
|
|
729
|
-
- Possibly set `ts.allowDefaultProject` to include files which are not part of any TypeScript project (tsconfig file), but for which TypeScript type-aware rules (rules requiring type information) should still work.
|
|
869
|
+
- Possibly set `ts.allowDefaultProject` to include files which are not part of any TypeScript project (tsconfig file), but for which TypeScript type-aware rules (rules requiring type information) should still work.
|
|
870
|
+
Conversely, if for some files type-aware linting should be disabled, specify them in `ts.configTypeAware.ignores` option (or set `ts.configTypeAware` to `false` to disable type-aware linting altogether);
|
|
730
871
|
- Add `<!-- eslint-skip -->` comments before fenced code blocks in Markdown files for which code parsing is failing;
|
|
731
872
|
- Fix/resolve any other issues and difficulties.
|
|
732
873
|
5. Remove `noStylisticRules` config and probably re-run ESLint as you would do normally to make sure everything is working as intended.
|
|
@@ -735,10 +876,11 @@ We recommend that every step and sub-step below is done in a separate commit and
|
|
|
735
876
|
|
|
736
877
|
### Why are there reports from `node` plugin in my frontend code?
|
|
737
878
|
|
|
738
|
-
All code is assumed to be Node.JS code by default (`eslint-plugin-n` plugin is run on such code).
|
|
879
|
+
All code is assumed to be Node.JS code by default (`eslint-plugin-n` plugin is run on such code).
|
|
880
|
+
Please specify `files`, `ignores` or disable `node` config altogether to avoid false positives.
|
|
739
881
|
|
|
740
882
|
<!-- eslint-disable-next-line markdown-preferences/heading-casing -->
|
|
741
|
-
### TypeError: Key `languageOptions`: Key `globals`: Global `AudioWorkletGlobalScope ` has leading or trailing whitespace
|
|
883
|
+
### TypeError: Key `languageOptions`: Key `globals`: Global `AudioWorkletGlobalScope ` has leading or trailing whitespace
|
|
742
884
|
|
|
743
885
|
Install `globals` package as a dev dependency.
|
|
744
886
|
|