@luxass/eslint-config 4.0.0-beta.8 → 4.0.0
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 +351 -48
- package/dist/{chunk-TQ476NL2.mjs → chunk-4YBQZLPS.mjs} +13 -2
- package/dist/{chunk-NDNDG7BH.mjs → chunk-5NK24IKQ.mjs} +2 -5
- package/dist/{chunk-2SW2E3TH.mjs → chunk-5SDSWPKR.mjs} +14 -4
- package/dist/chunk-6T7MXPCT.mjs +17 -0
- package/dist/{chunk-ADP4MYOS.mjs → chunk-ANUYBAYV.mjs} +1 -1
- package/dist/{chunk-R4NSLRAE.mjs → chunk-ATRL3UZP.mjs} +14 -8
- package/dist/{chunk-P3N5WLFL.mjs → chunk-BXBN56WI.mjs} +11 -7
- package/dist/chunk-CJ3ZUYUJ.mjs +183 -0
- package/dist/chunk-DAJA5AV3.mjs +29 -0
- package/dist/{chunk-FK567E7G.mjs → chunk-DVQQVCGF.mjs} +7 -3
- package/dist/chunk-DZCXT6HT.mjs +288 -0
- package/dist/chunk-FU5SRKZU.mjs +104 -0
- package/dist/{chunk-LQLF2CMA.mjs → chunk-GBLPCM3X.mjs} +14 -17
- package/dist/chunk-KJ7ZCBK4.mjs +48 -0
- package/dist/{chunk-BAKUP7QM.mjs → chunk-P3QUAOFO.mjs} +36 -34
- package/dist/{chunk-I2ECCPNN.mjs → chunk-PYS26PF3.mjs} +15 -10
- package/dist/chunk-Q57BF3CR.mjs +63 -0
- package/dist/{chunk-SPQZTV4E.mjs → chunk-QK56GX3F.mjs} +12 -14
- package/dist/{chunk-3QHLEAXK.mjs → chunk-RDZJT36Z.mjs} +22 -8
- package/dist/{chunk-HE56XDG6.mjs → chunk-RVSUTDCE.mjs} +15 -5
- package/dist/chunk-UMUUVFB7.mjs +69 -0
- package/dist/{chunk-NUG6FLHN.mjs → chunk-VZ2YFMWH.mjs} +54 -11
- package/dist/chunk-WDSV2EFG.mjs +7 -0
- package/dist/{chunk-M5WNLLBT.mjs → chunk-WOYZWHPM.mjs} +20 -7
- package/dist/chunk-WRURTO5T.mjs +144 -0
- package/dist/configs/astro.cjs +11 -21
- package/dist/configs/astro.d.cts +3 -6
- package/dist/configs/astro.d.ts +3 -6
- package/dist/configs/astro.mjs +3 -3
- package/dist/configs/comments.cjs +9 -12
- package/dist/configs/comments.d.cts +3 -2
- package/dist/configs/comments.d.ts +3 -2
- package/dist/configs/comments.mjs +1 -2
- package/dist/configs/formatters.cjs +274 -0
- package/dist/configs/formatters.d.cts +11 -0
- package/dist/configs/formatters.d.ts +11 -0
- package/dist/configs/formatters.mjs +9 -0
- package/dist/configs/ignores.cjs +1 -8
- package/dist/configs/ignores.d.cts +3 -2
- package/dist/configs/ignores.d.ts +3 -2
- package/dist/configs/ignores.mjs +2 -2
- package/dist/configs/imports.cjs +35 -9
- package/dist/configs/imports.d.cts +13 -4
- package/dist/configs/imports.d.ts +13 -4
- package/dist/configs/imports.mjs +2 -2
- package/dist/configs/index.cjs +1116 -707
- package/dist/configs/index.d.cts +7 -18
- package/dist/configs/index.d.ts +7 -18
- package/dist/configs/index.mjs +40 -36
- package/dist/configs/javascript.cjs +9 -23
- package/dist/configs/javascript.d.cts +3 -6
- package/dist/configs/javascript.d.ts +3 -6
- package/dist/configs/javascript.mjs +2 -3
- package/dist/configs/jsdoc.cjs +6 -2
- package/dist/configs/jsdoc.d.cts +17 -4
- package/dist/configs/jsdoc.d.ts +17 -4
- package/dist/configs/jsdoc.mjs +2 -2
- package/dist/configs/jsonc.cjs +8 -11
- package/dist/configs/jsonc.d.cts +3 -6
- package/dist/configs/jsonc.d.ts +3 -6
- package/dist/configs/jsonc.mjs +3 -3
- package/dist/configs/markdown.cjs +46 -35
- package/dist/configs/markdown.d.cts +25 -4
- package/dist/configs/markdown.d.ts +25 -4
- package/dist/configs/markdown.mjs +3 -3
- package/dist/configs/nextjs.cjs +15 -12
- package/dist/configs/nextjs.d.cts +3 -6
- package/dist/configs/nextjs.d.ts +3 -6
- package/dist/configs/nextjs.mjs +3 -3
- package/dist/configs/node.cjs +0 -10
- package/dist/configs/node.d.cts +3 -2
- package/dist/configs/node.d.ts +3 -2
- package/dist/configs/node.mjs +1 -2
- package/dist/configs/perfectionist.cjs +2 -20
- package/dist/configs/perfectionist.d.cts +4 -3
- package/dist/configs/perfectionist.d.ts +4 -3
- package/dist/configs/perfectionist.mjs +1 -2
- package/dist/configs/react.cjs +201 -203
- package/dist/configs/react.d.cts +3 -6
- package/dist/configs/react.d.ts +3 -6
- package/dist/configs/react.mjs +3 -3
- package/dist/configs/sort.cjs +6 -6
- package/dist/configs/sort.d.cts +3 -2
- package/dist/configs/sort.d.ts +3 -2
- package/dist/configs/sort.mjs +1 -1
- package/dist/configs/stylistic.cjs +20 -11
- package/dist/configs/stylistic.d.cts +4 -7
- package/dist/configs/stylistic.d.ts +4 -7
- package/dist/configs/stylistic.mjs +4 -3
- package/dist/configs/tailwindcss.cjs +34 -45
- package/dist/configs/tailwindcss.d.cts +3 -6
- package/dist/configs/tailwindcss.d.ts +3 -6
- package/dist/configs/tailwindcss.mjs +3 -3
- package/dist/configs/test.cjs +103 -16
- package/dist/configs/test.d.cts +3 -6
- package/dist/configs/test.d.ts +3 -6
- package/dist/configs/test.mjs +4 -3
- package/dist/configs/toml.cjs +131 -0
- package/dist/configs/toml.d.cts +11 -0
- package/dist/configs/toml.d.ts +11 -0
- package/dist/configs/toml.mjs +8 -0
- package/dist/configs/typescript.cjs +32 -43
- package/dist/configs/typescript.d.cts +3 -6
- package/dist/configs/typescript.d.ts +3 -6
- package/dist/configs/typescript.mjs +3 -4
- package/dist/configs/unicorn.cjs +13 -10
- package/dist/configs/unicorn.d.cts +3 -2
- package/dist/configs/unicorn.d.ts +3 -2
- package/dist/configs/unicorn.mjs +1 -2
- package/dist/configs/unocss.cjs +74 -4
- package/dist/configs/unocss.d.cts +3 -6
- package/dist/configs/unocss.d.ts +3 -6
- package/dist/configs/unocss.mjs +3 -2
- package/dist/configs/vue.cjs +51 -15
- package/dist/configs/vue.d.cts +3 -6
- package/dist/configs/vue.d.ts +3 -6
- package/dist/configs/vue.mjs +3 -3
- package/dist/configs/yaml.cjs +17 -11
- package/dist/configs/yaml.d.cts +3 -6
- package/dist/configs/yaml.d.ts +3 -6
- package/dist/configs/yaml.mjs +3 -3
- package/dist/custom-rules/utils.cjs +31 -0
- package/dist/custom-rules/utils.d.cts +6 -0
- package/dist/custom-rules/utils.d.ts +6 -0
- package/dist/custom-rules/utils.mjs +6 -0
- package/dist/globs.cjs +157 -0
- package/dist/globs.d.cts +28 -0
- package/dist/globs.d.ts +28 -0
- package/dist/globs.mjs +56 -0
- package/dist/index.cjs +1470 -1040
- package/dist/index.d.cts +10 -44
- package/dist/index.d.ts +10 -44
- package/dist/index.mjs +106 -140
- package/dist/types-spTEGSaV.d.cts +632 -0
- package/dist/types-spTEGSaV.d.ts +632 -0
- package/package.json +69 -37
- package/dist/chunk-24KJPXII.mjs +0 -51
- package/dist/chunk-4HH6LYJ6.mjs +0 -25
- package/dist/chunk-4JKENKIP.mjs +0 -67
- package/dist/chunk-C5VMTRKT.mjs +0 -18
- package/dist/chunk-CFSYEIE4.mjs +0 -23
- package/dist/chunk-ERFDRAGW.mjs +0 -86
- package/dist/chunk-HLDEUDLN.mjs +0 -28
- package/dist/chunk-UBPIYSHC.mjs +0 -284
- package/dist/types-fxhbVLKI.d.cts +0 -235
- package/dist/types-fxhbVLKI.d.ts +0 -235
- package/dist/{chunk-FKAOMYGL.mjs → chunk-ME2OAMS3.mjs} +0 -0
- package/dist/{chunk-FOIFEV73.mjs → chunk-XBASVDU6.mjs} +6 -6
package/README.md
CHANGED
|
@@ -1,31 +1,79 @@
|
|
|
1
1
|
# @luxass/eslint-config
|
|
2
2
|
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
+
|
|
3
6
|
> [!IMPORTANT]
|
|
4
|
-
> The configuration is not currently finished.
|
|
5
|
-
> I could change at any moment.
|
|
7
|
+
> The configuration is not currently finished, it could change at any moment.
|
|
6
8
|
|
|
7
9
|
## ✨ Features
|
|
8
10
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
11
|
+
- Based on [Antfu's ESLint Config](https://github.com/antfu/eslint-config)
|
|
12
|
+
- Auto fix for formatting (aimed to be used standalone **without** Prettier)
|
|
13
|
+
- Designed to work with TypeScript, JSX, Vue & Astro out-of-box
|
|
14
|
+
- Lints also for json, yaml, toml, markdown
|
|
15
|
+
- Sorted imports, dangling commas
|
|
16
|
+
- Reasonable defaults, best practices, only one-line of config
|
|
17
|
+
- Opinionated, but [very customizable](#customization)
|
|
12
18
|
- [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), compose easily!
|
|
13
|
-
- Using [ESLint Stylistic](https://
|
|
19
|
+
- Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
20
|
+
- Respects `.gitignore` by default
|
|
21
|
+
- Optional [formatters](#formatters) support for CSS, HTML, etc.
|
|
14
22
|
|
|
15
23
|
## 📦 Install
|
|
16
24
|
|
|
17
25
|
```bash
|
|
18
|
-
pnpm
|
|
26
|
+
pnpm install -D eslint @luxass/eslint-config
|
|
19
27
|
```
|
|
20
28
|
|
|
21
29
|
## 🚀 Usage
|
|
30
|
+
|
|
31
|
+
With [`"type": "module"`](https://nodejs.org/api/packages.html#type) in `package.json` (recommended):
|
|
32
|
+
|
|
22
33
|
```js
|
|
23
34
|
// eslint.config.js
|
|
24
|
-
import
|
|
35
|
+
import luxass from "@luxass/eslint-config";
|
|
25
36
|
|
|
26
37
|
export default luxass();
|
|
27
38
|
```
|
|
28
39
|
|
|
40
|
+
With CJS:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
// eslint.config.js
|
|
44
|
+
const luxass = require("@luxass/eslint-config").default;
|
|
45
|
+
|
|
46
|
+
module.exports = luxass();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Combined with legacy config:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
// eslint.config.js
|
|
53
|
+
const luxass = require("@luxass/eslint-config").default;
|
|
54
|
+
const { FlatCompat } = require("@eslint/eslintrc");
|
|
55
|
+
|
|
56
|
+
const compat = new FlatCompat();
|
|
57
|
+
|
|
58
|
+
module.exports = luxass(
|
|
59
|
+
{
|
|
60
|
+
ignores: [],
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// Legacy config
|
|
64
|
+
...compat.config({
|
|
65
|
+
extends: [
|
|
66
|
+
"eslint:recommended",
|
|
67
|
+
// Other extends...
|
|
68
|
+
],
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// Other flat configs...
|
|
72
|
+
);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
> Note that `.eslintignore` no longer works in Flat config, see [customization](#customization) for more details.
|
|
76
|
+
|
|
29
77
|
## Setup for Visual Studio Code
|
|
30
78
|
|
|
31
79
|
Install [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and add the following to your `.vscode/settings.json`:
|
|
@@ -42,7 +90,7 @@ Install [ESLint extension](https://marketplace.visualstudio.com/items?itemName=d
|
|
|
42
90
|
|
|
43
91
|
// auto fix on save
|
|
44
92
|
"editor.codeActionsOnSave": {
|
|
45
|
-
"source.fixAll": "explicit",
|
|
93
|
+
"source.fixAll.eslint": "explicit",
|
|
46
94
|
"source.organizeImports": "never"
|
|
47
95
|
},
|
|
48
96
|
|
|
@@ -84,7 +132,7 @@ Normally you would only need to import the `luxass` preset:
|
|
|
84
132
|
|
|
85
133
|
```js
|
|
86
134
|
// eslint.config.js
|
|
87
|
-
import
|
|
135
|
+
import luxass from "@luxass/eslint-config";
|
|
88
136
|
|
|
89
137
|
export default luxass();
|
|
90
138
|
```
|
|
@@ -93,16 +141,20 @@ you can also configure each `config` individually:
|
|
|
93
141
|
|
|
94
142
|
```js
|
|
95
143
|
// eslint.config.js
|
|
96
|
-
import
|
|
144
|
+
import luxass from "@luxass/eslint-config";
|
|
97
145
|
|
|
98
146
|
export default luxass({
|
|
147
|
+
stylistic: true,
|
|
99
148
|
typescript: true,
|
|
100
149
|
vue: true,
|
|
101
150
|
react: false,
|
|
102
151
|
astro: true,
|
|
103
|
-
svelte: false,
|
|
104
152
|
unocss: true,
|
|
105
|
-
|
|
153
|
+
|
|
154
|
+
// `.eslintignore` is no longer supported in Flat config, use `ignores` instead.
|
|
155
|
+
ignores: [
|
|
156
|
+
"./fixtures"
|
|
157
|
+
]
|
|
106
158
|
});
|
|
107
159
|
```
|
|
108
160
|
|
|
@@ -110,70 +162,321 @@ The `luxass` function accepts an arbitrary number of `flat configs` overrides:
|
|
|
110
162
|
|
|
111
163
|
```js
|
|
112
164
|
// eslint.config.js
|
|
113
|
-
import
|
|
165
|
+
import luxass from "@luxass/eslint-config";
|
|
114
166
|
|
|
115
|
-
export default luxass({
|
|
167
|
+
export default luxass({
|
|
168
|
+
// configuration points for my config
|
|
169
|
+
}, {
|
|
116
170
|
rules: {}
|
|
117
171
|
}, {
|
|
118
172
|
rules: {}
|
|
119
173
|
});
|
|
120
174
|
```
|
|
121
175
|
|
|
122
|
-
|
|
176
|
+
<details>
|
|
177
|
+
<summary>Advanced Example</summary>
|
|
123
178
|
|
|
124
|
-
|
|
179
|
+
We don't recommend using this style in general usages, as there are shared options between configs and might need extra care to make them consistent.
|
|
125
180
|
|
|
126
181
|
```js
|
|
127
182
|
// eslint.config.js
|
|
128
183
|
import {
|
|
129
|
-
astro,
|
|
130
184
|
comments,
|
|
131
185
|
ignores,
|
|
132
186
|
imports,
|
|
133
187
|
javascript,
|
|
134
|
-
javascriptStylistic,
|
|
135
188
|
jsdoc,
|
|
136
189
|
jsonc,
|
|
137
190
|
markdown,
|
|
138
191
|
node,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
tailwindcss,
|
|
192
|
+
sortPackageJson,
|
|
193
|
+
sortTsconfig,
|
|
194
|
+
stylistic,
|
|
143
195
|
typescript,
|
|
144
|
-
typescriptStylistic,
|
|
145
196
|
unicorn,
|
|
146
|
-
unocss,
|
|
147
197
|
vue,
|
|
148
|
-
|
|
198
|
+
yaml,
|
|
149
199
|
} from "@luxass/eslint-config/configs";
|
|
150
200
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
...unicorn,
|
|
169
|
-
...unocss,
|
|
170
|
-
...vue,
|
|
171
|
-
...yml
|
|
172
|
-
];
|
|
201
|
+
import { combine } from "@luxass/eslint-config";
|
|
202
|
+
|
|
203
|
+
export default combine(
|
|
204
|
+
ignores(),
|
|
205
|
+
javascript(/* Options */),
|
|
206
|
+
comments(),
|
|
207
|
+
node(),
|
|
208
|
+
jsdoc(),
|
|
209
|
+
imports(),
|
|
210
|
+
unicorn(),
|
|
211
|
+
typescript(/* Options */),
|
|
212
|
+
stylistic(),
|
|
213
|
+
vue(),
|
|
214
|
+
jsonc(),
|
|
215
|
+
yaml(),
|
|
216
|
+
markdown(),
|
|
217
|
+
);
|
|
173
218
|
```
|
|
174
219
|
|
|
220
|
+
</details>
|
|
221
|
+
|
|
222
|
+
Check out the [configs](https://github.com/luxass/eslint-config/blob/main/src/configs) and [factory](https://github.com/luxass/eslint-config/blob/main/src/factory.ts) for more details.
|
|
223
|
+
|
|
175
224
|
> Thanks to [sxzz/eslint-config](https://github.com/sxzz/eslint-config) and [antfu/eslint-config](https://github.com/antfu/eslint-config) for the inspiration and references.
|
|
176
225
|
|
|
226
|
+
### Plugins Renaming
|
|
227
|
+
|
|
228
|
+
Since flat config requires us to explicitly provide the plugin names (instead of mandatory convention from npm package name), we renamed some plugins to make overall scope more consistent and easier to write.
|
|
229
|
+
|
|
230
|
+
| New Prefix | Original Prefix | Source Plugin |
|
|
231
|
+
| ---------- | ---------------------- | ------------------------------------------------------------------------------------------ |
|
|
232
|
+
| `import/*` | `i/*` | [eslint-plugin-i](https://github.com/un-es/eslint-plugin-i) |
|
|
233
|
+
| `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
|
|
234
|
+
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
|
|
235
|
+
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
|
|
236
|
+
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
|
|
237
|
+
| `test/*` | `vitest/*` | [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) |
|
|
238
|
+
|
|
239
|
+
When you want to override rules, or disable them inline, you need to update to the new prefix:
|
|
240
|
+
|
|
241
|
+
```diff
|
|
242
|
+
-// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
243
|
+
+// eslint-disable-next-line ts/consistent-type-definitions
|
|
244
|
+
type foo = { bar: 2 }
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Rules Overrides
|
|
248
|
+
|
|
249
|
+
Certain rules would only be enabled in specific files, for example, `ts/*` rules would only be enabled in `.ts` files and `vue/*` rules would only be enabled in `.vue` files. If you want to override the rules, you need to specify the file extension:
|
|
250
|
+
|
|
251
|
+
```js
|
|
252
|
+
// eslint.config.js
|
|
253
|
+
import luxass from "@luxass/eslint-config";
|
|
254
|
+
|
|
255
|
+
export default luxass(
|
|
256
|
+
{ vue: true, typescript: true },
|
|
257
|
+
{
|
|
258
|
+
// Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files
|
|
259
|
+
files: ["**/*.vue"],
|
|
260
|
+
rules: {
|
|
261
|
+
"vue/operator-linebreak": ["error", "before"],
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
// Without `files`, they are general rules for all files
|
|
266
|
+
rules: {
|
|
267
|
+
"style/semi": ["error", "never"],
|
|
268
|
+
},
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
We also provided a `overrides` options to make it easier:
|
|
274
|
+
|
|
275
|
+
```js
|
|
276
|
+
// eslint.config.js
|
|
277
|
+
import luxass from "@luxass/eslint-config";
|
|
278
|
+
|
|
279
|
+
export default luxass({
|
|
280
|
+
overrides: {
|
|
281
|
+
vue: {
|
|
282
|
+
"vue/operator-linebreak": ["error", "before"],
|
|
283
|
+
},
|
|
284
|
+
typescript: {
|
|
285
|
+
"ts/consistent-type-definitions": ["error", "interface"],
|
|
286
|
+
},
|
|
287
|
+
yaml: {},
|
|
288
|
+
// ...
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Optional Configs
|
|
294
|
+
|
|
295
|
+
We provide some optional configs for specific use cases, that we don't include their dependencies by default.
|
|
296
|
+
|
|
297
|
+
#### Formatters
|
|
298
|
+
|
|
299
|
+
> [!WARNING]
|
|
300
|
+
> Experimental feature, changes might not follow semver.
|
|
301
|
+
|
|
302
|
+
Use external formatters to format files that ESLint cannot handle yet (`.css`, `.html`, etc). Powered by [`eslint-plugin-format`](https://github.com/antfu/eslint-plugin-format).
|
|
303
|
+
|
|
304
|
+
```js
|
|
305
|
+
// eslint.config.js
|
|
306
|
+
import luxass from "@luxass/eslint-config";
|
|
307
|
+
|
|
308
|
+
export default luxass({
|
|
309
|
+
formatters: {
|
|
310
|
+
/**
|
|
311
|
+
* Format CSS, LESS, SCSS files, also the `<style>` blocks in Vue
|
|
312
|
+
* By default uses Prettier
|
|
313
|
+
*/
|
|
314
|
+
css: true,
|
|
315
|
+
/**
|
|
316
|
+
* Format HTML files
|
|
317
|
+
* By default uses Prettier
|
|
318
|
+
*/
|
|
319
|
+
html: true,
|
|
320
|
+
/**
|
|
321
|
+
* Format TOML files
|
|
322
|
+
* Currently only supports dprint
|
|
323
|
+
*/
|
|
324
|
+
toml: "dprint",
|
|
325
|
+
/**
|
|
326
|
+
* Format Markdown files
|
|
327
|
+
* Supports Prettier and dprint
|
|
328
|
+
* By default uses Prettier
|
|
329
|
+
*/
|
|
330
|
+
markdown: "prettier"
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
npm i -D eslint-plugin-format
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
#### React
|
|
342
|
+
|
|
343
|
+
To enable React support, need to explicitly turn it on:
|
|
344
|
+
|
|
345
|
+
```js
|
|
346
|
+
// eslint.config.js
|
|
347
|
+
import luxass from "@luxass/eslint-config";
|
|
348
|
+
|
|
349
|
+
export default luxass({
|
|
350
|
+
react: true,
|
|
351
|
+
});
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
#### Next.JS
|
|
361
|
+
|
|
362
|
+
To enable Next.JS support, need to explicitly turn it on:
|
|
363
|
+
|
|
364
|
+
Next.JS also enables React support.
|
|
365
|
+
|
|
366
|
+
```js
|
|
367
|
+
// eslint.config.js
|
|
368
|
+
import luxass from "@luxass/eslint-config";
|
|
369
|
+
|
|
370
|
+
export default luxass({
|
|
371
|
+
nextjs: true,
|
|
372
|
+
});
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh @next/eslint-plugin-next
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
#### UnoCSS
|
|
382
|
+
|
|
383
|
+
To enable UnoCSS support, need to explicitly turn it on:
|
|
384
|
+
|
|
385
|
+
```js
|
|
386
|
+
// eslint.config.js
|
|
387
|
+
import luxass from "@luxass/eslint-config";
|
|
388
|
+
|
|
389
|
+
export default luxass({
|
|
390
|
+
unocss: true,
|
|
391
|
+
});
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
npm i -D @unocss/eslint-plugin
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
#### TailwindCSS
|
|
401
|
+
|
|
402
|
+
To enable TailwindCSS support, need to explicitly turn it on:
|
|
403
|
+
|
|
404
|
+
```js
|
|
405
|
+
// eslint.config.js
|
|
406
|
+
import luxass from "@luxass/eslint-config";
|
|
407
|
+
|
|
408
|
+
export default luxass({
|
|
409
|
+
tailwindcss: true,
|
|
410
|
+
});
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
npm i -D eslint-plugin-tailwindcss
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### Optional Rules
|
|
420
|
+
|
|
421
|
+
This config also provides some optional plugins/rules for extended usages.
|
|
422
|
+
|
|
423
|
+
#### `perfectionist` (sorting)
|
|
424
|
+
|
|
425
|
+
This plugin [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) allows you to sorted object keys, imports, etc, with auto-fix.
|
|
426
|
+
|
|
427
|
+
The plugin is installed but no rules are enabled by default.
|
|
428
|
+
|
|
429
|
+
It's recommended to opt-in on each file individually using [configuration comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1).
|
|
430
|
+
|
|
431
|
+
```js
|
|
432
|
+
/* eslint perfectionist/sort-objects: "error" */
|
|
433
|
+
const objectWantedToSort = {
|
|
434
|
+
a: 2,
|
|
435
|
+
b: 1,
|
|
436
|
+
c: 3,
|
|
437
|
+
};
|
|
438
|
+
/* eslint perfectionist/sort-objects: "off" */
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### Type Aware Rules
|
|
442
|
+
|
|
443
|
+
You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the options object to the `typescript` config:
|
|
444
|
+
|
|
445
|
+
```js
|
|
446
|
+
// eslint.config.js
|
|
447
|
+
import luxass from "@luxass/eslint-config";
|
|
448
|
+
|
|
449
|
+
export default luxass({
|
|
450
|
+
typescript: {
|
|
451
|
+
tsconfigPath: "tsconfig.json",
|
|
452
|
+
},
|
|
453
|
+
});
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
## Versioning Policy
|
|
457
|
+
|
|
458
|
+
This project follows [Semantic Versioning](https://semver.org/) for releases. However, since this is just a config and involves opinions and many moving parts, we don't treat rules changes as breaking changes.
|
|
459
|
+
|
|
460
|
+
### Changes Considered as Breaking Changes
|
|
461
|
+
|
|
462
|
+
- Node.js version requirement changes
|
|
463
|
+
- Huge refactors that might break the config
|
|
464
|
+
- Plugins made major changes that might break the config
|
|
465
|
+
- Changes that might affect most of the codebases
|
|
466
|
+
|
|
467
|
+
### Changes Considered as Non-breaking Changes
|
|
468
|
+
|
|
469
|
+
- Enable/disable rules and plugins (that might become stricter)
|
|
470
|
+
- Rules options changes
|
|
471
|
+
- Version bumps of dependencies
|
|
472
|
+
|
|
177
473
|
## 📄 License
|
|
178
474
|
|
|
179
475
|
Published under [MIT License](./LICENSE).
|
|
476
|
+
|
|
477
|
+
<!-- Badges -->
|
|
478
|
+
|
|
479
|
+
[npm-version-src]: https://img.shields.io/npm/v/@luxass/eslint-config?style=flat&colorA=18181B&colorB=4169E1
|
|
480
|
+
[npm-version-href]: https://npmjs.com/package/@luxass/eslint-config
|
|
481
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@luxass/eslint-config?style=flat&colorA=18181B&colorB=4169E1
|
|
482
|
+
[npm-downloads-href]: https://npmjs.com/package/@luxass/eslint-config
|
|
@@ -35,8 +35,8 @@ async function ensure(packages) {
|
|
|
35
35
|
const { default: prompts } = await import("prompts");
|
|
36
36
|
const { result } = await prompts([
|
|
37
37
|
{
|
|
38
|
-
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
39
38
|
name: "result",
|
|
39
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
40
40
|
type: "confirm"
|
|
41
41
|
}
|
|
42
42
|
]);
|
|
@@ -47,11 +47,22 @@ async function ensure(packages) {
|
|
|
47
47
|
}
|
|
48
48
|
;
|
|
49
49
|
}
|
|
50
|
+
function resolveSubOptions(options, key) {
|
|
51
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
52
|
+
}
|
|
53
|
+
function getOverrides(options, key) {
|
|
54
|
+
const sub = resolveSubOptions(options, key);
|
|
55
|
+
return {
|
|
56
|
+
..."overrides" in sub ? sub.overrides : {}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
50
59
|
|
|
51
60
|
export {
|
|
52
61
|
combine,
|
|
53
62
|
renameRules,
|
|
54
63
|
toArray,
|
|
55
64
|
interop,
|
|
56
|
-
ensure
|
|
65
|
+
ensure,
|
|
66
|
+
resolveSubOptions,
|
|
67
|
+
getOverrides
|
|
57
68
|
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
default3 as default2
|
|
3
|
-
} from "./chunk-C5VMTRKT.mjs";
|
|
4
|
-
|
|
5
1
|
// src/configs/node.ts
|
|
2
|
+
import pluginNode from "eslint-plugin-n";
|
|
6
3
|
function node() {
|
|
7
4
|
return [
|
|
8
5
|
{
|
|
9
6
|
name: "luxass:node",
|
|
10
7
|
plugins: {
|
|
11
|
-
node:
|
|
8
|
+
node: pluginNode
|
|
12
9
|
},
|
|
13
10
|
rules: {
|
|
14
11
|
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-C5VMTRKT.mjs";
|
|
2
|
+
GLOB_SRC_EXT
|
|
3
|
+
} from "./chunk-ATRL3UZP.mjs";
|
|
5
4
|
|
|
6
5
|
// src/configs/imports.ts
|
|
6
|
+
import pluginImport from "eslint-plugin-i";
|
|
7
|
+
import pluginAntfu from "eslint-plugin-antfu";
|
|
7
8
|
async function imports(options = {}) {
|
|
8
9
|
const {
|
|
9
10
|
stylistic = true
|
|
@@ -12,11 +13,12 @@ async function imports(options = {}) {
|
|
|
12
13
|
{
|
|
13
14
|
name: "luxass:imports",
|
|
14
15
|
plugins: {
|
|
15
|
-
antfu:
|
|
16
|
+
antfu: pluginAntfu,
|
|
16
17
|
import: pluginImport
|
|
17
18
|
},
|
|
18
19
|
rules: {
|
|
19
20
|
"antfu/import-dedupe": "error",
|
|
21
|
+
"antfu/no-import-dist": "error",
|
|
20
22
|
"antfu/no-import-node-modules-by-path": "error",
|
|
21
23
|
"import/first": "error",
|
|
22
24
|
"import/no-duplicates": "error",
|
|
@@ -29,6 +31,14 @@ async function imports(options = {}) {
|
|
|
29
31
|
"import/newline-after-import": ["error", { considerComments: true, count: 1 }]
|
|
30
32
|
} : {}
|
|
31
33
|
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "luxass:imports:bin",
|
|
37
|
+
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
38
|
+
rules: {
|
|
39
|
+
"antfu/no-import-dist": "off",
|
|
40
|
+
"antfu/no-import-node-modules-by-path": "off"
|
|
41
|
+
}
|
|
32
42
|
}
|
|
33
43
|
];
|
|
34
44
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/configs/perfectionist.ts
|
|
2
|
+
import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
3
|
+
async function perfectionist() {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
name: "luxass:perfectionist",
|
|
7
|
+
plugins: {
|
|
8
|
+
perfectionist: pluginPerfectionist
|
|
9
|
+
},
|
|
10
|
+
rules: {}
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
perfectionist
|
|
17
|
+
};
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
// src/globs.ts
|
|
2
2
|
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
3
|
-
var GLOB_SRC =
|
|
3
|
+
var GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
|
|
4
4
|
var GLOB_JS = "**/*.?([cm])js";
|
|
5
|
+
var GLOB_JSX = "**/*.?([cm])jsx";
|
|
5
6
|
var GLOB_TS = "**/*.?([cm])ts";
|
|
6
|
-
var
|
|
7
|
-
var GLOB_JSX = `**/*.${GLOB_JSX_EXT}`;
|
|
7
|
+
var GLOB_TSX = "**/*.?([cm])tsx";
|
|
8
8
|
var GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
9
9
|
var GLOB_CSS = "**/*.css";
|
|
10
|
+
var GLOB_POSTCSS = "**/*.{p,post}css";
|
|
10
11
|
var GLOB_LESS = "**/*.less";
|
|
11
12
|
var GLOB_SCSS = "**/*.scss";
|
|
12
13
|
var GLOB_JSON = "**/*.json";
|
|
13
14
|
var GLOB_JSON5 = "**/*.json5";
|
|
14
15
|
var GLOB_JSONC = "**/*.jsonc";
|
|
15
16
|
var GLOB_MARKDOWN = "**/*.md";
|
|
17
|
+
var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
16
18
|
var GLOB_VUE = "**/*.vue";
|
|
17
19
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
20
|
+
var GLOB_TOML = "**/*.toml";
|
|
18
21
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
19
22
|
var GLOB_ASTRO = "**/*.astro";
|
|
20
23
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
@@ -26,9 +29,9 @@ var GLOB_TESTS = [
|
|
|
26
29
|
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
27
30
|
];
|
|
28
31
|
var GLOB_NEXTJS_OG = [
|
|
29
|
-
`**/app/**/opengraph-image
|
|
30
|
-
`**/app/**/twitter-image
|
|
31
|
-
`**/app/**/route
|
|
32
|
+
`**/app/**/opengraph-image.[jt]s?(x)`,
|
|
33
|
+
`**/app/**/twitter-image.[jt]s?(x)`,
|
|
34
|
+
`**/app/**/route.[jt]s?(x)`
|
|
32
35
|
];
|
|
33
36
|
var GLOB_NEXTJS_ROUTES = [
|
|
34
37
|
`**/app/**/page.${GLOB_SRC_EXT}`,
|
|
@@ -79,19 +82,22 @@ export {
|
|
|
79
82
|
GLOB_SRC_EXT,
|
|
80
83
|
GLOB_SRC,
|
|
81
84
|
GLOB_JS,
|
|
82
|
-
GLOB_TS,
|
|
83
|
-
GLOB_JSX_EXT,
|
|
84
85
|
GLOB_JSX,
|
|
86
|
+
GLOB_TS,
|
|
87
|
+
GLOB_TSX,
|
|
85
88
|
GLOB_STYLE,
|
|
86
89
|
GLOB_CSS,
|
|
90
|
+
GLOB_POSTCSS,
|
|
87
91
|
GLOB_LESS,
|
|
88
92
|
GLOB_SCSS,
|
|
89
93
|
GLOB_JSON,
|
|
90
94
|
GLOB_JSON5,
|
|
91
95
|
GLOB_JSONC,
|
|
92
96
|
GLOB_MARKDOWN,
|
|
97
|
+
GLOB_MARKDOWN_IN_MARKDOWN,
|
|
93
98
|
GLOB_VUE,
|
|
94
99
|
GLOB_YAML,
|
|
100
|
+
GLOB_TOML,
|
|
95
101
|
GLOB_HTML,
|
|
96
102
|
GLOB_ASTRO,
|
|
97
103
|
GLOB_MARKDOWN_CODE,
|