@vp-tw/eslint-config 0.0.2 → 0.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/dist/configs/mdx.d.ts +2 -227
- package/dist/configs/mdx.js +32 -15
- package/dist/configs/prettier.d.ts +1 -2
- package/dist/configs/prettier.js +2 -2
- package/dist/configs/storybook.d.ts +2 -0
- package/dist/configs/storybook.js +30 -0
- package/dist/eslint-typegen.d.ts +80 -0
- package/dist/esm/configs/mdx.d.ts +2 -227
- package/dist/esm/configs/mdx.mjs +37 -20
- package/dist/esm/configs/prettier.d.ts +1 -2
- package/dist/esm/configs/prettier.mjs +2 -2
- package/dist/esm/configs/storybook.d.ts +2 -0
- package/dist/esm/configs/storybook.mjs +15 -0
- package/dist/esm/eslint-typegen.d.ts +80 -0
- package/dist/esm/lib/eslint-plugin-react-compiler.d.ts +8 -12
- package/dist/esm/lib/eslint-plugin-react-compiler.mjs +3 -0
- package/dist/esm/utils/renameRules.d.ts +3 -0
- package/dist/esm/utils/renameRules.mjs +5 -0
- package/dist/esm/vdustr.d.ts +1 -1
- package/dist/esm/vdustr.mjs +99 -52
- package/dist/lib/eslint-plugin-react-compiler.d.ts +8 -12
- package/dist/lib/eslint-plugin-react-compiler.js +10 -1
- package/dist/utils/renameRules.d.ts +3 -0
- package/dist/utils/renameRules.js +10 -0
- package/dist/vdustr.d.ts +1 -1
- package/dist/vdustr.js +95 -54
- package/package.json +1 -1
- package/scripts/typegen.ts +2 -1
- package/src/configs/mdx.ts +10 -15
- package/src/lib/eslint-plugin-react-compiler.ts +15 -12
- package/src/vdustr.ts +5 -4
- package/tsconfig.json +1 -1
package/dist/esm/vdustr.mjs
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import antfu from "@antfu/eslint-config";
|
|
2
2
|
import packageJson from "eslint-plugin-package-json/configs/recommended";
|
|
3
|
-
import
|
|
3
|
+
import { isPackageExists } from "local-pkg";
|
|
4
4
|
import { mdx } from "./configs/mdx.mjs";
|
|
5
5
|
import { prettier } from "./configs/prettier.mjs";
|
|
6
|
-
import "./
|
|
6
|
+
import { storybook } from "./configs/storybook.mjs";
|
|
7
|
+
import { reactCompiler } from "./lib/eslint-plugin-react-compiler.mjs";
|
|
7
8
|
const vdustr = (options, ...userConfigs) => {
|
|
8
|
-
const
|
|
9
|
+
const typescriptEnabled = isPackageExists("typescript");
|
|
9
10
|
const jsoncEnabled = Boolean(options?.jsonc ?? true);
|
|
11
|
+
const reactEnabled = Boolean(options?.react ?? false);
|
|
12
|
+
const storybookEnabled = Boolean(options?.storybook ?? false);
|
|
13
|
+
const mdxOptions = options?.mdx ?? true;
|
|
10
14
|
const defaultConfigs = [
|
|
11
15
|
...!jsoncEnabled ? [] : [packageJson],
|
|
12
16
|
...!mdxOptions ? [] : mdx({
|
|
13
17
|
...typeof mdxOptions !== "object" ? null : mdxOptions
|
|
14
18
|
}),
|
|
19
|
+
...!storybookEnabled ? [] : storybook,
|
|
15
20
|
prettier
|
|
16
21
|
];
|
|
17
|
-
|
|
22
|
+
let config = antfu(
|
|
18
23
|
{
|
|
19
24
|
// We use `prettier`.
|
|
20
25
|
stylistic: false,
|
|
@@ -22,10 +27,11 @@ const vdustr = (options, ...userConfigs) => {
|
|
|
22
27
|
},
|
|
23
28
|
...defaultConfigs,
|
|
24
29
|
...userConfigs
|
|
25
|
-
)
|
|
26
|
-
|
|
30
|
+
);
|
|
31
|
+
config = config.override("antfu/javascript/rules", (config2) => ({
|
|
32
|
+
...config2,
|
|
27
33
|
rules: {
|
|
28
|
-
...
|
|
34
|
+
...config2.rules,
|
|
29
35
|
/**
|
|
30
36
|
* Some callbacks are purposefully named to make the code self-documenting.
|
|
31
37
|
*/
|
|
@@ -40,62 +46,103 @@ const vdustr = (options, ...userConfigs) => {
|
|
|
40
46
|
"unused-imports/no-unused-vars-ts": "off",
|
|
41
47
|
"unused-imports/no-unused-imports": "off"
|
|
42
48
|
}
|
|
43
|
-
})).override("antfu/imports/rules", (
|
|
44
|
-
...
|
|
49
|
+
})).override("antfu/imports/rules", (config2) => ({
|
|
50
|
+
...config2,
|
|
45
51
|
rules: {
|
|
46
|
-
...
|
|
52
|
+
...config2.rules,
|
|
47
53
|
/**
|
|
48
54
|
* Forbid `import {} from "module"`.
|
|
49
55
|
*/
|
|
50
|
-
"import/no-empty-named-blocks": "error"
|
|
51
|
-
}
|
|
52
|
-
})).override("antfu/typescript/rules", (config) => ({
|
|
53
|
-
...config,
|
|
54
|
-
rules: {
|
|
55
|
-
...config.rules,
|
|
56
|
-
"ts/array-type": ["error", { default: "generic" }],
|
|
56
|
+
"import/no-empty-named-blocks": "error",
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* - References:
|
|
62
|
-
* - <https://x.com/mattpocockuk/status/1805606072167940167>
|
|
58
|
+
* Wildcard imports can prevent tree shaking and cause name conflicts.
|
|
59
|
+
* Consider using named imports instead.
|
|
63
60
|
*/
|
|
64
|
-
"
|
|
65
|
-
"ts/no-redeclare": "off",
|
|
61
|
+
"import/no-namespace": "error",
|
|
66
62
|
/**
|
|
67
|
-
*
|
|
63
|
+
* Enforcing named exports improves consistency, enhances auto-completion and refactoring, and avoids issues
|
|
64
|
+
* with default export renaming. Additionally, default exports might lead to different behavior when transformed
|
|
65
|
+
* to CJS.
|
|
68
66
|
*/
|
|
69
|
-
"
|
|
67
|
+
"import/no-default-export": "error"
|
|
70
68
|
}
|
|
71
|
-
})).
|
|
72
|
-
|
|
69
|
+
})).insertAfter("antfu/imports/rules", {
|
|
70
|
+
name: "vdustr/allow-default-export",
|
|
73
71
|
rules: {
|
|
74
|
-
|
|
75
|
-
"jsonc/sort-keys": "error"
|
|
72
|
+
"import/no-default-export": "off"
|
|
76
73
|
},
|
|
77
|
-
files: [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
*/
|
|
83
|
-
"**/package.json"
|
|
74
|
+
files: [
|
|
75
|
+
"**/*.config.*",
|
|
76
|
+
// Single file components
|
|
77
|
+
"**/*.vue",
|
|
78
|
+
"**/*.svelte"
|
|
84
79
|
]
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
...
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
80
|
+
});
|
|
81
|
+
if (typescriptEnabled) {
|
|
82
|
+
config = config.override("antfu/typescript/rules", (config2) => ({
|
|
83
|
+
...config2,
|
|
84
|
+
rules: {
|
|
85
|
+
...config2.rules,
|
|
86
|
+
"ts/array-type": ["error", { default: "generic" }],
|
|
87
|
+
/**
|
|
88
|
+
* Namespaces are useful for centralizing the management of types. Just avoid
|
|
89
|
+
* overusing them with runtime code.
|
|
90
|
+
*
|
|
91
|
+
* - References:
|
|
92
|
+
* - <https://x.com/mattpocockuk/status/1805606072167940167>
|
|
93
|
+
*/
|
|
94
|
+
"ts/no-namespace": "off",
|
|
95
|
+
"ts/no-redeclare": "off",
|
|
96
|
+
/**
|
|
97
|
+
* Check for unused variables in TypeScript.
|
|
98
|
+
*/
|
|
99
|
+
"ts/no-unused-vars": "off"
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
if (jsoncEnabled) {
|
|
104
|
+
config = config.override("antfu/jsonc/rules", (config2) => ({
|
|
105
|
+
...config2,
|
|
106
|
+
rules: {
|
|
107
|
+
...config2.rules,
|
|
108
|
+
"jsonc/sort-keys": "error"
|
|
109
|
+
},
|
|
110
|
+
files: [...config2.files ?? [], "**/*.code-workspace"],
|
|
111
|
+
ignores: [
|
|
112
|
+
...config2.ignores ?? [],
|
|
113
|
+
/**
|
|
114
|
+
* Lint `package.json` files with `eslint-plugin-package-json` instead.
|
|
115
|
+
*/
|
|
116
|
+
"**/package.json"
|
|
117
|
+
]
|
|
118
|
+
})).remove("antfu/sort/package-json").remove("antfu/sort/tsconfig-json");
|
|
119
|
+
}
|
|
120
|
+
if (reactEnabled) {
|
|
121
|
+
config = config.override("antfu/react/rules", (config2) => ({
|
|
122
|
+
...config2,
|
|
123
|
+
plugins: {
|
|
124
|
+
...config2.plugins,
|
|
125
|
+
"react-compiler": reactCompiler
|
|
126
|
+
},
|
|
127
|
+
rules: {
|
|
128
|
+
...config2.rules,
|
|
129
|
+
"react-compiler/react-compiler": "error",
|
|
130
|
+
/**
|
|
131
|
+
* Not all destructuring assignments are more readable than their alternatives.
|
|
132
|
+
*/
|
|
133
|
+
"react/prefer-destructuring-assignment": "off"
|
|
134
|
+
}
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
if (storybookEnabled) {
|
|
138
|
+
config = config.override("storybook:csf:stories-rules", (config2) => ({
|
|
139
|
+
...config2,
|
|
140
|
+
rules: {
|
|
141
|
+
...config2.rules,
|
|
142
|
+
"import/no-default-export": "off"
|
|
143
|
+
}
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
return config;
|
|
100
147
|
};
|
|
101
148
|
export { vdustr };
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
recommended: LegacyConfig;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
const rules: ReactCompiler["rules"];
|
|
11
|
-
const configs: ReactCompiler["configs"];
|
|
12
|
-
export { configs, rules };
|
|
1
|
+
import type { ESLint, Linter } from "eslint";
|
|
2
|
+
interface ReactCompiler extends ESLint.Plugin {
|
|
3
|
+
rules: NonNullable<ESLint.Plugin["rules"]>;
|
|
4
|
+
configs: {
|
|
5
|
+
recommended: Linter.LegacyConfig;
|
|
6
|
+
};
|
|
13
7
|
}
|
|
8
|
+
declare const reactCompilerInternal: ReactCompiler;
|
|
9
|
+
export { reactCompilerInternal as reactCompiler };
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.reactCompiler = void 0;
|
|
7
|
+
var reactCompiler = _interopRequireWildcard(require("eslint-plugin-react-compiler"));
|
|
8
|
+
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
|
+
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;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renameRules = renameRulesInternal;
|
|
7
|
+
var _eslintConfig = require("@antfu/eslint-config");
|
|
8
|
+
function renameRulesInternal(rules) {
|
|
9
|
+
return (0, _eslintConfig.renameRules)(rules, _eslintConfig.defaultPluginRenaming);
|
|
10
|
+
}
|
package/dist/vdustr.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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.d";
|
|
5
4
|
type Options = NonNullable<Parameters<typeof antfu>[0]> & {
|
|
6
5
|
mdx?: boolean | mdx.Options;
|
|
6
|
+
storybook?: boolean;
|
|
7
7
|
};
|
|
8
8
|
declare const vdustr: (options?: Options, ...userConfigs: Array<Config>) => import("eslint-flat-config-utils/index").FlatConfigComposer<import("@antfu/eslint-config").TypedFlatConfigItem, import("@antfu/eslint-config").ConfigNames>;
|
|
9
9
|
export { vdustr };
|
package/dist/vdustr.js
CHANGED
|
@@ -6,27 +6,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.vdustr = void 0;
|
|
7
7
|
var _eslintConfig = _interopRequireDefault(require("@antfu/eslint-config"));
|
|
8
8
|
var _recommended = _interopRequireDefault(require("eslint-plugin-package-json/configs/recommended"));
|
|
9
|
-
var
|
|
9
|
+
var _localPkg = require("local-pkg");
|
|
10
10
|
var _mdx = require("./configs/mdx");
|
|
11
11
|
var _prettier = require("./configs/prettier");
|
|
12
|
-
require("./
|
|
13
|
-
|
|
14
|
-
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; }
|
|
12
|
+
var _storybook = require("./configs/storybook");
|
|
13
|
+
var _eslintPluginReactCompiler = require("./lib/eslint-plugin-react-compiler");
|
|
15
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
15
|
const vdustr = (options, ...userConfigs) => {
|
|
17
|
-
const
|
|
16
|
+
const typescriptEnabled = (0, _localPkg.isPackageExists)("typescript");
|
|
18
17
|
const jsoncEnabled = Boolean(options?.jsonc ?? true);
|
|
18
|
+
const reactEnabled = Boolean(options?.react ?? false);
|
|
19
|
+
const storybookEnabled = Boolean(options?.storybook ?? false);
|
|
20
|
+
const mdxOptions = options?.mdx ?? true;
|
|
19
21
|
const defaultConfigs = [...(!jsoncEnabled ? [] : [_recommended.default]), ...(!mdxOptions ? [] : (0, _mdx.mdx)({
|
|
20
22
|
...(typeof mdxOptions !== "object" ? null : mdxOptions)
|
|
21
|
-
})), _prettier.prettier];
|
|
22
|
-
|
|
23
|
+
})), ...(!storybookEnabled ? [] : _storybook.storybook), _prettier.prettier];
|
|
24
|
+
let config = (0, _eslintConfig.default)({
|
|
23
25
|
// We use `prettier`.
|
|
24
26
|
stylistic: false,
|
|
25
27
|
...options
|
|
26
|
-
}, ...defaultConfigs, ...userConfigs)
|
|
27
|
-
|
|
28
|
+
}, ...defaultConfigs, ...userConfigs);
|
|
29
|
+
config = config.override("antfu/javascript/rules", config2 => ({
|
|
30
|
+
...config2,
|
|
28
31
|
rules: {
|
|
29
|
-
...
|
|
32
|
+
...config2.rules,
|
|
30
33
|
/**
|
|
31
34
|
* Some callbacks are purposefully named to make the code self-documenting.
|
|
32
35
|
*/
|
|
@@ -41,62 +44,100 @@ const vdustr = (options, ...userConfigs) => {
|
|
|
41
44
|
"unused-imports/no-unused-vars-ts": "off",
|
|
42
45
|
"unused-imports/no-unused-imports": "off"
|
|
43
46
|
}
|
|
44
|
-
})).override("antfu/imports/rules",
|
|
45
|
-
...
|
|
47
|
+
})).override("antfu/imports/rules", config2 => ({
|
|
48
|
+
...config2,
|
|
46
49
|
rules: {
|
|
47
|
-
...
|
|
50
|
+
...config2.rules,
|
|
48
51
|
/**
|
|
49
52
|
* Forbid `import {} from "module"`.
|
|
50
53
|
*/
|
|
51
|
-
"import/no-empty-named-blocks": "error"
|
|
52
|
-
}
|
|
53
|
-
})).override("antfu/typescript/rules", config => ({
|
|
54
|
-
...config,
|
|
55
|
-
rules: {
|
|
56
|
-
...config.rules,
|
|
57
|
-
"ts/array-type": ["error", {
|
|
58
|
-
default: "generic"
|
|
59
|
-
}],
|
|
54
|
+
"import/no-empty-named-blocks": "error",
|
|
60
55
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* - References:
|
|
65
|
-
* - <https://x.com/mattpocockuk/status/1805606072167940167>
|
|
56
|
+
* Wildcard imports can prevent tree shaking and cause name conflicts.
|
|
57
|
+
* Consider using named imports instead.
|
|
66
58
|
*/
|
|
67
|
-
"
|
|
68
|
-
"ts/no-redeclare": "off",
|
|
59
|
+
"import/no-namespace": "error",
|
|
69
60
|
/**
|
|
70
|
-
*
|
|
61
|
+
* Enforcing named exports improves consistency, enhances auto-completion and refactoring, and avoids issues
|
|
62
|
+
* with default export renaming. Additionally, default exports might lead to different behavior when transformed
|
|
63
|
+
* to CJS.
|
|
71
64
|
*/
|
|
72
|
-
"
|
|
65
|
+
"import/no-default-export": "error"
|
|
73
66
|
}
|
|
74
|
-
})).
|
|
75
|
-
|
|
67
|
+
})).insertAfter("antfu/imports/rules", {
|
|
68
|
+
name: "vdustr/allow-default-export",
|
|
76
69
|
rules: {
|
|
77
|
-
|
|
78
|
-
"jsonc/sort-keys": "error"
|
|
70
|
+
"import/no-default-export": "off"
|
|
79
71
|
},
|
|
80
|
-
files: [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
72
|
+
files: ["**/*.config.*",
|
|
73
|
+
// Single file components
|
|
74
|
+
"**/*.vue", "**/*.svelte"]
|
|
75
|
+
});
|
|
76
|
+
if (typescriptEnabled) {
|
|
77
|
+
config = config.override("antfu/typescript/rules", config2 => ({
|
|
78
|
+
...config2,
|
|
79
|
+
rules: {
|
|
80
|
+
...config2.rules,
|
|
81
|
+
"ts/array-type": ["error", {
|
|
82
|
+
default: "generic"
|
|
83
|
+
}],
|
|
84
|
+
/**
|
|
85
|
+
* Namespaces are useful for centralizing the management of types. Just avoid
|
|
86
|
+
* overusing them with runtime code.
|
|
87
|
+
*
|
|
88
|
+
* - References:
|
|
89
|
+
* - <https://x.com/mattpocockuk/status/1805606072167940167>
|
|
90
|
+
*/
|
|
91
|
+
"ts/no-namespace": "off",
|
|
92
|
+
"ts/no-redeclare": "off",
|
|
93
|
+
/**
|
|
94
|
+
* Check for unused variables in TypeScript.
|
|
95
|
+
*/
|
|
96
|
+
"ts/no-unused-vars": "off"
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
if (jsoncEnabled) {
|
|
101
|
+
config = config.override("antfu/jsonc/rules", config2 => ({
|
|
102
|
+
...config2,
|
|
103
|
+
rules: {
|
|
104
|
+
...config2.rules,
|
|
105
|
+
"jsonc/sort-keys": "error"
|
|
106
|
+
},
|
|
107
|
+
files: [...(config2.files ?? []), "**/*.code-workspace"],
|
|
108
|
+
ignores: [...(config2.ignores ?? []),
|
|
95
109
|
/**
|
|
96
|
-
*
|
|
110
|
+
* Lint `package.json` files with `eslint-plugin-package-json` instead.
|
|
97
111
|
*/
|
|
98
|
-
"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
112
|
+
"**/package.json"]
|
|
113
|
+
})).remove("antfu/sort/package-json").remove("antfu/sort/tsconfig-json");
|
|
114
|
+
}
|
|
115
|
+
if (reactEnabled) {
|
|
116
|
+
config = config.override("antfu/react/rules", config2 => ({
|
|
117
|
+
...config2,
|
|
118
|
+
plugins: {
|
|
119
|
+
...config2.plugins,
|
|
120
|
+
"react-compiler": _eslintPluginReactCompiler.reactCompiler
|
|
121
|
+
},
|
|
122
|
+
rules: {
|
|
123
|
+
...config2.rules,
|
|
124
|
+
"react-compiler/react-compiler": "error",
|
|
125
|
+
/**
|
|
126
|
+
* Not all destructuring assignments are more readable than their alternatives.
|
|
127
|
+
*/
|
|
128
|
+
"react/prefer-destructuring-assignment": "off"
|
|
129
|
+
}
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
if (storybookEnabled) {
|
|
133
|
+
config = config.override("storybook:csf:stories-rules", config2 => ({
|
|
134
|
+
...config2,
|
|
135
|
+
rules: {
|
|
136
|
+
...config2.rules,
|
|
137
|
+
"import/no-default-export": "off"
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
return config;
|
|
101
142
|
};
|
|
102
143
|
exports.vdustr = vdustr;
|
package/package.json
CHANGED
package/scripts/typegen.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ESLint } from "eslint";
|
|
2
2
|
import { rules as mdxRules } from "eslint-plugin-mdx/lib/rules";
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import storybook from "eslint-plugin-storybook";
|
|
5
5
|
import { pluginsToRulesDTS } from "eslint-typegen/core";
|
|
6
6
|
import fs from "fs-extra";
|
|
7
7
|
import path from "pathe";
|
|
8
8
|
import { packageDirectory } from "pkg-dir";
|
|
9
|
+
import { reactCompiler } from "../src/lib/eslint-plugin-react-compiler";
|
|
9
10
|
|
|
10
11
|
(async () => {
|
|
11
12
|
const pkgDir = await packageDirectory();
|
package/src/configs/mdx.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
2
2
|
import type { DistributiveOmit } from "@mui/types";
|
|
3
|
-
import { defaultPluginRenaming, renameRules } from "@antfu/eslint-config";
|
|
4
3
|
|
|
5
4
|
// eslint-disable-next-line import/no-namespace -- `mdx` exports the plugin as a namespace.
|
|
6
5
|
import * as mdxPlugin from "eslint-plugin-mdx";
|
|
6
|
+
import { renameRules } from "../utils/renameRules";
|
|
7
7
|
|
|
8
8
|
namespace mdx {
|
|
9
9
|
export interface Options
|
|
@@ -20,18 +20,15 @@ const mdx = ({
|
|
|
20
20
|
}: mdx.Options = {}) => {
|
|
21
21
|
const flatCodeBlocksOptions: TypedFlatConfigItem =
|
|
22
22
|
typeof flatCodeBlocks !== "object" ? {} : flatCodeBlocks;
|
|
23
|
-
|
|
23
|
+
const configs: Array<TypedFlatConfigItem> = [
|
|
24
24
|
{
|
|
25
25
|
name: "vdustr/mdx",
|
|
26
26
|
...mdxPlugin.flat,
|
|
27
27
|
...options,
|
|
28
28
|
rules: {
|
|
29
|
-
...renameRules(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
defaultPluginRenaming,
|
|
34
|
-
),
|
|
29
|
+
...renameRules({
|
|
30
|
+
...mdxPlugin.flat.rules,
|
|
31
|
+
}),
|
|
35
32
|
...options.rules,
|
|
36
33
|
},
|
|
37
34
|
processor: mdxPlugin.createRemarkProcessor({
|
|
@@ -50,17 +47,15 @@ const mdx = ({
|
|
|
50
47
|
...mdxPlugin.flatCodeBlocks,
|
|
51
48
|
...flatCodeBlocksOptions,
|
|
52
49
|
rules: {
|
|
53
|
-
...renameRules(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
defaultPluginRenaming,
|
|
58
|
-
),
|
|
50
|
+
...renameRules({
|
|
51
|
+
...mdxPlugin.flatCodeBlocks.rules,
|
|
52
|
+
}),
|
|
59
53
|
...flatCodeBlocksOptions.rules,
|
|
60
54
|
},
|
|
61
55
|
} satisfies TypedFlatConfigItem,
|
|
62
56
|
]),
|
|
63
|
-
]
|
|
57
|
+
];
|
|
58
|
+
return configs;
|
|
64
59
|
};
|
|
65
60
|
|
|
66
61
|
export { mdx };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const configs: ReactCompiler["configs"];
|
|
12
|
-
export { configs, rules };
|
|
1
|
+
import type { ESLint, Linter } from "eslint";
|
|
2
|
+
// @ts-expect-error -- Untyped library.
|
|
3
|
+
// eslint-disable-next-line import/no-namespace -- `react-compiler` exports the plugin as a namespace.
|
|
4
|
+
import * as reactCompiler from "eslint-plugin-react-compiler";
|
|
5
|
+
|
|
6
|
+
interface ReactCompiler extends ESLint.Plugin {
|
|
7
|
+
rules: NonNullable<ESLint.Plugin["rules"]>;
|
|
8
|
+
configs: {
|
|
9
|
+
recommended: Linter.LegacyConfig;
|
|
10
|
+
};
|
|
13
11
|
}
|
|
12
|
+
|
|
13
|
+
const reactCompilerInternal: ReactCompiler =
|
|
14
|
+
reactCompiler.default ?? reactCompiler;
|
|
15
|
+
|
|
16
|
+
export { reactCompilerInternal as reactCompiler };
|
package/src/vdustr.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-empty-named-blocks -- Type only import.
|
|
2
|
+
import type {} from "./eslint-typegen";
|
|
1
3
|
import type { Config } from "./types";
|
|
2
4
|
import antfu from "@antfu/eslint-config";
|
|
5
|
+
|
|
3
6
|
import packageJson from "eslint-plugin-package-json/configs/recommended";
|
|
4
7
|
|
|
5
|
-
// eslint-disable-next-line import/no-namespace -- This is a cjs module.
|
|
6
|
-
import * as reactCompilerPlugin from "eslint-plugin-react-compiler";
|
|
7
8
|
import { isPackageExists } from "local-pkg";
|
|
8
9
|
import { mdx } from "./configs/mdx";
|
|
9
10
|
import { prettier } from "./configs/prettier";
|
|
10
11
|
import { storybook } from "./configs/storybook";
|
|
11
|
-
import "./eslint-
|
|
12
|
+
import { reactCompiler } from "./lib/eslint-plugin-react-compiler";
|
|
12
13
|
|
|
13
14
|
type Options = NonNullable<Parameters<typeof antfu>[0]> & {
|
|
14
15
|
mdx?: boolean | mdx.Options;
|
|
@@ -154,7 +155,7 @@ const vdustr = (options?: Options, ...userConfigs: Array<Config>) => {
|
|
|
154
155
|
...config,
|
|
155
156
|
plugins: {
|
|
156
157
|
...config.plugins,
|
|
157
|
-
"react-compiler":
|
|
158
|
+
"react-compiler": reactCompiler,
|
|
158
159
|
},
|
|
159
160
|
rules: {
|
|
160
161
|
...config.rules,
|
package/tsconfig.json
CHANGED