@coderwyd/eslint-config 2.0.3 → 2.1.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 +157 -8
- package/dist/cli.cjs +7 -5
- package/dist/cli.js +13 -11
- package/dist/index.cjs +125 -21
- package/dist/index.d.cts +2 -9
- package/dist/index.d.ts +2 -9
- package/dist/index.js +131 -27
- package/package.json +24 -9
package/README.md
CHANGED
|
@@ -6,14 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
## Feature
|
|
8
8
|
|
|
9
|
-
- ✨ Single quotes, no semi
|
|
10
9
|
- 🛠️ Auto fix for formatting
|
|
10
|
+
- ✨ Support Vue, React, Svelte.
|
|
11
11
|
- 🎯 Designed to work with TypeScript, Vue out-of-box
|
|
12
|
-
- 🔍 Lints also for json
|
|
13
|
-
- 🧩 Sorted imports, dangling commas
|
|
14
12
|
- 🏆 Reasonable defaults, best practices, only one-line of config
|
|
15
|
-
-
|
|
16
|
-
- 🎨 Use ESlint and Prettier to format HTML, CSS, LESS, SCSS, YAML, TOML, Markdown.
|
|
13
|
+
- 🎨 Use ESlint and Prettier to format HTML, CSS, LESS, SCSS, YAML, TOML, Markdown, JSON, JSONC.
|
|
17
14
|
|
|
18
15
|
## Usage
|
|
19
16
|
|
|
@@ -60,8 +57,6 @@ For example:
|
|
|
60
57
|
|
|
61
58
|
## VS Code support (auto fix)
|
|
62
59
|
|
|
63
|
-
Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
64
|
-
|
|
65
60
|
Add the following settings to your `.vscode/settings.json`:
|
|
66
61
|
|
|
67
62
|
```jsonc
|
|
@@ -109,12 +104,166 @@ If you want to apply lint and auto-fix before every commit, you can add the foll
|
|
|
109
104
|
}
|
|
110
105
|
}
|
|
111
106
|
```
|
|
112
|
-
|
|
113
107
|
and then
|
|
114
108
|
|
|
115
109
|
```bash
|
|
116
110
|
npm i -D lint-staged simple-git-hooks
|
|
117
111
|
```
|
|
112
|
+
## Options
|
|
113
|
+
|
|
114
|
+
### interface Options
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
interface OptionsConfig {
|
|
118
|
+
/**
|
|
119
|
+
* The current working directory
|
|
120
|
+
*
|
|
121
|
+
* @default process.cwd()
|
|
122
|
+
*/
|
|
123
|
+
cwd?: string
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Enable gitignore support.
|
|
127
|
+
*
|
|
128
|
+
* Passing an object to configure the options.
|
|
129
|
+
*
|
|
130
|
+
* @see https://github.com/antfu/eslint-config-flat-gitignore
|
|
131
|
+
* @default true
|
|
132
|
+
*/
|
|
133
|
+
gitignore?: boolean | FlatGitignoreOptions
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Core rules. Can't be disabled.
|
|
137
|
+
*/
|
|
138
|
+
javascript?: OptionsOverrides
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Enable TypeScript support.
|
|
142
|
+
*
|
|
143
|
+
* Passing an object to enable TypeScript Language Server support.
|
|
144
|
+
*
|
|
145
|
+
* @default auto-detect based on the dependencies
|
|
146
|
+
*/
|
|
147
|
+
typescript?: boolean | OptionsTypescript
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Enable test support.
|
|
151
|
+
*
|
|
152
|
+
* @default true
|
|
153
|
+
*/
|
|
154
|
+
test?: boolean | OptionsOverrides
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Enable Vue support.
|
|
158
|
+
*
|
|
159
|
+
* @default auto-detect based on the dependencies
|
|
160
|
+
*/
|
|
161
|
+
vue?: boolean | OptionsVue
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Enable JSONC support.
|
|
165
|
+
*
|
|
166
|
+
* @default true
|
|
167
|
+
*/
|
|
168
|
+
jsonc?: boolean | OptionsOverrides
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Enable react rules.
|
|
172
|
+
*
|
|
173
|
+
* Requires installing:
|
|
174
|
+
* - `eslint-plugin-react`
|
|
175
|
+
* - `eslint-plugin-react-hooks`
|
|
176
|
+
* - `eslint-plugin-react-refresh`
|
|
177
|
+
*
|
|
178
|
+
* @default false
|
|
179
|
+
*/
|
|
180
|
+
react?: boolean | OptionsOverrides
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Enable svelte rules.
|
|
184
|
+
*
|
|
185
|
+
* Requires installing:
|
|
186
|
+
* - `eslint-plugin-svelte`
|
|
187
|
+
*
|
|
188
|
+
* @default false
|
|
189
|
+
*/
|
|
190
|
+
svelte?: boolean | OptionsOverrides
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Enable unocss rules.
|
|
194
|
+
*
|
|
195
|
+
* Requires installing:
|
|
196
|
+
* - `@unocss/eslint-plugin`
|
|
197
|
+
*
|
|
198
|
+
* @default false
|
|
199
|
+
*/
|
|
200
|
+
unocss?: boolean | OptionsUnoCSS
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Whether to use prettierrc
|
|
204
|
+
*
|
|
205
|
+
* If true, the rules in prettierrc will override the default rules
|
|
206
|
+
*
|
|
207
|
+
* @default true
|
|
208
|
+
*/
|
|
209
|
+
usePrettierrc?: boolean
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Use external formatters to format files.
|
|
213
|
+
*
|
|
214
|
+
* Requires installing:
|
|
215
|
+
* - `eslint-plugin-prettier`
|
|
216
|
+
*
|
|
217
|
+
* @default
|
|
218
|
+
* {
|
|
219
|
+
* "html": true,
|
|
220
|
+
* "css": true,
|
|
221
|
+
* "graphql": true,
|
|
222
|
+
* "markdown": true
|
|
223
|
+
* "yaml": true
|
|
224
|
+
* "toml": true
|
|
225
|
+
* }
|
|
226
|
+
*/
|
|
227
|
+
formatter?: OptionsFormatters
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Default prettier rules
|
|
231
|
+
*
|
|
232
|
+
* @default
|
|
233
|
+
* ```json
|
|
234
|
+
* {
|
|
235
|
+
* "arrowParens": "avoid",
|
|
236
|
+
* "htmlWhitespaceSensitivity": "ignore"
|
|
237
|
+
* "printWidth": 120,
|
|
238
|
+
* "semi": false,
|
|
239
|
+
* "singleQuote": true,
|
|
240
|
+
* }
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
prettierRules?: PartialPrettierExtendedOptions
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Control to disable some rules in editors.
|
|
247
|
+
* @default auto-detect based on the process.env
|
|
248
|
+
*/
|
|
249
|
+
isInEditor?: boolean
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Provide overrides for rules for each integration.
|
|
253
|
+
*
|
|
254
|
+
* @deprecated use `overrides` option in each integration key instead
|
|
255
|
+
*/
|
|
256
|
+
overrides?: {
|
|
257
|
+
javascript?: FlatConfigItem['rules']
|
|
258
|
+
typescript?: FlatConfigItem['rules']
|
|
259
|
+
test?: FlatConfigItem['rules']
|
|
260
|
+
vue?: FlatConfigItem['rules']
|
|
261
|
+
jsonc?: FlatConfigItem['rules']
|
|
262
|
+
react?: FlatConfigItem['rules']
|
|
263
|
+
svelte?: FlatConfigItem['rules']
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
118
267
|
|
|
119
268
|
## Thanks
|
|
120
269
|
|
package/dist/cli.cjs
CHANGED
|
@@ -46,7 +46,7 @@ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
|
46
46
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
47
47
|
|
|
48
48
|
// package.json
|
|
49
|
-
var version = "2.0
|
|
49
|
+
var version = "2.1.0";
|
|
50
50
|
var devDependencies = {
|
|
51
51
|
"@antfu/ni": "^0.21.12",
|
|
52
52
|
"@types/eslint": "^8.56.2",
|
|
@@ -55,12 +55,13 @@ var devDependencies = {
|
|
|
55
55
|
"@types/prompts": "^2.4.9",
|
|
56
56
|
"@types/yargs": "^17.0.32",
|
|
57
57
|
"@unocss/eslint-plugin": "^0.58.3",
|
|
58
|
-
bumpp: "^9.
|
|
58
|
+
bumpp: "^9.3.0",
|
|
59
59
|
eslint: "^8.56.0",
|
|
60
|
-
"eslint-flat-config-viewer": "^0.1.
|
|
60
|
+
"eslint-flat-config-viewer": "^0.1.11",
|
|
61
61
|
"eslint-plugin-react": "^7.33.2",
|
|
62
62
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
63
63
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
64
|
+
"eslint-plugin-svelte": "^2.35.1",
|
|
64
65
|
esno: "^4.0.0",
|
|
65
66
|
execa: "^8.0.1",
|
|
66
67
|
"fast-glob": "^3.3.2",
|
|
@@ -68,6 +69,7 @@ var devDependencies = {
|
|
|
68
69
|
"lint-staged": "^15.2.0",
|
|
69
70
|
rimraf: "^5.0.5",
|
|
70
71
|
"simple-git-hooks": "^2.9.0",
|
|
72
|
+
"svelte-eslint-parser": "^0.33.1",
|
|
71
73
|
tsup: "^8.0.1",
|
|
72
74
|
typescript: "^5.3.3"
|
|
73
75
|
};
|
|
@@ -149,7 +151,7 @@ async function run(options = {}) {
|
|
|
149
151
|
console.log(import_picocolors2.default.cyan(`${ARROW} bumping @coderwyd/eslint-config to v${version}`));
|
|
150
152
|
const pkgContent = await import_promises.default.readFile(pathPackageJSON, "utf-8");
|
|
151
153
|
const pkg = JSON.parse(pkgContent);
|
|
152
|
-
pkg.devDependencies
|
|
154
|
+
pkg.devDependencies ??= {};
|
|
153
155
|
pkg.devDependencies["@coderwyd/eslint-config"] = `^${version}`;
|
|
154
156
|
if (!pkg.devDependencies.eslint)
|
|
155
157
|
pkg.devDependencies.eslint = eslintVersion;
|
|
@@ -224,7 +226,7 @@ ${coderwydConfig}
|
|
|
224
226
|
return;
|
|
225
227
|
}
|
|
226
228
|
}
|
|
227
|
-
if (
|
|
229
|
+
if (promptResult?.updateVscodeSettings ?? true) {
|
|
228
230
|
const dotVscodePath = import_node_path.default.join(cwd, ".vscode");
|
|
229
231
|
const settingsPath = import_node_path.default.join(dotVscodePath, "settings.json");
|
|
230
232
|
if (!import_node_fs.default.existsSync(dotVscodePath))
|
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// src/cli/index.ts
|
|
2
|
-
import process2 from "process";
|
|
2
|
+
import process2 from "node:process";
|
|
3
3
|
import c3 from "picocolors";
|
|
4
4
|
import { hideBin } from "yargs/helpers";
|
|
5
5
|
import yargs from "yargs";
|
|
6
6
|
|
|
7
7
|
// src/cli/run.ts
|
|
8
|
-
import fs from "fs";
|
|
9
|
-
import fsp from "fs/promises";
|
|
10
|
-
import path from "path";
|
|
11
|
-
import process from "process";
|
|
8
|
+
import fs from "node:fs";
|
|
9
|
+
import fsp from "node:fs/promises";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import process from "node:process";
|
|
12
12
|
import prompts from "prompts";
|
|
13
13
|
import c2 from "picocolors";
|
|
14
14
|
import parse from "parse-gitignore";
|
|
@@ -17,7 +17,7 @@ import parse from "parse-gitignore";
|
|
|
17
17
|
import c from "picocolors";
|
|
18
18
|
|
|
19
19
|
// package.json
|
|
20
|
-
var version = "2.0
|
|
20
|
+
var version = "2.1.0";
|
|
21
21
|
var devDependencies = {
|
|
22
22
|
"@antfu/ni": "^0.21.12",
|
|
23
23
|
"@types/eslint": "^8.56.2",
|
|
@@ -26,12 +26,13 @@ var devDependencies = {
|
|
|
26
26
|
"@types/prompts": "^2.4.9",
|
|
27
27
|
"@types/yargs": "^17.0.32",
|
|
28
28
|
"@unocss/eslint-plugin": "^0.58.3",
|
|
29
|
-
bumpp: "^9.
|
|
29
|
+
bumpp: "^9.3.0",
|
|
30
30
|
eslint: "^8.56.0",
|
|
31
|
-
"eslint-flat-config-viewer": "^0.1.
|
|
31
|
+
"eslint-flat-config-viewer": "^0.1.11",
|
|
32
32
|
"eslint-plugin-react": "^7.33.2",
|
|
33
33
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
34
34
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
35
|
+
"eslint-plugin-svelte": "^2.35.1",
|
|
35
36
|
esno: "^4.0.0",
|
|
36
37
|
execa: "^8.0.1",
|
|
37
38
|
"fast-glob": "^3.3.2",
|
|
@@ -39,6 +40,7 @@ var devDependencies = {
|
|
|
39
40
|
"lint-staged": "^15.2.0",
|
|
40
41
|
rimraf: "^5.0.5",
|
|
41
42
|
"simple-git-hooks": "^2.9.0",
|
|
43
|
+
"svelte-eslint-parser": "^0.33.1",
|
|
42
44
|
tsup: "^8.0.1",
|
|
43
45
|
typescript: "^5.3.3"
|
|
44
46
|
};
|
|
@@ -81,7 +83,7 @@ var vscodeSettingsString = `
|
|
|
81
83
|
`;
|
|
82
84
|
|
|
83
85
|
// src/cli/utils.ts
|
|
84
|
-
import { execSync } from "child_process";
|
|
86
|
+
import { execSync } from "node:child_process";
|
|
85
87
|
function isGitClean() {
|
|
86
88
|
try {
|
|
87
89
|
execSync("git diff-index --quiet HEAD --");
|
|
@@ -120,7 +122,7 @@ async function run(options = {}) {
|
|
|
120
122
|
console.log(c2.cyan(`${ARROW} bumping @coderwyd/eslint-config to v${version}`));
|
|
121
123
|
const pkgContent = await fsp.readFile(pathPackageJSON, "utf-8");
|
|
122
124
|
const pkg = JSON.parse(pkgContent);
|
|
123
|
-
pkg.devDependencies
|
|
125
|
+
pkg.devDependencies ??= {};
|
|
124
126
|
pkg.devDependencies["@coderwyd/eslint-config"] = `^${version}`;
|
|
125
127
|
if (!pkg.devDependencies.eslint)
|
|
126
128
|
pkg.devDependencies.eslint = eslintVersion;
|
|
@@ -195,7 +197,7 @@ ${coderwydConfig}
|
|
|
195
197
|
return;
|
|
196
198
|
}
|
|
197
199
|
}
|
|
198
|
-
if (
|
|
200
|
+
if (promptResult?.updateVscodeSettings ?? true) {
|
|
199
201
|
const dotVscodePath = path.join(cwd, ".vscode");
|
|
200
202
|
const settingsPath = path.join(dotVscodePath, "settings.json");
|
|
201
203
|
if (!fs.existsSync(dotVscodePath))
|
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ var import_local_pkg3 = require("local-pkg");
|
|
|
41
41
|
var DEFAULT_PRETTIER_RULES = {
|
|
42
42
|
arrowParens: "avoid",
|
|
43
43
|
htmlWhitespaceSensitivity: "ignore",
|
|
44
|
-
printWidth:
|
|
44
|
+
printWidth: 120,
|
|
45
45
|
semi: false,
|
|
46
46
|
singleQuote: true
|
|
47
47
|
};
|
|
@@ -80,6 +80,7 @@ var GLOB_JSX = "**/*.?([cm])jsx";
|
|
|
80
80
|
var GLOB_TS = "**/*.?([cm])ts";
|
|
81
81
|
var GLOB_TSX = "**/*.?([cm])tsx";
|
|
82
82
|
var GLOB_VUE = "**/*.vue";
|
|
83
|
+
var GLOB_SVELTE = "**/*.svelte";
|
|
83
84
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
84
85
|
var GLOB_CSS = "**/*.css";
|
|
85
86
|
var GLOB_POSTCSS = "**/*.{p,post}css";
|
|
@@ -530,11 +531,10 @@ function resolveSubOptions(options, key) {
|
|
|
530
531
|
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
531
532
|
}
|
|
532
533
|
function getOverrides(options, key) {
|
|
533
|
-
var _a;
|
|
534
534
|
const sub = resolveSubOptions(options, key);
|
|
535
535
|
return {
|
|
536
|
-
...
|
|
537
|
-
..."overrides" in sub ? sub.overrides : {}
|
|
536
|
+
...options.overrides?.[key],
|
|
537
|
+
..."overrides" in sub ? sub.overrides || {} : {}
|
|
538
538
|
};
|
|
539
539
|
}
|
|
540
540
|
|
|
@@ -859,10 +859,14 @@ async function prettier(rules) {
|
|
|
859
859
|
};
|
|
860
860
|
const configs = [
|
|
861
861
|
{
|
|
862
|
-
|
|
862
|
+
name: "coderwyd:prettier:setup",
|
|
863
863
|
plugins: {
|
|
864
864
|
prettier: pluginPrettier
|
|
865
|
-
}
|
|
865
|
+
}
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
files: GLOB_PRETTIER_LINT,
|
|
869
|
+
name: "coderwyd:prettier:rules",
|
|
866
870
|
rules: {
|
|
867
871
|
...eslintRules,
|
|
868
872
|
"prettier/prettier": ["warn", pRules],
|
|
@@ -884,6 +888,8 @@ async function typescript(options = {}) {
|
|
|
884
888
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
885
889
|
];
|
|
886
890
|
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
891
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
892
|
+
const isTypeAware = !!tsconfigPath;
|
|
887
893
|
const typeAwareRules = {
|
|
888
894
|
"dot-notation": "off",
|
|
889
895
|
"no-implied-eval": "off",
|
|
@@ -905,34 +911,45 @@ async function typescript(options = {}) {
|
|
|
905
911
|
"ts/restrict-template-expressions": "error",
|
|
906
912
|
"ts/unbound-method": "error"
|
|
907
913
|
};
|
|
908
|
-
const tsconfigPath = (options == null ? void 0 : options.tsconfigPath) ? toArray(options.tsconfigPath) : void 0;
|
|
909
914
|
const [pluginTs, parserTs] = await Promise.all([
|
|
910
915
|
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
911
916
|
interopDefault(import("@typescript-eslint/parser"))
|
|
912
917
|
]);
|
|
913
|
-
|
|
914
|
-
{
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
plugins: {
|
|
918
|
-
antfu: import_eslint_plugin_antfu.default,
|
|
919
|
-
ts: pluginTs
|
|
920
|
-
}
|
|
921
|
-
},
|
|
922
|
-
{
|
|
923
|
-
files,
|
|
918
|
+
function makeParser(typeAware, files2, ignores2) {
|
|
919
|
+
return {
|
|
920
|
+
files: files2,
|
|
921
|
+
...ignores2 ? { ignores: ignores2 } : {},
|
|
924
922
|
languageOptions: {
|
|
925
923
|
parser: parserTs,
|
|
926
924
|
parserOptions: {
|
|
927
925
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
928
926
|
sourceType: "module",
|
|
929
|
-
...
|
|
927
|
+
...typeAware ? {
|
|
930
928
|
project: tsconfigPath,
|
|
931
929
|
tsconfigRootDir: import_node_process2.default.cwd()
|
|
932
930
|
} : {},
|
|
933
931
|
...parserOptions
|
|
934
932
|
}
|
|
935
933
|
},
|
|
934
|
+
name: `coderwyd:typescript:${typeAware ? "type-aware-parser" : "parser"}`
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
return [
|
|
938
|
+
{
|
|
939
|
+
// Install the plugins without globs, so they can be configured separately.
|
|
940
|
+
name: "coderwyd:typescript:setup",
|
|
941
|
+
plugins: {
|
|
942
|
+
antfu: import_eslint_plugin_antfu.default,
|
|
943
|
+
ts: pluginTs
|
|
944
|
+
}
|
|
945
|
+
},
|
|
946
|
+
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
947
|
+
...isTypeAware ? [
|
|
948
|
+
makeParser(true, filesTypeAware),
|
|
949
|
+
makeParser(false, files, filesTypeAware)
|
|
950
|
+
] : [makeParser(false, files)],
|
|
951
|
+
{
|
|
952
|
+
files,
|
|
936
953
|
name: "coderwyd:typescript:rules",
|
|
937
954
|
rules: {
|
|
938
955
|
...renameRules(
|
|
@@ -1062,11 +1079,11 @@ async function unicorn() {
|
|
|
1062
1079
|
// src/configs/vue.ts
|
|
1063
1080
|
async function vue(options = {}) {
|
|
1064
1081
|
const { files = [GLOB_VUE], overrides = {} } = options;
|
|
1065
|
-
const isVue3 = getVueVersion() === 3;
|
|
1066
1082
|
const [pluginVue, parserVue] = await Promise.all([
|
|
1067
1083
|
interopDefault(import("eslint-plugin-vue")),
|
|
1068
1084
|
interopDefault(import("vue-eslint-parser"))
|
|
1069
1085
|
]);
|
|
1086
|
+
const isVue3 = getVueVersion() === 3;
|
|
1070
1087
|
const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
|
|
1071
1088
|
const vueRules = configKeys.reduce((preRules, key) => {
|
|
1072
1089
|
const config = pluginVue.configs[key];
|
|
@@ -1357,7 +1374,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1357
1374
|
...prettierRules2,
|
|
1358
1375
|
parser
|
|
1359
1376
|
};
|
|
1360
|
-
if (plugins
|
|
1377
|
+
if (plugins?.length) {
|
|
1361
1378
|
rules.plugins = [...rules.plugins || [], ...plugins];
|
|
1362
1379
|
}
|
|
1363
1380
|
const config = {
|
|
@@ -1415,6 +1432,84 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1415
1432
|
return configs;
|
|
1416
1433
|
}
|
|
1417
1434
|
|
|
1435
|
+
// src/configs/svelte.ts
|
|
1436
|
+
async function svelte(options = {}) {
|
|
1437
|
+
const { files = [GLOB_SVELTE], overrides = {} } = options;
|
|
1438
|
+
await ensurePackages(["eslint-plugin-svelte"]);
|
|
1439
|
+
const [pluginSvelte, parserSvelte] = await Promise.all([
|
|
1440
|
+
interopDefault(import("eslint-plugin-svelte")),
|
|
1441
|
+
interopDefault(import("svelte-eslint-parser"))
|
|
1442
|
+
]);
|
|
1443
|
+
return [
|
|
1444
|
+
{
|
|
1445
|
+
name: "coderwyd:svelte:setup",
|
|
1446
|
+
plugins: {
|
|
1447
|
+
svelte: pluginSvelte
|
|
1448
|
+
}
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
files,
|
|
1452
|
+
languageOptions: {
|
|
1453
|
+
parser: parserSvelte,
|
|
1454
|
+
parserOptions: {
|
|
1455
|
+
extraFileExtensions: [".svelte"],
|
|
1456
|
+
parser: options.typescript ? await interopDefault(
|
|
1457
|
+
import("@typescript-eslint/parser")
|
|
1458
|
+
) : null
|
|
1459
|
+
}
|
|
1460
|
+
},
|
|
1461
|
+
name: "coderwyd:svelte:rules",
|
|
1462
|
+
processor: pluginSvelte.processors[".svelte"],
|
|
1463
|
+
rules: {
|
|
1464
|
+
"import/no-mutable-exports": "off",
|
|
1465
|
+
"no-undef": "off",
|
|
1466
|
+
// incompatible with most recent (attribute-form) generic types RFC
|
|
1467
|
+
"no-unused-vars": [
|
|
1468
|
+
"error",
|
|
1469
|
+
{
|
|
1470
|
+
args: "none",
|
|
1471
|
+
caughtErrors: "none",
|
|
1472
|
+
ignoreRestSiblings: true,
|
|
1473
|
+
vars: "all",
|
|
1474
|
+
varsIgnorePattern: "^\\$\\$Props$"
|
|
1475
|
+
}
|
|
1476
|
+
],
|
|
1477
|
+
"svelte/comment-directive": "error",
|
|
1478
|
+
"svelte/no-at-debug-tags": "warn",
|
|
1479
|
+
"svelte/no-at-html-tags": "error",
|
|
1480
|
+
"svelte/no-dupe-else-if-blocks": "error",
|
|
1481
|
+
"svelte/no-dupe-style-properties": "error",
|
|
1482
|
+
"svelte/no-dupe-use-directives": "error",
|
|
1483
|
+
"svelte/no-dynamic-slot-name": "error",
|
|
1484
|
+
"svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
|
|
1485
|
+
"svelte/no-inner-declarations": "error",
|
|
1486
|
+
"svelte/no-not-function-handler": "error",
|
|
1487
|
+
"svelte/no-object-in-text-mustaches": "error",
|
|
1488
|
+
"svelte/no-reactive-functions": "error",
|
|
1489
|
+
"svelte/no-reactive-literals": "error",
|
|
1490
|
+
"svelte/no-shorthand-style-property-overrides": "error",
|
|
1491
|
+
"svelte/no-unknown-style-directive-property": "error",
|
|
1492
|
+
"svelte/no-unused-svelte-ignore": "error",
|
|
1493
|
+
"svelte/no-useless-mustaches": "error",
|
|
1494
|
+
"svelte/require-store-callbacks-use-set-param": "error",
|
|
1495
|
+
"svelte/system": "error",
|
|
1496
|
+
"svelte/valid-compile": "error",
|
|
1497
|
+
"svelte/valid-each-key": "error",
|
|
1498
|
+
"unused-imports/no-unused-vars": [
|
|
1499
|
+
"error",
|
|
1500
|
+
{
|
|
1501
|
+
args: "after-used",
|
|
1502
|
+
argsIgnorePattern: "^_",
|
|
1503
|
+
vars: "all",
|
|
1504
|
+
varsIgnorePattern: "^(_|\\$\\$Props$)"
|
|
1505
|
+
}
|
|
1506
|
+
],
|
|
1507
|
+
...overrides
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
];
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1418
1513
|
// src/index.ts
|
|
1419
1514
|
var flatConfigProps = [
|
|
1420
1515
|
"files",
|
|
@@ -1433,6 +1528,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1433
1528
|
gitignore: enableGitignore = true,
|
|
1434
1529
|
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
|
|
1435
1530
|
react: enableReact = false,
|
|
1531
|
+
svelte: enableSvelte = false,
|
|
1436
1532
|
typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
|
|
1437
1533
|
unocss: enableUnoCSS = false,
|
|
1438
1534
|
usePrettierrc = true,
|
|
@@ -1505,6 +1601,14 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1505
1601
|
})
|
|
1506
1602
|
);
|
|
1507
1603
|
}
|
|
1604
|
+
if (enableSvelte) {
|
|
1605
|
+
configs.push(
|
|
1606
|
+
svelte({
|
|
1607
|
+
overrides: getOverrides(options, "svelte"),
|
|
1608
|
+
typescript: !!enableTypeScript
|
|
1609
|
+
})
|
|
1610
|
+
);
|
|
1611
|
+
}
|
|
1508
1612
|
if (enableUnoCSS) {
|
|
1509
1613
|
configs.push(
|
|
1510
1614
|
unocss({
|
package/dist/index.d.cts
CHANGED
|
@@ -38,22 +38,14 @@ type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (Opti
|
|
|
38
38
|
interface OptionsFormatters {
|
|
39
39
|
/**
|
|
40
40
|
* Enable formatting support for CSS, Less, Sass, and SCSS.
|
|
41
|
-
*
|
|
42
|
-
* Currently only support Prettier.
|
|
43
41
|
*/
|
|
44
42
|
css?: boolean;
|
|
45
43
|
/**
|
|
46
44
|
* Enable formatting support for HTML.
|
|
47
|
-
*
|
|
48
|
-
* Currently only support Prettier.
|
|
49
45
|
*/
|
|
50
46
|
html?: boolean;
|
|
51
47
|
/**
|
|
52
48
|
* Enable formatting support for Markdown.
|
|
53
|
-
*
|
|
54
|
-
* Support both Prettier.
|
|
55
|
-
*
|
|
56
|
-
* When set to `true`, it will use Prettier.
|
|
57
49
|
*/
|
|
58
50
|
markdown?: boolean;
|
|
59
51
|
/**
|
|
@@ -227,7 +219,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
227
219
|
* {
|
|
228
220
|
* "arrowParens": "avoid",
|
|
229
221
|
* "htmlWhitespaceSensitivity": "ignore"
|
|
230
|
-
* "printWidth":
|
|
222
|
+
* "printWidth": 120,
|
|
231
223
|
* "semi": false,
|
|
232
224
|
* "singleQuote": true,
|
|
233
225
|
* }
|
|
@@ -251,6 +243,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
251
243
|
vue?: FlatConfigItem['rules'];
|
|
252
244
|
jsonc?: FlatConfigItem['rules'];
|
|
253
245
|
react?: FlatConfigItem['rules'];
|
|
246
|
+
svelte?: FlatConfigItem['rules'];
|
|
254
247
|
};
|
|
255
248
|
}
|
|
256
249
|
|
package/dist/index.d.ts
CHANGED
|
@@ -38,22 +38,14 @@ type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (Opti
|
|
|
38
38
|
interface OptionsFormatters {
|
|
39
39
|
/**
|
|
40
40
|
* Enable formatting support for CSS, Less, Sass, and SCSS.
|
|
41
|
-
*
|
|
42
|
-
* Currently only support Prettier.
|
|
43
41
|
*/
|
|
44
42
|
css?: boolean;
|
|
45
43
|
/**
|
|
46
44
|
* Enable formatting support for HTML.
|
|
47
|
-
*
|
|
48
|
-
* Currently only support Prettier.
|
|
49
45
|
*/
|
|
50
46
|
html?: boolean;
|
|
51
47
|
/**
|
|
52
48
|
* Enable formatting support for Markdown.
|
|
53
|
-
*
|
|
54
|
-
* Support both Prettier.
|
|
55
|
-
*
|
|
56
|
-
* When set to `true`, it will use Prettier.
|
|
57
49
|
*/
|
|
58
50
|
markdown?: boolean;
|
|
59
51
|
/**
|
|
@@ -227,7 +219,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
227
219
|
* {
|
|
228
220
|
* "arrowParens": "avoid",
|
|
229
221
|
* "htmlWhitespaceSensitivity": "ignore"
|
|
230
|
-
* "printWidth":
|
|
222
|
+
* "printWidth": 120,
|
|
231
223
|
* "semi": false,
|
|
232
224
|
* "singleQuote": true,
|
|
233
225
|
* }
|
|
@@ -251,6 +243,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
251
243
|
vue?: FlatConfigItem['rules'];
|
|
252
244
|
jsonc?: FlatConfigItem['rules'];
|
|
253
245
|
react?: FlatConfigItem['rules'];
|
|
246
|
+
svelte?: FlatConfigItem['rules'];
|
|
254
247
|
};
|
|
255
248
|
}
|
|
256
249
|
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import process3 from "process";
|
|
3
|
-
import fs from "fs";
|
|
2
|
+
import process3 from "node:process";
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import { isPackageExists as isPackageExists3 } from "local-pkg";
|
|
5
5
|
|
|
6
6
|
// src/constants/prettier.ts
|
|
7
7
|
var DEFAULT_PRETTIER_RULES = {
|
|
8
8
|
arrowParens: "avoid",
|
|
9
9
|
htmlWhitespaceSensitivity: "ignore",
|
|
10
|
-
printWidth:
|
|
10
|
+
printWidth: 120,
|
|
11
11
|
semi: false,
|
|
12
12
|
singleQuote: true
|
|
13
13
|
};
|
|
@@ -46,6 +46,7 @@ var GLOB_JSX = "**/*.?([cm])jsx";
|
|
|
46
46
|
var GLOB_TS = "**/*.?([cm])ts";
|
|
47
47
|
var GLOB_TSX = "**/*.?([cm])tsx";
|
|
48
48
|
var GLOB_VUE = "**/*.vue";
|
|
49
|
+
var GLOB_SVELTE = "**/*.svelte";
|
|
49
50
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
50
51
|
var GLOB_CSS = "**/*.css";
|
|
51
52
|
var GLOB_POSTCSS = "**/*.{p,post}css";
|
|
@@ -412,9 +413,9 @@ async function javascript(options = {}) {
|
|
|
412
413
|
}
|
|
413
414
|
|
|
414
415
|
// src/shared/index.ts
|
|
415
|
-
import process from "process";
|
|
416
|
-
import { readFile } from "fs/promises";
|
|
417
|
-
import path from "path";
|
|
416
|
+
import process from "node:process";
|
|
417
|
+
import { readFile } from "node:fs/promises";
|
|
418
|
+
import path from "node:path";
|
|
418
419
|
import { getPackageInfoSync, isPackageExists } from "local-pkg";
|
|
419
420
|
var parserPlain = {
|
|
420
421
|
meta: {
|
|
@@ -496,11 +497,10 @@ function resolveSubOptions(options, key) {
|
|
|
496
497
|
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
497
498
|
}
|
|
498
499
|
function getOverrides(options, key) {
|
|
499
|
-
var _a;
|
|
500
500
|
const sub = resolveSubOptions(options, key);
|
|
501
501
|
return {
|
|
502
|
-
...
|
|
503
|
-
..."overrides" in sub ? sub.overrides : {}
|
|
502
|
+
...options.overrides?.[key],
|
|
503
|
+
..."overrides" in sub ? sub.overrides || {} : {}
|
|
504
504
|
};
|
|
505
505
|
}
|
|
506
506
|
|
|
@@ -825,10 +825,14 @@ async function prettier(rules) {
|
|
|
825
825
|
};
|
|
826
826
|
const configs = [
|
|
827
827
|
{
|
|
828
|
-
|
|
828
|
+
name: "coderwyd:prettier:setup",
|
|
829
829
|
plugins: {
|
|
830
830
|
prettier: pluginPrettier
|
|
831
|
-
}
|
|
831
|
+
}
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
files: GLOB_PRETTIER_LINT,
|
|
835
|
+
name: "coderwyd:prettier:rules",
|
|
832
836
|
rules: {
|
|
833
837
|
...eslintRules,
|
|
834
838
|
"prettier/prettier": ["warn", pRules],
|
|
@@ -842,7 +846,7 @@ async function prettier(rules) {
|
|
|
842
846
|
}
|
|
843
847
|
|
|
844
848
|
// src/configs/typescript.ts
|
|
845
|
-
import process2 from "process";
|
|
849
|
+
import process2 from "node:process";
|
|
846
850
|
async function typescript(options = {}) {
|
|
847
851
|
const { componentExts = [], overrides = {}, parserOptions = {} } = options;
|
|
848
852
|
const files = options.files ?? [
|
|
@@ -850,6 +854,8 @@ async function typescript(options = {}) {
|
|
|
850
854
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
851
855
|
];
|
|
852
856
|
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
857
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
858
|
+
const isTypeAware = !!tsconfigPath;
|
|
853
859
|
const typeAwareRules = {
|
|
854
860
|
"dot-notation": "off",
|
|
855
861
|
"no-implied-eval": "off",
|
|
@@ -871,34 +877,45 @@ async function typescript(options = {}) {
|
|
|
871
877
|
"ts/restrict-template-expressions": "error",
|
|
872
878
|
"ts/unbound-method": "error"
|
|
873
879
|
};
|
|
874
|
-
const tsconfigPath = (options == null ? void 0 : options.tsconfigPath) ? toArray(options.tsconfigPath) : void 0;
|
|
875
880
|
const [pluginTs, parserTs] = await Promise.all([
|
|
876
881
|
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
877
882
|
interopDefault(import("@typescript-eslint/parser"))
|
|
878
883
|
]);
|
|
879
|
-
|
|
880
|
-
{
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
plugins: {
|
|
884
|
-
antfu: default2,
|
|
885
|
-
ts: pluginTs
|
|
886
|
-
}
|
|
887
|
-
},
|
|
888
|
-
{
|
|
889
|
-
files,
|
|
884
|
+
function makeParser(typeAware, files2, ignores2) {
|
|
885
|
+
return {
|
|
886
|
+
files: files2,
|
|
887
|
+
...ignores2 ? { ignores: ignores2 } : {},
|
|
890
888
|
languageOptions: {
|
|
891
889
|
parser: parserTs,
|
|
892
890
|
parserOptions: {
|
|
893
891
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
894
892
|
sourceType: "module",
|
|
895
|
-
...
|
|
893
|
+
...typeAware ? {
|
|
896
894
|
project: tsconfigPath,
|
|
897
895
|
tsconfigRootDir: process2.cwd()
|
|
898
896
|
} : {},
|
|
899
897
|
...parserOptions
|
|
900
898
|
}
|
|
901
899
|
},
|
|
900
|
+
name: `coderwyd:typescript:${typeAware ? "type-aware-parser" : "parser"}`
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
return [
|
|
904
|
+
{
|
|
905
|
+
// Install the plugins without globs, so they can be configured separately.
|
|
906
|
+
name: "coderwyd:typescript:setup",
|
|
907
|
+
plugins: {
|
|
908
|
+
antfu: default2,
|
|
909
|
+
ts: pluginTs
|
|
910
|
+
}
|
|
911
|
+
},
|
|
912
|
+
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
913
|
+
...isTypeAware ? [
|
|
914
|
+
makeParser(true, filesTypeAware),
|
|
915
|
+
makeParser(false, files, filesTypeAware)
|
|
916
|
+
] : [makeParser(false, files)],
|
|
917
|
+
{
|
|
918
|
+
files,
|
|
902
919
|
name: "coderwyd:typescript:rules",
|
|
903
920
|
rules: {
|
|
904
921
|
...renameRules(
|
|
@@ -1028,11 +1045,11 @@ async function unicorn() {
|
|
|
1028
1045
|
// src/configs/vue.ts
|
|
1029
1046
|
async function vue(options = {}) {
|
|
1030
1047
|
const { files = [GLOB_VUE], overrides = {} } = options;
|
|
1031
|
-
const isVue3 = getVueVersion() === 3;
|
|
1032
1048
|
const [pluginVue, parserVue] = await Promise.all([
|
|
1033
1049
|
interopDefault(import("eslint-plugin-vue")),
|
|
1034
1050
|
interopDefault(import("vue-eslint-parser"))
|
|
1035
1051
|
]);
|
|
1052
|
+
const isVue3 = getVueVersion() === 3;
|
|
1036
1053
|
const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
|
|
1037
1054
|
const vueRules = configKeys.reduce((preRules, key) => {
|
|
1038
1055
|
const config = pluginVue.configs[key];
|
|
@@ -1323,7 +1340,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1323
1340
|
...prettierRules2,
|
|
1324
1341
|
parser
|
|
1325
1342
|
};
|
|
1326
|
-
if (plugins
|
|
1343
|
+
if (plugins?.length) {
|
|
1327
1344
|
rules.plugins = [...rules.plugins || [], ...plugins];
|
|
1328
1345
|
}
|
|
1329
1346
|
const config = {
|
|
@@ -1381,6 +1398,84 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1381
1398
|
return configs;
|
|
1382
1399
|
}
|
|
1383
1400
|
|
|
1401
|
+
// src/configs/svelte.ts
|
|
1402
|
+
async function svelte(options = {}) {
|
|
1403
|
+
const { files = [GLOB_SVELTE], overrides = {} } = options;
|
|
1404
|
+
await ensurePackages(["eslint-plugin-svelte"]);
|
|
1405
|
+
const [pluginSvelte, parserSvelte] = await Promise.all([
|
|
1406
|
+
interopDefault(import("eslint-plugin-svelte")),
|
|
1407
|
+
interopDefault(import("svelte-eslint-parser"))
|
|
1408
|
+
]);
|
|
1409
|
+
return [
|
|
1410
|
+
{
|
|
1411
|
+
name: "coderwyd:svelte:setup",
|
|
1412
|
+
plugins: {
|
|
1413
|
+
svelte: pluginSvelte
|
|
1414
|
+
}
|
|
1415
|
+
},
|
|
1416
|
+
{
|
|
1417
|
+
files,
|
|
1418
|
+
languageOptions: {
|
|
1419
|
+
parser: parserSvelte,
|
|
1420
|
+
parserOptions: {
|
|
1421
|
+
extraFileExtensions: [".svelte"],
|
|
1422
|
+
parser: options.typescript ? await interopDefault(
|
|
1423
|
+
import("@typescript-eslint/parser")
|
|
1424
|
+
) : null
|
|
1425
|
+
}
|
|
1426
|
+
},
|
|
1427
|
+
name: "coderwyd:svelte:rules",
|
|
1428
|
+
processor: pluginSvelte.processors[".svelte"],
|
|
1429
|
+
rules: {
|
|
1430
|
+
"import/no-mutable-exports": "off",
|
|
1431
|
+
"no-undef": "off",
|
|
1432
|
+
// incompatible with most recent (attribute-form) generic types RFC
|
|
1433
|
+
"no-unused-vars": [
|
|
1434
|
+
"error",
|
|
1435
|
+
{
|
|
1436
|
+
args: "none",
|
|
1437
|
+
caughtErrors: "none",
|
|
1438
|
+
ignoreRestSiblings: true,
|
|
1439
|
+
vars: "all",
|
|
1440
|
+
varsIgnorePattern: "^\\$\\$Props$"
|
|
1441
|
+
}
|
|
1442
|
+
],
|
|
1443
|
+
"svelte/comment-directive": "error",
|
|
1444
|
+
"svelte/no-at-debug-tags": "warn",
|
|
1445
|
+
"svelte/no-at-html-tags": "error",
|
|
1446
|
+
"svelte/no-dupe-else-if-blocks": "error",
|
|
1447
|
+
"svelte/no-dupe-style-properties": "error",
|
|
1448
|
+
"svelte/no-dupe-use-directives": "error",
|
|
1449
|
+
"svelte/no-dynamic-slot-name": "error",
|
|
1450
|
+
"svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
|
|
1451
|
+
"svelte/no-inner-declarations": "error",
|
|
1452
|
+
"svelte/no-not-function-handler": "error",
|
|
1453
|
+
"svelte/no-object-in-text-mustaches": "error",
|
|
1454
|
+
"svelte/no-reactive-functions": "error",
|
|
1455
|
+
"svelte/no-reactive-literals": "error",
|
|
1456
|
+
"svelte/no-shorthand-style-property-overrides": "error",
|
|
1457
|
+
"svelte/no-unknown-style-directive-property": "error",
|
|
1458
|
+
"svelte/no-unused-svelte-ignore": "error",
|
|
1459
|
+
"svelte/no-useless-mustaches": "error",
|
|
1460
|
+
"svelte/require-store-callbacks-use-set-param": "error",
|
|
1461
|
+
"svelte/system": "error",
|
|
1462
|
+
"svelte/valid-compile": "error",
|
|
1463
|
+
"svelte/valid-each-key": "error",
|
|
1464
|
+
"unused-imports/no-unused-vars": [
|
|
1465
|
+
"error",
|
|
1466
|
+
{
|
|
1467
|
+
args: "after-used",
|
|
1468
|
+
argsIgnorePattern: "^_",
|
|
1469
|
+
vars: "all",
|
|
1470
|
+
varsIgnorePattern: "^(_|\\$\\$Props$)"
|
|
1471
|
+
}
|
|
1472
|
+
],
|
|
1473
|
+
...overrides
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
];
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1384
1479
|
// src/index.ts
|
|
1385
1480
|
var flatConfigProps = [
|
|
1386
1481
|
"files",
|
|
@@ -1399,6 +1494,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1399
1494
|
gitignore: enableGitignore = true,
|
|
1400
1495
|
isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
|
|
1401
1496
|
react: enableReact = false,
|
|
1497
|
+
svelte: enableSvelte = false,
|
|
1402
1498
|
typescript: enableTypeScript = isPackageExists3("typescript"),
|
|
1403
1499
|
unocss: enableUnoCSS = false,
|
|
1404
1500
|
usePrettierrc = true,
|
|
@@ -1471,6 +1567,14 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1471
1567
|
})
|
|
1472
1568
|
);
|
|
1473
1569
|
}
|
|
1570
|
+
if (enableSvelte) {
|
|
1571
|
+
configs.push(
|
|
1572
|
+
svelte({
|
|
1573
|
+
overrides: getOverrides(options, "svelte"),
|
|
1574
|
+
typescript: !!enableTypeScript
|
|
1575
|
+
})
|
|
1576
|
+
);
|
|
1577
|
+
}
|
|
1474
1578
|
if (enableUnoCSS) {
|
|
1475
1579
|
configs.push(
|
|
1476
1580
|
unocss({
|
package/package.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderwyd/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"packageManager": "pnpm@8.14.1",
|
|
6
6
|
"description": "Donny's ESLint config",
|
|
7
7
|
"author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"homepage": "https://github.com/coderwyd/eslint-config",
|
|
10
10
|
"keywords": [
|
|
11
|
-
"eslint
|
|
11
|
+
"eslint",
|
|
12
|
+
"eslint-config",
|
|
13
|
+
"eslint-config-vue",
|
|
14
|
+
"eslint-config-react",
|
|
15
|
+
"eslint-config-svelte",
|
|
16
|
+
"prettier"
|
|
12
17
|
],
|
|
13
18
|
"exports": {
|
|
14
19
|
".": {
|
|
@@ -36,7 +41,9 @@
|
|
|
36
41
|
"eslint": ">=8.40.0",
|
|
37
42
|
"eslint-plugin-react": "^7.33.2",
|
|
38
43
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
39
|
-
"eslint-plugin-react-refresh": "^0.4.4"
|
|
44
|
+
"eslint-plugin-react-refresh": "^0.4.4",
|
|
45
|
+
"eslint-plugin-svelte": "^2.34.1",
|
|
46
|
+
"svelte-eslint-parser": "^0.33.1"
|
|
40
47
|
},
|
|
41
48
|
"peerDependenciesMeta": {
|
|
42
49
|
"@unocss/eslint-plugin": {
|
|
@@ -50,13 +57,19 @@
|
|
|
50
57
|
},
|
|
51
58
|
"eslint-plugin-react-refresh": {
|
|
52
59
|
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"eslint-plugin-svelte": {
|
|
62
|
+
"optional": true
|
|
63
|
+
},
|
|
64
|
+
"svelte-eslint-parser": {
|
|
65
|
+
"optional": true
|
|
53
66
|
}
|
|
54
67
|
},
|
|
55
68
|
"dependencies": {
|
|
56
69
|
"@antfu/eslint-define-config": "1.23.0-2",
|
|
57
70
|
"@antfu/install-pkg": "^0.3.1",
|
|
58
71
|
"@eslint-types/jsdoc": "48.0.2",
|
|
59
|
-
"@eslint-types/typescript-eslint": "^6.
|
|
72
|
+
"@eslint-types/typescript-eslint": "^6.18.1",
|
|
60
73
|
"@eslint-types/unicorn": "^50.0.1",
|
|
61
74
|
"@toml-tools/parser": "^1.0.0",
|
|
62
75
|
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
|
@@ -67,7 +80,7 @@
|
|
|
67
80
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
68
81
|
"eslint-plugin-i": "^2.29.1",
|
|
69
82
|
"eslint-plugin-jsdoc": "^48.0.2",
|
|
70
|
-
"eslint-plugin-jsonc": "^2.
|
|
83
|
+
"eslint-plugin-jsonc": "^2.12.2",
|
|
71
84
|
"eslint-plugin-n": "^16.6.2",
|
|
72
85
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
73
86
|
"eslint-plugin-perfectionist": "^2.5.0",
|
|
@@ -75,13 +88,13 @@
|
|
|
75
88
|
"eslint-plugin-unicorn": "^50.0.1",
|
|
76
89
|
"eslint-plugin-unused-imports": "^3.0.0",
|
|
77
90
|
"eslint-plugin-vitest": "^0.3.20",
|
|
78
|
-
"eslint-plugin-vue": "^9.
|
|
91
|
+
"eslint-plugin-vue": "^9.20.1",
|
|
79
92
|
"globals": "^13.24.0",
|
|
80
93
|
"jsonc-eslint-parser": "^2.4.0",
|
|
81
94
|
"local-pkg": "^0.5.0",
|
|
82
95
|
"parse-gitignore": "^2.0.0",
|
|
83
96
|
"picocolors": "^1.0.0",
|
|
84
|
-
"prettier": "^3.
|
|
97
|
+
"prettier": "^3.2.4",
|
|
85
98
|
"prettier-plugin-toml": "^2.0.1",
|
|
86
99
|
"prompts": "^2.4.2",
|
|
87
100
|
"vue-eslint-parser": "^9.4.0",
|
|
@@ -95,12 +108,13 @@
|
|
|
95
108
|
"@types/prompts": "^2.4.9",
|
|
96
109
|
"@types/yargs": "^17.0.32",
|
|
97
110
|
"@unocss/eslint-plugin": "^0.58.3",
|
|
98
|
-
"bumpp": "^9.
|
|
111
|
+
"bumpp": "^9.3.0",
|
|
99
112
|
"eslint": "^8.56.0",
|
|
100
|
-
"eslint-flat-config-viewer": "^0.1.
|
|
113
|
+
"eslint-flat-config-viewer": "^0.1.11",
|
|
101
114
|
"eslint-plugin-react": "^7.33.2",
|
|
102
115
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
103
116
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
117
|
+
"eslint-plugin-svelte": "^2.35.1",
|
|
104
118
|
"esno": "^4.0.0",
|
|
105
119
|
"execa": "^8.0.1",
|
|
106
120
|
"fast-glob": "^3.3.2",
|
|
@@ -108,6 +122,7 @@
|
|
|
108
122
|
"lint-staged": "^15.2.0",
|
|
109
123
|
"rimraf": "^5.0.5",
|
|
110
124
|
"simple-git-hooks": "^2.9.0",
|
|
125
|
+
"svelte-eslint-parser": "^0.33.1",
|
|
111
126
|
"tsup": "^8.0.1",
|
|
112
127
|
"typescript": "^5.3.3"
|
|
113
128
|
},
|