@antfu/eslint-config 8.2.0 → 9.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/dist/index.mjs CHANGED
@@ -293,6 +293,9 @@ async function angular(options = {}) {
293
293
  "angular-template/eqeqeq": "error",
294
294
  "angular-template/no-negated-async": "error",
295
295
  "angular-template/prefer-control-flow": "error",
296
+ /**
297
+ * we need to mute some style lint rules for angular inline templates,
298
+ */
296
299
  "style/indent": "off",
297
300
  "style/no-multiple-empty-lines": ["error", { max: 1 }],
298
301
  "style/no-trailing-spaces": "off",
@@ -427,6 +430,7 @@ async function disables() {
427
430
  //#endregion
428
431
  //#region src/configs/stylistic.ts
429
432
  const StylisticConfigDefaults = {
433
+ braceStyle: "stroustrup",
430
434
  experimental: false,
431
435
  indent: 2,
432
436
  jsx: true,
@@ -434,12 +438,13 @@ const StylisticConfigDefaults = {
434
438
  semi: false
435
439
  };
436
440
  async function stylistic(options = {}) {
437
- const { experimental, indent, jsx, lessOpinionated = false, overrides = {}, quotes, semi } = {
441
+ const { braceStyle, experimental, indent, jsx, lessOpinionated = false, overrides = {}, quotes, semi } = {
438
442
  ...StylisticConfigDefaults,
439
443
  ...options
440
444
  };
441
445
  const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
442
446
  const config = pluginStylistic.configs.customize({
447
+ braceStyle,
443
448
  experimental,
444
449
  indent,
445
450
  jsx,
@@ -1065,21 +1070,6 @@ async function markdown(options = {}) {
1065
1070
  ...overridesMarkdown
1066
1071
  }
1067
1072
  },
1068
- {
1069
- files,
1070
- name: "antfu/markdown/disables/markdown",
1071
- rules: {
1072
- "command/command": "off",
1073
- "no-irregular-whitespace": "off",
1074
- "perfectionist/sort-exports": "off",
1075
- "perfectionist/sort-imports": "off",
1076
- "regexp/no-legacy-features": "off",
1077
- "regexp/no-missing-g-flag": "off",
1078
- "regexp/no-useless-dollar-replacements": "off",
1079
- "regexp/no-useless-flag": "off",
1080
- "style/indent": "off"
1081
- }
1082
- },
1083
1073
  {
1084
1074
  files: [GLOB_MARKDOWN_CODE, ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)],
1085
1075
  languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
@@ -1176,7 +1166,8 @@ async function node() {
1176
1166
  *
1177
1167
  * @see https://github.com/azat-io/eslint-plugin-perfectionist
1178
1168
  */
1179
- async function perfectionist() {
1169
+ async function perfectionist(options) {
1170
+ const { overrides = {} } = options;
1180
1171
  return [{
1181
1172
  name: "antfu/perfectionist/setup",
1182
1173
  plugins: { perfectionist: pluginPerfectionist },
@@ -1218,7 +1209,8 @@ async function perfectionist() {
1218
1209
  "perfectionist/sort-named-imports": ["error", {
1219
1210
  order: "asc",
1220
1211
  type: "natural"
1221
- }]
1212
+ }],
1213
+ ...overrides
1222
1214
  }
1223
1215
  }];
1224
1216
  }
@@ -1374,17 +1366,12 @@ async function react(options = {}) {
1374
1366
  const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
1375
1367
  const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
1376
1368
  const isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
1377
- const plugins = pluginReact.configs.all.plugins;
1378
1369
  return [
1379
1370
  {
1380
1371
  name: "antfu/react/setup",
1381
1372
  plugins: {
1382
- "react": plugins["@eslint-react"],
1383
- "react-dom": plugins["@eslint-react/dom"],
1384
- "react-naming-convention": plugins["@eslint-react/naming-convention"],
1385
- "react-refresh": pluginReactRefresh,
1386
- "react-rsc": plugins["@eslint-react/rsc"],
1387
- "react-web-api": plugins["@eslint-react/web-api"]
1373
+ "react": pluginReact.configs.all.plugins["@eslint-react"],
1374
+ "react-refresh": pluginReactRefresh
1388
1375
  }
1389
1376
  },
1390
1377
  {
@@ -1396,7 +1383,6 @@ async function react(options = {}) {
1396
1383
  name: "antfu/react/rules",
1397
1384
  rules: {
1398
1385
  ...pluginReact.configs.recommended.rules,
1399
- "react/prefer-namespace-import": "error",
1400
1386
  "react-refresh/only-export-components": ["error", {
1401
1387
  allowConstantExport: isAllowConstantExport,
1402
1388
  allowExportNames: [...isUsingNext ? [
@@ -1433,8 +1419,8 @@ async function react(options = {}) {
1433
1419
  files: filesTypeAware,
1434
1420
  name: "antfu/react/typescript",
1435
1421
  rules: {
1436
- "react-dom/no-string-style-prop": "off",
1437
- "react-dom/no-unknown-property": "off"
1422
+ "react/dom-no-string-style-prop": "off",
1423
+ "react/dom-no-unknown-property": "off"
1438
1424
  }
1439
1425
  },
1440
1426
  ...isTypeAware ? [{
@@ -1775,25 +1761,10 @@ async function svelte(options = {}) {
1775
1761
  vars: "all",
1776
1762
  varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1777
1763
  }],
1778
- "svelte/comment-directive": "error",
1779
- "svelte/no-at-debug-tags": "warn",
1780
- "svelte/no-at-html-tags": "error",
1781
- "svelte/no-dupe-else-if-blocks": "error",
1782
- "svelte/no-dupe-style-properties": "error",
1783
- "svelte/no-dupe-use-directives": "error",
1784
- "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
1785
- "svelte/no-inner-declarations": "error",
1786
- "svelte/no-not-function-handler": "error",
1787
- "svelte/no-object-in-text-mustaches": "error",
1788
- "svelte/no-reactive-functions": "error",
1789
- "svelte/no-reactive-literals": "error",
1790
- "svelte/no-shorthand-style-property-overrides": "error",
1791
- "svelte/no-unknown-style-directive-property": "error",
1792
- "svelte/no-unused-svelte-ignore": "error",
1793
- "svelte/no-useless-mustaches": "error",
1794
- "svelte/require-store-callbacks-use-set-param": "error",
1795
- "svelte/system": "error",
1796
- "svelte/valid-each-key": "error",
1764
+ ...pluginSvelte.configs.recommended.map((config) => config.rules).reduce((acc, rules) => ({
1765
+ ...acc,
1766
+ ...rules
1767
+ }), {}),
1797
1768
  "unused-imports/no-unused-vars": ["error", {
1798
1769
  args: "after-used",
1799
1770
  argsIgnorePattern: "^_",
@@ -2030,7 +2001,7 @@ async function typescript(options = {}) {
2030
2001
  }] : [],
2031
2002
  ...erasableOnly ? [{
2032
2003
  name: "antfu/typescript/erasable-syntax-only",
2033
- plugins: { "erasable-syntax-only": await interopDefault(import("./lib-UO5evvxw.mjs")) },
2004
+ plugins: { "erasable-syntax-only": await interopDefault(import("./lib-C1Uxp5ZW.mjs")) },
2034
2005
  rules: {
2035
2006
  "erasable-syntax-only/enums": "error",
2036
2007
  "erasable-syntax-only/import-aliases": "error",
@@ -2090,7 +2061,7 @@ async function unocss(options = {}) {
2090
2061
  async function vue(options = {}) {
2091
2062
  const { a11y = false, files = [GLOB_VUE], overrides = {}, stylistic = true, vueVersion = 3 } = options;
2092
2063
  const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
2093
- const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
2064
+ const { braceStyle = "stroustrup", indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
2094
2065
  if (a11y) await ensurePackages(["eslint-plugin-vuejs-accessibility"]);
2095
2066
  const [pluginVue, parserVue, processorVueBlocks, pluginVueA11y] = await Promise.all([
2096
2067
  interopDefault(import("eslint-plugin-vue")),
@@ -2231,7 +2202,7 @@ async function vue(options = {}) {
2231
2202
  }],
2232
2203
  "vue/brace-style": [
2233
2204
  "error",
2234
- "stroustrup",
2205
+ braceStyle,
2235
2206
  { allowSingleLine: true }
2236
2207
  ],
2237
2208
  "vue/comma-dangle": ["error", "always-multiline"],
@@ -2374,10 +2345,6 @@ const VuePackages = [
2374
2345
  ];
2375
2346
  const defaultPluginRenaming = {
2376
2347
  "@eslint-react": "react",
2377
- "@eslint-react/dom": "react-dom",
2378
- "@eslint-react/naming-convention": "react-naming-convention",
2379
- "@eslint-react/rsc": "react-rsc",
2380
- "@eslint-react/web-api": "react-web-api",
2381
2348
  "@next/next": "next",
2382
2349
  "@stylistic": "style",
2383
2350
  "@typescript-eslint": "ts",
@@ -2397,7 +2364,7 @@ const defaultPluginRenaming = {
2397
2364
  * The merged ESLint configurations.
2398
2365
  */
2399
2366
  function antfu(options = {}, ...userConfigs) {
2400
- const { angular: enableAngular = false, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, jsx: enableJsx = true, nextjs: enableNextjs = false, node: enableNode = true, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, solid: enableSolid = false, svelte: enableSvelte = false, type: appType = "app", typescript: enableTypeScript = isPackageExists("typescript") || isPackageExists("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
2367
+ const { angular: enableAngular = false, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, jsx: enableJsx = true, nextjs: enableNextjs = false, node: enableNode = true, perfectionist: enablePerfectionist = true, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, solid: enableSolid = false, svelte: enableSvelte = false, type: appType = "app", typescript: enableTypeScript = isPackageExists("typescript") || isPackageExists("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
2401
2368
  let isInEditor = options.isInEditor;
2402
2369
  if (isInEditor == null) {
2403
2370
  isInEditor = isInEditorEnv();
@@ -2419,7 +2386,8 @@ function antfu(options = {}, ...userConfigs) {
2419
2386
  configs.push(ignores(userIgnores, !enableTypeScript), javascript({
2420
2387
  isInEditor,
2421
2388
  overrides: getOverrides(options, "javascript")
2422
- }), comments(), command(), perfectionist());
2389
+ }), comments(), command());
2390
+ if (enablePerfectionist) configs.push(perfectionist({ overrides: getOverrides(options, "perfectionist") }));
2423
2391
  if (enableNode) configs.push(node());
2424
2392
  if (enableJsdoc) configs.push(jsdoc({ stylistic: stylisticOptions }));
2425
2393
  if (enableImports) configs.push(imports({
@@ -2516,6 +2484,7 @@ function antfu(options = {}, ...userConfigs) {
2516
2484
  if (Object.keys(fusedConfig).length) configs.push([fusedConfig]);
2517
2485
  let composer = new FlatConfigComposer();
2518
2486
  composer = composer.append(...configs, ...userConfigs);
2487
+ if (options.markdown ?? true) composer = composer.setDefaultIgnores((prev) => [...prev, GLOB_MARKDOWN]);
2519
2488
  if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
2520
2489
  if (isInEditor) composer = composer.disableRulesFix([
2521
2490
  "unused-imports/no-unused-imports",
@@ -2548,6 +2517,7 @@ const CONFIG_PRESET_FULL_ON = {
2548
2517
  markdown: true,
2549
2518
  nextjs: true,
2550
2519
  node: true,
2520
+ perfectionist: true,
2551
2521
  pnpm: true,
2552
2522
  react: true,
2553
2523
  regexp: true,
@@ -2577,6 +2547,7 @@ const CONFIG_PRESET_FULL_OFF = {
2577
2547
  markdown: false,
2578
2548
  nextjs: false,
2579
2549
  node: false,
2550
+ perfectionist: false,
2580
2551
  pnpm: false,
2581
2552
  react: false,
2582
2553
  regexp: false,