@vp-tw/eslint-config 1.0.2 → 1.0.4
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 +32 -5
- package/dist/configs/packageJson.js +1 -0
- package/dist/esm/configs/packageJson.mjs +1 -0
- package/dist/esm/extends/react.mjs +2 -1
- package/dist/esm/lib/eslint-react.d.ts +3 -0
- package/dist/esm/lib/eslint-react.mjs +3 -0
- package/dist/esm/vdustr.mjs +4 -1
- package/dist/extends/react.js +3 -3
- package/dist/lib/eslint-react.d.ts +3 -0
- package/dist/lib/eslint-react.js +9 -0
- package/dist/vdustr.js +4 -1
- package/package.json +39 -37
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
|
-
##
|
|
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
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
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"
|
|
@@ -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;
|
package/dist/esm/vdustr.mjs
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/dist/extends/react.js
CHANGED
|
@@ -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 ?
|
|
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,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
|
-
(
|
|
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.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "ViPro's ESLint configuration",
|
|
5
5
|
"homepage": "https://github.com/vdustr/eslint-config",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,41 +43,48 @@
|
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "unbuild",
|
|
48
|
+
"copy": "tsx scripts/copy",
|
|
49
|
+
"prepare": "run-s typegen",
|
|
50
|
+
"prepublishOnly": "run-s copy build",
|
|
51
|
+
"typegen": "jiti scripts/typegen"
|
|
52
|
+
},
|
|
46
53
|
"dependencies": {
|
|
47
|
-
"@mui/types": "
|
|
48
|
-
"@typescript-eslint/utils": "
|
|
49
|
-
"es-toolkit": "
|
|
50
|
-
"eslint-flat-config-utils": "
|
|
51
|
-
"local-pkg": "
|
|
54
|
+
"@mui/types": "catalog:",
|
|
55
|
+
"@typescript-eslint/utils": "catalog:",
|
|
56
|
+
"es-toolkit": "catalog:",
|
|
57
|
+
"eslint-flat-config-utils": "catalog:",
|
|
58
|
+
"local-pkg": "catalog:"
|
|
52
59
|
},
|
|
53
60
|
"devDependencies": {
|
|
54
|
-
"@antfu/eslint-config": "
|
|
55
|
-
"@emotion/eslint-plugin": "
|
|
56
|
-
"@tanstack/eslint-plugin-query": "
|
|
57
|
-
"@types/eslint-config-prettier": "
|
|
58
|
-
"eslint": "
|
|
59
|
-
"eslint-config-prettier": "
|
|
60
|
-
"eslint-plugin-mdx": "
|
|
61
|
-
"eslint-plugin-package-json": "
|
|
62
|
-
"eslint-plugin-react-compiler": "
|
|
63
|
-
"eslint-plugin-storybook": "
|
|
64
|
-
"eslint-plugin-yml": "
|
|
65
|
-
"eslint-typegen": "
|
|
66
|
-
"storybook": "
|
|
67
|
-
"unbuild": "
|
|
61
|
+
"@antfu/eslint-config": "catalog:",
|
|
62
|
+
"@emotion/eslint-plugin": "catalog:",
|
|
63
|
+
"@tanstack/eslint-plugin-query": "catalog:",
|
|
64
|
+
"@types/eslint-config-prettier": "catalog:",
|
|
65
|
+
"eslint": "catalog:",
|
|
66
|
+
"eslint-config-prettier": "catalog:",
|
|
67
|
+
"eslint-plugin-mdx": "catalog:",
|
|
68
|
+
"eslint-plugin-package-json": "catalog:",
|
|
69
|
+
"eslint-plugin-react-compiler": "catalog:",
|
|
70
|
+
"eslint-plugin-storybook": "catalog:",
|
|
71
|
+
"eslint-plugin-yml": "catalog:",
|
|
72
|
+
"eslint-typegen": "catalog:",
|
|
73
|
+
"storybook": "catalog:",
|
|
74
|
+
"unbuild": "catalog:"
|
|
68
75
|
},
|
|
69
76
|
"peerDependencies": {
|
|
70
|
-
"@emotion/eslint-plugin": "
|
|
71
|
-
"@tanstack/eslint-plugin-query": "
|
|
72
|
-
"@types/eslint-config-prettier": "
|
|
73
|
-
"eslint": "
|
|
74
|
-
"eslint-config-prettier": "
|
|
75
|
-
"eslint-plugin-mdx": "
|
|
76
|
-
"eslint-plugin-package-json": "
|
|
77
|
-
"eslint-plugin-react-compiler": "
|
|
78
|
-
"eslint-plugin-storybook": "
|
|
79
|
-
"eslint-plugin-yml": "
|
|
80
|
-
"storybook": "
|
|
77
|
+
"@emotion/eslint-plugin": "catalog:",
|
|
78
|
+
"@tanstack/eslint-plugin-query": "catalog:",
|
|
79
|
+
"@types/eslint-config-prettier": "catalog:",
|
|
80
|
+
"eslint": "catalog:",
|
|
81
|
+
"eslint-config-prettier": "catalog:",
|
|
82
|
+
"eslint-plugin-mdx": "catalog:",
|
|
83
|
+
"eslint-plugin-package-json": "catalog:",
|
|
84
|
+
"eslint-plugin-react-compiler": "catalog:",
|
|
85
|
+
"eslint-plugin-storybook": "catalog:",
|
|
86
|
+
"eslint-plugin-yml": "catalog:",
|
|
87
|
+
"storybook": "catalog:"
|
|
81
88
|
},
|
|
82
89
|
"peerDependenciesMeta": {
|
|
83
90
|
"@emotion/eslint-plugin": {
|
|
@@ -110,10 +117,5 @@
|
|
|
110
117
|
"storybook": {
|
|
111
118
|
"optional": true
|
|
112
119
|
}
|
|
113
|
-
},
|
|
114
|
-
"scripts": {
|
|
115
|
-
"build": "unbuild",
|
|
116
|
-
"copy": "tsx scripts/copy",
|
|
117
|
-
"typegen": "jiti scripts/typegen"
|
|
118
120
|
}
|
|
119
|
-
}
|
|
121
|
+
}
|