@antfu/eslint-config 2.4.5 → 2.5.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 CHANGED
@@ -4,14 +4,15 @@
4
4
 
5
5
  - Single quotes, no semi
6
6
  - Auto fix for formatting (aimed to be used standalone **without** Prettier)
7
+ - Sorted imports, dangling commas
8
+ - Reasonable defaults, best practices, only one line of config
7
9
  - Designed to work with TypeScript, JSX, Vue out-of-box
8
10
  - Lints also for json, yaml, toml, markdown
9
- - Sorted imports, dangling commas
10
- - Reasonable defaults, best practices, only one-line of config
11
11
  - Opinionated, but [very customizable](#customization)
12
12
  - [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), compose easily!
13
13
  - Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
14
14
  - Respects `.gitignore` by default
15
+ - Optional [React](#react), [Svelte](#svelte), [UnoCSS](#unocss) support
15
16
  - Optional [formatters](#formatters) support for CSS, HTML, etc.
16
17
  - **Style principle**: Minimal for reading, stable for diff, consistent
17
18
 
@@ -403,6 +404,25 @@ Running `npx eslint` should prompt you to install the required dependencies, oth
403
404
  npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
404
405
  ```
405
406
 
407
+ #### Svelte
408
+
409
+ To enable svelte support, you need to explicitly turn it on:
410
+
411
+ ```js
412
+ // eslint.config.js
413
+ import antfu from '@antfu/eslint-config'
414
+
415
+ export default antfu({
416
+ svelte: true,
417
+ })
418
+ ```
419
+
420
+ Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
421
+
422
+ ```bash
423
+ npm i -D eslint-plugin-svelte
424
+ ```
425
+
406
426
  #### UnoCSS
407
427
 
408
428
  To enable UnoCSS support, you need to explicitly turn it on:
package/bin/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
-
2
+ // eslint-disable-next-line antfu/no-import-dist
3
3
  import '../dist/cli.js'
package/dist/cli.cjs CHANGED
@@ -46,15 +46,15 @@ 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.4.5";
49
+ var version = "2.5.0";
50
50
  var devDependencies = {
51
51
  "@antfu/eslint-config": "workspace:*",
52
52
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
53
53
  "@antfu/ni": "^0.21.12",
54
54
  "@stylistic/eslint-plugin-migrate": "^1.5.1",
55
- "@types/eslint": "^8.44.8",
55
+ "@types/eslint": "^8.56.0",
56
56
  "@types/fs-extra": "^11.0.4",
57
- "@types/node": "^20.10.4",
57
+ "@types/node": "^20.10.5",
58
58
  "@types/prompts": "^2.4.9",
59
59
  "@types/yargs": "^17.0.32",
60
60
  "@unocss/eslint-plugin": "^0.58.0",
@@ -65,6 +65,7 @@ var devDependencies = {
65
65
  "eslint-plugin-react": "^7.33.2",
66
66
  "eslint-plugin-react-hooks": "^4.6.0",
67
67
  "eslint-plugin-react-refresh": "^0.4.5",
68
+ "eslint-plugin-svelte": "^2.35.1",
68
69
  "eslint-ts-patch": "^8.55.0-1",
69
70
  esno: "^4.0.0",
70
71
  execa: "^8.0.1",
@@ -73,10 +74,11 @@ var devDependencies = {
73
74
  "lint-staged": "^15.2.0",
74
75
  rimraf: "^5.0.5",
75
76
  "simple-git-hooks": "^2.9.0",
77
+ "svelte-eslint-parser": "^0.33.1",
76
78
  tsup: "^8.0.1",
77
79
  typescript: "^5.3.3",
78
- vitest: "^1.0.4",
79
- vue: "^3.3.11"
80
+ vitest: "^1.1.0",
81
+ vue: "^3.3.13"
80
82
  };
81
83
 
82
84
  // src/cli/constants.ts
package/dist/cli.js CHANGED
@@ -17,15 +17,15 @@ import parse from "parse-gitignore";
17
17
  import c from "picocolors";
18
18
 
19
19
  // package.json
20
- var version = "2.4.5";
20
+ var version = "2.5.0";
21
21
  var devDependencies = {
22
22
  "@antfu/eslint-config": "workspace:*",
23
23
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
24
24
  "@antfu/ni": "^0.21.12",
25
25
  "@stylistic/eslint-plugin-migrate": "^1.5.1",
26
- "@types/eslint": "^8.44.8",
26
+ "@types/eslint": "^8.56.0",
27
27
  "@types/fs-extra": "^11.0.4",
28
- "@types/node": "^20.10.4",
28
+ "@types/node": "^20.10.5",
29
29
  "@types/prompts": "^2.4.9",
30
30
  "@types/yargs": "^17.0.32",
31
31
  "@unocss/eslint-plugin": "^0.58.0",
@@ -36,6 +36,7 @@ var devDependencies = {
36
36
  "eslint-plugin-react": "^7.33.2",
37
37
  "eslint-plugin-react-hooks": "^4.6.0",
38
38
  "eslint-plugin-react-refresh": "^0.4.5",
39
+ "eslint-plugin-svelte": "^2.35.1",
39
40
  "eslint-ts-patch": "^8.55.0-1",
40
41
  esno: "^4.0.0",
41
42
  execa: "^8.0.1",
@@ -44,10 +45,11 @@ var devDependencies = {
44
45
  "lint-staged": "^15.2.0",
45
46
  rimraf: "^5.0.5",
46
47
  "simple-git-hooks": "^2.9.0",
48
+ "svelte-eslint-parser": "^0.33.1",
47
49
  tsup: "^8.0.1",
48
50
  typescript: "^5.3.3",
49
- vitest: "^1.0.4",
50
- vue: "^3.3.11"
51
+ vitest: "^1.1.0",
52
+ vue: "^3.3.13"
51
53
  };
52
54
 
53
55
  // src/cli/constants.ts
package/dist/index.cjs CHANGED
@@ -48,6 +48,7 @@ __export(src_exports, {
48
48
  GLOB_SRC: () => GLOB_SRC,
49
49
  GLOB_SRC_EXT: () => GLOB_SRC_EXT,
50
50
  GLOB_STYLE: () => GLOB_STYLE,
51
+ GLOB_SVELTE: () => GLOB_SVELTE,
51
52
  GLOB_TESTS: () => GLOB_TESTS,
52
53
  GLOB_TOML: () => GLOB_TOML,
53
54
  GLOB_TS: () => GLOB_TS,
@@ -69,12 +70,14 @@ __export(src_exports, {
69
70
  jsonc: () => jsonc,
70
71
  markdown: () => markdown,
71
72
  node: () => node,
73
+ parserPlain: () => parserPlain,
72
74
  perfectionist: () => perfectionist,
73
75
  react: () => react,
74
76
  renameRules: () => renameRules,
75
77
  sortPackageJson: () => sortPackageJson,
76
78
  sortTsconfig: () => sortTsconfig,
77
79
  stylistic: () => stylistic,
80
+ svelte: () => svelte,
78
81
  test: () => test,
79
82
  toArray: () => toArray,
80
83
  toml: () => toml,
@@ -135,6 +138,7 @@ var GLOB_JSON5 = "**/*.json5";
135
138
  var GLOB_JSONC = "**/*.jsonc";
136
139
  var GLOB_MARKDOWN = "**/*.md";
137
140
  var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
141
+ var GLOB_SVELTE = "**/*.svelte";
138
142
  var GLOB_VUE = "**/*.vue";
139
143
  var GLOB_YAML = "**/*.y?(a)ml";
140
144
  var GLOB_TOML = "**/*.toml";
@@ -153,6 +157,7 @@ var GLOB_ALL_SRC = [
153
157
  GLOB_JSON,
154
158
  GLOB_JSON5,
155
159
  GLOB_MARKDOWN,
160
+ GLOB_SVELTE,
156
161
  GLOB_VUE,
157
162
  GLOB_YAML,
158
163
  GLOB_HTML
@@ -211,6 +216,7 @@ async function imports(options = {}) {
211
216
  },
212
217
  rules: {
213
218
  "antfu/import-dedupe": "error",
219
+ "antfu/no-import-dist": "error",
214
220
  "antfu/no-import-node-modules-by-path": "error",
215
221
  "import/first": "error",
216
222
  "import/no-duplicates": "error",
@@ -447,6 +453,26 @@ async function javascript(options = {}) {
447
453
  // src/utils.ts
448
454
  var import_node_process = __toESM(require("process"), 1);
449
455
  var import_local_pkg = require("local-pkg");
456
+ var parserPlain = {
457
+ meta: {
458
+ name: "parser-plain"
459
+ },
460
+ parseForESLint: (code) => ({
461
+ ast: {
462
+ body: [],
463
+ comments: [],
464
+ loc: { end: code.length, start: 0 },
465
+ range: [0, code.length],
466
+ tokens: [],
467
+ type: "Program"
468
+ },
469
+ scopeManager: null,
470
+ services: { isPlain: true },
471
+ visitorKeys: {
472
+ Program: []
473
+ }
474
+ })
475
+ };
450
476
  async function combine(...configs) {
451
477
  const resolved = await Promise.all(configs);
452
478
  return resolved.flat();
@@ -598,7 +624,6 @@ async function jsonc(options = {}) {
598
624
  }
599
625
 
600
626
  // src/configs/markdown.ts
601
- var parserPlain = __toESM(require("eslint-parser-plain"), 1);
602
627
  var import_eslint_merge_processors = require("eslint-merge-processors");
603
628
  async function markdown(options = {}) {
604
629
  const {
@@ -729,9 +754,6 @@ async function perfectionist() {
729
754
  ];
730
755
  }
731
756
 
732
- // src/configs/formatters.ts
733
- var parserPlain2 = __toESM(require("eslint-parser-plain"), 1);
734
-
735
757
  // src/configs/stylistic.ts
736
758
  var StylisticConfigDefaults = {
737
759
  indent: 2,
@@ -743,6 +765,7 @@ async function stylistic(options = {}) {
743
765
  const {
744
766
  indent,
745
767
  jsx,
768
+ overrides = {},
746
769
  quotes,
747
770
  semi
748
771
  } = {
@@ -770,7 +793,8 @@ async function stylistic(options = {}) {
770
793
  "antfu/consistent-list-newline": "error",
771
794
  "antfu/if-newline": "error",
772
795
  "antfu/top-level-function": "error",
773
- "curly": ["error", "multi-or-nest", "consistent"]
796
+ "curly": ["error", "multi-or-nest", "consistent"],
797
+ ...overrides
774
798
  }
775
799
  }
776
800
  ];
@@ -830,7 +854,7 @@ async function formatters(options = {}, stylistic2 = {}) {
830
854
  {
831
855
  files: [GLOB_CSS, GLOB_POSTCSS],
832
856
  languageOptions: {
833
- parser: parserPlain2
857
+ parser: parserPlain
834
858
  },
835
859
  name: "antfu:formatter:css",
836
860
  rules: {
@@ -846,7 +870,7 @@ async function formatters(options = {}, stylistic2 = {}) {
846
870
  {
847
871
  files: [GLOB_SCSS],
848
872
  languageOptions: {
849
- parser: parserPlain2
873
+ parser: parserPlain
850
874
  },
851
875
  name: "antfu:formatter:scss",
852
876
  rules: {
@@ -862,7 +886,7 @@ async function formatters(options = {}, stylistic2 = {}) {
862
886
  {
863
887
  files: [GLOB_LESS],
864
888
  languageOptions: {
865
- parser: parserPlain2
889
+ parser: parserPlain
866
890
  },
867
891
  name: "antfu:formatter:less",
868
892
  rules: {
@@ -881,7 +905,7 @@ async function formatters(options = {}, stylistic2 = {}) {
881
905
  configs.push({
882
906
  files: ["**/*.html"],
883
907
  languageOptions: {
884
- parser: parserPlain2
908
+ parser: parserPlain
885
909
  },
886
910
  name: "antfu:formatter:html",
887
911
  rules: {
@@ -900,13 +924,14 @@ async function formatters(options = {}, stylistic2 = {}) {
900
924
  configs.push({
901
925
  files: [GLOB_MARKDOWN],
902
926
  languageOptions: {
903
- parser: parserPlain2
927
+ parser: parserPlain
904
928
  },
905
929
  name: "antfu:formatter:markdown",
906
930
  rules: {
907
931
  [`format/${formater}`]: [
908
932
  "error",
909
933
  formater === "prettier" ? {
934
+ printWidth: 120,
910
935
  ...prettierOptions,
911
936
  embeddedLanguageFormatting: "off",
912
937
  parser: "markdown"
@@ -922,7 +947,7 @@ async function formatters(options = {}, stylistic2 = {}) {
922
947
  configs.push({
923
948
  files: ["**/*.graphql"],
924
949
  languageOptions: {
925
- parser: parserPlain2
950
+ parser: parserPlain
926
951
  },
927
952
  name: "antfu:formatter:graphql",
928
953
  rules: {
@@ -1100,15 +1125,11 @@ async function sortPackageJson() {
1100
1125
  },
1101
1126
  {
1102
1127
  order: { type: "asc" },
1103
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1104
- },
1105
- {
1106
- order: { type: "asc" },
1107
- pathPattern: "^resolutions$"
1128
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1108
1129
  },
1109
1130
  {
1110
1131
  order: { type: "asc" },
1111
- pathPattern: "^pnpm.overrides$"
1132
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1112
1133
  },
1113
1134
  {
1114
1135
  order: [
@@ -1250,6 +1271,98 @@ function sortTsconfig() {
1250
1271
  ];
1251
1272
  }
1252
1273
 
1274
+ // src/configs/svelte.ts
1275
+ async function svelte(options = {}) {
1276
+ const {
1277
+ files = [GLOB_SVELTE],
1278
+ overrides = {},
1279
+ stylistic: stylistic2 = true
1280
+ } = options;
1281
+ const {
1282
+ indent = 2,
1283
+ quotes = "single"
1284
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1285
+ await ensurePackages([
1286
+ "eslint-plugin-svelte"
1287
+ ]);
1288
+ const [
1289
+ pluginSvelte,
1290
+ parserSvelte
1291
+ ] = await Promise.all([
1292
+ interopDefault(import("eslint-plugin-svelte")),
1293
+ interopDefault(import("svelte-eslint-parser"))
1294
+ ]);
1295
+ return [
1296
+ {
1297
+ name: "antfu:svelte:setup",
1298
+ plugins: {
1299
+ svelte: pluginSvelte
1300
+ }
1301
+ },
1302
+ {
1303
+ files,
1304
+ languageOptions: {
1305
+ parser: parserSvelte,
1306
+ parserOptions: {
1307
+ extraFileExtensions: [".svelte"],
1308
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1309
+ }
1310
+ },
1311
+ name: "antfu:svelte:rules",
1312
+ rules: {
1313
+ "import/no-mutable-exports": "off",
1314
+ "no-undef": "off",
1315
+ // incompatible with most recent (attribute-form) generic types RFC
1316
+ "no-unused-vars": ["error", {
1317
+ args: "none",
1318
+ caughtErrors: "none",
1319
+ ignoreRestSiblings: true,
1320
+ vars: "all",
1321
+ varsIgnorePattern: "^\\$\\$Props$"
1322
+ }],
1323
+ "svelte/comment-directive": "error",
1324
+ "svelte/no-at-debug-tags": "warn",
1325
+ "svelte/no-at-html-tags": "error",
1326
+ "svelte/no-dupe-else-if-blocks": "error",
1327
+ "svelte/no-dupe-style-properties": "error",
1328
+ "svelte/no-dupe-use-directives": "error",
1329
+ "svelte/no-dynamic-slot-name": "error",
1330
+ "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
1331
+ "svelte/no-inner-declarations": "error",
1332
+ "svelte/no-not-function-handler": "error",
1333
+ "svelte/no-object-in-text-mustaches": "error",
1334
+ "svelte/no-reactive-functions": "error",
1335
+ "svelte/no-reactive-literals": "error",
1336
+ "svelte/no-shorthand-style-property-overrides": "error",
1337
+ "svelte/no-unknown-style-directive-property": "error",
1338
+ "svelte/no-unused-svelte-ignore": "error",
1339
+ "svelte/no-useless-mustaches": "error",
1340
+ "svelte/require-store-callbacks-use-set-param": "error",
1341
+ "svelte/system": "error",
1342
+ "svelte/valid-compile": "error",
1343
+ "svelte/valid-each-key": "error",
1344
+ "unused-imports/no-unused-vars": [
1345
+ "error",
1346
+ { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
1347
+ ],
1348
+ ...stylistic2 ? {
1349
+ "style/no-trailing-spaces": "off",
1350
+ // superseded by svelte/no-trailing-spaces
1351
+ "svelte/derived-has-same-inputs-outputs": "error",
1352
+ "svelte/html-closing-bracket-spacing": "error",
1353
+ "svelte/html-quotes": ["error", { prefer: quotes }],
1354
+ "svelte/indent": ["error", { alignAttributesVertically: true, indent }],
1355
+ "svelte/mustache-spacing": "error",
1356
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1357
+ "svelte/no-trailing-spaces": "error",
1358
+ "svelte/spaced-html-comment": "error"
1359
+ } : {},
1360
+ ...overrides
1361
+ }
1362
+ }
1363
+ ];
1364
+ }
1365
+
1253
1366
  // src/configs/test.ts
1254
1367
  async function test(options = {}) {
1255
1368
  const {
@@ -1308,6 +1421,7 @@ async function typescript(options = {}) {
1308
1421
  GLOB_SRC,
1309
1422
  ...componentExts.map((ext) => `**/*.${ext}`)
1310
1423
  ];
1424
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1311
1425
  const typeAwareRules = {
1312
1426
  "dot-notation": "off",
1313
1427
  "no-implied-eval": "off",
@@ -1397,6 +1511,13 @@ async function typescript(options = {}) {
1397
1511
  "ts/prefer-ts-expect-error": "error",
1398
1512
  "ts/triple-slash-reference": "off",
1399
1513
  "ts/unified-signatures": "off",
1514
+ ...overrides
1515
+ }
1516
+ },
1517
+ {
1518
+ files: filesTypeAware,
1519
+ name: "antfu:typescript:rules-type-aware",
1520
+ rules: {
1400
1521
  ...tsconfigPath ? typeAwareRules : {},
1401
1522
  ...overrides
1402
1523
  }
@@ -1787,9 +1908,10 @@ async function antfu(options = {}, ...userConfigs) {
1787
1908
  const {
1788
1909
  componentExts = [],
1789
1910
  gitignore: enableGitignore = true,
1790
- isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
1911
+ 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),
1791
1912
  overrides = {},
1792
1913
  react: enableReact = false,
1914
+ svelte: enableSvelte = false,
1793
1915
  typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
1794
1916
  unocss: enableUnoCSS = false,
1795
1917
  vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
@@ -1833,8 +1955,12 @@ async function antfu(options = {}, ...userConfigs) {
1833
1955
  overrides: overrides.typescript
1834
1956
  }));
1835
1957
  }
1836
- if (stylisticOptions)
1837
- configs.push(stylistic(stylisticOptions));
1958
+ if (stylisticOptions) {
1959
+ configs.push(stylistic({
1960
+ ...stylisticOptions,
1961
+ overrides: overrides.stylistic
1962
+ }));
1963
+ }
1838
1964
  if (options.test ?? true) {
1839
1965
  configs.push(test({
1840
1966
  isInEditor,
@@ -1855,6 +1981,13 @@ async function antfu(options = {}, ...userConfigs) {
1855
1981
  typescript: !!enableTypeScript
1856
1982
  }));
1857
1983
  }
1984
+ if (enableSvelte) {
1985
+ configs.push(svelte({
1986
+ overrides: overrides.svelte,
1987
+ stylistic: stylisticOptions,
1988
+ typescript: !!enableTypeScript
1989
+ }));
1990
+ }
1858
1991
  if (enableUnoCSS) {
1859
1992
  configs.push(unocss(
1860
1993
  typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
@@ -1934,6 +2067,7 @@ var src_default = antfu;
1934
2067
  GLOB_SRC,
1935
2068
  GLOB_SRC_EXT,
1936
2069
  GLOB_STYLE,
2070
+ GLOB_SVELTE,
1937
2071
  GLOB_TESTS,
1938
2072
  GLOB_TOML,
1939
2073
  GLOB_TS,
@@ -1954,12 +2088,14 @@ var src_default = antfu;
1954
2088
  jsonc,
1955
2089
  markdown,
1956
2090
  node,
2091
+ parserPlain,
1957
2092
  perfectionist,
1958
2093
  react,
1959
2094
  renameRules,
1960
2095
  sortPackageJson,
1961
2096
  sortTsconfig,
1962
2097
  stylistic,
2098
+ svelte,
1963
2099
  test,
1964
2100
  toArray,
1965
2101
  toml,
package/dist/index.d.cts CHANGED
@@ -14,6 +14,11 @@ import { UnprefixedRuleOptions, StylisticCustomizeOptions } from '@stylistic/esl
14
14
  */
15
15
  type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
16
16
  interface VendoredPrettierOptionsRequired {
17
+ /**
18
+ * Specify the line length that the printer will wrap on.
19
+ * @default 120
20
+ */
21
+ printWidth: number;
17
22
  /**
18
23
  * Specify the number of spaces per indentation-level.
19
24
  */
@@ -198,6 +203,11 @@ interface OptionsTypeScriptParserOptions {
198
203
  * Additional parser options for TypeScript.
199
204
  */
200
205
  parserOptions?: Partial<ParserOptions>;
206
+ /**
207
+ * Glob patterns for files that should be type aware.
208
+ * @default ['**\/*.{ts,tsx}']
209
+ */
210
+ filesTypeAware?: string[];
201
211
  }
202
212
  interface OptionsTypeScriptWithTypes {
203
213
  /**
@@ -313,6 +323,15 @@ interface OptionsConfig extends OptionsComponentExts {
313
323
  * @default false
314
324
  */
315
325
  react?: boolean;
326
+ /**
327
+ * Enable svelte rules.
328
+ *
329
+ * Requires installing:
330
+ * - `eslint-plugin-svelte`
331
+ *
332
+ * @default false
333
+ */
334
+ svelte?: boolean;
316
335
  /**
317
336
  * Enable unocss rules.
318
337
  *
@@ -342,6 +361,7 @@ interface OptionsConfig extends OptionsComponentExts {
342
361
  * Provide overrides for rules for each integration.
343
362
  */
344
363
  overrides?: {
364
+ stylistic?: FlatConfigItem['rules'];
345
365
  javascript?: FlatConfigItem['rules'];
346
366
  typescript?: FlatConfigItem['rules'];
347
367
  test?: FlatConfigItem['rules'];
@@ -351,6 +371,7 @@ interface OptionsConfig extends OptionsComponentExts {
351
371
  yaml?: FlatConfigItem['rules'];
352
372
  toml?: FlatConfigItem['rules'];
353
373
  react?: FlatConfigItem['rules'];
374
+ svelte?: FlatConfigItem['rules'];
354
375
  };
355
376
  }
356
377
 
@@ -400,7 +421,9 @@ declare function sortPackageJson(): Promise<FlatConfigItem[]>;
400
421
  declare function sortTsconfig(): FlatConfigItem[];
401
422
 
402
423
  declare const StylisticConfigDefaults: StylisticConfig;
403
- declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
424
+ declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
425
+
426
+ declare function svelte(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
404
427
 
405
428
  declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
406
429
 
@@ -432,6 +455,7 @@ declare const GLOB_JSON5 = "**/*.json5";
432
455
  declare const GLOB_JSONC = "**/*.jsonc";
433
456
  declare const GLOB_MARKDOWN = "**/*.md";
434
457
  declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
458
+ declare const GLOB_SVELTE = "**/*.svelte";
435
459
  declare const GLOB_VUE = "**/*.vue";
436
460
  declare const GLOB_YAML = "**/*.y?(a)ml";
437
461
  declare const GLOB_TOML = "**/*.toml";
@@ -441,6 +465,31 @@ declare const GLOB_TESTS: string[];
441
465
  declare const GLOB_ALL_SRC: string[];
442
466
  declare const GLOB_EXCLUDE: string[];
443
467
 
468
+ declare const parserPlain: {
469
+ meta: {
470
+ name: string;
471
+ };
472
+ parseForESLint: (code: string) => {
473
+ ast: {
474
+ body: never[];
475
+ comments: never[];
476
+ loc: {
477
+ end: number;
478
+ start: number;
479
+ };
480
+ range: number[];
481
+ tokens: never[];
482
+ type: string;
483
+ };
484
+ scopeManager: null;
485
+ services: {
486
+ isPlain: boolean;
487
+ };
488
+ visitorKeys: {
489
+ Program: never[];
490
+ };
491
+ };
492
+ };
444
493
  /**
445
494
  * Combine array and non-array configs into a single array.
446
495
  */
@@ -454,4 +503,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
454
503
  } ? U : T>;
455
504
  declare function ensurePackages(packages: string[]): Promise<void>;
456
505
 
457
- export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
506
+ export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.d.ts CHANGED
@@ -14,6 +14,11 @@ import { UnprefixedRuleOptions, StylisticCustomizeOptions } from '@stylistic/esl
14
14
  */
15
15
  type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
16
16
  interface VendoredPrettierOptionsRequired {
17
+ /**
18
+ * Specify the line length that the printer will wrap on.
19
+ * @default 120
20
+ */
21
+ printWidth: number;
17
22
  /**
18
23
  * Specify the number of spaces per indentation-level.
19
24
  */
@@ -198,6 +203,11 @@ interface OptionsTypeScriptParserOptions {
198
203
  * Additional parser options for TypeScript.
199
204
  */
200
205
  parserOptions?: Partial<ParserOptions>;
206
+ /**
207
+ * Glob patterns for files that should be type aware.
208
+ * @default ['**\/*.{ts,tsx}']
209
+ */
210
+ filesTypeAware?: string[];
201
211
  }
202
212
  interface OptionsTypeScriptWithTypes {
203
213
  /**
@@ -313,6 +323,15 @@ interface OptionsConfig extends OptionsComponentExts {
313
323
  * @default false
314
324
  */
315
325
  react?: boolean;
326
+ /**
327
+ * Enable svelte rules.
328
+ *
329
+ * Requires installing:
330
+ * - `eslint-plugin-svelte`
331
+ *
332
+ * @default false
333
+ */
334
+ svelte?: boolean;
316
335
  /**
317
336
  * Enable unocss rules.
318
337
  *
@@ -342,6 +361,7 @@ interface OptionsConfig extends OptionsComponentExts {
342
361
  * Provide overrides for rules for each integration.
343
362
  */
344
363
  overrides?: {
364
+ stylistic?: FlatConfigItem['rules'];
345
365
  javascript?: FlatConfigItem['rules'];
346
366
  typescript?: FlatConfigItem['rules'];
347
367
  test?: FlatConfigItem['rules'];
@@ -351,6 +371,7 @@ interface OptionsConfig extends OptionsComponentExts {
351
371
  yaml?: FlatConfigItem['rules'];
352
372
  toml?: FlatConfigItem['rules'];
353
373
  react?: FlatConfigItem['rules'];
374
+ svelte?: FlatConfigItem['rules'];
354
375
  };
355
376
  }
356
377
 
@@ -400,7 +421,9 @@ declare function sortPackageJson(): Promise<FlatConfigItem[]>;
400
421
  declare function sortTsconfig(): FlatConfigItem[];
401
422
 
402
423
  declare const StylisticConfigDefaults: StylisticConfig;
403
- declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
424
+ declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
425
+
426
+ declare function svelte(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
404
427
 
405
428
  declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
406
429
 
@@ -432,6 +455,7 @@ declare const GLOB_JSON5 = "**/*.json5";
432
455
  declare const GLOB_JSONC = "**/*.jsonc";
433
456
  declare const GLOB_MARKDOWN = "**/*.md";
434
457
  declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
458
+ declare const GLOB_SVELTE = "**/*.svelte";
435
459
  declare const GLOB_VUE = "**/*.vue";
436
460
  declare const GLOB_YAML = "**/*.y?(a)ml";
437
461
  declare const GLOB_TOML = "**/*.toml";
@@ -441,6 +465,31 @@ declare const GLOB_TESTS: string[];
441
465
  declare const GLOB_ALL_SRC: string[];
442
466
  declare const GLOB_EXCLUDE: string[];
443
467
 
468
+ declare const parserPlain: {
469
+ meta: {
470
+ name: string;
471
+ };
472
+ parseForESLint: (code: string) => {
473
+ ast: {
474
+ body: never[];
475
+ comments: never[];
476
+ loc: {
477
+ end: number;
478
+ start: number;
479
+ };
480
+ range: number[];
481
+ tokens: never[];
482
+ type: string;
483
+ };
484
+ scopeManager: null;
485
+ services: {
486
+ isPlain: boolean;
487
+ };
488
+ visitorKeys: {
489
+ Program: never[];
490
+ };
491
+ };
492
+ };
444
493
  /**
445
494
  * Combine array and non-array configs into a single array.
446
495
  */
@@ -454,4 +503,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
454
503
  } ? U : T>;
455
504
  declare function ensurePackages(packages: string[]): Promise<void>;
456
505
 
457
- export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
506
+ export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.js CHANGED
@@ -47,6 +47,7 @@ var GLOB_JSON5 = "**/*.json5";
47
47
  var GLOB_JSONC = "**/*.jsonc";
48
48
  var GLOB_MARKDOWN = "**/*.md";
49
49
  var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
50
+ var GLOB_SVELTE = "**/*.svelte";
50
51
  var GLOB_VUE = "**/*.vue";
51
52
  var GLOB_YAML = "**/*.y?(a)ml";
52
53
  var GLOB_TOML = "**/*.toml";
@@ -65,6 +66,7 @@ var GLOB_ALL_SRC = [
65
66
  GLOB_JSON,
66
67
  GLOB_JSON5,
67
68
  GLOB_MARKDOWN,
69
+ GLOB_SVELTE,
68
70
  GLOB_VUE,
69
71
  GLOB_YAML,
70
72
  GLOB_HTML
@@ -123,6 +125,7 @@ async function imports(options = {}) {
123
125
  },
124
126
  rules: {
125
127
  "antfu/import-dedupe": "error",
128
+ "antfu/no-import-dist": "error",
126
129
  "antfu/no-import-node-modules-by-path": "error",
127
130
  "import/first": "error",
128
131
  "import/no-duplicates": "error",
@@ -359,6 +362,26 @@ async function javascript(options = {}) {
359
362
  // src/utils.ts
360
363
  import process from "process";
361
364
  import { isPackageExists } from "local-pkg";
365
+ var parserPlain = {
366
+ meta: {
367
+ name: "parser-plain"
368
+ },
369
+ parseForESLint: (code) => ({
370
+ ast: {
371
+ body: [],
372
+ comments: [],
373
+ loc: { end: code.length, start: 0 },
374
+ range: [0, code.length],
375
+ tokens: [],
376
+ type: "Program"
377
+ },
378
+ scopeManager: null,
379
+ services: { isPlain: true },
380
+ visitorKeys: {
381
+ Program: []
382
+ }
383
+ })
384
+ };
362
385
  async function combine(...configs) {
363
386
  const resolved = await Promise.all(configs);
364
387
  return resolved.flat();
@@ -510,7 +533,6 @@ async function jsonc(options = {}) {
510
533
  }
511
534
 
512
535
  // src/configs/markdown.ts
513
- import * as parserPlain from "eslint-parser-plain";
514
536
  import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
515
537
  async function markdown(options = {}) {
516
538
  const {
@@ -641,9 +663,6 @@ async function perfectionist() {
641
663
  ];
642
664
  }
643
665
 
644
- // src/configs/formatters.ts
645
- import * as parserPlain2 from "eslint-parser-plain";
646
-
647
666
  // src/configs/stylistic.ts
648
667
  var StylisticConfigDefaults = {
649
668
  indent: 2,
@@ -655,6 +674,7 @@ async function stylistic(options = {}) {
655
674
  const {
656
675
  indent,
657
676
  jsx,
677
+ overrides = {},
658
678
  quotes,
659
679
  semi
660
680
  } = {
@@ -682,7 +702,8 @@ async function stylistic(options = {}) {
682
702
  "antfu/consistent-list-newline": "error",
683
703
  "antfu/if-newline": "error",
684
704
  "antfu/top-level-function": "error",
685
- "curly": ["error", "multi-or-nest", "consistent"]
705
+ "curly": ["error", "multi-or-nest", "consistent"],
706
+ ...overrides
686
707
  }
687
708
  }
688
709
  ];
@@ -742,7 +763,7 @@ async function formatters(options = {}, stylistic2 = {}) {
742
763
  {
743
764
  files: [GLOB_CSS, GLOB_POSTCSS],
744
765
  languageOptions: {
745
- parser: parserPlain2
766
+ parser: parserPlain
746
767
  },
747
768
  name: "antfu:formatter:css",
748
769
  rules: {
@@ -758,7 +779,7 @@ async function formatters(options = {}, stylistic2 = {}) {
758
779
  {
759
780
  files: [GLOB_SCSS],
760
781
  languageOptions: {
761
- parser: parserPlain2
782
+ parser: parserPlain
762
783
  },
763
784
  name: "antfu:formatter:scss",
764
785
  rules: {
@@ -774,7 +795,7 @@ async function formatters(options = {}, stylistic2 = {}) {
774
795
  {
775
796
  files: [GLOB_LESS],
776
797
  languageOptions: {
777
- parser: parserPlain2
798
+ parser: parserPlain
778
799
  },
779
800
  name: "antfu:formatter:less",
780
801
  rules: {
@@ -793,7 +814,7 @@ async function formatters(options = {}, stylistic2 = {}) {
793
814
  configs.push({
794
815
  files: ["**/*.html"],
795
816
  languageOptions: {
796
- parser: parserPlain2
817
+ parser: parserPlain
797
818
  },
798
819
  name: "antfu:formatter:html",
799
820
  rules: {
@@ -812,13 +833,14 @@ async function formatters(options = {}, stylistic2 = {}) {
812
833
  configs.push({
813
834
  files: [GLOB_MARKDOWN],
814
835
  languageOptions: {
815
- parser: parserPlain2
836
+ parser: parserPlain
816
837
  },
817
838
  name: "antfu:formatter:markdown",
818
839
  rules: {
819
840
  [`format/${formater}`]: [
820
841
  "error",
821
842
  formater === "prettier" ? {
843
+ printWidth: 120,
822
844
  ...prettierOptions,
823
845
  embeddedLanguageFormatting: "off",
824
846
  parser: "markdown"
@@ -834,7 +856,7 @@ async function formatters(options = {}, stylistic2 = {}) {
834
856
  configs.push({
835
857
  files: ["**/*.graphql"],
836
858
  languageOptions: {
837
- parser: parserPlain2
859
+ parser: parserPlain
838
860
  },
839
861
  name: "antfu:formatter:graphql",
840
862
  rules: {
@@ -1012,15 +1034,11 @@ async function sortPackageJson() {
1012
1034
  },
1013
1035
  {
1014
1036
  order: { type: "asc" },
1015
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1016
- },
1017
- {
1018
- order: { type: "asc" },
1019
- pathPattern: "^resolutions$"
1037
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1020
1038
  },
1021
1039
  {
1022
1040
  order: { type: "asc" },
1023
- pathPattern: "^pnpm.overrides$"
1041
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1024
1042
  },
1025
1043
  {
1026
1044
  order: [
@@ -1162,6 +1180,98 @@ function sortTsconfig() {
1162
1180
  ];
1163
1181
  }
1164
1182
 
1183
+ // src/configs/svelte.ts
1184
+ async function svelte(options = {}) {
1185
+ const {
1186
+ files = [GLOB_SVELTE],
1187
+ overrides = {},
1188
+ stylistic: stylistic2 = true
1189
+ } = options;
1190
+ const {
1191
+ indent = 2,
1192
+ quotes = "single"
1193
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1194
+ await ensurePackages([
1195
+ "eslint-plugin-svelte"
1196
+ ]);
1197
+ const [
1198
+ pluginSvelte,
1199
+ parserSvelte
1200
+ ] = await Promise.all([
1201
+ interopDefault(import("eslint-plugin-svelte")),
1202
+ interopDefault(import("svelte-eslint-parser"))
1203
+ ]);
1204
+ return [
1205
+ {
1206
+ name: "antfu:svelte:setup",
1207
+ plugins: {
1208
+ svelte: pluginSvelte
1209
+ }
1210
+ },
1211
+ {
1212
+ files,
1213
+ languageOptions: {
1214
+ parser: parserSvelte,
1215
+ parserOptions: {
1216
+ extraFileExtensions: [".svelte"],
1217
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1218
+ }
1219
+ },
1220
+ name: "antfu:svelte:rules",
1221
+ rules: {
1222
+ "import/no-mutable-exports": "off",
1223
+ "no-undef": "off",
1224
+ // incompatible with most recent (attribute-form) generic types RFC
1225
+ "no-unused-vars": ["error", {
1226
+ args: "none",
1227
+ caughtErrors: "none",
1228
+ ignoreRestSiblings: true,
1229
+ vars: "all",
1230
+ varsIgnorePattern: "^\\$\\$Props$"
1231
+ }],
1232
+ "svelte/comment-directive": "error",
1233
+ "svelte/no-at-debug-tags": "warn",
1234
+ "svelte/no-at-html-tags": "error",
1235
+ "svelte/no-dupe-else-if-blocks": "error",
1236
+ "svelte/no-dupe-style-properties": "error",
1237
+ "svelte/no-dupe-use-directives": "error",
1238
+ "svelte/no-dynamic-slot-name": "error",
1239
+ "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
1240
+ "svelte/no-inner-declarations": "error",
1241
+ "svelte/no-not-function-handler": "error",
1242
+ "svelte/no-object-in-text-mustaches": "error",
1243
+ "svelte/no-reactive-functions": "error",
1244
+ "svelte/no-reactive-literals": "error",
1245
+ "svelte/no-shorthand-style-property-overrides": "error",
1246
+ "svelte/no-unknown-style-directive-property": "error",
1247
+ "svelte/no-unused-svelte-ignore": "error",
1248
+ "svelte/no-useless-mustaches": "error",
1249
+ "svelte/require-store-callbacks-use-set-param": "error",
1250
+ "svelte/system": "error",
1251
+ "svelte/valid-compile": "error",
1252
+ "svelte/valid-each-key": "error",
1253
+ "unused-imports/no-unused-vars": [
1254
+ "error",
1255
+ { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
1256
+ ],
1257
+ ...stylistic2 ? {
1258
+ "style/no-trailing-spaces": "off",
1259
+ // superseded by svelte/no-trailing-spaces
1260
+ "svelte/derived-has-same-inputs-outputs": "error",
1261
+ "svelte/html-closing-bracket-spacing": "error",
1262
+ "svelte/html-quotes": ["error", { prefer: quotes }],
1263
+ "svelte/indent": ["error", { alignAttributesVertically: true, indent }],
1264
+ "svelte/mustache-spacing": "error",
1265
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1266
+ "svelte/no-trailing-spaces": "error",
1267
+ "svelte/spaced-html-comment": "error"
1268
+ } : {},
1269
+ ...overrides
1270
+ }
1271
+ }
1272
+ ];
1273
+ }
1274
+
1165
1275
  // src/configs/test.ts
1166
1276
  async function test(options = {}) {
1167
1277
  const {
@@ -1220,6 +1330,7 @@ async function typescript(options = {}) {
1220
1330
  GLOB_SRC,
1221
1331
  ...componentExts.map((ext) => `**/*.${ext}`)
1222
1332
  ];
1333
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1223
1334
  const typeAwareRules = {
1224
1335
  "dot-notation": "off",
1225
1336
  "no-implied-eval": "off",
@@ -1309,6 +1420,13 @@ async function typescript(options = {}) {
1309
1420
  "ts/prefer-ts-expect-error": "error",
1310
1421
  "ts/triple-slash-reference": "off",
1311
1422
  "ts/unified-signatures": "off",
1423
+ ...overrides
1424
+ }
1425
+ },
1426
+ {
1427
+ files: filesTypeAware,
1428
+ name: "antfu:typescript:rules-type-aware",
1429
+ rules: {
1312
1430
  ...tsconfigPath ? typeAwareRules : {},
1313
1431
  ...overrides
1314
1432
  }
@@ -1699,9 +1817,10 @@ async function antfu(options = {}, ...userConfigs) {
1699
1817
  const {
1700
1818
  componentExts = [],
1701
1819
  gitignore: enableGitignore = true,
1702
- isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
1820
+ isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
1703
1821
  overrides = {},
1704
1822
  react: enableReact = false,
1823
+ svelte: enableSvelte = false,
1705
1824
  typescript: enableTypeScript = isPackageExists3("typescript"),
1706
1825
  unocss: enableUnoCSS = false,
1707
1826
  vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
@@ -1745,8 +1864,12 @@ async function antfu(options = {}, ...userConfigs) {
1745
1864
  overrides: overrides.typescript
1746
1865
  }));
1747
1866
  }
1748
- if (stylisticOptions)
1749
- configs.push(stylistic(stylisticOptions));
1867
+ if (stylisticOptions) {
1868
+ configs.push(stylistic({
1869
+ ...stylisticOptions,
1870
+ overrides: overrides.stylistic
1871
+ }));
1872
+ }
1750
1873
  if (options.test ?? true) {
1751
1874
  configs.push(test({
1752
1875
  isInEditor,
@@ -1767,6 +1890,13 @@ async function antfu(options = {}, ...userConfigs) {
1767
1890
  typescript: !!enableTypeScript
1768
1891
  }));
1769
1892
  }
1893
+ if (enableSvelte) {
1894
+ configs.push(svelte({
1895
+ overrides: overrides.svelte,
1896
+ stylistic: stylisticOptions,
1897
+ typescript: !!enableTypeScript
1898
+ }));
1899
+ }
1770
1900
  if (enableUnoCSS) {
1771
1901
  configs.push(unocss(
1772
1902
  typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
@@ -1845,6 +1975,7 @@ export {
1845
1975
  GLOB_SRC,
1846
1976
  GLOB_SRC_EXT,
1847
1977
  GLOB_STYLE,
1978
+ GLOB_SVELTE,
1848
1979
  GLOB_TESTS,
1849
1980
  GLOB_TOML,
1850
1981
  GLOB_TS,
@@ -1866,12 +1997,14 @@ export {
1866
1997
  jsonc,
1867
1998
  markdown,
1868
1999
  node,
2000
+ parserPlain,
1869
2001
  perfectionist,
1870
2002
  react,
1871
2003
  renameRules,
1872
2004
  sortPackageJson,
1873
2005
  sortTsconfig,
1874
2006
  stylistic,
2007
+ svelte,
1875
2008
  test,
1876
2009
  toArray,
1877
2010
  toml,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@antfu/eslint-config",
3
3
  "type": "module",
4
- "version": "2.4.5",
5
- "packageManager": "pnpm@8.12.0",
4
+ "version": "2.5.0",
5
+ "packageManager": "pnpm@8.12.1",
6
6
  "description": "Anthony's ESLint config",
7
7
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
8
8
  "license": "MIT",
@@ -30,13 +30,15 @@
30
30
  "eslint-plugin-format": ">=0.1.0",
31
31
  "eslint-plugin-react": "^7.33.2",
32
32
  "eslint-plugin-react-hooks": "^4.6.0",
33
- "eslint-plugin-react-refresh": "^0.4.4"
33
+ "eslint-plugin-react-refresh": "^0.4.4",
34
+ "eslint-plugin-svelte": "^2.34.1",
35
+ "svelte-eslint-parser": "^0.33.1"
34
36
  },
35
37
  "peerDependenciesMeta": {
36
- "eslint-plugin-format": {
38
+ "@unocss/eslint-plugin": {
37
39
  "optional": true
38
40
  },
39
- "@unocss/eslint-plugin": {
41
+ "eslint-plugin-format": {
40
42
  "optional": true
41
43
  },
42
44
  "eslint-plugin-react": {
@@ -47,6 +49,12 @@
47
49
  },
48
50
  "eslint-plugin-react-refresh": {
49
51
  "optional": true
52
+ },
53
+ "eslint-plugin-svelte": {
54
+ "optional": true
55
+ },
56
+ "svelte-eslint-parser": {
57
+ "optional": true
50
58
  }
51
59
  },
52
60
  "dependencies": {
@@ -56,26 +64,25 @@
56
64
  "@eslint-types/typescript-eslint": "^6.12.0",
57
65
  "@eslint-types/unicorn": "^49.0.0",
58
66
  "@stylistic/eslint-plugin": "^1.5.1",
59
- "@typescript-eslint/eslint-plugin": "^6.13.2",
60
- "@typescript-eslint/parser": "^6.13.2",
67
+ "@typescript-eslint/eslint-plugin": "^6.15.0",
68
+ "@typescript-eslint/parser": "^6.15.0",
61
69
  "eslint-config-flat-gitignore": "^0.1.2",
62
70
  "eslint-merge-processors": "^0.1.0",
63
- "eslint-parser-plain": "^0.1.0",
64
- "eslint-plugin-antfu": "^2.0.0",
71
+ "eslint-plugin-antfu": "^2.1.0",
65
72
  "eslint-plugin-eslint-comments": "^3.2.0",
66
- "eslint-plugin-i": "^2.29.0",
67
- "eslint-plugin-jsdoc": "^46.9.0",
68
- "eslint-plugin-jsonc": "^2.10.0",
73
+ "eslint-plugin-i": "^2.29.1",
74
+ "eslint-plugin-jsdoc": "^46.9.1",
75
+ "eslint-plugin-jsonc": "^2.11.2",
69
76
  "eslint-plugin-markdown": "^3.0.1",
70
- "eslint-plugin-n": "^16.4.0",
77
+ "eslint-plugin-n": "^16.5.0",
71
78
  "eslint-plugin-no-only-tests": "^3.1.0",
72
79
  "eslint-plugin-perfectionist": "^2.5.0",
73
- "eslint-plugin-toml": "^0.7.1",
74
- "eslint-plugin-unicorn": "^49.0.0",
80
+ "eslint-plugin-toml": "^0.8.0",
81
+ "eslint-plugin-unicorn": "^50.0.1",
75
82
  "eslint-plugin-unused-imports": "^3.0.0",
76
- "eslint-plugin-vitest": "^0.3.15",
83
+ "eslint-plugin-vitest": "^0.3.20",
77
84
  "eslint-plugin-vue": "^9.19.2",
78
- "eslint-plugin-yml": "^1.10.0",
85
+ "eslint-plugin-yml": "^1.11.0",
79
86
  "eslint-processor-vue-blocks": "^0.1.1",
80
87
  "globals": "^13.24.0",
81
88
  "jsonc-eslint-parser": "^2.4.0",
@@ -92,9 +99,9 @@
92
99
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
93
100
  "@antfu/ni": "^0.21.12",
94
101
  "@stylistic/eslint-plugin-migrate": "^1.5.1",
95
- "@types/eslint": "^8.44.8",
102
+ "@types/eslint": "^8.56.0",
96
103
  "@types/fs-extra": "^11.0.4",
97
- "@types/node": "^20.10.4",
104
+ "@types/node": "^20.10.5",
98
105
  "@types/prompts": "^2.4.9",
99
106
  "@types/yargs": "^17.0.32",
100
107
  "@unocss/eslint-plugin": "^0.58.0",
@@ -105,6 +112,7 @@
105
112
  "eslint-plugin-react": "^7.33.2",
106
113
  "eslint-plugin-react-hooks": "^4.6.0",
107
114
  "eslint-plugin-react-refresh": "^0.4.5",
115
+ "eslint-plugin-svelte": "^2.35.1",
108
116
  "eslint-ts-patch": "^8.55.0-1",
109
117
  "esno": "^4.0.0",
110
118
  "execa": "^8.0.1",
@@ -113,11 +121,12 @@
113
121
  "lint-staged": "^15.2.0",
114
122
  "rimraf": "^5.0.5",
115
123
  "simple-git-hooks": "^2.9.0",
124
+ "svelte-eslint-parser": "^0.33.1",
116
125
  "tsup": "^8.0.1",
117
126
  "typescript": "^5.3.3",
118
- "vitest": "^1.0.4",
119
- "vue": "^3.3.11",
120
- "@antfu/eslint-config": "2.4.5"
127
+ "vitest": "^1.1.0",
128
+ "vue": "^3.3.13",
129
+ "@antfu/eslint-config": "2.5.0"
121
130
  },
122
131
  "simple-git-hooks": {
123
132
  "pre-commit": "pnpm lint-staged"