@vp-tw/eslint-config 0.0.7 → 0.0.8

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
@@ -5,7 +5,7 @@ ViPro's ESLint configuration.
5
5
  - Built on top of [antfu/eslint-config](https://github.com/antfu/eslint-config).
6
6
  - Integrates with:
7
7
  - [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier)
8
- - [eslint-mdx](https://github.com/mdx-js/eslint-mdx).
8
+ - [eslint-mdx](https://github.com/mdx-js/eslint-mdx)
9
9
  - [eslint-plugin-storybook](https://github.com/storybookjs/eslint-plugin-storybook)
10
10
  - [eslint-plugin-react-compiler](https://www.npmjs.com/package/eslint-plugin-react-compiler)
11
11
  - Fine-tuned to provide an opinionated, optimal DX. Please copy the VSCode settings from [eslint-config.code-workspace](https://github.com/VdustR/eslint-config/blob/main/eslint-config.code-workspace).
@@ -7,5 +7,5 @@ declare namespace mdx {
7
7
  flatCodeBlocks?: boolean | TypedFlatConfigItem;
8
8
  }
9
9
  }
10
- declare const mdx: ({ flatCodeBlocks, processorOptions, ...options }?: mdx.Options) => TypedFlatConfigItem[];
10
+ declare const mdx: ({ flatCodeBlocks, processorOptions, ...options }?: mdx.Options) => Promise<Array<TypedFlatConfigItem>>;
11
11
  export { mdx };
@@ -4,15 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.mdx = void 0;
7
+ var _eslintConfig = require("@antfu/eslint-config");
7
8
  var mdxPlugin = _interopRequireWildcard(require("eslint-plugin-mdx"));
8
9
  var _renameRules = require("../utils/renameRules");
9
10
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
11
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
- const mdx = ({
12
+ const mdx = async ({
12
13
  flatCodeBlocks = true,
13
14
  processorOptions,
14
15
  ...options
15
16
  } = {}) => {
17
+ await (0, _eslintConfig.ensurePackages)(["eslint-plugin-mdx"]);
16
18
  const flatCodeBlocksOptions = typeof flatCodeBlocks !== "object" ? {} : flatCodeBlocks;
17
19
  const configs = [{
18
20
  name: "vdustr/mdx",
@@ -1,2 +1,3 @@
1
- declare const prettier: any;
1
+ import type { TypedFlatConfigItem } from "@antfu/eslint-config";
2
+ declare const prettier: () => Promise<TypedFlatConfigItem>;
2
3
  export { prettier };
@@ -4,11 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.prettier = void 0;
7
+ var _eslintConfig = require("@antfu/eslint-config");
7
8
  var _eslintConfigPrettier = _interopRequireDefault(require("eslint-config-prettier"));
8
9
  var _renameRules = require("../utils/renameRules");
9
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- const prettier = exports.prettier = {
11
- name: "vdustr/prettier",
12
- ..._eslintConfigPrettier.default,
13
- rules: (0, _renameRules.renameRules)(_eslintConfigPrettier.default.rules)
14
- };
11
+ const prettier = async () => {
12
+ await (0, _eslintConfig.ensurePackages)(["eslint-config-prettier"]);
13
+ return {
14
+ name: "vdustr/prettier",
15
+ ..._eslintConfigPrettier.default,
16
+ rules: (0, _renameRules.renameRules)(_eslintConfigPrettier.default.rules)
17
+ };
18
+ };
19
+ exports.prettier = prettier;
@@ -1,2 +1,3 @@
1
- declare const storybook: any;
1
+ import type { TypedFlatConfigItem } from "@antfu/eslint-config";
2
+ declare const storybook: () => Promise<Array<TypedFlatConfigItem>>;
2
3
  export { storybook };
@@ -4,27 +4,32 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.storybook = void 0;
7
+ var _eslintConfig = require("@antfu/eslint-config");
7
8
  var _eslintPluginStorybook = _interopRequireDefault(require("eslint-plugin-storybook"));
8
9
  var _renameRules = require("../utils/renameRules");
9
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- const storybook = exports.storybook = _eslintPluginStorybook.default.configs["flat/csf-strict"].map(config => {
11
- const allConfig = config;
12
- const {
13
- rules,
14
- files,
15
- plugins,
16
- ...rest
17
- } = allConfig;
18
- return {
19
- ...rest,
20
- ...(!rules ? null : {
21
- rules: (0, _renameRules.renameRules)(rules)
22
- }),
23
- ...(!files ? null : {
24
- files
25
- }),
26
- ...(!plugins ? null : {
27
- plugins
28
- })
29
- };
30
- });
11
+ const storybook = async () => {
12
+ await (0, _eslintConfig.ensurePackages)(["eslint-plugin-storybook"]);
13
+ return _eslintPluginStorybook.default.configs["flat/csf-strict"].map(config => {
14
+ const allConfig = config;
15
+ const {
16
+ rules,
17
+ files,
18
+ plugins,
19
+ ...rest
20
+ } = allConfig;
21
+ return {
22
+ ...rest,
23
+ ...(!rules ? null : {
24
+ rules: (0, _renameRules.renameRules)(rules)
25
+ }),
26
+ ...(!files ? null : {
27
+ files
28
+ }),
29
+ ...(!plugins ? null : {
30
+ plugins
31
+ })
32
+ };
33
+ });
34
+ };
35
+ exports.storybook = storybook;
@@ -7,5 +7,5 @@ declare namespace mdx {
7
7
  flatCodeBlocks?: boolean | TypedFlatConfigItem;
8
8
  }
9
9
  }
10
- declare const mdx: ({ flatCodeBlocks, processorOptions, ...options }?: mdx.Options) => TypedFlatConfigItem[];
10
+ declare const mdx: ({ flatCodeBlocks, processorOptions, ...options }?: mdx.Options) => Promise<Array<TypedFlatConfigItem>>;
11
11
  export { mdx };
@@ -1,10 +1,12 @@
1
+ import { ensurePackages } from "@antfu/eslint-config";
1
2
  import * as mdxPlugin from "eslint-plugin-mdx";
2
3
  import { renameRules } from "../utils/renameRules.mjs";
3
- const mdx = ({
4
+ const mdx = async ({
4
5
  flatCodeBlocks = true,
5
6
  processorOptions,
6
7
  ...options
7
8
  } = {}) => {
9
+ await ensurePackages(["eslint-plugin-mdx"]);
8
10
  const flatCodeBlocksOptions = typeof flatCodeBlocks !== "object" ? {} : flatCodeBlocks;
9
11
  const configs = [
10
12
  {
@@ -1,2 +1,3 @@
1
- declare const prettier: any;
1
+ import type { TypedFlatConfigItem } from "@antfu/eslint-config";
2
+ declare const prettier: () => Promise<TypedFlatConfigItem>;
2
3
  export { prettier };
@@ -1,8 +1,12 @@
1
+ import { ensurePackages } from "@antfu/eslint-config";
1
2
  import eslintConfigPrettier from "eslint-config-prettier";
2
3
  import { renameRules } from "../utils/renameRules.mjs";
3
- const prettier = {
4
- name: "vdustr/prettier",
5
- ...eslintConfigPrettier,
6
- rules: renameRules(eslintConfigPrettier.rules)
4
+ const prettier = async () => {
5
+ await ensurePackages(["eslint-config-prettier"]);
6
+ return {
7
+ name: "vdustr/prettier",
8
+ ...eslintConfigPrettier,
9
+ rules: renameRules(eslintConfigPrettier.rules)
10
+ };
7
11
  };
8
12
  export { prettier };
@@ -1,2 +1,3 @@
1
- declare const storybook: any;
1
+ import type { TypedFlatConfigItem } from "@antfu/eslint-config";
2
+ declare const storybook: () => Promise<Array<TypedFlatConfigItem>>;
2
3
  export { storybook };
@@ -1,15 +1,19 @@
1
+ import { ensurePackages } from "@antfu/eslint-config";
1
2
  import storybookPlugin from "eslint-plugin-storybook";
2
3
  import { renameRules } from "../utils/renameRules.mjs";
3
- const storybook = storybookPlugin.configs["flat/csf-strict"].map((config) => {
4
- const allConfig = config;
5
- const { rules, files, plugins, ...rest } = allConfig;
6
- return {
7
- ...rest,
8
- ...!rules ? null : {
9
- rules: renameRules(rules)
10
- },
11
- ...!files ? null : { files },
12
- ...!plugins ? null : { plugins }
13
- };
14
- });
4
+ const storybook = async () => {
5
+ await ensurePackages(["eslint-plugin-storybook"]);
6
+ return storybookPlugin.configs["flat/csf-strict"].map((config) => {
7
+ const allConfig = config;
8
+ const { rules, files, plugins, ...rest } = allConfig;
9
+ return {
10
+ ...rest,
11
+ ...!rules ? null : {
12
+ rules: renameRules(rules)
13
+ },
14
+ ...!files ? null : { files },
15
+ ...!plugins ? null : { plugins }
16
+ };
17
+ });
18
+ };
15
19
  export { storybook };
@@ -5,5 +5,5 @@ interface ReactCompiler extends ESLint.Plugin {
5
5
  recommended: Linter.LegacyConfig;
6
6
  };
7
7
  }
8
- declare const reactCompilerInternal: ReactCompiler;
8
+ declare const reactCompilerInternal: () => Promise<ReactCompiler>;
9
9
  export { reactCompilerInternal as reactCompiler };
@@ -1,3 +1,7 @@
1
+ import { ensurePackages } from "@antfu/eslint-config";
1
2
  import * as reactCompiler from "eslint-plugin-react-compiler";
2
- const reactCompilerInternal = reactCompiler.default ?? reactCompiler;
3
+ const reactCompilerInternal = async () => {
4
+ await ensurePackages(["eslint-plugin-react-compiler"]);
5
+ return reactCompiler.default ?? reactCompiler;
6
+ };
3
7
  export { reactCompilerInternal as reactCompiler };
@@ -1,6 +1,7 @@
1
1
  import type { Config } from "./types";
2
2
  import antfu from "@antfu/eslint-config";
3
3
  import { mdx } from "./configs/mdx";
4
+ import "./eslint-typegen";
4
5
  type Options = Omit<NonNullable<Parameters<typeof antfu>[0]>, "stylistic"> & {
5
6
  mdx?: boolean | mdx.Options;
6
7
  storybook?: boolean;
@@ -1,10 +1,17 @@
1
- import antfu from "@antfu/eslint-config";
1
+ import antfu, {
2
+ GLOB_ASTRO_TS,
3
+ GLOB_JS,
4
+ GLOB_JSX,
5
+ GLOB_TS,
6
+ GLOB_TSX
7
+ } from "@antfu/eslint-config";
2
8
  import packageJson from "eslint-plugin-package-json/configs/recommended";
3
9
  import { isPackageExists } from "local-pkg";
4
10
  import { mdx } from "./configs/mdx.mjs";
5
11
  import { prettier } from "./configs/prettier.mjs";
6
12
  import { storybook } from "./configs/storybook.mjs";
7
13
  import { reactCompiler } from "./lib/eslint-plugin-react-compiler.mjs";
14
+ import "./eslint-typegen";
8
15
  const vdustr = (options, ...userConfigs) => {
9
16
  const typescriptEnabled = isPackageExists("typescript");
10
17
  const jsoncEnabled = Boolean(options?.jsonc ?? true);
@@ -58,25 +65,23 @@ const vdustr = (options, ...userConfigs) => {
58
65
  * Wildcard imports can prevent tree shaking and cause name conflicts.
59
66
  * Consider using named imports instead.
60
67
  */
61
- "import/no-namespace": "error",
68
+ "import/no-namespace": "error"
69
+ }
70
+ })).insertAfter("antfu/imports/rules", {
71
+ name: "vdustr/no-default-export",
72
+ rules: {
62
73
  /**
63
74
  * Enforcing named exports improves consistency, enhances auto-completion and refactoring, and avoids issues
64
75
  * with default export renaming. Additionally, default exports might lead to different behavior when transformed
65
76
  * to CJS.
66
77
  */
67
78
  "import/no-default-export": "error"
68
- }
69
- })).insertAfter("antfu/imports/rules", {
70
- name: "vdustr/allow-default-export",
71
- rules: {
72
- "import/no-default-export": "off"
73
79
  },
74
- files: [
80
+ files: [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
81
+ ignores: [
75
82
  // Configuration files
76
83
  "**/*.config.*",
77
- // Single file components
78
- "**/*.vue",
79
- "**/*.svelte"
84
+ GLOB_ASTRO_TS
80
85
  ]
81
86
  });
82
87
  if (typescriptEnabled) {
@@ -119,24 +124,26 @@ const vdustr = (options, ...userConfigs) => {
119
124
  })).insertAfter("antfu/jsonc/rules", packageJson).remove("antfu/sort/package-json").remove("antfu/sort/tsconfig-json");
120
125
  }
121
126
  if (reactEnabled) {
122
- config = config.override("antfu/react/rules", (config2) => ({
123
- ...config2,
124
- plugins: {
125
- ...config2.plugins,
126
- "react-compiler": reactCompiler
127
- },
128
- rules: {
129
- ...config2.rules,
130
- "react-compiler/react-compiler": "error",
131
- /**
132
- * Not all destructuring assignments are more readable than their alternatives.
133
- */
134
- "react/prefer-destructuring-assignment": "off"
135
- }
136
- }));
127
+ config = config.override("antfu/react/rules", async (config2) => {
128
+ return {
129
+ ...config2,
130
+ plugins: {
131
+ ...config2.plugins,
132
+ "react-compiler": await reactCompiler()
133
+ },
134
+ rules: {
135
+ ...config2.rules,
136
+ "react-compiler/react-compiler": "error",
137
+ /**
138
+ * Not all destructuring assignments are more readable than their alternatives.
139
+ */
140
+ "react/prefer-destructuring-assignment": "off"
141
+ }
142
+ };
143
+ });
137
144
  }
138
145
  if (storybookEnabled) {
139
- config = config.append(storybook).override("storybook:csf:stories-rules", (config2) => ({
146
+ config = config.append(storybook()).override("storybook:csf:stories-rules", (config2) => ({
140
147
  ...config2,
141
148
  rules: {
142
149
  ...config2.rules,
@@ -158,7 +165,7 @@ const vdustr = (options, ...userConfigs) => {
158
165
  })
159
166
  );
160
167
  }
161
- config = config.append(prettier);
168
+ config = config.append(prettier());
162
169
  return config;
163
170
  };
164
171
  export { vdustr };
@@ -5,5 +5,5 @@ interface ReactCompiler extends ESLint.Plugin {
5
5
  recommended: Linter.LegacyConfig;
6
6
  };
7
7
  }
8
- declare const reactCompilerInternal: ReactCompiler;
8
+ declare const reactCompilerInternal: () => Promise<ReactCompiler>;
9
9
  export { reactCompilerInternal as reactCompiler };
@@ -4,7 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.reactCompiler = void 0;
7
+ var _eslintConfig = require("@antfu/eslint-config");
7
8
  var reactCompiler = _interopRequireWildcard(require("eslint-plugin-react-compiler"));
8
9
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
10
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
- const reactCompilerInternal = exports.reactCompiler = reactCompiler.default ?? reactCompiler;
11
+ const reactCompilerInternal = async () => {
12
+ await (0, _eslintConfig.ensurePackages)(["eslint-plugin-react-compiler"]);
13
+ return reactCompiler.default ?? reactCompiler;
14
+ };
15
+ exports.reactCompiler = reactCompilerInternal;
package/dist/vdustr.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Config } from "./types";
2
2
  import antfu from "@antfu/eslint-config";
3
3
  import { mdx } from "./configs/mdx";
4
+ import "./eslint-typegen";
4
5
  type Options = Omit<NonNullable<Parameters<typeof antfu>[0]>, "stylistic"> & {
5
6
  mdx?: boolean | mdx.Options;
6
7
  storybook?: boolean;
package/dist/vdustr.js CHANGED
@@ -4,14 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.vdustr = void 0;
7
- var _eslintConfig = _interopRequireDefault(require("@antfu/eslint-config"));
7
+ var _eslintConfig = _interopRequireWildcard(require("@antfu/eslint-config"));
8
8
  var _recommended = _interopRequireDefault(require("eslint-plugin-package-json/configs/recommended"));
9
9
  var _localPkg = require("local-pkg");
10
10
  var _mdx = require("./configs/mdx");
11
11
  var _prettier = require("./configs/prettier");
12
12
  var _storybook = require("./configs/storybook");
13
13
  var _eslintPluginReactCompiler = require("./lib/eslint-plugin-react-compiler");
14
+ require("./eslint-typegen");
14
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
18
  const vdustr = (options, ...userConfigs) => {
16
19
  const typescriptEnabled = (0, _localPkg.isPackageExists)("typescript");
17
20
  const jsoncEnabled = Boolean(options?.jsonc ?? true);
@@ -60,24 +63,22 @@ const vdustr = (options, ...userConfigs) => {
60
63
  * Wildcard imports can prevent tree shaking and cause name conflicts.
61
64
  * Consider using named imports instead.
62
65
  */
63
- "import/no-namespace": "error",
66
+ "import/no-namespace": "error"
67
+ }
68
+ })).insertAfter("antfu/imports/rules", {
69
+ name: "vdustr/no-default-export",
70
+ rules: {
64
71
  /**
65
72
  * Enforcing named exports improves consistency, enhances auto-completion and refactoring, and avoids issues
66
73
  * with default export renaming. Additionally, default exports might lead to different behavior when transformed
67
74
  * to CJS.
68
75
  */
69
76
  "import/no-default-export": "error"
70
- }
71
- })).insertAfter("antfu/imports/rules", {
72
- name: "vdustr/allow-default-export",
73
- rules: {
74
- "import/no-default-export": "off"
75
77
  },
76
- files: [
78
+ files: [_eslintConfig.GLOB_JS, _eslintConfig.GLOB_JSX, _eslintConfig.GLOB_TS, _eslintConfig.GLOB_TSX],
79
+ ignores: [
77
80
  // Configuration files
78
- "**/*.config.*",
79
- // Single file components
80
- "**/*.vue", "**/*.svelte"]
81
+ "**/*.config.*", _eslintConfig.GLOB_ASTRO_TS]
81
82
  });
82
83
  if (typescriptEnabled) {
83
84
  config = config.override("antfu/typescript/rules", config2 => ({
@@ -119,24 +120,26 @@ const vdustr = (options, ...userConfigs) => {
119
120
  })).insertAfter("antfu/jsonc/rules", _recommended.default).remove("antfu/sort/package-json").remove("antfu/sort/tsconfig-json");
120
121
  }
121
122
  if (reactEnabled) {
122
- config = config.override("antfu/react/rules", config2 => ({
123
- ...config2,
124
- plugins: {
125
- ...config2.plugins,
126
- "react-compiler": _eslintPluginReactCompiler.reactCompiler
127
- },
128
- rules: {
129
- ...config2.rules,
130
- "react-compiler/react-compiler": "error",
131
- /**
132
- * Not all destructuring assignments are more readable than their alternatives.
133
- */
134
- "react/prefer-destructuring-assignment": "off"
135
- }
136
- }));
123
+ config = config.override("antfu/react/rules", async config2 => {
124
+ return {
125
+ ...config2,
126
+ plugins: {
127
+ ...config2.plugins,
128
+ "react-compiler": await (0, _eslintPluginReactCompiler.reactCompiler)()
129
+ },
130
+ rules: {
131
+ ...config2.rules,
132
+ "react-compiler/react-compiler": "error",
133
+ /**
134
+ * Not all destructuring assignments are more readable than their alternatives.
135
+ */
136
+ "react/prefer-destructuring-assignment": "off"
137
+ }
138
+ };
139
+ });
137
140
  }
138
141
  if (storybookEnabled) {
139
- config = config.append(_storybook.storybook).override("storybook:csf:stories-rules", config2 => ({
142
+ config = config.append((0, _storybook.storybook)()).override("storybook:csf:stories-rules", config2 => ({
140
143
  ...config2,
141
144
  rules: {
142
145
  ...config2.rules,
@@ -156,7 +159,7 @@ const vdustr = (options, ...userConfigs) => {
156
159
  }
157
160
  }));
158
161
  }
159
- config = config.append(_prettier.prettier);
162
+ config = config.append((0, _prettier.prettier)());
160
163
  return config;
161
164
  };
162
165
  exports.vdustr = vdustr;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vp-tw/eslint-config",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "ViPro's ESLint configuration",
5
5
  "homepage": "https://github.com/vdustr/eslint-config",
6
6
  "author": {
@@ -37,17 +37,11 @@
37
37
  "types": "./dist/index.d.ts",
38
38
  "dependencies": {
39
39
  "@antfu/eslint-config": "^4.1.0",
40
- "@eslint-react/eslint-plugin": "^1.25.0",
41
- "@eslint/compat": "^1.2.5",
42
40
  "@mui/types": "^7.2.21",
43
41
  "@types/eslint-config-prettier": "^6.11.3",
44
- "@types/eslint__eslintrc": "^2.1.2",
45
42
  "eslint-config-prettier": "^10.0.1",
46
43
  "eslint-flat-config-utils": "^2.0.0",
47
- "eslint-plugin-mdx": "^3.1.5",
48
44
  "eslint-plugin-package-json": "^0.21.1",
49
- "eslint-plugin-react-compiler": "^19.0.0-beta-27714ef-20250124",
50
- "eslint-plugin-storybook": "^0.11.2",
51
45
  "local-pkg": "^1.0.0"
52
46
  },
53
47
  "devDependencies": {
@@ -24,7 +24,7 @@ import { reactCompiler } from "../src/lib/eslint-plugin-react-compiler";
24
24
  }
25
25
 
26
26
  const plugins: Plugins = {
27
- ...definePlugins({ "react-compiler": reactCompiler }),
27
+ ...definePlugins({ "react-compiler": await reactCompiler() }),
28
28
  ...definePlugins({
29
29
  mdx: {
30
30
  rules: mdxRules,
@@ -1,5 +1,6 @@
1
1
  import type { TypedFlatConfigItem } from "@antfu/eslint-config";
2
2
  import type { DistributiveOmit } from "@mui/types";
3
+ import { ensurePackages } from "@antfu/eslint-config";
3
4
 
4
5
  // eslint-disable-next-line import/no-namespace -- `mdx` exports the plugin as a namespace.
5
6
  import * as mdxPlugin from "eslint-plugin-mdx";
@@ -13,11 +14,12 @@ namespace mdx {
13
14
  }
14
15
  }
15
16
 
16
- const mdx = ({
17
+ const mdx = async ({
17
18
  flatCodeBlocks = true,
18
19
  processorOptions,
19
20
  ...options
20
- }: mdx.Options = {}) => {
21
+ }: mdx.Options = {}): Promise<Array<TypedFlatConfigItem>> => {
22
+ await ensurePackages(["eslint-plugin-mdx"]);
21
23
  const flatCodeBlocksOptions: TypedFlatConfigItem =
22
24
  typeof flatCodeBlocks !== "object" ? {} : flatCodeBlocks;
23
25
  const configs: Array<TypedFlatConfigItem> = [
@@ -1,12 +1,16 @@
1
1
  import type { TypedFlatConfigItem } from "@antfu/eslint-config";
2
+ import { ensurePackages } from "@antfu/eslint-config";
2
3
 
3
4
  import eslintConfigPrettier from "eslint-config-prettier";
4
5
  import { renameRules } from "../utils/renameRules";
5
6
 
6
- const prettier = {
7
- name: "vdustr/prettier",
8
- ...eslintConfigPrettier,
9
- rules: renameRules(eslintConfigPrettier.rules),
10
- } satisfies TypedFlatConfigItem;
7
+ const prettier = async (): Promise<TypedFlatConfigItem> => {
8
+ await ensurePackages(["eslint-config-prettier"]);
9
+ return {
10
+ name: "vdustr/prettier",
11
+ ...eslintConfigPrettier,
12
+ rules: renameRules(eslintConfigPrettier.rules),
13
+ };
14
+ };
11
15
 
12
16
  export { prettier };
@@ -1,20 +1,24 @@
1
1
  import type { TypedFlatConfigItem } from "@antfu/eslint-config";
2
+ import { ensurePackages } from "@antfu/eslint-config";
2
3
  import storybookPlugin from "eslint-plugin-storybook";
3
4
  import { renameRules } from "../utils/renameRules";
4
5
 
5
- const storybook = storybookPlugin.configs["flat/csf-strict"].map((config) => {
6
- const allConfig = config as TypedFlatConfigItem;
7
- const { rules, files, plugins, ...rest } = allConfig;
8
- return {
9
- ...rest,
10
- ...(!rules
11
- ? null
12
- : {
13
- rules: renameRules(rules),
14
- }),
15
- ...(!files ? null : { files }),
16
- ...(!plugins ? null : { plugins }),
17
- } satisfies TypedFlatConfigItem;
18
- });
6
+ const storybook = async (): Promise<Array<TypedFlatConfigItem>> => {
7
+ await ensurePackages(["eslint-plugin-storybook"]);
8
+ return storybookPlugin.configs["flat/csf-strict"].map((config) => {
9
+ const allConfig = config as TypedFlatConfigItem;
10
+ const { rules, files, plugins, ...rest } = allConfig;
11
+ return {
12
+ ...rest,
13
+ ...(!rules
14
+ ? null
15
+ : {
16
+ rules: renameRules(rules),
17
+ }),
18
+ ...(!files ? null : { files }),
19
+ ...(!plugins ? null : { plugins }),
20
+ } satisfies TypedFlatConfigItem;
21
+ });
22
+ };
19
23
 
20
24
  export { storybook };
@@ -0,0 +1 @@
1
+ // This is a placeholder for `eslint-typegen.d.ts`.
@@ -1,4 +1,5 @@
1
1
  import type { ESLint, Linter } from "eslint";
2
+ import { ensurePackages } from "@antfu/eslint-config";
2
3
  // @ts-expect-error -- Untyped library.
3
4
  // eslint-disable-next-line import/no-namespace -- `react-compiler` exports the plugin as a namespace.
4
5
  import * as reactCompiler from "eslint-plugin-react-compiler";
@@ -10,7 +11,9 @@ interface ReactCompiler extends ESLint.Plugin {
10
11
  };
11
12
  }
12
13
 
13
- const reactCompilerInternal: ReactCompiler =
14
- reactCompiler.default ?? reactCompiler;
14
+ const reactCompilerInternal = async (): Promise<ReactCompiler> => {
15
+ await ensurePackages(["eslint-plugin-react-compiler"]);
16
+ return reactCompiler.default ?? reactCompiler;
17
+ };
15
18
 
16
19
  export { reactCompilerInternal as reactCompiler };
package/src/vdustr.ts CHANGED
@@ -1,15 +1,20 @@
1
- // eslint-disable-next-line import/no-empty-named-blocks -- Type only import.
2
- import type {} from "./eslint-typegen";
3
1
  import type { Config } from "./types";
4
- import antfu from "@antfu/eslint-config";
2
+ import antfu, {
3
+ GLOB_ASTRO_TS,
4
+ GLOB_JS,
5
+ GLOB_JSX,
6
+ GLOB_TS,
7
+ GLOB_TSX,
8
+ } from "@antfu/eslint-config";
5
9
 
6
10
  import packageJson from "eslint-plugin-package-json/configs/recommended";
7
-
8
11
  import { isPackageExists } from "local-pkg";
12
+
9
13
  import { mdx } from "./configs/mdx";
10
14
  import { prettier } from "./configs/prettier";
11
15
  import { storybook } from "./configs/storybook";
12
16
  import { reactCompiler } from "./lib/eslint-plugin-react-compiler";
17
+ import "./eslint-typegen";
13
18
 
14
19
  type Options = Omit<NonNullable<Parameters<typeof antfu>[0]>, "stylistic"> & {
15
20
  mdx?: boolean | mdx.Options;
@@ -80,13 +85,6 @@ const vdustr = (options?: Options, ...userConfigs: Array<Config>) => {
80
85
  * Consider using named imports instead.
81
86
  */
82
87
  "import/no-namespace": "error",
83
-
84
- /**
85
- * Enforcing named exports improves consistency, enhances auto-completion and refactoring, and avoids issues
86
- * with default export renaming. Additionally, default exports might lead to different behavior when transformed
87
- * to CJS.
88
- */
89
- "import/no-default-export": "error",
90
88
  },
91
89
  }))
92
90
 
@@ -94,17 +92,20 @@ const vdustr = (options?: Options, ...userConfigs: Array<Config>) => {
94
92
  * Allow default exports in certain files.
95
93
  */
96
94
  .insertAfter("antfu/imports/rules", {
97
- name: "vdustr/allow-default-export",
95
+ name: "vdustr/no-default-export",
98
96
  rules: {
99
- "import/no-default-export": "off",
97
+ /**
98
+ * Enforcing named exports improves consistency, enhances auto-completion and refactoring, and avoids issues
99
+ * with default export renaming. Additionally, default exports might lead to different behavior when transformed
100
+ * to CJS.
101
+ */
102
+ "import/no-default-export": "error",
100
103
  },
101
- files: [
104
+ files: [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
105
+ ignores: [
102
106
  // Configuration files
103
107
  "**/*.config.*",
104
-
105
- // Single file components
106
- "**/*.vue",
107
- "**/*.svelte",
108
+ GLOB_ASTRO_TS,
108
109
  ],
109
110
  });
110
111
 
@@ -156,27 +157,29 @@ const vdustr = (options?: Options, ...userConfigs: Array<Config>) => {
156
157
  }
157
158
 
158
159
  if (reactEnabled) {
159
- config = config.override("antfu/react/rules", (config) => ({
160
- ...config,
161
- plugins: {
162
- ...config.plugins,
163
- "react-compiler": reactCompiler,
164
- },
165
- rules: {
166
- ...config.rules,
167
- "react-compiler/react-compiler": "error",
160
+ config = config.override("antfu/react/rules", async (config) => {
161
+ return {
162
+ ...config,
163
+ plugins: {
164
+ ...config.plugins,
165
+ "react-compiler": await reactCompiler(),
166
+ },
167
+ rules: {
168
+ ...config.rules,
169
+ "react-compiler/react-compiler": "error",
168
170
 
169
- /**
170
- * Not all destructuring assignments are more readable than their alternatives.
171
- */
172
- "react/prefer-destructuring-assignment": "off",
173
- },
174
- }));
171
+ /**
172
+ * Not all destructuring assignments are more readable than their alternatives.
173
+ */
174
+ "react/prefer-destructuring-assignment": "off",
175
+ },
176
+ };
177
+ });
175
178
  }
176
179
 
177
180
  if (storybookEnabled) {
178
181
  config = config
179
- .append(storybook)
182
+ .append(storybook())
180
183
  .override("storybook:csf:stories-rules", (config) => ({
181
184
  ...config,
182
185
  rules: {
@@ -203,7 +206,7 @@ const vdustr = (options?: Options, ...userConfigs: Array<Config>) => {
203
206
  );
204
207
  }
205
208
 
206
- config = config.append(prettier);
209
+ config = config.append(prettier());
207
210
 
208
211
  return config;
209
212
  };