@vp-tw/eslint-config 1.0.2 → 1.0.5

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
@@ -85,16 +85,43 @@ export default vdustr({
85
85
 
86
86
  Automatically sorts keys in `pnpm-workspace.yaml` alphabetically using `yaml/sort-keys` rule.
87
87
 
88
- ## Release
88
+ ## Contributing
89
+
90
+ ### Development
91
+
92
+ ```bash
93
+ pnpm install # Install dependencies
94
+ pnpm build # Build @vp-tw/eslint-config (in packages/eslint-config)
95
+ pnpm test # Run tests for @vp-tw/eslint-config
96
+ pnpm run checkTypes # Type check entire workspace
97
+ pnpm lint # Lint entire workspace
98
+ ```
99
+
100
+ ### Release
101
+
102
+ Managed by [changesets](https://github.com/changesets/changesets). CI auto-publishes when merged to main.
89
103
 
90
104
  ```bash
91
- pnpm -w v:patch # or
92
- pnpm -w v:minor # or
93
- pnpm -w v:major
105
+ pnpm changeset # Create changeset interactively
106
+ ```
107
+
108
+ ### Adding Dynamic Import Wrappers
109
+
110
+ When adding support for optional ESLint plugins, create a wrapper in `src/lib/`:
94
111
 
95
- pnpm -r publish
112
+ ```typescript
113
+ // src/lib/my-plugin.ts
114
+ import type MyPlugin from "eslint-plugin-my";
115
+ import { interopDefault } from "@antfu/eslint-config";
116
+
117
+ // Explicit return type required to avoid TS2742 build errors
118
+ const myPlugin = (): Promise<typeof MyPlugin> => interopDefault(import("eslint-plugin-my"));
119
+
120
+ export { myPlugin };
96
121
  ```
97
122
 
123
+ See [CLAUDE.md](./CLAUDE.md) for detailed architecture and patterns.
124
+
98
125
  ## License
99
126
 
100
127
  MIT © ViPro <vdustr@gmail.com> (<http://vdustr.dev>)
@@ -20,6 +20,7 @@ const packageJson = async options => {
20
20
  ...(0, _esToolkit.omit)(recommended, ["name", "plugins"]),
21
21
  rules: (0, _renameRules.renameRules)({
22
22
  ...recommended.rules,
23
+ // sorted by oxfmt
23
24
  "package-json/order-properties": "off"
24
25
  }),
25
26
  name: "vdustr/package-json/rules"
@@ -14,6 +14,7 @@ const packageJson = async (options) => {
14
14
  ...omit(recommended, ["name", "plugins"]),
15
15
  rules: renameRules({
16
16
  ...recommended.rules,
17
+ // sorted by oxfmt
17
18
  "package-json/order-properties": "off"
18
19
  }),
19
20
  name: "vdustr/package-json/rules"
@@ -1,8 +1,8 @@
1
1
  import { GLOB_MARKDOWN_CODE } from "@antfu/eslint-config";
2
- import eslintReact from "@eslint-react/eslint-plugin";
3
2
  import { omit, pick } from "es-toolkit";
4
3
  import { reactCompiler } from "../configs/reactCompiler.mjs";
5
4
  import { GLOB_MDX_CODE } from "../globs.mjs";
5
+ import { eslintReact as importEslintReact } from "../lib/eslint-react.mjs";
6
6
  import { extendsConfig } from "../utils/extendsConfig.mjs";
7
7
  import { mergeConfig } from "../utils/mergeConfig.mjs";
8
8
  import { ignoreKeys } from "./_utils.mjs";
@@ -32,6 +32,7 @@ function renameReactRules(rules) {
32
32
  const react = (composer, options) => {
33
33
  const typescriptEnabled = options?.typescript ?? true;
34
34
  extendsConfig(composer, "antfu/react/rules", async (config) => {
35
+ const eslintReact = await importEslintReact();
35
36
  const modifiedConfig = mergeConfig(pick(options?.react ?? {}, ["files", "ignores"]), config);
36
37
  const omittedConfig = omit(modifiedConfig, ignoreKeys);
37
38
  const baseConfig = typescriptEnabled ? eslintReact.configs["strict-typescript"] : eslintReact.configs.strict;
@@ -0,0 +1,3 @@
1
+ import type EslintReact from "@eslint-react/eslint-plugin";
2
+ declare const eslintReact: () => Promise<typeof EslintReact>;
3
+ export { eslintReact };
@@ -0,0 +1,3 @@
1
+ import { interopDefault } from "@antfu/eslint-config";
2
+ const eslintReact = () => interopDefault(import("@eslint-react/eslint-plugin"));
3
+ export { eslintReact };
@@ -40,6 +40,7 @@ const vdustr = (options, ...userConfigs) => {
40
40
  const mdxEnabled = Boolean(vpOptions?.mdx ?? false);
41
41
  const storybookEnabled = Boolean(vpOptions?.storybook ?? false);
42
42
  const prettierEnabled = Boolean(vpOptions?.prettier ?? true);
43
+ const reactEnabled = Boolean(antfuOptions?.react ?? false);
43
44
  let config = antfu({
44
45
  ...antfuOptions,
45
46
  ...!prettierEnabled ? null : {
@@ -56,7 +57,9 @@ const vdustr = (options, ...userConfigs) => {
56
57
  sortJsonKeys(config, vpOptions?.extends?.sort?.jsoncSortKeys);
57
58
  sortJsonArrayValues(config, vpOptions?.extends?.sort?.jsoncSortArrayValues);
58
59
  yaml(config, vpOptions?.extends?.yaml);
59
- react(config, vpOptions?.extends?.react);
60
+ if (reactEnabled) {
61
+ react(config, vpOptions?.extends?.react);
62
+ }
60
63
  pnpm(config, vpOptions?.extends?.pnpm);
61
64
  if (packageJsonEnabled) {
62
65
  const packageJsonOptions = typeof vpOptions?.packageJson !== "object" ? void 0 : vpOptions.packageJson;
@@ -5,14 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.react = void 0;
7
7
  var _eslintConfig = require("@antfu/eslint-config");
8
- var _eslintPlugin = _interopRequireDefault(require("@eslint-react/eslint-plugin"));
9
8
  var _esToolkit = require("es-toolkit");
10
9
  var _reactCompiler = require("../configs/reactCompiler");
11
10
  var _globs = require("../globs");
11
+ var _eslintReact = require("../lib/eslint-react");
12
12
  var _extendsConfig = require("../utils/extendsConfig");
13
13
  var _mergeConfig = require("../utils/mergeConfig");
14
14
  var _utils = require("./_utils");
15
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
15
  const reactRulesRenameMap = {
17
16
  "@eslint-react": "react",
18
17
  "@eslint-react/dom": "react-dom",
@@ -37,9 +36,10 @@ function renameReactRules(rules) {
37
36
  const react = (composer, options) => {
38
37
  const typescriptEnabled = options?.typescript ?? true;
39
38
  (0, _extendsConfig.extendsConfig)(composer, "antfu/react/rules", async config => {
39
+ const eslintReact = await (0, _eslintReact.eslintReact)();
40
40
  const modifiedConfig = (0, _mergeConfig.mergeConfig)((0, _esToolkit.pick)(options?.react ?? {}, ["files", "ignores"]), config);
41
41
  const omittedConfig = (0, _esToolkit.omit)(modifiedConfig, _utils.ignoreKeys);
42
- const baseConfig = typescriptEnabled ? _eslintPlugin.default.configs["strict-typescript"] : _eslintPlugin.default.configs.strict;
42
+ const baseConfig = typescriptEnabled ? eslintReact.configs["strict-typescript"] : eslintReact.configs.strict;
43
43
  const rulesConfig = (0, _mergeConfig.mergeConfig)((0, _esToolkit.omit)(options?.react ?? {}, ["files", "ignores"]), {
44
44
  // plugins already setup by antfu
45
45
  ...(0, _esToolkit.omit)(baseConfig, ["plugins"]),
@@ -0,0 +1,3 @@
1
+ import type EslintReact from "@eslint-react/eslint-plugin";
2
+ declare const eslintReact: () => Promise<typeof EslintReact>;
3
+ export { eslintReact };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.eslintReact = void 0;
7
+ var _eslintConfig = require("@antfu/eslint-config");
8
+ const eslintReact = () => (0, _eslintConfig.interopDefault)(Promise.resolve().then(() => require("@eslint-react/eslint-plugin")));
9
+ exports.eslintReact = eslintReact;
package/dist/vdustr.js CHANGED
@@ -31,6 +31,7 @@ const vdustr = (options, ...userConfigs) => {
31
31
  const mdxEnabled = Boolean(vpOptions?.mdx ?? false);
32
32
  const storybookEnabled = Boolean(vpOptions?.storybook ?? false);
33
33
  const prettierEnabled = Boolean(vpOptions?.prettier ?? true);
34
+ const reactEnabled = Boolean(antfuOptions?.react ?? false);
34
35
  let config = (0, _eslintConfig.default)({
35
36
  ...antfuOptions,
36
37
  ...(!prettierEnabled ? null : {
@@ -47,7 +48,9 @@ const vdustr = (options, ...userConfigs) => {
47
48
  (0, _sort.sortJsonKeys)(config, vpOptions?.extends?.sort?.jsoncSortKeys);
48
49
  (0, _sort.sortJsonArrayValues)(config, vpOptions?.extends?.sort?.jsoncSortArrayValues);
49
50
  (0, _yaml.yaml)(config, vpOptions?.extends?.yaml);
50
- (0, _react.react)(config, vpOptions?.extends?.react);
51
+ if (reactEnabled) {
52
+ (0, _react.react)(config, vpOptions?.extends?.react);
53
+ }
51
54
  (0, _pnpm.pnpm)(config, vpOptions?.extends?.pnpm);
52
55
  if (packageJsonEnabled) {
53
56
  const packageJsonOptions = typeof vpOptions?.packageJson !== "object" ? void 0 : vpOptions.packageJson;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vp-tw/eslint-config",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "ViPro's ESLint configuration",
5
5
  "homepage": "https://github.com/vdustr/eslint-config",
6
6
  "license": "MIT",