@vp-tw/eslint-config 0.0.1
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/LICENSE +21 -0
- package/README.md +12 -0
- package/build.config.ts +31 -0
- package/dist/configs/mdx.d.ts +236 -0
- package/dist/configs/mdx.js +30 -0
- package/dist/configs/prettier.d.ts +3 -0
- package/dist/configs/prettier.js +14 -0
- package/dist/eslint-typegen.d.ts +26 -0
- package/dist/esm/configs/mdx.d.ts +236 -0
- package/dist/esm/configs/mdx.mjs +27 -0
- package/dist/esm/configs/prettier.d.ts +3 -0
- package/dist/esm/configs/prettier.mjs +8 -0
- package/dist/esm/eslint-typegen.d.ts +26 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/lib/eslint-plugin-react-compiler.d.ts +13 -0
- package/dist/esm/lib/eslint-plugin-react-compiler.mjs +0 -0
- package/dist/esm/types.d.ts +3 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/vdustr.d.ts +9 -0
- package/dist/esm/vdustr.mjs +101 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -0
- package/dist/lib/eslint-plugin-react-compiler.d.ts +13 -0
- package/dist/lib/eslint-plugin-react-compiler.js +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +1 -0
- package/dist/vdustr.d.ts +9 -0
- package/dist/vdustr.js +102 -0
- package/global.d.ts +1 -0
- package/lib/eslint-plugin-react-compiler.ts +13 -0
- package/package.json +61 -0
- package/scripts/typegen.ts +34 -0
- package/src/configs/mdx.ts +44 -0
- package/src/configs/prettier.ts +12 -0
- package/src/eslint-typegen.d.ts +26 -0
- package/src/index.ts +1 -0
- package/src/tsconfig.json +4 -0
- package/src/types.ts +5 -0
- package/src/vdustr.ts +123 -0
- package/tsconfig.json +4 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as mdxPlugin from "eslint-plugin-mdx";
|
|
2
|
+
const mdx = ({
|
|
3
|
+
flatCodeBlocks = true,
|
|
4
|
+
processorOptions,
|
|
5
|
+
...options
|
|
6
|
+
} = {}) => [
|
|
7
|
+
{
|
|
8
|
+
name: "vdustr/mdx",
|
|
9
|
+
...mdxPlugin.flat,
|
|
10
|
+
...options,
|
|
11
|
+
processor: mdxPlugin.createRemarkProcessor({
|
|
12
|
+
lintCodeBlocks: Boolean(flatCodeBlocks),
|
|
13
|
+
...processorOptions,
|
|
14
|
+
languageMapper: {
|
|
15
|
+
...processorOptions?.languageMapper
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
},
|
|
19
|
+
...!flatCodeBlocks ? [] : [
|
|
20
|
+
{
|
|
21
|
+
name: "vdustr/mdx/flat-code-blocks",
|
|
22
|
+
...mdxPlugin.flatCodeBlocks,
|
|
23
|
+
...typeof flatCodeBlocks !== "object" ? null : flatCodeBlocks
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
];
|
|
27
|
+
export { mdx };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defaultPluginRenaming, renameRules } from "@antfu/eslint-config";
|
|
2
|
+
import eslintConfigPrettier from "eslint-config-prettier";
|
|
3
|
+
const prettier = {
|
|
4
|
+
name: "vdustr/prettier",
|
|
5
|
+
...eslintConfigPrettier,
|
|
6
|
+
rules: renameRules(eslintConfigPrettier.rules, defaultPluginRenaming)
|
|
7
|
+
};
|
|
8
|
+
export { prettier };
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
|
|
22
|
+
/* ======= Declarations ======= */
|
|
23
|
+
// ----- react-compiler/react-compiler -----
|
|
24
|
+
type ReactCompilerReactCompiler = []|[{
|
|
25
|
+
[k: string]: unknown | undefined
|
|
26
|
+
}]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./vdustr";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./vdustr.mjs";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare module "eslint-plugin-react-compiler" {
|
|
2
|
+
type Plugin = import("eslint").ESLint.Plugin;
|
|
3
|
+
type LegacyConfig = import("eslint").Linter.LegacyConfig;
|
|
4
|
+
interface ReactCompiler extends Plugin {
|
|
5
|
+
rules: NonNullable<Plugin["rules"]>;
|
|
6
|
+
configs: {
|
|
7
|
+
recommended: LegacyConfig;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
const rules: ReactCompiler["rules"];
|
|
11
|
+
const configs: ReactCompiler["configs"];
|
|
12
|
+
export { configs, rules };
|
|
13
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Config } from "./types";
|
|
2
|
+
import antfu from "@antfu/eslint-config";
|
|
3
|
+
import { mdx } from "./configs/mdx";
|
|
4
|
+
import "./eslint-typegen.d";
|
|
5
|
+
type Options = NonNullable<Parameters<typeof antfu>[0]> & {
|
|
6
|
+
mdx?: boolean | mdx.Options;
|
|
7
|
+
};
|
|
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
|
+
export { vdustr };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import antfu from "@antfu/eslint-config";
|
|
2
|
+
import packageJson from "eslint-plugin-package-json/configs/recommended";
|
|
3
|
+
import * as reactCompilerPlugin from "eslint-plugin-react-compiler";
|
|
4
|
+
import { mdx } from "./configs/mdx.mjs";
|
|
5
|
+
import { prettier } from "./configs/prettier.mjs";
|
|
6
|
+
import "./eslint-typegen.d";
|
|
7
|
+
const vdustr = (options, ...userConfigs) => {
|
|
8
|
+
const mdxOptions = options?.mdx ?? true;
|
|
9
|
+
const jsoncEnabled = Boolean(options?.jsonc ?? true);
|
|
10
|
+
const defaultConfigs = [
|
|
11
|
+
...!jsoncEnabled ? [] : [packageJson],
|
|
12
|
+
...!mdxOptions ? [] : mdx({
|
|
13
|
+
...typeof mdxOptions !== "object" ? null : mdxOptions
|
|
14
|
+
}),
|
|
15
|
+
prettier
|
|
16
|
+
];
|
|
17
|
+
return antfu(
|
|
18
|
+
{
|
|
19
|
+
// We use `prettier`.
|
|
20
|
+
stylistic: false,
|
|
21
|
+
...options
|
|
22
|
+
},
|
|
23
|
+
...defaultConfigs,
|
|
24
|
+
...userConfigs
|
|
25
|
+
).override("antfu/javascript/rules", (config) => ({
|
|
26
|
+
...config,
|
|
27
|
+
rules: {
|
|
28
|
+
...config.rules,
|
|
29
|
+
/**
|
|
30
|
+
* Some callbacks are purposefully named to make the code self-documenting.
|
|
31
|
+
*/
|
|
32
|
+
"prefer-arrow-callback": "off",
|
|
33
|
+
/**
|
|
34
|
+
* This rule does not integrate well with JSDoc `@link` tags. It's advised
|
|
35
|
+
* to verify its behavior with TypeScript instead.
|
|
36
|
+
*/
|
|
37
|
+
"no-unused-vars": "off",
|
|
38
|
+
"unused-imports/no-unused-vars": "off",
|
|
39
|
+
"unused-imports/no-unused-imports-ts": "off",
|
|
40
|
+
"unused-imports/no-unused-vars-ts": "off",
|
|
41
|
+
"unused-imports/no-unused-imports": "off"
|
|
42
|
+
}
|
|
43
|
+
})).override("antfu/imports/rules", (config) => ({
|
|
44
|
+
...config,
|
|
45
|
+
rules: {
|
|
46
|
+
...config.rules,
|
|
47
|
+
/**
|
|
48
|
+
* Forbid `import {} from "module"`.
|
|
49
|
+
*/
|
|
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" }],
|
|
57
|
+
/**
|
|
58
|
+
* Namespaces are useful for centralizing the management of types. Just avoid
|
|
59
|
+
* overusing them with runtime code.
|
|
60
|
+
*
|
|
61
|
+
* - References:
|
|
62
|
+
* - <https://x.com/mattpocockuk/status/1805606072167940167>
|
|
63
|
+
*/
|
|
64
|
+
"ts/no-namespace": "off",
|
|
65
|
+
"ts/no-redeclare": "off",
|
|
66
|
+
/**
|
|
67
|
+
* Check for unused variables in TypeScript.
|
|
68
|
+
*/
|
|
69
|
+
"ts/no-unused-vars": "off"
|
|
70
|
+
}
|
|
71
|
+
})).override("antfu/jsonc/rules", (config) => ({
|
|
72
|
+
...config,
|
|
73
|
+
rules: {
|
|
74
|
+
...config.rules,
|
|
75
|
+
"jsonc/sort-keys": "error"
|
|
76
|
+
},
|
|
77
|
+
files: [...config.files ?? [], "**/*.code-workspace"],
|
|
78
|
+
ignores: [
|
|
79
|
+
...config.ignores ?? [],
|
|
80
|
+
/**
|
|
81
|
+
* Lint `package.json` files with `eslint-plugin-package-json` instead.
|
|
82
|
+
*/
|
|
83
|
+
"**/package.json"
|
|
84
|
+
]
|
|
85
|
+
})).remove("antfu/sort/package-json").remove("antfu/sort/tsconfig-json").override("antfu/react/rules", (config) => ({
|
|
86
|
+
...config,
|
|
87
|
+
plugins: {
|
|
88
|
+
...config.plugins,
|
|
89
|
+
"react-compiler": reactCompilerPlugin
|
|
90
|
+
},
|
|
91
|
+
rules: {
|
|
92
|
+
...config.rules,
|
|
93
|
+
"react-compiler/react-compiler": "error",
|
|
94
|
+
/**
|
|
95
|
+
* Not all destructuring assignments are more readable than their alternatives.
|
|
96
|
+
*/
|
|
97
|
+
"react/prefer-destructuring-assignment": "off"
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
};
|
|
101
|
+
export { vdustr };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./vdustr";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _vdustr = require("./vdustr");
|
|
7
|
+
Object.keys(_vdustr).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _vdustr[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _vdustr[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare module "eslint-plugin-react-compiler" {
|
|
2
|
+
type Plugin = import("eslint").ESLint.Plugin;
|
|
3
|
+
type LegacyConfig = import("eslint").Linter.LegacyConfig;
|
|
4
|
+
interface ReactCompiler extends Plugin {
|
|
5
|
+
rules: NonNullable<Plugin["rules"]>;
|
|
6
|
+
configs: {
|
|
7
|
+
recommended: LegacyConfig;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
const rules: ReactCompiler["rules"];
|
|
11
|
+
const configs: ReactCompiler["configs"];
|
|
12
|
+
export { configs, rules };
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/vdustr.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Config } from "./types";
|
|
2
|
+
import antfu from "@antfu/eslint-config";
|
|
3
|
+
import { mdx } from "./configs/mdx";
|
|
4
|
+
import "./eslint-typegen.d";
|
|
5
|
+
type Options = NonNullable<Parameters<typeof antfu>[0]> & {
|
|
6
|
+
mdx?: boolean | mdx.Options;
|
|
7
|
+
};
|
|
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
|
+
export { vdustr };
|
package/dist/vdustr.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.vdustr = void 0;
|
|
7
|
+
var _eslintConfig = _interopRequireDefault(require("@antfu/eslint-config"));
|
|
8
|
+
var _recommended = _interopRequireDefault(require("eslint-plugin-package-json/configs/recommended"));
|
|
9
|
+
var reactCompilerPlugin = _interopRequireWildcard(require("eslint-plugin-react-compiler"));
|
|
10
|
+
var _mdx = require("./configs/mdx");
|
|
11
|
+
var _prettier = require("./configs/prettier");
|
|
12
|
+
require("./eslint-typegen.d");
|
|
13
|
+
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); }
|
|
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; }
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
const vdustr = (options, ...userConfigs) => {
|
|
17
|
+
const mdxOptions = options?.mdx ?? true;
|
|
18
|
+
const jsoncEnabled = Boolean(options?.jsonc ?? true);
|
|
19
|
+
const defaultConfigs = [...(!jsoncEnabled ? [] : [_recommended.default]), ...(!mdxOptions ? [] : (0, _mdx.mdx)({
|
|
20
|
+
...(typeof mdxOptions !== "object" ? null : mdxOptions)
|
|
21
|
+
})), _prettier.prettier];
|
|
22
|
+
return (0, _eslintConfig.default)({
|
|
23
|
+
// We use `prettier`.
|
|
24
|
+
stylistic: false,
|
|
25
|
+
...options
|
|
26
|
+
}, ...defaultConfigs, ...userConfigs).override("antfu/javascript/rules", config => ({
|
|
27
|
+
...config,
|
|
28
|
+
rules: {
|
|
29
|
+
...config.rules,
|
|
30
|
+
/**
|
|
31
|
+
* Some callbacks are purposefully named to make the code self-documenting.
|
|
32
|
+
*/
|
|
33
|
+
"prefer-arrow-callback": "off",
|
|
34
|
+
/**
|
|
35
|
+
* This rule does not integrate well with JSDoc `@link` tags. It's advised
|
|
36
|
+
* to verify its behavior with TypeScript instead.
|
|
37
|
+
*/
|
|
38
|
+
"no-unused-vars": "off",
|
|
39
|
+
"unused-imports/no-unused-vars": "off",
|
|
40
|
+
"unused-imports/no-unused-imports-ts": "off",
|
|
41
|
+
"unused-imports/no-unused-vars-ts": "off",
|
|
42
|
+
"unused-imports/no-unused-imports": "off"
|
|
43
|
+
}
|
|
44
|
+
})).override("antfu/imports/rules", config => ({
|
|
45
|
+
...config,
|
|
46
|
+
rules: {
|
|
47
|
+
...config.rules,
|
|
48
|
+
/**
|
|
49
|
+
* Forbid `import {} from "module"`.
|
|
50
|
+
*/
|
|
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
|
+
}],
|
|
60
|
+
/**
|
|
61
|
+
* Namespaces are useful for centralizing the management of types. Just avoid
|
|
62
|
+
* overusing them with runtime code.
|
|
63
|
+
*
|
|
64
|
+
* - References:
|
|
65
|
+
* - <https://x.com/mattpocockuk/status/1805606072167940167>
|
|
66
|
+
*/
|
|
67
|
+
"ts/no-namespace": "off",
|
|
68
|
+
"ts/no-redeclare": "off",
|
|
69
|
+
/**
|
|
70
|
+
* Check for unused variables in TypeScript.
|
|
71
|
+
*/
|
|
72
|
+
"ts/no-unused-vars": "off"
|
|
73
|
+
}
|
|
74
|
+
})).override("antfu/jsonc/rules", config => ({
|
|
75
|
+
...config,
|
|
76
|
+
rules: {
|
|
77
|
+
...config.rules,
|
|
78
|
+
"jsonc/sort-keys": "error"
|
|
79
|
+
},
|
|
80
|
+
files: [...(config.files ?? []), "**/*.code-workspace"],
|
|
81
|
+
ignores: [...(config.ignores ?? []),
|
|
82
|
+
/**
|
|
83
|
+
* Lint `package.json` files with `eslint-plugin-package-json` instead.
|
|
84
|
+
*/
|
|
85
|
+
"**/package.json"]
|
|
86
|
+
})).remove("antfu/sort/package-json").remove("antfu/sort/tsconfig-json").override("antfu/react/rules", config => ({
|
|
87
|
+
...config,
|
|
88
|
+
plugins: {
|
|
89
|
+
...config.plugins,
|
|
90
|
+
"react-compiler": reactCompilerPlugin
|
|
91
|
+
},
|
|
92
|
+
rules: {
|
|
93
|
+
...config.rules,
|
|
94
|
+
"react-compiler/react-compiler": "error",
|
|
95
|
+
/**
|
|
96
|
+
* Not all destructuring assignments are more readable than their alternatives.
|
|
97
|
+
*/
|
|
98
|
+
"react/prefer-destructuring-assignment": "off"
|
|
99
|
+
}
|
|
100
|
+
}));
|
|
101
|
+
};
|
|
102
|
+
exports.vdustr = vdustr;
|
package/global.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@total-typescript/ts-reset" />
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare module "eslint-plugin-react-compiler" {
|
|
2
|
+
type Plugin = import("eslint").ESLint.Plugin;
|
|
3
|
+
type LegacyConfig = import("eslint").Linter.LegacyConfig;
|
|
4
|
+
interface ReactCompiler extends Plugin {
|
|
5
|
+
rules: NonNullable<Plugin["rules"]>;
|
|
6
|
+
configs: {
|
|
7
|
+
recommended: LegacyConfig;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
const rules: ReactCompiler["rules"];
|
|
11
|
+
const configs: ReactCompiler["configs"];
|
|
12
|
+
export { configs, rules };
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vp-tw/eslint-config",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "ViPro's ESLint configuration",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"import": {
|
|
8
|
+
"types": "./dist/esm/index.d.ts",
|
|
9
|
+
"default": "./dist/esm/index.mjs"
|
|
10
|
+
},
|
|
11
|
+
"default": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"./*": {
|
|
17
|
+
"import": {
|
|
18
|
+
"types": "./dist/esm/*.d.ts",
|
|
19
|
+
"default": "./dist/esm/*.mjs"
|
|
20
|
+
},
|
|
21
|
+
"default": {
|
|
22
|
+
"types": "./dist/*.d.ts",
|
|
23
|
+
"default": "./dist/*.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"./README.md": "./README.md",
|
|
27
|
+
"./package": "./package.json",
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"main": "./dist/index.js",
|
|
31
|
+
"module": "./dist/esm/index.mjs",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@antfu/eslint-config": "^4.1.0",
|
|
35
|
+
"@eslint-react/eslint-plugin": "^1.25.0",
|
|
36
|
+
"@eslint/compat": "^1.2.5",
|
|
37
|
+
"@mui/types": "^7.2.21",
|
|
38
|
+
"@types/eslint-config-prettier": "^6.11.3",
|
|
39
|
+
"@types/eslint__eslintrc": "^2.1.2",
|
|
40
|
+
"eslint-config-prettier": "^10.0.1",
|
|
41
|
+
"eslint-flat-config-utils": "^2.0.0",
|
|
42
|
+
"eslint-plugin-mdx": "^3.1.5",
|
|
43
|
+
"eslint-plugin-package-json": "^0.21.1",
|
|
44
|
+
"eslint-plugin-react": "^7.37.4",
|
|
45
|
+
"eslint-plugin-react-compiler": "^19.0.0-beta-27714ef-20250124"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"eslint-typegen": "^1.0.0",
|
|
49
|
+
"unbuild": "^3.3.1"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "unbuild",
|
|
56
|
+
"copy": "run-p copy:*",
|
|
57
|
+
"copy:license": "fse copy ../../LICENSE LICENSE",
|
|
58
|
+
"copy:readme": "fse copy ../../README.md README.md",
|
|
59
|
+
"typegen": "tsx scripts/typegen.ts"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ESLint } from "eslint";
|
|
2
|
+
import { rules } from "eslint-plugin-mdx/lib/rules";
|
|
3
|
+
import reactCompiler from "eslint-plugin-react-compiler";
|
|
4
|
+
import { pluginsToRulesDTS } from "eslint-typegen/core";
|
|
5
|
+
import fs from "fs-extra";
|
|
6
|
+
import path from "pathe";
|
|
7
|
+
import { packageDirectory } from "pkg-dir";
|
|
8
|
+
|
|
9
|
+
(async () => {
|
|
10
|
+
const pkgDir = await packageDirectory();
|
|
11
|
+
if (!pkgDir) {
|
|
12
|
+
throw new Error("Could not find package directory");
|
|
13
|
+
}
|
|
14
|
+
const distDir = path.join(pkgDir, "src");
|
|
15
|
+
const targetPath = path.join(distDir, "eslint-typegen.d.ts");
|
|
16
|
+
await fs.ensureDir(path.dirname(targetPath));
|
|
17
|
+
|
|
18
|
+
type Plugins = Record<string, ESLint.Plugin>;
|
|
19
|
+
|
|
20
|
+
function definePlugins<T extends Plugins>(plugins: T): T {
|
|
21
|
+
return plugins;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const plugins: Plugins = {
|
|
25
|
+
...definePlugins({ "react-compiler": reactCompiler }),
|
|
26
|
+
...definePlugins({
|
|
27
|
+
mdx: {
|
|
28
|
+
rules,
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
await fs.writeFile(targetPath, await pluginsToRulesDTS(plugins));
|
|
34
|
+
})();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
2
|
+
import type { DistributiveOmit } from "@mui/types";
|
|
3
|
+
import type { Config } from "../types";
|
|
4
|
+
|
|
5
|
+
import * as mdxPlugin from "eslint-plugin-mdx";
|
|
6
|
+
|
|
7
|
+
namespace mdx {
|
|
8
|
+
export interface Options
|
|
9
|
+
extends DistributiveOmit<TypedFlatConfigItem, "processor"> {
|
|
10
|
+
processorOptions?: mdxPlugin.ProcessorOptions;
|
|
11
|
+
flatCodeBlocks?: boolean | Config;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const mdx = ({
|
|
16
|
+
flatCodeBlocks = true,
|
|
17
|
+
processorOptions,
|
|
18
|
+
...options
|
|
19
|
+
}: mdx.Options = {}) =>
|
|
20
|
+
[
|
|
21
|
+
{
|
|
22
|
+
name: "vdustr/mdx",
|
|
23
|
+
...mdxPlugin.flat,
|
|
24
|
+
...options,
|
|
25
|
+
processor: mdxPlugin.createRemarkProcessor({
|
|
26
|
+
lintCodeBlocks: Boolean(flatCodeBlocks),
|
|
27
|
+
...processorOptions,
|
|
28
|
+
languageMapper: {
|
|
29
|
+
...processorOptions?.languageMapper,
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
...(!flatCodeBlocks
|
|
34
|
+
? []
|
|
35
|
+
: [
|
|
36
|
+
{
|
|
37
|
+
name: "vdustr/mdx/flat-code-blocks",
|
|
38
|
+
...mdxPlugin.flatCodeBlocks,
|
|
39
|
+
...(typeof flatCodeBlocks !== "object" ? null : flatCodeBlocks),
|
|
40
|
+
} satisfies Config,
|
|
41
|
+
]),
|
|
42
|
+
] satisfies Array<Config>;
|
|
43
|
+
|
|
44
|
+
export { mdx };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Config } from "../types";
|
|
2
|
+
import { defaultPluginRenaming, renameRules } from "@antfu/eslint-config";
|
|
3
|
+
|
|
4
|
+
import eslintConfigPrettier from "eslint-config-prettier";
|
|
5
|
+
|
|
6
|
+
const prettier: Config = {
|
|
7
|
+
name: "vdustr/prettier",
|
|
8
|
+
...eslintConfigPrettier,
|
|
9
|
+
rules: renameRules(eslintConfigPrettier.rules, defaultPluginRenaming),
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { prettier };
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
|
|
22
|
+
/* ======= Declarations ======= */
|
|
23
|
+
// ----- react-compiler/react-compiler -----
|
|
24
|
+
type ReactCompilerReactCompiler = []|[{
|
|
25
|
+
[k: string]: unknown | undefined
|
|
26
|
+
}]
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./vdustr";
|