eslint-config-un 0.10.0 → 1.0.0-alpha.1
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 +437 -85
- package/dist/angular-CZP5B6PU.js +314 -0
- package/dist/astro-VC37R5SD.js +83 -0
- package/dist/ava-IC73LJAD.js +46 -0
- package/dist/better-tailwind-IVMOH2XX.js +65 -0
- package/dist/case-police-HYINYUV4.js +32 -0
- package/dist/chunk-A4T36FF7.js +265 -0
- package/dist/chunk-CLYYBEIT.js +100 -0
- package/dist/chunk-FIQ2GO5T.js +938 -0
- package/dist/chunk-HDHWCCOH.js +35 -0
- package/dist/chunk-HJAZT7KW.js +106 -0
- package/dist/chunk-ZR5D2CB3.js +141 -0
- package/dist/cli-TYIGSEDW.js +41 -0
- package/dist/cloudfront-functions-CNIXOROP.js +199 -0
- package/dist/cspell-KQIOPQFW.js +33 -0
- package/dist/css-UYP436GL.js +61 -0
- package/dist/css-in-js-BWONGTRT.js +49 -0
- package/dist/cypress-SGO3AZ33.js +39 -0
- package/dist/de-morgan-MEFQ3C7W.js +24 -0
- package/dist/depend-HPAPNJQY.js +37 -0
- package/dist/ember-FB4WEBAS.js +70 -0
- package/dist/erasable-syntax-only-RKYYPNZS.js +33 -0
- package/dist/es-6UCBYG6E.js +8 -0
- package/dist/eslint-comments-GB63NHW5.js +41 -0
- package/dist/eslint-plugin-5TEJBMEH.js +58 -0
- package/dist/eslint-plugin-prettier-AFP3AEI3.js +1732 -0
- package/dist/graphql-CVFYA742.js +154 -0
- package/dist/html-XVGEOIYY.js +49 -0
- package/dist/import-MUM6PTDU.js +84 -0
- package/dist/index.d.ts +64871 -39724
- package/dist/index.js +411 -3998
- package/dist/jest-DUKU3RRL.js +136 -0
- package/dist/js-6FKBOXDA.js +91 -0
- package/dist/js-inline-UPNMUC5N.js +95 -0
- package/dist/jsdoc-VRWJC7BP.js +74 -0
- package/dist/json-schema-validator-Z3UT36NX.js +84 -0
- package/dist/jsonc-VJAG2XHR.js +59 -0
- package/dist/jsx-a11y-XNZEO3TT.js +8 -0
- package/dist/markdown-EH2PZC5H.js +166 -0
- package/dist/math-7EFRPUKE.js +32 -0
- package/dist/nextjs-USEAMMH5.js +42 -0
- package/dist/no-stylistic-rules-FTOCZXYG.js +7029 -0
- package/dist/no-unsanitized-GLQYPMO6.js +24 -0
- package/dist/node-3QT4ZZCH.js +64 -0
- package/dist/node-dependencies-3V2DRIYC.js +44 -0
- package/dist/package-json-LKTU3BJL.js +10 -0
- package/dist/perfectionist-JSUJHRIV.js +119 -0
- package/dist/pnpm-RMI4VGPL.js +67 -0
- package/dist/prefer-arrow-functions-UKGE6QML.js +30 -0
- package/dist/promise-7XLSHWXO.js +26 -0
- package/dist/qwik-7QOKCKW7.js +41 -0
- package/dist/react-3N7FZBRN.js +525 -0
- package/dist/regexp-3SPW4IJ5.js +26 -0
- package/dist/security-DDDRYKOQ.js +26 -0
- package/dist/solid-4CCWF2EY.js +47 -0
- package/dist/sonar-HGMQWXDH.js +39 -0
- package/dist/storybook-C6Q7Y4DD.js +40 -0
- package/dist/svelte-OYOVVZFW.js +126 -0
- package/dist/tailwind-42GL2ZLR.js +54 -0
- package/dist/tanstack-query-2M66QWTM.js +24 -0
- package/dist/testing-library-XLRJQGO6.js +112 -0
- package/dist/toml-V6MCXCML.js +57 -0
- package/dist/ts-T4IT4MIG.js +703 -0
- package/dist/turbo-NA3JLCR2.js +29 -0
- package/dist/unicorn-HV56AD7U.js +28 -0
- package/dist/unused-imports-5PUAMEBR.js +39 -0
- package/dist/vitest-DGDPTNFP.js +85 -0
- package/dist/vue-OLQU6OVH.js +372 -0
- package/dist/yaml-ED34EVJF.js +66 -0
- package/package.json +132 -85
- package/dist/index.cjs +0 -4199
- package/dist/index.d.cts +0 -43649
package/README.md
CHANGED
|
@@ -1,112 +1,464 @@
|
|
|
1
|
-
# eslint-config-un
|
|
1
|
+
# eslint-config-un [](https://npmjs.com/eslint-config-un)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
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.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Every major plugin** is included (50+ in total):
|
|
8
|
+
[ Vanilla JS rules](https://eslint.org/docs/latest/rules),
|
|
9
|
+
[ typescript-eslint](https://typescript-eslint.io/rules),
|
|
10
|
+
[🦄unicorn](https://npmjs.com/eslint-plugin-unicorn),
|
|
11
|
+
[⭐regexp](https://github.com/ota-meshi/eslint-plugin-regexp),
|
|
12
|
+
[ node](https://github.com/eslint-community/eslint-plugin-n),
|
|
13
|
+
[ vue](https://eslint.vuejs.org),
|
|
14
|
+
[ angular](https://github.com/angular-eslint/angular-eslint)
|
|
15
|
+
[ react](https://github.com/jsx-eslint/eslint-plugin-react) and 4 sister plugins,
|
|
16
|
+
[ solid](https://github.com/solidjs-community/eslint-plugin-solid),
|
|
17
|
+
[ tailwind](https://github.com/francoismassart/eslint-plugin-tailwindcss),
|
|
18
|
+
[ css](https://github.com/eslint/css),
|
|
19
|
+
[ yaml](https://github.com/ota-meshi/eslint-plugin-yml)
|
|
20
|
+
and many more;
|
|
21
|
+
- **Every single rule** was evaluated and given a reasonable default severity and options;
|
|
22
|
+
- **Extremely configurable:** you can easily override any rule's severity and **granularly** alter the default options;
|
|
23
|
+
- **Zero configuration by default:** exporting `eslintConfig()` from `eslint.config.ts` is enough to get started;
|
|
24
|
+
- **Strictly typed:** all the options and rule names exist in TypeScript types;
|
|
25
|
+
- **Well documented:** every single config, sub-config and their options are documented in JSDoc format;
|
|
26
|
+
- **Respects your `.gitignore`**: those files are not linted by default.
|
|
27
|
+
- Provides the ability **to disable autofix** on a per-rule basis.
|
|
28
|
+
- **Works great with Prettier**: conflicting rules are disabled if you use Prettier.
|
|
29
|
+
- **Rename plugin prefixes** easily if you would like to.
|
|
6
30
|
|
|
7
31
|
## Installation
|
|
8
32
|
|
|
33
|
+
Minimum supported versions:
|
|
34
|
+
- NodeJS: ^20.10 or >=21.2
|
|
35
|
+
- ESLint: ^9.15.0 (peer dependency)
|
|
36
|
+
|
|
9
37
|
```shell
|
|
10
|
-
npm i -D eslint-config-un
|
|
11
|
-
pnpm i -D eslint-config-un
|
|
12
|
-
yarn add -D eslint-config-un
|
|
38
|
+
npm i -D eslint-config-un eslint@latest
|
|
39
|
+
pnpm i -D eslint-config-un eslint@latest
|
|
40
|
+
yarn add -D eslint-config-un eslint@latest
|
|
13
41
|
```
|
|
14
42
|
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
Certain plugins are optional peer dependencies, which means that you need to install them manually if they are end up being used.
|
|
46
|
+
|
|
47
|
+
<details>
|
|
48
|
+
<summary>Optional peer dependencies & reason</summary>
|
|
49
|
+
|
|
50
|
+
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.
|
|
51
|
+
|
|
52
|
+
| Default plugin prefix | Package name | Reason |
|
|
53
|
+
| --------------------- | ------------ | ------ |
|
|
54
|
+
| `graphql` | `@graphql-eslint/eslint-plugin` | Heavy dependency `graphql` |
|
|
55
|
+
| `betterTailwindcss` | `eslint-plugin-better-tailwindcss` | Heavy dependency `tailwindcss` |
|
|
56
|
+
| `storybook` | `eslint-plugin-storybook` | Heavy dependency `storybook` |
|
|
57
|
+
| `tailwindcss` | `eslint-plugin-tailwindcss` | Heavy dependency `tailwindcss` |
|
|
58
|
+
| `turbo` | `eslint-plugin-turbo` | Heavy dependency `turbo` |
|
|
59
|
+
| `eslintPlugin` | `eslint-plugin-eslint-plugin` | Very specific plugin |
|
|
60
|
+
</details>
|
|
61
|
+
|
|
62
|
+
### Usage
|
|
63
|
+
|
|
64
|
+
In your `eslint.config.ts`:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import {eslintConfig} from 'eslint-config-un';
|
|
68
|
+
|
|
69
|
+
export default eslintConfig({
|
|
70
|
+
// ... optional configuration ...
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
<!-- eslint-disable-next-line markdown/no-missing-label-refs -->
|
|
75
|
+
> [!NOTE]
|
|
76
|
+
> 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.
|
|
77
|
+
|
|
15
78
|
## List of configs
|
|
16
79
|
|
|
17
|
-
|
|
18
|
-
- [Vanilla ESLint rules](https://eslint.org/docs/latest/rules/)
|
|
19
|
-
- [eslint-config-prettier](https://www.npmjs.com/package/eslint-config-prettier) to disable Prettier-incompatible rules
|
|
20
|
-
- [typescript-eslint](https://typescript-eslint.io/rules/)
|
|
21
|
-
- [vue](https://eslint.vuejs.org/rules/) (+ [vuejs-accessibility](https://www.npmjs.com/package/eslint-plugin-vuejs-accessibility) and [pinia](https://www.npmjs.com/package/eslint-plugin-pinia))
|
|
22
|
-
- [unicorn](https://www.npmjs.com/package/eslint-plugin-unicorn)
|
|
23
|
-
- [node](https://www.npmjs.com/package/eslint-plugin-n) (`eslint-plugin-n` with `node` prefix)
|
|
24
|
-
- [import](https://www.npmjs.com/package/eslint-plugin-import-x) (`eslint-plugin-import-x` with `import` prefix)
|
|
25
|
-
- [promise](https://www.npmjs.com/package/eslint-plugin-promise)
|
|
26
|
-
- [regexp](https://www.npmjs.com/package/eslint-plugin-regexp)
|
|
27
|
-
- [security](https://www.npmjs.com/package/eslint-plugin-security)
|
|
28
|
-
- [sonar](https://www.npmjs.com/package/eslint-plugin-sonarjs) (v3 since v0.4.0, v1 before)
|
|
29
|
-
- [tailwind](https://www.npmjs.com/package/eslint-plugin-tailwindcss)
|
|
30
|
-
- [jsonc](https://www.npmjs.com/package/eslint-plugin-jsonc) (since v0.1.4)
|
|
31
|
-
- [yaml](https://www.npmjs.com/package/eslint-plugin-yaml) (since v0.1.0)
|
|
32
|
-
- [toml](https://www.npmjs.com/package/eslint-plugin-toml) (since v0.1.3)
|
|
33
|
-
- [prefer-arrow-functions](https://www.npmjs.com/package/eslint-plugin-prefer-arrow-functions) (since v0.1.0)
|
|
34
|
-
- [eslint-comments](https://www.npmjs.com/package/@eslint-community/eslint-plugin-eslint-comments) (since v0.1.3)
|
|
35
|
-
- [package-json](https://www.npmjs.com/package/eslint-plugin-package-json) (since v0.1.5)
|
|
36
|
-
- [markdown](https://www.npmjs.com/package/@eslint/markdown) (since v0.2.0)
|
|
37
|
-
- `cssInJs` (since v0.2.0), using [`eslint-plugin-css`](https://www.npmjs.com/package/eslint-plugin-css)
|
|
38
|
-
- [jest](https://www.npmjs.com/package/eslint-plugin-jest) (+ [jest-extended](https://www.npmjs.com/package/eslint-plugin-jest-extended)) (since v0.3.0)
|
|
39
|
-
- [vitest](https://www.npmjs.com/package/@vitest/eslint-plugin) (since v0.3.0)
|
|
40
|
-
- [jsdoc](https://www.npmjs.com/package/eslint-plugin-jsdoc) (since v0.3.1)
|
|
41
|
-
- [perfectionist](https://www.npmjs.com/package/eslint-plugin-perfectionist) (since v0.4.0)
|
|
42
|
-
- [de-morgan](https://www.npmjs.com/package/eslint-plugin-de-morgan) (since v0.5.0)
|
|
43
|
-
- [qwik](https://www.npmjs.com/package/eslint-plugin-qwik) (since v0.6.0)
|
|
44
|
-
- [json-schema-validator](https://www.npmjs.com/package/eslint-plugin-json-schema-validator) (since v0.6.0)
|
|
45
|
-
- `angular` (since v0.7.0), using [`@angular-eslint/eslint-plugin`](https://www.npmjs.com/package/@angular-eslint/eslint-plugin) and [`@angular-eslint/eslint-plugin-template`](https://www.npmjs.com/package/@angular-eslint/eslint-plugin-template)
|
|
46
|
-
- `css` (since v0.7.0), using [`@eslint/css`](https://www.npmjs.com/package/@eslint/css)
|
|
47
|
-
- `noUnusedImports` (since v0.7.0), using [`eslint-plugin-unused-imports`](https://www.npmjs.com/package/eslint-plugin-unused-imports)
|
|
48
|
-
- `react` (since v0.8.0), using [`@eslint-react/eslint-plugin`](https://www.npmjs.com/package/@eslint-react/eslint-plugin), [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react), [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks), [`eslint-plugin-react-refresh`](https://www.npmjs.com/package/eslint-plugin-react-refresh) and [`eslint-plugin-react-compiler`](https://www.npmjs.com/package/eslint-plugin-react-compiler)
|
|
49
|
-
- `jsxA11y` (since v0.8.0), using [`eslint-plugin-jsx-a11y`](https://www.npmjs.com/package/eslint-plugin-jsx-a11y)
|
|
50
|
-
- `pnpm` (since v0.8.0), using [`eslint-plugin-pnpm`](https://www.npmjs.com/package/eslint-plugin-pnpm)
|
|
51
|
-
- `nextJs` (since v0.9.0), using [`@next/eslint-plugin-next`](https://www.npmjs.com/package/@next/eslint-plugin-next)
|
|
52
|
-
- `casePolice` (since v0.9.0), using [`eslint-plugin-case-police`](https://www.npmjs.com/package/eslint-plugin-case-police)
|
|
53
|
-
- `astro` (since v0.9.0), using [`eslint-plugin-astro`](https://www.npmjs.com/package/eslint-plugin-astro)
|
|
54
|
-
- `svelte` (since v0.10.0), using [`eslint-plugin-svelte`](https://www.npmjs.com/package/eslint-plugin-svelte)
|
|
55
|
-
- `es` (since v0.10.0), using [`eslint-plugin-es-x`](https://www.npmjs.com/package/eslint-plugin-es-x)
|
|
56
|
-
- `cloudfrontFunctions` (since v0.10.0) for [Amazon CloudFront Functions](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-functions.html)
|
|
57
|
-
- `solid` (since v0.10.0), using [`eslint-plugin-solid`](https://www.npmjs.com/package/eslint-plugin-solid)
|
|
58
|
-
- `nodeDependencies` (since v0.10.0), using [`eslint-plugin-node-dependencies`](https://www.npmjs.com/package/eslint-plugin-node-dependencies)
|
|
59
|
-
- `jsInline` (since v0.10.0), using [`eslint-plugin-html`](https://www.npmjs.com/package/eslint-plugin-html)
|
|
60
|
-
- `html` (since v0.10.0), using [`@html-eslint/eslint-plugin`](https://www.npmjs.com/package/@html-eslint/eslint-plugin)
|
|
80
|
+
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.
|
|
61
81
|
|
|
62
|
-
|
|
82
|
+
You can enable any Config by setting it to `true` or an object with the Config's options. Passing `false` disables the Config.
|
|
83
|
+
|
|
84
|
+
<details>
|
|
85
|
+
<summary>Config interface & docs</summary>
|
|
86
|
+
|
|
87
|
+
The Config has the following interface (exact types are simplified for docs):
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
type UnConfig =
|
|
91
|
+
| boolean
|
|
92
|
+
| {
|
|
93
|
+
files?: string[];
|
|
94
|
+
ignores?: string[];
|
|
95
|
+
|
|
96
|
+
[RuleName in ('overrides' | 'overridesAny')]?: {
|
|
97
|
+
[RuleName in string]:
|
|
98
|
+
| Severity
|
|
99
|
+
| [Severity, RuleOptions[RuleName]]
|
|
100
|
+
| ((
|
|
101
|
+
// These are severity and options *maybe* set by eslint-config-un
|
|
102
|
+
ourSeverity: Severity,
|
|
103
|
+
ourOptions?: RuleOptions[RuleName],
|
|
104
|
+
) => Severity | [Severity, RuleOptions[RuleName]]);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
forceSeverity?: '2' | 'error' | '1' | 'warn';
|
|
108
|
+
|
|
109
|
+
[`config${string}`]: UnConfig; // These are Sub-configs
|
|
110
|
+
|
|
111
|
+
[customOptions: string]: unknown; // Custom config options, individual for each config
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
type Severity = 0 | 1 | 2 | 'off' | 'warn' | 'error';
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- The Config is usually tied to a one or more ESLint plugins and produces one or more ESLint flat config objects.
|
|
118
|
+
- Sub-configs are the same as Configs, but configured within Config options. All Sub-configs use `configXXX` naming convention.
|
|
119
|
+
- 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`.
|
|
120
|
+
- `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.
|
|
121
|
+
- `ignores` is exactly the same as ESLint's `ignores`.
|
|
122
|
+
- `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.
|
|
123
|
+
- 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.
|
|
124
|
+
- `overridesAny` will be applied **after** `overrides`.
|
|
125
|
+
- `forceSeverity` allows to bulk override the severity of all the rules not overridden via `overrides` or `overridesAny`.
|
|
126
|
+
</details>
|
|
127
|
+
|
|
128
|
+
<br>
|
|
129
|
+
|
|
130
|
+
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.
|
|
131
|
+
|
|
132
|
+
### Most popular and well known
|
|
133
|
+
|
|
134
|
+
| Un config name | Enabled by default?<br>(optional condition) | Primary plugin(s) (`default-prefix`) | Description/Notes |
|
|
135
|
+
| -------------- | ------------------------------------------- | ------------------------------------ | ----------------- |
|
|
136
|
+
|  `js` | ✅ | [Vanilla ESLint rules](https://eslint.org/docs/latest/rules) | - |
|
|
137
|
+
|  `ts` | ✅ | [typescript-eslint](https://npmjs.com/typescript-eslint) (`ts`) | Only rules **not** requiring type information. |
|
|
138
|
+
|  `ts/typeAware` | ✅ | ^ | Only rules requiring type information. |
|
|
139
|
+
|  `ts/noTypeAssertion` | ✅ | [eslint-plugin-no-type-assertion](https://npmjs.com/eslint-plugin-no-type-assertion) (`no-type-assertion`) | - |
|
|
140
|
+
|  `ts/sortTsconfigKeys` | ❌ | - | Sort type-level and `compilerOptions` keys in tsconfig files. |
|
|
141
|
+
| 🦄 `unicorn` | ✅ | [eslint-plugin-unicorn](https://npmjs.com/eslint-plugin-unicorn) (`unicorn`) | - |
|
|
142
|
+
| ⭐ `regexp` | ✅ | [eslint-plugin-regexp](https://npmjs.com/eslint-plugin-regexp) (`regexp`) | - |
|
|
143
|
+
| `promise` | ✅ | [eslint-plugin-promise](https://npmjs.com/eslint-plugin-promise) (`promise`) | - |
|
|
144
|
+
| `import` | ✅ | [eslint-plugin-import-x](https://npmjs.com/eslint-plugin-import-x) (`import`) | - |
|
|
145
|
+
| `sonarjs` | ✅ | [eslint-plugin-sonarjs](https://npmjs.com/eslint-plugin-sonarjs) (`sonarjs`) | - |
|
|
146
|
+
| `eslintComments` | ✅ | [@eslint-community/eslint-plugin-eslint-comments](https://npmjs.com/@eslint-community/eslint-plugin-eslint-comments) (`@eslint-community/eslint-comments`) | Since v0.1.3 |
|
|
147
|
+
| `jsdoc` | ✅ | [eslint-plugin-jsdoc](https://npmjs.com/eslint-plugin-jsdoc) (`jsdoc`) | Since v0.3.1 |
|
|
148
|
+
| `jsdoc/typescript` | ✅ (`ts` config is enabled) | - | Config for disabling or disabling certain rules for TypeScript files |
|
|
149
|
+
|
|
150
|
+
### Web frameworks & related
|
|
151
|
+
|
|
152
|
+
| Un config name | Enabled by default?<br>(optional condition) | Primary plugin(s) (`default-prefix`) | Description/Notes |
|
|
153
|
+
| -------------- | ------------------------------------------- | ------------------------------------ | ----------------- |
|
|
154
|
+
|  `vue` | ✅ (`vue` is installed) | [eslint-plugin-vue](https://npmjs.com/eslint-plugin-vue) (`vue`) | - |
|
|
155
|
+
|  `vue/a11y` | ✅ | [eslint-plugin-vuejs-accessibility](https://npmjs.com/eslint-plugin-vuejs-accessibility) (`vuejs-accessibility`) | - |
|
|
156
|
+
|  `vue/pinia` | ✅ | [eslint-plugin-pinia](https://npmjs.com/eslint-plugin-pinia) (`pinia`) | - |
|
|
157
|
+
|  `angular` | ✅ (`@angular/core` is installed) | [@angular-eslint/eslint-plugin](https://npmjs.com/@angular-eslint/eslint-plugin) (`@angular-eslint`) | Since v0.78.0 |
|
|
158
|
+
|  `angular/template` | ✅ | [@angular-eslint/eslint-plugin/template](https://npmjs.com/@angular-eslint/eslint-plugin/template) (`@angular-eslint/template`) | - |
|
|
159
|
+
|  `react` | ✅ (`react` is installed) | [eslint-plugin-react](https://npmjs.com/eslint-plugin-react) (`react`) | Since v0.8.0 |
|
|
160
|
+
|  `react/reactX` | ✅ | [@eslint-react/eslint-plugin](https://npmjs.com/@eslint-react/eslint-plugin) (`@eslint-react`) | - |
|
|
161
|
+
|  `react/hooks` | ✅ | [eslint-plugin-react-hooks](https://npmjs.com/eslint-plugin-react-hooks) (`react-hooks`)<br>[@eslint-react/eslint-plugin](https://npmjs.com/@eslint-react/eslint-plugin) (`@eslint-react`) | Includes rules with `@eslint-react/hooks-extra` prefix from `@eslint-react/eslint-plugin` |
|
|
162
|
+
|  `react/dom` | ✅ (`react-dom` is installed) | [@eslint-react/eslint-plugin](https://npmjs.com/@eslint-react/eslint-plugin) (`@eslint-react`)<br>[eslint-plugin-react](https://npmjs.com/eslint-plugin-react) | Includes rules with `@eslint-react/dom` prefix from `@eslint-react/eslint-plugin` and DOM related rules from `eslint-plugin-react` |
|
|
163
|
+
|  `react/refresh` | ✅ | [eslint-plugin-react-refresh](https://npmjs.com/eslint-plugin-react-refresh) (`react-refresh`) | - |
|
|
164
|
+
|  `react/compiler` | ✅ (if React version is at least 19) | [eslint-plugin-react-compiler](https://npmjs.com/eslint-plugin-react-compiler) (`react-compiler`) | - |
|
|
165
|
+
|  `react/allowDefaultExportsInJsxFiles` | ✅ | - | Config that allows default exports in all JSX files |
|
|
166
|
+
|  `nextJs` | ✅ (`next` is installed) | [@next/eslint-plugin-next](https://npmjs.com/@next/eslint-plugin-next) (`@next/next`) | Since v0.9.0 |
|
|
167
|
+
|  `solid` | ✅ (`solid-js` is installed) | [eslint-plugin-solid](https://npmjs.com/eslint-plugin-solid) (`solid`) | Since v0.10.0 |
|
|
168
|
+
|  `qwik` | ✅ (`@builder.io/qwik` or `@qwik.dev/core` is installed) | [eslint-plugin-qwik](https://npmjs.com/eslint-plugin-qwik) (`qwik`) | Since v0.6.0 |
|
|
169
|
+
|  `astro` | ✅ (`astro` is installed) | [eslint-plugin-astro](https://npmjs.com/eslint-plugin-astro) (`astro`) | Since v0.9.0<br>Without A11Y rules |
|
|
170
|
+
|  `astro/jsxA11y` | ✅ | ^ | Only A11Y rules from `eslint-plugin-astro` |
|
|
171
|
+
|  `svelte` | ✅ (`svelte` is installed) | [eslint-plugin-svelte](https://npmjs.com/eslint-plugin-svelte) (`svelte`) | Since v0.10.0 |
|
|
172
|
+
|  `ember` | ✅ (`ember-source` is installed) | [eslint-plugin-ember](https://npmjs.com/eslint-plugin-ember) (`ember`) | Since v1.0.0 |
|
|
173
|
+
|  `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 |
|
|
174
|
+
|  `tailwind` | ❌ | [eslint-plugin-tailwindcss](https://npmjs.com/eslint-plugin-tailwindcss) (`tailwindcss`) | Only supports v3 |
|
|
175
|
+
|
|
176
|
+
### Runtimes & related
|
|
177
|
+
|
|
178
|
+
| Un config name | Enabled by default?<br>(optional condition) | Primary plugin(s) (`default-prefix`) | Description/Notes |
|
|
179
|
+
| -------------- | ------------------------------------------- | ------------------------------------ | ----------------- |
|
|
180
|
+
|  `node` | ✅ | [eslint-plugin-n](https://npmjs.com/eslint-plugin-n) (`node`) | - |
|
|
181
|
+
|  `packageJson` | ❌ | [eslint-plugin-package-json](https://npmjs.com/eslint-plugin-package-json) (`package-json`) | Since v0.1.5 |
|
|
182
|
+
|  `nodeDependencies` | ❌ | [eslint-plugin-node-dependencies](https://npmjs.com/eslint-plugin-node-dependencies) (`node-dependencies`) | Since v0.10.0 |
|
|
183
|
+
|  `depend` | ❌ | [eslint-plugin-depend](https://npmjs.com/eslint-plugin-depend) (`depend`) | Since v1.0.0 |
|
|
184
|
+
|  `pnpm` | ✅ (pnpm is detected as a package manager) | [eslint-plugin-pnpm](https://npmjs.com/eslint-plugin-pnpm) (`pnpm`) | Since v0.8.0<br>Does nothing, split into sub-configs |
|
|
185
|
+
|  `pnpm/packageJson` | ✅ | ^ | Plugin rules related to `package.json` files |
|
|
186
|
+
|  `pnpm/pnpmWorkspace` | ✅ | ^ | Plugin rules related to `pnpm-workspace.yaml` file |
|
|
187
|
+
|  `cloudfrontFunctions` | ❌ | - | Since v0.10.0<br>For linting [Amazon CloudFront Functions](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-functions.html) written for JavaScript Runtime v2 |
|
|
188
|
+
|  `cloudfrontFunctions/V1` | ❌ | - | Same, but for JavaScript Runtime v1 functions |
|
|
189
|
+
|
|
190
|
+
### Languages
|
|
191
|
+
|
|
192
|
+
| Un config name | Enabled by default?<br>(optional condition) | Primary plugin(s) (`default-prefix`) | Description/Notes |
|
|
193
|
+
| -------------- | ------------------------------------------- | ------------------------------------ | ----------------- |
|
|
194
|
+
|  `markdown` | ✅ | [@eslint/markdown](https://npmjs.com/@eslint/markdown) (`markdown`) | Since v0.7.0<br>Configured to also lint fenced code blocks |
|
|
195
|
+
|  `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 |
|
|
196
|
+
|  `css` | ✅ (unless `stylelint` is installed) | [@eslint/css](https://npmjs.com/@eslint/css) (`css`) | Since v0.7.0 |
|
|
197
|
+
|  `cssInJs` | ✅ | [eslint-plugin-css](https://npmjs.com/eslint-plugin-css) (`css-in-js`) | Since v0.2.0<br>Lints inlined CSS |
|
|
198
|
+
| `jsxA11y` | ✅ | [eslint-plugin-jsx-a11y](https://npmjs.com/eslint-plugin-jsx-a11y) (`jsx-a11y`) | Since v0.8.0 |
|
|
199
|
+
|  `yaml` | ❌ | [eslint-plugin-yaml](https://npmjs.com/eslint-plugin-yaml) (`yaml`) | Since v0.1.0 |
|
|
200
|
+
|  `jsonc` | ❌ | [eslint-plugin-jsonc](https://npmjs.com/eslint-plugin-jsonc) (`jsonc`) | Since v0.1.4<br>Supports JSON, JSON5, JSONC |
|
|
201
|
+
| `jsonc/json` | ❌ | ^ | Config exclusively for `.json` files, does nothing by default |
|
|
202
|
+
| `jsonc/jsonc` | ❌ | ^ | Config exclusively for `.jsonc` files, does nothing by default |
|
|
203
|
+
| `jsonc/json5` | ❌ | ^ | Config exclusively for `.json5` files, does nothing by default |
|
|
204
|
+
| `jsonSchemaValidator` | ❌ | [eslint-plugin-json-schema-validator](https://npmjs.com/eslint-plugin-json-schema-validator) (`json-schema-validator`) | Since v0.6.0 |
|
|
205
|
+
|  `toml` | ❌ | [eslint-plugin-toml](https://npmjs.com/eslint-plugin-toml) (`toml`) | Since v0.1.3 |
|
|
206
|
+
|  `html` | ✅ | [@html-eslint/eslint-plugin](https://npmjs.com/@html-eslint/eslint-plugin) (`@html-eslint`) | Since v0.10.0 |
|
|
207
|
+
|  `graphql` | ✅ (`graphql` is installed) | [@graphql-eslint/eslint-plugin](https://npmjs.com/@graphql-eslint/eslint-plugin) (`graphql`) | Since v1.0.0 |
|
|
208
|
+
|
|
209
|
+
### JS/TS - Miscellaneous
|
|
210
|
+
|
|
211
|
+
| Un config name | Enabled by default?<br>(optional condition) | Primary plugin(s) (`default-prefix`) | Description/Notes |
|
|
212
|
+
| -------------- | ------------------------------------------- | ------------------------------------ | ----------------- |
|
|
213
|
+
| `security` | ❌ | [eslint-plugin-security](https://npmjs.com/eslint-plugin-security) (`security`) | - |
|
|
214
|
+
| `unusedImports` | ❌ | [eslint-plugin-unused-imports](https://npmjs.com/eslint-plugin-unused-imports) (`unused-imports`) | Since v0.7.0 |
|
|
215
|
+
| `unusedImports/noUnusedVars` | ❌ | ^ | Disables [`no-unused-vars`](https://eslint.org/docs/latest/rules/no-unused-vars), [`ts/no-unused-vars`](https://typescript-eslint.io/rules/no-unused-vars) and [`sonarjs/no-unused-vars`](https://sonarsource.github.io/rspec/#/rspec/S1481/javascript) rules in favor of `unused-imports/no-unused-vars` |
|
|
216
|
+
| `prefer-arrow-functions` | ❌ | [eslint-plugin-prefer-arrow-functions](https://npmjs.com/eslint-plugin-prefer-arrow-functions) (`prefer-arrow-functions`) | Since v0.1.0 |
|
|
217
|
+
| `perfectionist` | ❌ | [eslint-plugin-perfectionist](https://npmjs.com/eslint-plugin-perfectionist) (`perfectionist`) | Since v0.4.0<br>Supports sub-configs for each rule from the plugin since v1.0.0 |
|
|
218
|
+
| `de-morgan` | ❌ | [eslint-plugin-de-morgan](https://npmjs.com/eslint-plugin-de-morgan) (`de-morgan`) | Since v0.5.0 |
|
|
219
|
+
| `es` | ❌ | [eslint-plugin-es-x](https://npmjs.com/eslint-plugin-es-x) (`es-x`) | Since v0.10.0 |
|
|
220
|
+
| `jsInline` | ✅ | [eslint-plugin-html](https://npmjs.com/eslint-plugin-html) (`html`) | Since v0.10.0<br>For linting inlined JS in HTML files |
|
|
221
|
+
| `math` | ✅ | [eslint-plugin-math](https://npmjs.com/eslint-plugin-math) (`math`) | Since v1.0.0 |
|
|
222
|
+
| `erasableSyntaxOnly` | ❌ | [eslint-plugin-erasable-syntax-only](https://npmjs.com/eslint-plugin-erasable-syntax-only) (`erasable-syntax-only`) | Since v1.0.0 |
|
|
223
|
+
|
|
224
|
+
### Libraries
|
|
225
|
+
|
|
226
|
+
| Un config name | Enabled by default?<br>(optional condition) | Primary plugin(s) (`default-prefix`) | Description/Notes |
|
|
227
|
+
| -------------- | ------------------------------------------- | ------------------------------------ | ----------------- |
|
|
228
|
+
| `jest` | ✅ (`jest` is installed) | [eslint-plugin-jest](https://npmjs.com/eslint-plugin-jest) (`jest`) | Since v0.3.0 |
|
|
229
|
+
| `jest/extended` | ✅ (`jest-extended` is installed) | [eslint-plugin-jest-extended](https://npmjs.com/eslint-plugin-jest-extended) (`jest-extended`) | - |
|
|
230
|
+
| `jest/typescript` | ✅ (`ts` config is enabled) | [eslint-plugin-jest](https://npmjs.com/eslint-plugin-jest) (`jest`) | Only TypeScript-specific rules from `eslint-plugin-jest` |
|
|
231
|
+
| `vitest` | ✅ (`vitest` is installed) | [@vitest/eslint-plugin](https://npmjs.com/@vitest/eslint-plugin) (`vitest`) | Since v0.3.0 |
|
|
232
|
+
| `ava` | ✅ (`ava` is installed) | [eslint-plugin-ava](https://npmjs.com/eslint-plugin-ava) (`ava`) | Since v1.0.0 |
|
|
233
|
+
|  `testingLibrary` | ✅ (`@testing-library/dom` is installed) | [eslint-plugin-testing-library](https://npmjs.com/eslint-plugin-testing-library) (`testing-library`) | Since v1.0.0 |
|
|
234
|
+
| `tanstackQuery` | ✅ (`@tanstack/query-core` is installed) | [@tanstack/eslint-plugin-query](https://npmjs.com/@tanstack/eslint-plugin-query) (`@tanstack/query`) | Since v1.0.0 |
|
|
235
|
+
|  `storybook` | ✅ (`storybook` is installed) | [eslint-plugin-storybook](https://npmjs.com/eslint-plugin-storybook) (`storybook`) | Since v1.0.0 |
|
|
236
|
+
|  `cypress` | ✅ (`cypress` is installed) | [eslint-plugin-cypress](https://npmjs.com/eslint-plugin-cypress) (`cypress`) | Since v1.0.0 |
|
|
237
|
+
|  `turbo` | ✅ (`turbo` is installed) | [eslint-plugin-turbo](https://npmjs.com/eslint-plugin-turbo) (`turbo`) | Since v1.0.0 |
|
|
238
|
+
|
|
239
|
+
### Miscellaneous
|
|
240
|
+
|
|
241
|
+
| Un config name | Enabled by default?<br>(optional condition) | Primary plugin(s) (`default-prefix`) | Description/Notes |
|
|
242
|
+
| -------------- | ------------------------------------------- | ------------------------------------ | ----------------- |
|
|
243
|
+
| `casePolice` | ❌ | [eslint-plugin-case-police](https://npmjs.com/eslint-plugin-case-police) (`case-police`) | Since v0.9.0 |
|
|
244
|
+
| `noStylisticRules` | ❌ | - | Since v1.0.0<br>Config to disable most of the stylistic rules. Can be useful when integrating eslint-config-un into an existing project. |
|
|
245
|
+
| `noUnsanitized` | ✅ | [eslint-plugin-no-unsanitized](https://npmjs.com/eslint-plugin-no-unsanitized) (`no-unsanitized`) | Since v1.0.0 |
|
|
246
|
+
|  `cspell` | ❌ | [@cspell/eslint-plugin](https://npmjs.com/package/@cspell/eslint-plugin) (`@cspell`) | Since v1.0.0 |
|
|
247
|
+
|  `eslintPlugin` | ❌ | [eslint-plugin-eslint-plugin](https://npmjs.com/eslint-plugin-eslint-plugin) (`eslint-plugin`) | Since v1.0.0<br>For linting ESLint plugins |
|
|
248
|
+
|
|
249
|
+
## How to use
|
|
250
|
+
|
|
251
|
+
### Rules configuration (`configs` and `extraConfigs` option)
|
|
252
|
+
|
|
253
|
+
Example of configuration:
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
import {eslintConfig} from 'eslint-config-un';
|
|
257
|
+
|
|
258
|
+
export default eslintConfig({
|
|
259
|
+
configs: {
|
|
260
|
+
// This is a Config
|
|
261
|
+
node: {
|
|
262
|
+
// By default `node` rules are applied to all files, so let's narrow the file list down
|
|
263
|
+
files: ['backend/**'],
|
|
264
|
+
},
|
|
265
|
+
vue: {
|
|
266
|
+
// For some reason we're not ready to lint *.vue files
|
|
267
|
+
files: [],
|
|
268
|
+
// This is a Sub-config
|
|
269
|
+
configPinia: {
|
|
270
|
+
ignores: ['./path/to/pinia/store/with-many-error.ts'],
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
// This config is disabled too, and if we provide an object with configuration, it will be enabled too
|
|
274
|
+
perfectionist: {
|
|
275
|
+
files: ['src/big-list-of-something.ts'],
|
|
276
|
+
overrides: {
|
|
277
|
+
'perfectionist/sort-objects': 2,
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
// This plugin is enabled by default, but we don't use JSDoc so don't need it
|
|
281
|
+
jsdoc: false,
|
|
282
|
+
// This plugin is conversely disabled by default, but we want to use it
|
|
283
|
+
security: true,
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
#### Providing user defined flag configs
|
|
289
|
+
|
|
290
|
+
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.
|
|
291
|
+
|
|
292
|
+
Example:
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
import {eslintConfig} from 'eslint-config-un';
|
|
296
|
+
|
|
297
|
+
export default eslintConfig({
|
|
298
|
+
configs: {
|
|
299
|
+
/* ... */
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
extraConfigs: [
|
|
303
|
+
{
|
|
304
|
+
files: ['src/big-list-of-something.ts'],
|
|
305
|
+
rules: {
|
|
306
|
+
'perfectionist/sort-objects': 2,
|
|
307
|
+
'perfectionist/sort-object-types': 2,
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
|
|
311
|
+
// More flat configs ...
|
|
312
|
+
],
|
|
313
|
+
});
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Plugin prefixes (`pluginRenames` option)
|
|
63
317
|
|
|
64
|
-
|
|
65
|
-
- Every block of rules supports `overrides` for rules.
|
|
66
|
-
- Designed to be used separately from Prettier: *almost* all the rules potentially conflicting with Prettier are disabled *by default*.
|
|
67
|
-
- Written in TypeScript so all the options are typed.
|
|
318
|
+
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`.
|
|
68
319
|
|
|
69
|
-
|
|
320
|
+
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.
|
|
70
321
|
|
|
71
|
-
|
|
322
|
+
#### Default renames
|
|
72
323
|
|
|
73
|
-
|
|
74
|
-
|
|
324
|
+
| Plugin | Suggested prefix | Our prefix | Reason |
|
|
325
|
+
| -------------------------------------------------------------------- | -------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
326
|
+
| [`typescript-eslint`](https://npmjs.com/typescript-eslint) | `@typescript-eslint` | `ts` | More concise and convenient to use |
|
|
327
|
+
| [`eslint-plugin-import-x`](https://npmjs.com/eslint-plugin-import-x) | `import-x` | `import` | This plugin is a fork and is meant to replace the original plugin with `import` prefix |
|
|
328
|
+
| [`eslint-plugin-n`](https://npmjs.com/eslint-plugin-n) | `n` | `node` | Same ^ |
|
|
329
|
+
| [`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 |
|
|
330
|
+
|
|
331
|
+
<!-- eslint-disable-next-line markdown/no-missing-label-refs -->
|
|
332
|
+
> [!NOTE]
|
|
333
|
+
> 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.
|
|
334
|
+
|
|
335
|
+
<!-- eslint-disable-next-line markdown/no-missing-label-refs -->
|
|
336
|
+
> [!WARNING] Renaming plugins and `eslint-disable` directives
|
|
337
|
+
> If you rename a plugin, you will have to manually rename the rules within `eslint-disable-*` directives.
|
|
338
|
+
|
|
339
|
+
### Disabling rule autofix
|
|
340
|
+
|
|
341
|
+
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. 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.
|
|
342
|
+
|
|
343
|
+
To disable autofix for a rule, use an object notation for the rule entry:
|
|
344
|
+
|
|
345
|
+
```ts
|
|
75
346
|
import {eslintConfig} from 'eslint-config-un';
|
|
76
347
|
|
|
77
348
|
export default eslintConfig({
|
|
78
|
-
|
|
349
|
+
configs: {
|
|
350
|
+
unicorn: {
|
|
351
|
+
overrides: {
|
|
352
|
+
'unicorn/better-regex': {
|
|
353
|
+
severity: 2,
|
|
354
|
+
disableAutofix: 'prefixed', // or `unprefixed` or `true`/`false`
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
},
|
|
79
359
|
});
|
|
80
360
|
```
|
|
81
361
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
362
|
+
* `unprefixed`: will disable autofix without changing the name of the rule, but it will be disabled for **all** files.
|
|
363
|
+
* `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.
|
|
364
|
+
* `true`: use the default autofix disabling method, determined in `disableAutofixMethod.default` root option, which defaults to `unprefixed`.
|
|
365
|
+
* `false`: re-enable autofix for the rule (does nothing if autofix for this rule is disabled anywhere else with `unprefixed` method).
|
|
366
|
+
|
|
367
|
+
## Configs notes
|
|
368
|
+
|
|
369
|
+
### TypeScript
|
|
370
|
+
|
|
371
|
+
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. 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.
|
|
372
|
+
|
|
373
|
+
### Frontend frameworks
|
|
374
|
+
|
|
375
|
+
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.
|
|
376
|
+
|
|
377
|
+
#### Vue
|
|
378
|
+
|
|
379
|
+
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.
|
|
380
|
+
|
|
381
|
+
#### Angular
|
|
382
|
+
|
|
383
|
+
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.
|
|
384
|
+
|
|
385
|
+
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.
|
|
386
|
+
|
|
387
|
+
#### React
|
|
388
|
+
|
|
389
|
+
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.
|
|
390
|
+
|
|
391
|
+
### Markdown
|
|
392
|
+
|
|
393
|
+
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`](https://npmjs.com/@eslint/markdown) that provides that functionality will create virtual files for each code block with the same extension as specified after ```.
|
|
105
394
|
|
|
106
395
|
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.
|
|
107
396
|
|
|
108
|
-
##
|
|
397
|
+
## Other root options
|
|
398
|
+
|
|
399
|
+
### `ignores`
|
|
400
|
+
|
|
401
|
+
Specifies a list of globally ignored files. By default will be merged with our ignore patterns, unless `overrideIgnores` is set to `true`.
|
|
402
|
+
|
|
403
|
+
### `overrideIgnores`
|
|
404
|
+
|
|
405
|
+
Set to `true` if you don't want `ignores` to be merged with our ignore patterns, which are `['**/dist']`.
|
|
406
|
+
|
|
407
|
+
### `gitignore`
|
|
408
|
+
|
|
409
|
+
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](https://npmjs.com/eslint-config-flat-gitignore), which provides this functionality in the first place.
|
|
410
|
+
|
|
411
|
+
### `mode`
|
|
412
|
+
|
|
413
|
+
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.
|
|
414
|
+
|
|
415
|
+
### `disablePrettierIncompatibleRules`
|
|
416
|
+
|
|
417
|
+
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. Defaults to `true` if `prettier` package is installed.
|
|
418
|
+
|
|
419
|
+
### `forceSeverity`
|
|
420
|
+
|
|
421
|
+
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.
|
|
422
|
+
|
|
423
|
+
## FAQ
|
|
424
|
+
|
|
425
|
+
### How do I add my own flat configs?
|
|
426
|
+
|
|
427
|
+
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.
|
|
428
|
+
|
|
429
|
+
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.
|
|
430
|
+
|
|
431
|
+
### Do I have to install any of the used plugins?
|
|
432
|
+
|
|
433
|
+
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.
|
|
434
|
+
|
|
435
|
+
### How do I know how eslint-config-un configures rules?
|
|
436
|
+
|
|
437
|
+
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.
|
|
438
|
+
|
|
439
|
+
### How does exactly eslint-config-un knows if some package is installed?
|
|
440
|
+
|
|
441
|
+
We use [`local-pkg`](https://npmjs.com/local-pkg) package to detect if a package is installed.
|
|
442
|
+
|
|
443
|
+
### How can I know which configs will be enabled, for which rules autofix will be disabled, etc.?
|
|
444
|
+
|
|
445
|
+
You can enable the debug mode by setting `DEBUG=eslint-config-un` environment variable when running ESLint command.
|
|
446
|
+
|
|
447
|
+
Alternatively, you can use [`@eslint/config-inspector`](https://npmjs.com/package/@eslint/config-inspector) to inspect the final config.
|
|
448
|
+
|
|
449
|
+
## Troubleshooting & caveats
|
|
109
450
|
|
|
110
451
|
### TypeError: Key `languageOptions`: Key `globals`: Global `AudioWorkletGlobalScope ` has leading or trailing whitespace.
|
|
111
452
|
|
|
112
|
-
Install `globals` package as a dev dependency.
|
|
453
|
+
Install `globals` package as a dev dependency.
|
|
454
|
+
|
|
455
|
+
### Some dependencies are [bundled with `bundleDependencies` feature](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bundledependencies)
|
|
456
|
+
|
|
457
|
+
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:
|
|
458
|
+
|
|
459
|
+
| Package name | Reason |
|
|
460
|
+
| ------------ | ------ |
|
|
461
|
+
| [`eslint-plugin-prettier`](https://npmjs.com/eslint-plugin-prettier) | Patched by us to enable formatting of "fenced code blocks" inside Markdown files |
|
|
462
|
+
| [`eslint-plugin-no-type-assertion`](https://npmjs.com/eslint-plugin-no-type-assertion) | Has outdated requirements of peer dependencies |
|
|
463
|
+
| [`@angular-eslint/eslint-plugin-template@17.5.3`](https://npmjs.com/package/@angular-eslint/eslint-plugin-template/v/17.5.3) | Old version with outdated requirements of peer dependencies |
|
|
464
|
+
| [`@angular-eslint/eslint-plugin@18.4.3`](https://npmjs.com/package/@angular-eslint/eslint-plugin-template/v/18.4.3) | ^ |
|