@moluoxixi/eslint-config 0.0.10-beta.2

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 ADDED
@@ -0,0 +1,24 @@
1
+ # EslintConfig
2
+
3
+ 一行集成 ESLint 规则的工具包。导出 `createEslintConfig(config, ...userConfigs)`,便捷生成可复用的 ESLint 配置。
4
+
5
+ ## 使用示例
6
+
7
+ ```ts
8
+ import createEslintConfig from '@moluoxixi/eslintconfig'
9
+
10
+ export default createEslintConfig({
11
+ ignores: [
12
+ '.husky/**',
13
+ '**/*.md',
14
+ ],
15
+ })
16
+ ```
17
+
18
+ ## API
19
+
20
+ ### createEslintConfig(config, ...userConfigs)
21
+
22
+ - `config`: 基础配置对象
23
+ - `...userConfigs`: 额外用户配置,按序合并覆盖
24
+
package/es/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { default as createEslintConfig } from './src/index.ts';
2
+ export default createEslintConfig;
package/es/index.mjs ADDED
@@ -0,0 +1,59 @@
1
+ import "vue";
2
+ import antfu from "@antfu/eslint-config";
3
+ function isObject(value) {
4
+ return Object.prototype.toString.call(value) === "[object Object]";
5
+ }
6
+ function deepMerge(target, source) {
7
+ if (!isObject(source)) {
8
+ return target;
9
+ }
10
+ return Object.keys(source).reduce((acc, key) => {
11
+ const sourceValue = source[key];
12
+ const targetValue = acc[key];
13
+ if (isObject(sourceValue) && isObject(targetValue)) {
14
+ acc[key] = deepMerge(targetValue, sourceValue);
15
+ } else if (isObject(sourceValue)) {
16
+ acc[key] = deepMerge({}, sourceValue);
17
+ } else {
18
+ acc[key] = sourceValue;
19
+ }
20
+ return acc;
21
+ }, { ...target });
22
+ }
23
+ function createEslintConfig(config, ...userConfigs) {
24
+ const { ignores = [], ...otherOptions } = config;
25
+ return antfu(
26
+ deepMerge({
27
+ typescript: true,
28
+ vue: true,
29
+ yaml: true,
30
+ formatters: true,
31
+ ignores: [
32
+ ".husky/**",
33
+ "**/*.md",
34
+ ...ignores
35
+ ],
36
+ rules: {
37
+ "style/spaced-comment": ["error", "always", {
38
+ line: {
39
+ markers: [
40
+ "#region",
41
+ "#endregion"
42
+ ]
43
+ }
44
+ }],
45
+ "vue/block-order": ["error", {
46
+ order: ["template", "script", "style"]
47
+ }],
48
+ "no-use-before-define": "off",
49
+ "ts/no-use-before-define": "off",
50
+ "jsonc/sort-keys": "off",
51
+ "no-console": "off"
52
+ }
53
+ }, otherOptions),
54
+ ...userConfigs
55
+ );
56
+ }
57
+ export {
58
+ createEslintConfig as default
59
+ };
@@ -0,0 +1,6 @@
1
+ import { Awaitable, OptionsConfig, TypedFlatConfigItem } from '@antfu/eslint-config';
2
+ export type optionsType = OptionsConfig & Omit<TypedFlatConfigItem, 'files'> & {
3
+ ignores?: string[];
4
+ };
5
+ export type userConfigType = Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>;
6
+ export type createEslintConfigReturnType = Awaitable<TypedFlatConfigItem[]>;
@@ -0,0 +1,2 @@
1
+ import { createEslintConfigReturnType, optionsType, userConfigType } from './_types/index.ts';
2
+ export default function createEslintConfig(config: optionsType, ...userConfigs: userConfigType[]): createEslintConfigReturnType;
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@moluoxixi/eslint-config",
3
+ "version": "0.0.10-beta.2",
4
+ "description": "EslintConfig 组件",
5
+ "sideEffects": [
6
+ "*.css",
7
+ "*.scss"
8
+ ],
9
+ "peerDependencies": {
10
+ "vue": "3.5.19"
11
+ },
12
+ "dependencies": {
13
+ "@antfu/eslint-config": "4.19.0"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "license": "MIT",
19
+ "module": "es/index.mjs",
20
+ "types": "es/index.d.ts",
21
+ "exports": {
22
+ "./es": {
23
+ "import": {
24
+ "types": "./es/index.d.ts",
25
+ "default": "./es/index.mjs"
26
+ }
27
+ },
28
+ ".": {
29
+ "import": {
30
+ "types": "./es/index.d.ts",
31
+ "default": "./es/index.mjs"
32
+ }
33
+ }
34
+ }
35
+ }