@vp-tw/eslint-config 0.0.8 → 0.0.9
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 +1 -1
- package/dist/configs/mdx.d.ts +1 -2
- package/dist/configs/mdx.js +1 -3
- package/dist/configs/storybook.js +2 -3
- package/dist/eslint-typegen.js +2 -0
- package/dist/esm/configs/mdx.d.ts +1 -2
- package/dist/esm/configs/mdx.mjs +2 -2
- package/dist/esm/configs/storybook.mjs +4 -2
- package/dist/esm/lib/eslint-plugin-react-compiler.d.ts +2 -2
- package/dist/esm/lib/eslint-plugin-react-compiler.mjs +10 -5
- package/dist/lib/eslint-plugin-react-compiler.d.ts +2 -2
- package/dist/lib/eslint-plugin-react-compiler.js +4 -6
- package/package.json +8 -2
- package/build.config.ts +0 -31
- package/global.d.ts +0 -1
- package/scripts/copy.ts +0 -23
- package/scripts/typegen.ts +0 -45
- package/src/configs/mdx.ts +0 -63
- package/src/configs/prettier.ts +0 -16
- package/src/configs/storybook.ts +0 -24
- package/src/eslint-typegen.d.ts +0 -106
- package/src/index.ts +0 -1
- package/src/lib/eslint-plugin-react-compiler.ts +0 -19
- package/src/tsconfig.json +0 -3
- package/src/types.ts +0 -5
- package/src/utils/renameRules.ts +0 -7
- package/src/vdustr.ts +0 -214
- package/tsconfig.json +0 -4
- /package/{src/eslint-typegen.js → dist/esm/eslint-typegen.mjs} +0 -0
package/README.md
CHANGED
package/dist/configs/mdx.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
2
2
|
import type { DistributiveOmit } from "@mui/types";
|
|
3
|
-
import * as mdxPlugin from "eslint-plugin-mdx";
|
|
4
3
|
declare namespace mdx {
|
|
5
4
|
interface Options extends DistributiveOmit<TypedFlatConfigItem, "processor"> {
|
|
6
|
-
processorOptions?:
|
|
5
|
+
processorOptions?: import("eslint-plugin-mdx").ProcessorOptions;
|
|
7
6
|
flatCodeBlocks?: boolean | TypedFlatConfigItem;
|
|
8
7
|
}
|
|
9
8
|
}
|
package/dist/configs/mdx.js
CHANGED
|
@@ -5,16 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.mdx = void 0;
|
|
7
7
|
var _eslintConfig = require("@antfu/eslint-config");
|
|
8
|
-
var mdxPlugin = _interopRequireWildcard(require("eslint-plugin-mdx"));
|
|
9
8
|
var _renameRules = require("../utils/renameRules");
|
|
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); }
|
|
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; }
|
|
12
9
|
const mdx = async ({
|
|
13
10
|
flatCodeBlocks = true,
|
|
14
11
|
processorOptions,
|
|
15
12
|
...options
|
|
16
13
|
} = {}) => {
|
|
17
14
|
await (0, _eslintConfig.ensurePackages)(["eslint-plugin-mdx"]);
|
|
15
|
+
const mdxPlugin = await (0, _eslintConfig.interopDefault)(await Promise.resolve().then(() => require("eslint-plugin-mdx")));
|
|
18
16
|
const flatCodeBlocksOptions = typeof flatCodeBlocks !== "object" ? {} : flatCodeBlocks;
|
|
19
17
|
const configs = [{
|
|
20
18
|
name: "vdustr/mdx",
|
|
@@ -5,12 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.storybook = void 0;
|
|
7
7
|
var _eslintConfig = require("@antfu/eslint-config");
|
|
8
|
-
var _eslintPluginStorybook = _interopRequireDefault(require("eslint-plugin-storybook"));
|
|
9
8
|
var _renameRules = require("../utils/renameRules");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
9
|
const storybook = async () => {
|
|
12
10
|
await (0, _eslintConfig.ensurePackages)(["eslint-plugin-storybook"]);
|
|
13
|
-
|
|
11
|
+
const storybookPlugin = await (0, _eslintConfig.interopDefault)(Promise.resolve().then(() => require("eslint-plugin-storybook")));
|
|
12
|
+
return storybookPlugin.configs["flat/csf-strict"].map(config => {
|
|
14
13
|
const allConfig = config;
|
|
15
14
|
const {
|
|
16
15
|
rules,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
2
2
|
import type { DistributiveOmit } from "@mui/types";
|
|
3
|
-
import * as mdxPlugin from "eslint-plugin-mdx";
|
|
4
3
|
declare namespace mdx {
|
|
5
4
|
interface Options extends DistributiveOmit<TypedFlatConfigItem, "processor"> {
|
|
6
|
-
processorOptions?:
|
|
5
|
+
processorOptions?: import("eslint-plugin-mdx").ProcessorOptions;
|
|
7
6
|
flatCodeBlocks?: boolean | TypedFlatConfigItem;
|
|
8
7
|
}
|
|
9
8
|
}
|
package/dist/esm/configs/mdx.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ensurePackages } from "@antfu/eslint-config";
|
|
2
|
-
import * as mdxPlugin from "eslint-plugin-mdx";
|
|
1
|
+
import { ensurePackages, interopDefault } from "@antfu/eslint-config";
|
|
3
2
|
import { renameRules } from "../utils/renameRules.mjs";
|
|
4
3
|
const mdx = async ({
|
|
5
4
|
flatCodeBlocks = true,
|
|
@@ -7,6 +6,7 @@ const mdx = async ({
|
|
|
7
6
|
...options
|
|
8
7
|
} = {}) => {
|
|
9
8
|
await ensurePackages(["eslint-plugin-mdx"]);
|
|
9
|
+
const mdxPlugin = await interopDefault(await import("eslint-plugin-mdx"));
|
|
10
10
|
const flatCodeBlocksOptions = typeof flatCodeBlocks !== "object" ? {} : flatCodeBlocks;
|
|
11
11
|
const configs = [
|
|
12
12
|
{
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { ensurePackages } from "@antfu/eslint-config";
|
|
2
|
-
import storybookPlugin from "eslint-plugin-storybook";
|
|
1
|
+
import { ensurePackages, interopDefault } from "@antfu/eslint-config";
|
|
3
2
|
import { renameRules } from "../utils/renameRules.mjs";
|
|
4
3
|
const storybook = async () => {
|
|
5
4
|
await ensurePackages(["eslint-plugin-storybook"]);
|
|
5
|
+
const storybookPlugin = await interopDefault(
|
|
6
|
+
import("eslint-plugin-storybook")
|
|
7
|
+
);
|
|
6
8
|
return storybookPlugin.configs["flat/csf-strict"].map((config) => {
|
|
7
9
|
const allConfig = config;
|
|
8
10
|
const { rules, files, plugins, ...rest } = allConfig;
|
|
@@ -5,5 +5,5 @@ interface ReactCompiler extends ESLint.Plugin {
|
|
|
5
5
|
recommended: Linter.LegacyConfig;
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
-
declare const
|
|
9
|
-
export {
|
|
8
|
+
declare const reactCompiler: () => Promise<ReactCompiler>;
|
|
9
|
+
export { reactCompiler };
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { ensurePackages } from "@antfu/eslint-config";
|
|
2
|
-
|
|
3
|
-
const reactCompilerInternal = async () => {
|
|
1
|
+
import { ensurePackages, interopDefault } from "@antfu/eslint-config";
|
|
2
|
+
const reactCompiler = async () => {
|
|
4
3
|
await ensurePackages(["eslint-plugin-react-compiler"]);
|
|
5
|
-
|
|
4
|
+
const reactCompiler2 = await interopDefault(
|
|
5
|
+
import(
|
|
6
|
+
// @ts-expect-error -- Untyped library.
|
|
7
|
+
"eslint-plugin-react-compiler"
|
|
8
|
+
)
|
|
9
|
+
);
|
|
10
|
+
return reactCompiler2;
|
|
6
11
|
};
|
|
7
|
-
export {
|
|
12
|
+
export { reactCompiler };
|
|
@@ -5,5 +5,5 @@ interface ReactCompiler extends ESLint.Plugin {
|
|
|
5
5
|
recommended: Linter.LegacyConfig;
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
-
declare const
|
|
9
|
-
export {
|
|
8
|
+
declare const reactCompiler: () => Promise<ReactCompiler>;
|
|
9
|
+
export { reactCompiler };
|
|
@@ -5,11 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.reactCompiler = void 0;
|
|
7
7
|
var _eslintConfig = require("@antfu/eslint-config");
|
|
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); }
|
|
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; }
|
|
11
|
-
const reactCompilerInternal = async () => {
|
|
8
|
+
const reactCompiler = async () => {
|
|
12
9
|
await (0, _eslintConfig.ensurePackages)(["eslint-plugin-react-compiler"]);
|
|
13
|
-
|
|
10
|
+
const reactCompiler2 = await (0, _eslintConfig.interopDefault)(Promise.resolve().then(() => require("eslint-plugin-react-compiler")));
|
|
11
|
+
return reactCompiler2;
|
|
14
12
|
};
|
|
15
|
-
exports.reactCompiler =
|
|
13
|
+
exports.reactCompiler = reactCompiler;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vp-tw/eslint-config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "ViPro's ESLint configuration",
|
|
5
5
|
"homepage": "https://github.com/vdustr/eslint-config",
|
|
6
6
|
"author": {
|
|
@@ -35,8 +35,10 @@
|
|
|
35
35
|
"main": "./dist/index.js",
|
|
36
36
|
"module": "./dist/esm/index.mjs",
|
|
37
37
|
"types": "./dist/index.d.ts",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
38
41
|
"dependencies": {
|
|
39
|
-
"@antfu/eslint-config": "^4.1.0",
|
|
40
42
|
"@mui/types": "^7.2.21",
|
|
41
43
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
42
44
|
"eslint-config-prettier": "^10.0.1",
|
|
@@ -45,9 +47,13 @@
|
|
|
45
47
|
"local-pkg": "^1.0.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
50
|
+
"@antfu/eslint-config": "^4.1.0",
|
|
48
51
|
"eslint-typegen": "^1.0.0",
|
|
49
52
|
"unbuild": "^3.3.1"
|
|
50
53
|
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@antfu/eslint-config": "^4.1.0"
|
|
56
|
+
},
|
|
51
57
|
"publishConfig": {
|
|
52
58
|
"access": "public"
|
|
53
59
|
},
|
package/build.config.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { BuildConfig } from "unbuild";
|
|
2
|
-
import { defineBuildConfig } from "unbuild";
|
|
3
|
-
|
|
4
|
-
const basicEntry = {
|
|
5
|
-
builder: "mkdist",
|
|
6
|
-
input: "./src/",
|
|
7
|
-
pattern: [
|
|
8
|
-
"**/*.ts",
|
|
9
|
-
"!**/*.test.ts",
|
|
10
|
-
"!**/*.test-d.ts",
|
|
11
|
-
"!**/spec/**",
|
|
12
|
-
"!**/test/**",
|
|
13
|
-
"!**/node_modules/**",
|
|
14
|
-
],
|
|
15
|
-
} satisfies NonNullable<BuildConfig["entries"]>[number];
|
|
16
|
-
|
|
17
|
-
export default defineBuildConfig({
|
|
18
|
-
entries: [
|
|
19
|
-
{
|
|
20
|
-
...basicEntry,
|
|
21
|
-
outDir: "./dist",
|
|
22
|
-
format: "cjs",
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
...basicEntry,
|
|
26
|
-
outDir: "./dist/esm",
|
|
27
|
-
format: "esm",
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
declaration: true,
|
|
31
|
-
});
|
package/global.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="@total-typescript/ts-reset" />
|
package/scripts/copy.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
2
|
-
import path from "pathe";
|
|
3
|
-
import { packageDirectory } from "pkg-dir";
|
|
4
|
-
|
|
5
|
-
const filesToCopy = ["README.md", "LICENSE"] satisfies Array<string>;
|
|
6
|
-
|
|
7
|
-
(async () => {
|
|
8
|
-
const pkgDir = await packageDirectory();
|
|
9
|
-
if (!pkgDir) {
|
|
10
|
-
throw new Error("Could not find package directory");
|
|
11
|
-
}
|
|
12
|
-
const rootPkgDir = await packageDirectory({
|
|
13
|
-
cwd: path.resolve(pkgDir, ".."),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
if (!rootPkgDir) {
|
|
17
|
-
throw new Error("Could not find root package directory");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
for (const file of filesToCopy) {
|
|
21
|
-
await fs.copyFile(path.join(rootPkgDir, file), path.join(pkgDir, file));
|
|
22
|
-
}
|
|
23
|
-
})();
|
package/scripts/typegen.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { ESLint } from "eslint";
|
|
2
|
-
import { rules as mdxRules } from "eslint-plugin-mdx/lib/rules";
|
|
3
|
-
|
|
4
|
-
import storybook from "eslint-plugin-storybook";
|
|
5
|
-
import { pluginsToRulesDTS } from "eslint-typegen/core";
|
|
6
|
-
import fs from "fs-extra";
|
|
7
|
-
import path from "pathe";
|
|
8
|
-
import { packageDirectory } from "pkg-dir";
|
|
9
|
-
import { reactCompiler } from "../src/lib/eslint-plugin-react-compiler";
|
|
10
|
-
|
|
11
|
-
(async () => {
|
|
12
|
-
const pkgDir = await packageDirectory();
|
|
13
|
-
if (!pkgDir) {
|
|
14
|
-
throw new Error("Could not find package directory");
|
|
15
|
-
}
|
|
16
|
-
const distDir = path.join(pkgDir, "src");
|
|
17
|
-
const targetPath = path.join(distDir, "eslint-typegen.d.ts");
|
|
18
|
-
await fs.ensureDir(path.dirname(targetPath));
|
|
19
|
-
|
|
20
|
-
type Plugins = Record<string, ESLint.Plugin>;
|
|
21
|
-
|
|
22
|
-
function definePlugins<T extends Plugins>(plugins: T): T {
|
|
23
|
-
return plugins;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const plugins: Plugins = {
|
|
27
|
-
...definePlugins({ "react-compiler": await reactCompiler() }),
|
|
28
|
-
...definePlugins({
|
|
29
|
-
mdx: {
|
|
30
|
-
rules: mdxRules,
|
|
31
|
-
},
|
|
32
|
-
}),
|
|
33
|
-
...definePlugins({
|
|
34
|
-
...Object.fromEntries(
|
|
35
|
-
storybook.configs["flat/csf-strict"].flatMap((config) =>
|
|
36
|
-
!("plugins" in config) || !config.plugins
|
|
37
|
-
? []
|
|
38
|
-
: Object.entries(config.plugins),
|
|
39
|
-
),
|
|
40
|
-
),
|
|
41
|
-
}),
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
await fs.writeFile(targetPath, await pluginsToRulesDTS(plugins));
|
|
45
|
-
})();
|
package/src/configs/mdx.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
2
|
-
import type { DistributiveOmit } from "@mui/types";
|
|
3
|
-
import { ensurePackages } from "@antfu/eslint-config";
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line import/no-namespace -- `mdx` exports the plugin as a namespace.
|
|
6
|
-
import * as mdxPlugin from "eslint-plugin-mdx";
|
|
7
|
-
import { renameRules } from "../utils/renameRules";
|
|
8
|
-
|
|
9
|
-
namespace mdx {
|
|
10
|
-
export interface Options
|
|
11
|
-
extends DistributiveOmit<TypedFlatConfigItem, "processor"> {
|
|
12
|
-
processorOptions?: mdxPlugin.ProcessorOptions;
|
|
13
|
-
flatCodeBlocks?: boolean | TypedFlatConfigItem;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const mdx = async ({
|
|
18
|
-
flatCodeBlocks = true,
|
|
19
|
-
processorOptions,
|
|
20
|
-
...options
|
|
21
|
-
}: mdx.Options = {}): Promise<Array<TypedFlatConfigItem>> => {
|
|
22
|
-
await ensurePackages(["eslint-plugin-mdx"]);
|
|
23
|
-
const flatCodeBlocksOptions: TypedFlatConfigItem =
|
|
24
|
-
typeof flatCodeBlocks !== "object" ? {} : flatCodeBlocks;
|
|
25
|
-
const configs: Array<TypedFlatConfigItem> = [
|
|
26
|
-
{
|
|
27
|
-
name: "vdustr/mdx",
|
|
28
|
-
...mdxPlugin.flat,
|
|
29
|
-
...options,
|
|
30
|
-
rules: {
|
|
31
|
-
...renameRules({
|
|
32
|
-
...mdxPlugin.flat.rules,
|
|
33
|
-
}),
|
|
34
|
-
...options.rules,
|
|
35
|
-
},
|
|
36
|
-
processor: mdxPlugin.createRemarkProcessor({
|
|
37
|
-
lintCodeBlocks: Boolean(flatCodeBlocks),
|
|
38
|
-
...processorOptions,
|
|
39
|
-
languageMapper: {
|
|
40
|
-
...processorOptions?.languageMapper,
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
},
|
|
44
|
-
...(!flatCodeBlocks
|
|
45
|
-
? []
|
|
46
|
-
: [
|
|
47
|
-
{
|
|
48
|
-
name: "vdustr/mdx/flat-code-blocks",
|
|
49
|
-
...mdxPlugin.flatCodeBlocks,
|
|
50
|
-
...flatCodeBlocksOptions,
|
|
51
|
-
rules: {
|
|
52
|
-
...renameRules({
|
|
53
|
-
...mdxPlugin.flatCodeBlocks.rules,
|
|
54
|
-
}),
|
|
55
|
-
...flatCodeBlocksOptions.rules,
|
|
56
|
-
},
|
|
57
|
-
} satisfies TypedFlatConfigItem,
|
|
58
|
-
]),
|
|
59
|
-
];
|
|
60
|
-
return configs;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export { mdx };
|
package/src/configs/prettier.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
2
|
-
import { ensurePackages } from "@antfu/eslint-config";
|
|
3
|
-
|
|
4
|
-
import eslintConfigPrettier from "eslint-config-prettier";
|
|
5
|
-
import { renameRules } from "../utils/renameRules";
|
|
6
|
-
|
|
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
|
-
};
|
|
15
|
-
|
|
16
|
-
export { prettier };
|
package/src/configs/storybook.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
2
|
-
import { ensurePackages } from "@antfu/eslint-config";
|
|
3
|
-
import storybookPlugin from "eslint-plugin-storybook";
|
|
4
|
-
import { renameRules } from "../utils/renameRules";
|
|
5
|
-
|
|
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
|
-
};
|
|
23
|
-
|
|
24
|
-
export { storybook };
|
package/src/eslint-typegen.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/* prettier-ignore */
|
|
3
|
-
import type { Linter } from 'eslint'
|
|
4
|
-
|
|
5
|
-
declare module 'eslint' {
|
|
6
|
-
namespace Linter {
|
|
7
|
-
interface RulesRecord extends RuleOptions {}
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface RuleOptions {
|
|
12
|
-
/**
|
|
13
|
-
* Linter integration with remark plugins
|
|
14
|
-
*/
|
|
15
|
-
'mdx/remark'?: Linter.RuleEntry<[]>
|
|
16
|
-
/**
|
|
17
|
-
* Surfaces diagnostics from React Forget
|
|
18
|
-
*/
|
|
19
|
-
'react-compiler/react-compiler'?: Linter.RuleEntry<ReactCompilerReactCompiler>
|
|
20
|
-
/**
|
|
21
|
-
* Interactions should be awaited
|
|
22
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/await-interactions.md
|
|
23
|
-
*/
|
|
24
|
-
'storybook/await-interactions'?: Linter.RuleEntry<[]>
|
|
25
|
-
/**
|
|
26
|
-
* Pass a context when invoking play function of another story
|
|
27
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/context-in-play-function.md
|
|
28
|
-
*/
|
|
29
|
-
'storybook/context-in-play-function'?: Linter.RuleEntry<[]>
|
|
30
|
-
/**
|
|
31
|
-
* The component property should be set
|
|
32
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/csf-component.md
|
|
33
|
-
*/
|
|
34
|
-
'storybook/csf-component'?: Linter.RuleEntry<[]>
|
|
35
|
-
/**
|
|
36
|
-
* Story files should have a default export
|
|
37
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/default-exports.md
|
|
38
|
-
*/
|
|
39
|
-
'storybook/default-exports'?: Linter.RuleEntry<[]>
|
|
40
|
-
/**
|
|
41
|
-
* Deprecated hierarchy separator in title property
|
|
42
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/hierarchy-separator.md
|
|
43
|
-
*/
|
|
44
|
-
'storybook/hierarchy-separator'?: Linter.RuleEntry<[]>
|
|
45
|
-
/**
|
|
46
|
-
* Meta should only have inline properties
|
|
47
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/meta-inline-properties.md
|
|
48
|
-
*/
|
|
49
|
-
'storybook/meta-inline-properties'?: Linter.RuleEntry<StorybookMetaInlineProperties>
|
|
50
|
-
/**
|
|
51
|
-
* A story should not have a redundant name property
|
|
52
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/no-redundant-story-name.md
|
|
53
|
-
*/
|
|
54
|
-
'storybook/no-redundant-story-name'?: Linter.RuleEntry<[]>
|
|
55
|
-
/**
|
|
56
|
-
* storiesOf is deprecated and should not be used
|
|
57
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/no-stories-of.md
|
|
58
|
-
*/
|
|
59
|
-
'storybook/no-stories-of'?: Linter.RuleEntry<[]>
|
|
60
|
-
/**
|
|
61
|
-
* Do not define a title in meta
|
|
62
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/no-title-property-in-meta.md
|
|
63
|
-
*/
|
|
64
|
-
'storybook/no-title-property-in-meta'?: Linter.RuleEntry<[]>
|
|
65
|
-
/**
|
|
66
|
-
* This rule identifies storybook addons that are invalid because they are either not installed or contain a typo in their name.
|
|
67
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/no-uninstalled-addons.md
|
|
68
|
-
*/
|
|
69
|
-
'storybook/no-uninstalled-addons'?: Linter.RuleEntry<StorybookNoUninstalledAddons>
|
|
70
|
-
/**
|
|
71
|
-
* Stories should use PascalCase
|
|
72
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/prefer-pascal-case.md
|
|
73
|
-
*/
|
|
74
|
-
'storybook/prefer-pascal-case'?: Linter.RuleEntry<[]>
|
|
75
|
-
/**
|
|
76
|
-
* A story file must contain at least one story export
|
|
77
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/story-exports.md
|
|
78
|
-
*/
|
|
79
|
-
'storybook/story-exports'?: Linter.RuleEntry<[]>
|
|
80
|
-
/**
|
|
81
|
-
* Use expect from `@storybook/test` or `@storybook/jest`
|
|
82
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/use-storybook-expect.md
|
|
83
|
-
*/
|
|
84
|
-
'storybook/use-storybook-expect'?: Linter.RuleEntry<[]>
|
|
85
|
-
/**
|
|
86
|
-
* Do not use testing-library directly on stories
|
|
87
|
-
* @see https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/use-storybook-testing-library.md
|
|
88
|
-
*/
|
|
89
|
-
'storybook/use-storybook-testing-library'?: Linter.RuleEntry<[]>
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/* ======= Declarations ======= */
|
|
93
|
-
// ----- react-compiler/react-compiler -----
|
|
94
|
-
type ReactCompilerReactCompiler = []|[{
|
|
95
|
-
[k: string]: unknown | undefined
|
|
96
|
-
}]
|
|
97
|
-
// ----- storybook/meta-inline-properties -----
|
|
98
|
-
type StorybookMetaInlineProperties = []|[{
|
|
99
|
-
csfVersion?: number
|
|
100
|
-
}]
|
|
101
|
-
// ----- storybook/no-uninstalled-addons -----
|
|
102
|
-
type StorybookNoUninstalledAddons = []|[{
|
|
103
|
-
packageJsonLocation?: string
|
|
104
|
-
ignore?: string[]
|
|
105
|
-
[k: string]: unknown | undefined
|
|
106
|
-
}]
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./vdustr";
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ESLint, Linter } from "eslint";
|
|
2
|
-
import { ensurePackages } from "@antfu/eslint-config";
|
|
3
|
-
// @ts-expect-error -- Untyped library.
|
|
4
|
-
// eslint-disable-next-line import/no-namespace -- `react-compiler` exports the plugin as a namespace.
|
|
5
|
-
import * as reactCompiler from "eslint-plugin-react-compiler";
|
|
6
|
-
|
|
7
|
-
interface ReactCompiler extends ESLint.Plugin {
|
|
8
|
-
rules: NonNullable<ESLint.Plugin["rules"]>;
|
|
9
|
-
configs: {
|
|
10
|
-
recommended: Linter.LegacyConfig;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const reactCompilerInternal = async (): Promise<ReactCompiler> => {
|
|
15
|
-
await ensurePackages(["eslint-plugin-react-compiler"]);
|
|
16
|
-
return reactCompiler.default ?? reactCompiler;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { reactCompilerInternal as reactCompiler };
|
package/src/tsconfig.json
DELETED
package/src/types.ts
DELETED
package/src/utils/renameRules.ts
DELETED
package/src/vdustr.ts
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import type { Config } from "./types";
|
|
2
|
-
import antfu, {
|
|
3
|
-
GLOB_ASTRO_TS,
|
|
4
|
-
GLOB_JS,
|
|
5
|
-
GLOB_JSX,
|
|
6
|
-
GLOB_TS,
|
|
7
|
-
GLOB_TSX,
|
|
8
|
-
} from "@antfu/eslint-config";
|
|
9
|
-
|
|
10
|
-
import packageJson from "eslint-plugin-package-json/configs/recommended";
|
|
11
|
-
import { isPackageExists } from "local-pkg";
|
|
12
|
-
|
|
13
|
-
import { mdx } from "./configs/mdx";
|
|
14
|
-
import { prettier } from "./configs/prettier";
|
|
15
|
-
import { storybook } from "./configs/storybook";
|
|
16
|
-
import { reactCompiler } from "./lib/eslint-plugin-react-compiler";
|
|
17
|
-
import "./eslint-typegen";
|
|
18
|
-
|
|
19
|
-
type Options = Omit<NonNullable<Parameters<typeof antfu>[0]>, "stylistic"> & {
|
|
20
|
-
mdx?: boolean | mdx.Options;
|
|
21
|
-
storybook?: boolean;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const vdustr = (options?: Options, ...userConfigs: Array<Config>) => {
|
|
25
|
-
const typescriptEnabled = isPackageExists("typescript");
|
|
26
|
-
const jsoncEnabled: boolean = Boolean(options?.jsonc ?? true);
|
|
27
|
-
const reactEnabled: boolean = Boolean(options?.react ?? false);
|
|
28
|
-
const storybookEnabled: boolean = Boolean(options?.storybook ?? false);
|
|
29
|
-
const mdxEnabled: boolean = Boolean(options?.mdx ?? false);
|
|
30
|
-
const mdxOptions: Extract<Options["mdx"], Record<PropertyKey, any>> = {
|
|
31
|
-
...(typeof options?.mdx !== "object" ? null : options.mdx),
|
|
32
|
-
};
|
|
33
|
-
const mdxFlatCodeBlocksEnabled: boolean = Boolean(
|
|
34
|
-
mdxOptions?.flatCodeBlocks ?? true,
|
|
35
|
-
);
|
|
36
|
-
const mdxFlatCodeBlocksOptions: Extract<
|
|
37
|
-
(typeof mdxOptions)["flatCodeBlocks"],
|
|
38
|
-
Record<PropertyKey, any>
|
|
39
|
-
> = {
|
|
40
|
-
...(typeof mdxOptions?.flatCodeBlocks !== "object"
|
|
41
|
-
? null
|
|
42
|
-
: mdxOptions.flatCodeBlocks),
|
|
43
|
-
};
|
|
44
|
-
let config = antfu(
|
|
45
|
-
{
|
|
46
|
-
// We use `prettier`.
|
|
47
|
-
stylistic: false,
|
|
48
|
-
...options,
|
|
49
|
-
},
|
|
50
|
-
...userConfigs,
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
config = config
|
|
54
|
-
.override("antfu/javascript/rules", (config) => ({
|
|
55
|
-
...config,
|
|
56
|
-
rules: {
|
|
57
|
-
...config.rules,
|
|
58
|
-
/**
|
|
59
|
-
* Some callbacks are purposefully named to make the code self-documenting.
|
|
60
|
-
*/
|
|
61
|
-
"prefer-arrow-callback": "off",
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* This rule does not integrate well with JSDoc `@link` tags. It's advised
|
|
65
|
-
* to verify its behavior with TypeScript instead.
|
|
66
|
-
*/
|
|
67
|
-
"no-unused-vars": "off",
|
|
68
|
-
"unused-imports/no-unused-vars": "off",
|
|
69
|
-
"unused-imports/no-unused-imports-ts": "off",
|
|
70
|
-
"unused-imports/no-unused-vars-ts": "off",
|
|
71
|
-
"unused-imports/no-unused-imports": "off",
|
|
72
|
-
},
|
|
73
|
-
}))
|
|
74
|
-
.override("antfu/imports/rules", (config) => ({
|
|
75
|
-
...config,
|
|
76
|
-
rules: {
|
|
77
|
-
...config.rules,
|
|
78
|
-
/**
|
|
79
|
-
* Forbid `import {} from "module"`.
|
|
80
|
-
*/
|
|
81
|
-
"import/no-empty-named-blocks": "error",
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Wildcard imports can prevent tree shaking and cause name conflicts.
|
|
85
|
-
* Consider using named imports instead.
|
|
86
|
-
*/
|
|
87
|
-
"import/no-namespace": "error",
|
|
88
|
-
},
|
|
89
|
-
}))
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Allow default exports in certain files.
|
|
93
|
-
*/
|
|
94
|
-
.insertAfter("antfu/imports/rules", {
|
|
95
|
-
name: "vdustr/no-default-export",
|
|
96
|
-
rules: {
|
|
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",
|
|
103
|
-
},
|
|
104
|
-
files: [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
|
|
105
|
-
ignores: [
|
|
106
|
-
// Configuration files
|
|
107
|
-
"**/*.config.*",
|
|
108
|
-
GLOB_ASTRO_TS,
|
|
109
|
-
],
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
if (typescriptEnabled) {
|
|
113
|
-
config = config.override("antfu/typescript/rules", (config) => ({
|
|
114
|
-
...config,
|
|
115
|
-
rules: {
|
|
116
|
-
...config.rules,
|
|
117
|
-
"ts/array-type": ["error", { default: "generic" }],
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Namespaces are useful for centralizing the management of types. Just avoid
|
|
121
|
-
* overusing them with runtime code.
|
|
122
|
-
*
|
|
123
|
-
* - References:
|
|
124
|
-
* - <https://x.com/mattpocockuk/status/1805606072167940167>
|
|
125
|
-
*/
|
|
126
|
-
"ts/no-namespace": "off",
|
|
127
|
-
"ts/no-redeclare": "off",
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Check for unused variables in TypeScript.
|
|
131
|
-
*/
|
|
132
|
-
"ts/no-unused-vars": "off",
|
|
133
|
-
},
|
|
134
|
-
}));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (jsoncEnabled) {
|
|
138
|
-
config = config
|
|
139
|
-
.override("antfu/jsonc/rules", (config) => ({
|
|
140
|
-
...config,
|
|
141
|
-
rules: {
|
|
142
|
-
...config.rules,
|
|
143
|
-
"jsonc/sort-keys": "error",
|
|
144
|
-
},
|
|
145
|
-
files: [...(config.files ?? []), "**/*.code-workspace"],
|
|
146
|
-
ignores: [
|
|
147
|
-
...(config.ignores ?? []),
|
|
148
|
-
/**
|
|
149
|
-
* Lint `package.json` files with `eslint-plugin-package-json` instead.
|
|
150
|
-
*/
|
|
151
|
-
"**/package.json",
|
|
152
|
-
],
|
|
153
|
-
}))
|
|
154
|
-
.insertAfter("antfu/jsonc/rules", packageJson)
|
|
155
|
-
.remove("antfu/sort/package-json")
|
|
156
|
-
.remove("antfu/sort/tsconfig-json");
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (reactEnabled) {
|
|
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",
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Not all destructuring assignments are more readable than their alternatives.
|
|
173
|
-
*/
|
|
174
|
-
"react/prefer-destructuring-assignment": "off",
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (storybookEnabled) {
|
|
181
|
-
config = config
|
|
182
|
-
.append(storybook())
|
|
183
|
-
.override("storybook:csf:stories-rules", (config) => ({
|
|
184
|
-
...config,
|
|
185
|
-
rules: {
|
|
186
|
-
...config.rules,
|
|
187
|
-
"import/no-default-export": "off",
|
|
188
|
-
},
|
|
189
|
-
}));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (mdxEnabled) {
|
|
193
|
-
config = config.append(
|
|
194
|
-
mdx({
|
|
195
|
-
...mdxOptions,
|
|
196
|
-
flatCodeBlocks: !mdxFlatCodeBlocksEnabled
|
|
197
|
-
? false
|
|
198
|
-
: {
|
|
199
|
-
...mdxFlatCodeBlocksOptions,
|
|
200
|
-
rules: {
|
|
201
|
-
"import/no-default-export": "off",
|
|
202
|
-
...mdxFlatCodeBlocksOptions?.rules,
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
}),
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
config = config.append(prettier());
|
|
210
|
-
|
|
211
|
-
return config;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export { vdustr };
|
package/tsconfig.json
DELETED
|
File without changes
|