@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
package/src/vdustr.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Config } from "./types";
|
|
2
|
+
import antfu from "@antfu/eslint-config";
|
|
3
|
+
import packageJson from "eslint-plugin-package-json/configs/recommended";
|
|
4
|
+
|
|
5
|
+
import * as reactCompilerPlugin from "eslint-plugin-react-compiler";
|
|
6
|
+
import { mdx } from "./configs/mdx";
|
|
7
|
+
import { prettier } from "./configs/prettier";
|
|
8
|
+
import "./eslint-typegen.d";
|
|
9
|
+
|
|
10
|
+
type Options = NonNullable<Parameters<typeof antfu>[0]> & {
|
|
11
|
+
mdx?: boolean | mdx.Options;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const vdustr = (options?: Options, ...userConfigs: Array<Config>) => {
|
|
15
|
+
const mdxOptions = options?.mdx ?? true;
|
|
16
|
+
const jsoncEnabled: boolean = Boolean(options?.jsonc ?? true);
|
|
17
|
+
type Config = NonNullable<Parameters<typeof antfu>[1]>;
|
|
18
|
+
const defaultConfigs: Array<Config> = [
|
|
19
|
+
...(!jsoncEnabled ? [] : [packageJson]),
|
|
20
|
+
...(!mdxOptions
|
|
21
|
+
? []
|
|
22
|
+
: mdx({
|
|
23
|
+
...(typeof mdxOptions !== "object" ? null : mdxOptions),
|
|
24
|
+
})),
|
|
25
|
+
prettier,
|
|
26
|
+
];
|
|
27
|
+
return antfu(
|
|
28
|
+
{
|
|
29
|
+
// We use `prettier`.
|
|
30
|
+
stylistic: false,
|
|
31
|
+
...options,
|
|
32
|
+
},
|
|
33
|
+
...defaultConfigs,
|
|
34
|
+
...userConfigs,
|
|
35
|
+
)
|
|
36
|
+
.override("antfu/javascript/rules", (config) => ({
|
|
37
|
+
...config,
|
|
38
|
+
rules: {
|
|
39
|
+
...config.rules,
|
|
40
|
+
/**
|
|
41
|
+
* Some callbacks are purposefully named to make the code self-documenting.
|
|
42
|
+
*/
|
|
43
|
+
"prefer-arrow-callback": "off",
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* This rule does not integrate well with JSDoc `@link` tags. It's advised
|
|
47
|
+
* to verify its behavior with TypeScript instead.
|
|
48
|
+
*/
|
|
49
|
+
"no-unused-vars": "off",
|
|
50
|
+
"unused-imports/no-unused-vars": "off",
|
|
51
|
+
"unused-imports/no-unused-imports-ts": "off",
|
|
52
|
+
"unused-imports/no-unused-vars-ts": "off",
|
|
53
|
+
"unused-imports/no-unused-imports": "off",
|
|
54
|
+
},
|
|
55
|
+
}))
|
|
56
|
+
.override("antfu/imports/rules", (config) => ({
|
|
57
|
+
...config,
|
|
58
|
+
rules: {
|
|
59
|
+
...config.rules,
|
|
60
|
+
/**
|
|
61
|
+
* Forbid `import {} from "module"`.
|
|
62
|
+
*/
|
|
63
|
+
"import/no-empty-named-blocks": "error",
|
|
64
|
+
},
|
|
65
|
+
}))
|
|
66
|
+
.override("antfu/typescript/rules", (config) => ({
|
|
67
|
+
...config,
|
|
68
|
+
rules: {
|
|
69
|
+
...config.rules,
|
|
70
|
+
"ts/array-type": ["error", { default: "generic" }],
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Namespaces are useful for centralizing the management of types. Just avoid
|
|
74
|
+
* overusing them with runtime code.
|
|
75
|
+
*
|
|
76
|
+
* - References:
|
|
77
|
+
* - <https://x.com/mattpocockuk/status/1805606072167940167>
|
|
78
|
+
*/
|
|
79
|
+
"ts/no-namespace": "off",
|
|
80
|
+
"ts/no-redeclare": "off",
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Check for unused variables in TypeScript.
|
|
84
|
+
*/
|
|
85
|
+
"ts/no-unused-vars": "off",
|
|
86
|
+
},
|
|
87
|
+
}))
|
|
88
|
+
.override("antfu/jsonc/rules", (config) => ({
|
|
89
|
+
...config,
|
|
90
|
+
rules: {
|
|
91
|
+
...config.rules,
|
|
92
|
+
"jsonc/sort-keys": "error",
|
|
93
|
+
},
|
|
94
|
+
files: [...(config.files ?? []), "**/*.code-workspace"],
|
|
95
|
+
ignores: [
|
|
96
|
+
...(config.ignores ?? []),
|
|
97
|
+
/**
|
|
98
|
+
* Lint `package.json` files with `eslint-plugin-package-json` instead.
|
|
99
|
+
*/
|
|
100
|
+
"**/package.json",
|
|
101
|
+
],
|
|
102
|
+
}))
|
|
103
|
+
.remove("antfu/sort/package-json")
|
|
104
|
+
.remove("antfu/sort/tsconfig-json")
|
|
105
|
+
.override("antfu/react/rules", (config) => ({
|
|
106
|
+
...config,
|
|
107
|
+
plugins: {
|
|
108
|
+
...config.plugins,
|
|
109
|
+
"react-compiler": reactCompilerPlugin,
|
|
110
|
+
},
|
|
111
|
+
rules: {
|
|
112
|
+
...config.rules,
|
|
113
|
+
"react-compiler/react-compiler": "error",
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Not all destructuring assignments are more readable than their alternatives.
|
|
117
|
+
*/
|
|
118
|
+
"react/prefer-destructuring-assignment": "off",
|
|
119
|
+
},
|
|
120
|
+
}));
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export { vdustr };
|
package/tsconfig.json
ADDED