@vp-tw/eslint-config 0.0.9 → 0.0.11
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 -1
- package/dist/configs/mdx.d.ts +22 -4
- package/dist/configs/mdx.js +72 -18
- package/dist/configs/prettier.d.ts +18 -1
- package/dist/configs/prettier.js +27 -4
- package/dist/configs/storybook.d.ts +24 -1
- package/dist/configs/storybook.js +68 -24
- package/dist/eslint-typegen.js +1 -1
- package/dist/esm/configs/mdx.d.ts +22 -4
- package/dist/esm/configs/mdx.mjs +82 -18
- package/dist/esm/configs/prettier.d.ts +18 -1
- package/dist/esm/configs/prettier.mjs +27 -3
- package/dist/esm/configs/storybook.d.ts +24 -1
- package/dist/esm/configs/storybook.mjs +72 -14
- package/dist/esm/eslint-typegen.mjs +1 -1
- package/dist/esm/extends/_utils.d.ts +2 -0
- package/dist/esm/extends/_utils.mjs +2 -0
- package/dist/esm/extends/imports.d.ts +25 -0
- package/dist/esm/extends/imports.mjs +87 -0
- package/dist/esm/extends/javascript.d.ts +21 -0
- package/dist/esm/extends/javascript.mjs +51 -0
- package/dist/esm/extends/jsonc.d.ts +30 -0
- package/dist/esm/extends/jsonc.mjs +149 -0
- package/dist/esm/extends/react.d.ts +21 -0
- package/dist/esm/extends/react.mjs +58 -0
- package/dist/esm/extends/typescript.d.ts +21 -0
- package/dist/esm/extends/typescript.mjs +52 -0
- package/dist/esm/extends/yaml.d.ts +25 -0
- package/dist/esm/extends/yaml.mjs +71 -0
- package/dist/esm/globs.d.ts +6 -0
- package/dist/esm/globs.mjs +12 -0
- package/dist/esm/types.d.ts +35 -1
- package/dist/esm/utils/extendsConfig.d.ts +4 -0
- package/dist/esm/utils/extendsConfig.mjs +56 -0
- package/dist/esm/vdustr.d.ts +21 -4
- package/dist/esm/vdustr.mjs +37 -141
- package/dist/extends/_utils.d.ts +2 -0
- package/dist/extends/_utils.js +7 -0
- package/dist/extends/imports.d.ts +25 -0
- package/dist/extends/imports.js +71 -0
- package/dist/extends/javascript.d.ts +21 -0
- package/dist/extends/javascript.js +53 -0
- package/dist/extends/jsonc.d.ts +30 -0
- package/dist/extends/jsonc.js +135 -0
- package/dist/extends/react.d.ts +21 -0
- package/dist/extends/react.js +60 -0
- package/dist/extends/typescript.d.ts +21 -0
- package/dist/extends/typescript.js +56 -0
- package/dist/extends/yaml.d.ts +25 -0
- package/dist/extends/yaml.js +66 -0
- package/dist/globs.d.ts +6 -0
- package/dist/globs.js +11 -0
- package/dist/types.d.ts +35 -1
- package/dist/utils/extendsConfig.d.ts +4 -0
- package/dist/utils/extendsConfig.js +53 -0
- package/dist/vdustr.d.ts +21 -4
- package/dist/vdustr.js +30 -132
- package/package.json +6 -3
package/dist/vdustr.js
CHANGED
|
@@ -4,153 +4,47 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.vdustr = void 0;
|
|
7
|
-
var _eslintConfig =
|
|
8
|
-
var _recommended = _interopRequireDefault(require("eslint-plugin-package-json/configs/recommended"));
|
|
9
|
-
var _localPkg = require("local-pkg");
|
|
7
|
+
var _eslintConfig = _interopRequireDefault(require("@antfu/eslint-config"));
|
|
10
8
|
var _mdx = require("./configs/mdx");
|
|
11
9
|
var _prettier = require("./configs/prettier");
|
|
12
10
|
var _storybook = require("./configs/storybook");
|
|
13
|
-
var
|
|
11
|
+
var _imports = require("./extends/imports");
|
|
12
|
+
var _javascript = require("./extends/javascript");
|
|
13
|
+
var _jsonc = require("./extends/jsonc");
|
|
14
|
+
var _react = require("./extends/react");
|
|
15
|
+
var _typescript = require("./extends/typescript");
|
|
16
|
+
var _yaml = require("./extends/yaml");
|
|
14
17
|
require("./eslint-typegen");
|
|
15
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
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); }
|
|
17
|
-
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; }
|
|
18
19
|
const vdustr = (options, ...userConfigs) => {
|
|
19
|
-
const typescriptEnabled = (0, _localPkg.isPackageExists)("typescript");
|
|
20
|
-
const jsoncEnabled = Boolean(options?.jsonc ?? true);
|
|
21
|
-
const reactEnabled = Boolean(options?.react ?? false);
|
|
22
|
-
const storybookEnabled = Boolean(options?.storybook ?? false);
|
|
23
|
-
const mdxEnabled = Boolean(options?.mdx ?? false);
|
|
24
|
-
const mdxOptions = {
|
|
25
|
-
...(typeof options?.mdx !== "object" ? null : options.mdx)
|
|
26
|
-
};
|
|
27
|
-
const mdxFlatCodeBlocksEnabled = Boolean(mdxOptions?.flatCodeBlocks ?? true);
|
|
28
|
-
const mdxFlatCodeBlocksOptions = {
|
|
29
|
-
...(typeof mdxOptions?.flatCodeBlocks !== "object" ? null : mdxOptions.flatCodeBlocks)
|
|
30
|
-
};
|
|
31
20
|
let config = (0, _eslintConfig.default)({
|
|
32
21
|
// We use `prettier`.
|
|
33
22
|
stylistic: false,
|
|
34
23
|
...options
|
|
35
24
|
}, ...userConfigs);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"prefer-arrow-callback": "off",
|
|
44
|
-
/**
|
|
45
|
-
* This rule does not integrate well with JSDoc `@link` tags. It's advised
|
|
46
|
-
* to verify its behavior with TypeScript instead.
|
|
47
|
-
*/
|
|
48
|
-
"no-unused-vars": "off",
|
|
49
|
-
"unused-imports/no-unused-vars": "off",
|
|
50
|
-
"unused-imports/no-unused-imports-ts": "off",
|
|
51
|
-
"unused-imports/no-unused-vars-ts": "off",
|
|
52
|
-
"unused-imports/no-unused-imports": "off"
|
|
53
|
-
}
|
|
54
|
-
})).override("antfu/imports/rules", config2 => ({
|
|
55
|
-
...config2,
|
|
56
|
-
rules: {
|
|
57
|
-
...config2.rules,
|
|
58
|
-
/**
|
|
59
|
-
* Forbid `import {} from "module"`.
|
|
60
|
-
*/
|
|
61
|
-
"import/no-empty-named-blocks": "error",
|
|
62
|
-
/**
|
|
63
|
-
* Wildcard imports can prevent tree shaking and cause name conflicts.
|
|
64
|
-
* Consider using named imports instead.
|
|
65
|
-
*/
|
|
66
|
-
"import/no-namespace": "error"
|
|
67
|
-
}
|
|
68
|
-
})).insertAfter("antfu/imports/rules", {
|
|
69
|
-
name: "vdustr/no-default-export",
|
|
70
|
-
rules: {
|
|
71
|
-
/**
|
|
72
|
-
* Enforcing named exports improves consistency, enhances auto-completion and refactoring, and avoids issues
|
|
73
|
-
* with default export renaming. Additionally, default exports might lead to different behavior when transformed
|
|
74
|
-
* to CJS.
|
|
75
|
-
*/
|
|
76
|
-
"import/no-default-export": "error"
|
|
77
|
-
},
|
|
78
|
-
files: [_eslintConfig.GLOB_JS, _eslintConfig.GLOB_JSX, _eslintConfig.GLOB_TS, _eslintConfig.GLOB_TSX],
|
|
79
|
-
ignores: [
|
|
80
|
-
// Configuration files
|
|
81
|
-
"**/*.config.*", _eslintConfig.GLOB_ASTRO_TS]
|
|
82
|
-
});
|
|
83
|
-
if (typescriptEnabled) {
|
|
84
|
-
config = config.override("antfu/typescript/rules", config2 => ({
|
|
85
|
-
...config2,
|
|
86
|
-
rules: {
|
|
87
|
-
...config2.rules,
|
|
88
|
-
"ts/array-type": ["error", {
|
|
89
|
-
default: "generic"
|
|
90
|
-
}],
|
|
91
|
-
/**
|
|
92
|
-
* Namespaces are useful for centralizing the management of types. Just avoid
|
|
93
|
-
* overusing them with runtime code.
|
|
94
|
-
*
|
|
95
|
-
* - References:
|
|
96
|
-
* - <https://x.com/mattpocockuk/status/1805606072167940167>
|
|
97
|
-
*/
|
|
98
|
-
"ts/no-namespace": "off",
|
|
99
|
-
"ts/no-redeclare": "off",
|
|
100
|
-
/**
|
|
101
|
-
* Check for unused variables in TypeScript.
|
|
102
|
-
*/
|
|
103
|
-
"ts/no-unused-vars": "off"
|
|
104
|
-
}
|
|
105
|
-
}));
|
|
106
|
-
}
|
|
107
|
-
if (jsoncEnabled) {
|
|
108
|
-
config = config.override("antfu/jsonc/rules", config2 => ({
|
|
109
|
-
...config2,
|
|
110
|
-
rules: {
|
|
111
|
-
...config2.rules,
|
|
112
|
-
"jsonc/sort-keys": "error"
|
|
113
|
-
},
|
|
114
|
-
files: [...(config2.files ?? []), "**/*.code-workspace"],
|
|
115
|
-
ignores: [...(config2.ignores ?? []),
|
|
116
|
-
/**
|
|
117
|
-
* Lint `package.json` files with `eslint-plugin-package-json` instead.
|
|
118
|
-
*/
|
|
119
|
-
"**/package.json"]
|
|
120
|
-
})).insertAfter("antfu/jsonc/rules", _recommended.default).remove("antfu/sort/package-json").remove("antfu/sort/tsconfig-json");
|
|
121
|
-
}
|
|
122
|
-
if (reactEnabled) {
|
|
123
|
-
config = config.override("antfu/react/rules", async config2 => {
|
|
124
|
-
return {
|
|
125
|
-
...config2,
|
|
126
|
-
plugins: {
|
|
127
|
-
...config2.plugins,
|
|
128
|
-
"react-compiler": await (0, _eslintPluginReactCompiler.reactCompiler)()
|
|
129
|
-
},
|
|
130
|
-
rules: {
|
|
131
|
-
...config2.rules,
|
|
132
|
-
"react-compiler/react-compiler": "error",
|
|
133
|
-
/**
|
|
134
|
-
* Not all destructuring assignments are more readable than their alternatives.
|
|
135
|
-
*/
|
|
136
|
-
"react/prefer-destructuring-assignment": "off"
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
});
|
|
140
|
-
}
|
|
25
|
+
(0, _javascript.javascript)(config, options?.javascriptExtends);
|
|
26
|
+
(0, _imports.imports)(config, options?.importsExtends);
|
|
27
|
+
(0, _typescript.typescript)(config, options?.typescriptExtends);
|
|
28
|
+
(0, _jsonc.jsonc)(config, options?.jsoncExtends);
|
|
29
|
+
(0, _yaml.yaml)(config, options?.yamlExtends);
|
|
30
|
+
(0, _react.react)(config, options?.reactExtends);
|
|
31
|
+
const storybookEnabled = Boolean(options?.storybook ?? false);
|
|
141
32
|
if (storybookEnabled) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
rules: {
|
|
145
|
-
...config2.rules,
|
|
146
|
-
"import/no-default-export": "off"
|
|
147
|
-
}
|
|
148
|
-
}));
|
|
33
|
+
const storybookOptions = typeof options?.storybook !== "object" ? void 0 : options.storybook;
|
|
34
|
+
config = config.append((0, _storybook.storybook)(...(!storybookOptions ? [] : [storybookOptions])));
|
|
149
35
|
}
|
|
36
|
+
const mdxEnabled = Boolean(options?.mdx ?? false);
|
|
150
37
|
if (mdxEnabled) {
|
|
38
|
+
const mdxOptions = {
|
|
39
|
+
...(typeof options?.mdx !== "object" ? null : options.mdx)
|
|
40
|
+
};
|
|
41
|
+
const mdxFlatCodeBlocksEnabled = Boolean(mdxOptions?.codeBlocks ?? true);
|
|
42
|
+
const mdxFlatCodeBlocksOptions = {
|
|
43
|
+
...(typeof mdxOptions?.codeBlocks !== "object" ? null : mdxOptions.codeBlocks)
|
|
44
|
+
};
|
|
151
45
|
config = config.append((0, _mdx.mdx)({
|
|
152
46
|
...mdxOptions,
|
|
153
|
-
|
|
47
|
+
codeBlocks: !mdxFlatCodeBlocksEnabled ? false : {
|
|
154
48
|
...mdxFlatCodeBlocksOptions,
|
|
155
49
|
rules: {
|
|
156
50
|
"import/no-default-export": "off",
|
|
@@ -159,7 +53,11 @@ const vdustr = (options, ...userConfigs) => {
|
|
|
159
53
|
}
|
|
160
54
|
}));
|
|
161
55
|
}
|
|
162
|
-
|
|
56
|
+
const prettierEnabled = Boolean(options?.prettier ?? true);
|
|
57
|
+
if (prettierEnabled) {
|
|
58
|
+
const prettierOptions = typeof options?.prettier !== "object" ? void 0 : options.prettier;
|
|
59
|
+
config = config.append((0, _prettier.prettier)(...(!prettierOptions ? [] : [prettierOptions])));
|
|
60
|
+
}
|
|
163
61
|
return config;
|
|
164
62
|
};
|
|
165
63
|
exports.vdustr = vdustr;
|
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.11",
|
|
4
4
|
"description": "ViPro's ESLint configuration",
|
|
5
5
|
"homepage": "https://github.com/vdustr/eslint-config",
|
|
6
6
|
"author": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@mui/types": "^7.2.21",
|
|
43
43
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
44
|
+
"es-toolkit": "^1.31.0",
|
|
44
45
|
"eslint-config-prettier": "^10.0.1",
|
|
45
46
|
"eslint-flat-config-utils": "^2.0.0",
|
|
46
47
|
"eslint-plugin-package-json": "^0.21.1",
|
|
@@ -58,8 +59,10 @@
|
|
|
58
59
|
"access": "public"
|
|
59
60
|
},
|
|
60
61
|
"scripts": {
|
|
61
|
-
"build": "unbuild",
|
|
62
|
+
"build": "run-s build:unbuild fixEslintTypegenDts",
|
|
63
|
+
"build:unbuild": "unbuild",
|
|
62
64
|
"copy": "tsx scripts/copy",
|
|
63
|
-
"
|
|
65
|
+
"fixEslintTypegenDts": "tsx scripts/fixEslintTypegenDts",
|
|
66
|
+
"typegen": "tsx scripts/typegen"
|
|
64
67
|
}
|
|
65
68
|
}
|