@vida0905/eslint-config 0.4.0 → 0.4.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/dist/index.cjs +155 -0
- package/dist/index.d.cts +77 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +45 -19
- package/package.json +2 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var src_exports = {};
|
|
33
|
+
__export(src_exports, {
|
|
34
|
+
deepMerge: () => deepMerge,
|
|
35
|
+
default: () => src_default,
|
|
36
|
+
defineConfig: () => defineConfig
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(src_exports);
|
|
39
|
+
var import_eslint_config2 = __toESM(require("@antfu/eslint-config"), 1);
|
|
40
|
+
var import_local_pkg = require("local-pkg");
|
|
41
|
+
|
|
42
|
+
// src/configs/pinia.ts
|
|
43
|
+
var import_eslint_config = require("@antfu/eslint-config");
|
|
44
|
+
var GLOB_PINIA_JS = `**/stores/${import_eslint_config.GLOB_JS}`;
|
|
45
|
+
var GLOB_PINIA_TS = `**/stores/${import_eslint_config.GLOB_TS}`;
|
|
46
|
+
async function pinia(options = {}) {
|
|
47
|
+
const {
|
|
48
|
+
files = [GLOB_PINIA_JS, GLOB_PINIA_TS],
|
|
49
|
+
overrides: overrides2 = {}
|
|
50
|
+
} = options;
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
name: "vida/pinia/rules",
|
|
54
|
+
files,
|
|
55
|
+
plugins: {
|
|
56
|
+
pinia: await (0, import_eslint_config.interopDefault)(import("eslint-plugin-pinia"))
|
|
57
|
+
},
|
|
58
|
+
rules: {
|
|
59
|
+
"pinia/never-export-initialized-store": "error",
|
|
60
|
+
"pinia/prefer-single-store-per-file": "warn",
|
|
61
|
+
"pinia/prefer-use-store-naming-convention": ["error", {
|
|
62
|
+
checkStoreNameMismatch: true,
|
|
63
|
+
storeSuffix: "Store"
|
|
64
|
+
}],
|
|
65
|
+
"pinia/require-setup-store-properties-export": "warn",
|
|
66
|
+
"pinia/no-duplicate-store-ids": "error",
|
|
67
|
+
...overrides2
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/overrides/javascript.ts
|
|
74
|
+
var javascript = {
|
|
75
|
+
"arrow-body-style": ["error", "as-needed"],
|
|
76
|
+
"no-unused-private-class-members": "error",
|
|
77
|
+
"require-atomic-updates": ["error", { allowProperties: true }]
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/overrides/stylistic.ts
|
|
81
|
+
var stylistic = {
|
|
82
|
+
"style/arrow-parens": ["error", "always"],
|
|
83
|
+
"style/brace-style": ["error", "1tbs", { allowSingleLine: true }]
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/overrides/vue.ts
|
|
87
|
+
var vue = {
|
|
88
|
+
"vue/max-attributes-per-line": ["error", {
|
|
89
|
+
singleline: 5,
|
|
90
|
+
multiline: 1
|
|
91
|
+
}]
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/overrides/index.ts
|
|
95
|
+
var overrides = {
|
|
96
|
+
javascript,
|
|
97
|
+
stylistic,
|
|
98
|
+
vue
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/utils.ts
|
|
102
|
+
function deepMerge(target, source) {
|
|
103
|
+
for (const key in source) {
|
|
104
|
+
if (Object.hasOwnProperty.call(source, key)) {
|
|
105
|
+
if (source[key] instanceof Object && target[key] instanceof Object) {
|
|
106
|
+
target[key] = deepMerge(target[key], source[key]);
|
|
107
|
+
} else {
|
|
108
|
+
target[key] = source[key];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return target;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/index.ts
|
|
116
|
+
__reExport(src_exports, require("@antfu/eslint-config"), module.exports);
|
|
117
|
+
function defineConfig(options = {}, ...userConfigs) {
|
|
118
|
+
const {
|
|
119
|
+
pinia: enablePinia = (0, import_local_pkg.isPackageExists)("pinia")
|
|
120
|
+
} = options;
|
|
121
|
+
const configs = [];
|
|
122
|
+
if (enablePinia)
|
|
123
|
+
configs.push(pinia((0, import_eslint_config2.resolveSubOptions)(options, "pinia")));
|
|
124
|
+
const antfuConfig = {
|
|
125
|
+
stylistic: {
|
|
126
|
+
indent: 2,
|
|
127
|
+
quotes: "single",
|
|
128
|
+
semi: false,
|
|
129
|
+
overrides: overrides.stylistic
|
|
130
|
+
},
|
|
131
|
+
javascript: {
|
|
132
|
+
overrides: overrides.javascript
|
|
133
|
+
},
|
|
134
|
+
vue: {
|
|
135
|
+
overrides: overrides.vue
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
return (0, import_eslint_config2.default)(
|
|
139
|
+
deepMerge(antfuConfig, options),
|
|
140
|
+
...configs,
|
|
141
|
+
...userConfigs
|
|
142
|
+
).prepend({
|
|
143
|
+
name: "vida/imports/setup",
|
|
144
|
+
settings: {
|
|
145
|
+
"import-x/resolver": "oxc"
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
var src_default = defineConfig;
|
|
150
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
151
|
+
0 && (module.exports = {
|
|
152
|
+
deepMerge,
|
|
153
|
+
defineConfig,
|
|
154
|
+
...require("@antfu/eslint-config")
|
|
155
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as eslint_flat_config_utils from 'eslint-flat-config-utils';
|
|
2
|
+
import * as _antfu_eslint_config from '@antfu/eslint-config';
|
|
3
|
+
import { OptionsConfig as OptionsConfig$1, TypedFlatConfigItem as TypedFlatConfigItem$1 } from '@antfu/eslint-config';
|
|
4
|
+
export * from '@antfu/eslint-config';
|
|
5
|
+
import { Linter } from 'eslint';
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
/* prettier-ignore */
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
interface RuleOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Never export an initialized named or default store.
|
|
14
|
+
* @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/never-export-initialized-store.md
|
|
15
|
+
*/
|
|
16
|
+
'pinia/never-export-initialized-store'?: Linter.RuleEntry<[]>
|
|
17
|
+
/**
|
|
18
|
+
* Disallow duplicate store ids.
|
|
19
|
+
* @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/no-duplicate-store-ids.md
|
|
20
|
+
*/
|
|
21
|
+
'pinia/no-duplicate-store-ids'?: Linter.RuleEntry<[]>
|
|
22
|
+
/**
|
|
23
|
+
* Disallows returning globally provided properties from Pinia stores.
|
|
24
|
+
* @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/no-return-global-properties.md
|
|
25
|
+
*/
|
|
26
|
+
'pinia/no-return-global-properties'?: Linter.RuleEntry<[]>
|
|
27
|
+
/**
|
|
28
|
+
* Encourages defining each store in a separate file.
|
|
29
|
+
* @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/prefer-single-store-per-file.md
|
|
30
|
+
*/
|
|
31
|
+
'pinia/prefer-single-store-per-file'?: Linter.RuleEntry<[]>
|
|
32
|
+
/**
|
|
33
|
+
* Enforces the convention of naming stores with the prefix `use` followed by the store name.
|
|
34
|
+
* @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/prefer-use-store-naming-convention.md
|
|
35
|
+
*/
|
|
36
|
+
'pinia/prefer-use-store-naming-convention'?: Linter.RuleEntry<PiniaPreferUseStoreNamingConvention>
|
|
37
|
+
/**
|
|
38
|
+
* In setup stores all state properties must be exported.
|
|
39
|
+
* @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/require-setup-store-properties-export.md
|
|
40
|
+
*/
|
|
41
|
+
'pinia/require-setup-store-properties-export'?: Linter.RuleEntry<[]>
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* ======= Declarations ======= */
|
|
45
|
+
// ----- pinia/prefer-use-store-naming-convention -----
|
|
46
|
+
type PiniaPreferUseStoreNamingConvention = []|[{
|
|
47
|
+
checkStoreNameMismatch?: boolean
|
|
48
|
+
storeSuffix?: string
|
|
49
|
+
[k: string]: unknown | undefined
|
|
50
|
+
}]
|
|
51
|
+
|
|
52
|
+
type Rules = RuleOptions;
|
|
53
|
+
type TypedFlatConfigItem = Omit<Linter.FlatConfig<Linter.RulesRecord & Rules>, 'plugins'> & {
|
|
54
|
+
/**
|
|
55
|
+
* An object containing a name-value mapping of plugin names to plugin objects. When `files` is specified, these plugins are only available to the matching files.
|
|
56
|
+
*
|
|
57
|
+
* @see [Using plugins in your configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-plugins-in-your-configuration)
|
|
58
|
+
*/
|
|
59
|
+
plugins?: Record<string, any>;
|
|
60
|
+
};
|
|
61
|
+
interface OptionsOverrides {
|
|
62
|
+
overrides?: TypedFlatConfigItem['rules'];
|
|
63
|
+
}
|
|
64
|
+
type OptionsConfig = Omit<OptionsConfig$1, 'overrides'> & {
|
|
65
|
+
/**
|
|
66
|
+
* Enable Pinia support.
|
|
67
|
+
*
|
|
68
|
+
* @default auto-detect based on the dependencies
|
|
69
|
+
*/
|
|
70
|
+
pinia?: boolean | OptionsOverrides;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
declare function deepMerge<T>(target: T, source: T): T;
|
|
74
|
+
|
|
75
|
+
declare function defineConfig(options?: OptionsConfig & TypedFlatConfigItem$1, ...userConfigs: TypedFlatConfigItem$1[]): eslint_flat_config_utils.FlatConfigComposer<TypedFlatConfigItem$1, _antfu_eslint_config.ConfigNames>;
|
|
76
|
+
|
|
77
|
+
export { deepMerge, defineConfig as default, defineConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as eslint_flat_config_utils from 'eslint-flat-config-utils';
|
|
2
2
|
import * as _antfu_eslint_config from '@antfu/eslint-config';
|
|
3
|
-
import {
|
|
3
|
+
import { OptionsConfig as OptionsConfig$1, TypedFlatConfigItem as TypedFlatConfigItem$1 } from '@antfu/eslint-config';
|
|
4
4
|
export * from '@antfu/eslint-config';
|
|
5
5
|
import { Linter } from 'eslint';
|
|
6
6
|
|
|
@@ -49,7 +49,6 @@ type PiniaPreferUseStoreNamingConvention = []|[{
|
|
|
49
49
|
[k: string]: unknown | undefined
|
|
50
50
|
}]
|
|
51
51
|
|
|
52
|
-
type AntfuOptions = Parameters<typeof antfu>[0];
|
|
53
52
|
type Rules = RuleOptions;
|
|
54
53
|
type TypedFlatConfigItem = Omit<Linter.FlatConfig<Linter.RulesRecord & Rules>, 'plugins'> & {
|
|
55
54
|
/**
|
|
@@ -62,7 +61,7 @@ type TypedFlatConfigItem = Omit<Linter.FlatConfig<Linter.RulesRecord & Rules>, '
|
|
|
62
61
|
interface OptionsOverrides {
|
|
63
62
|
overrides?: TypedFlatConfigItem['rules'];
|
|
64
63
|
}
|
|
65
|
-
type OptionsConfig = Omit<
|
|
64
|
+
type OptionsConfig = Omit<OptionsConfig$1, 'overrides'> & {
|
|
66
65
|
/**
|
|
67
66
|
* Enable Pinia support.
|
|
68
67
|
*
|
|
@@ -71,6 +70,8 @@ type OptionsConfig = Omit<AntfuOptions, 'overrides'> & {
|
|
|
71
70
|
pinia?: boolean | OptionsOverrides;
|
|
72
71
|
};
|
|
73
72
|
|
|
74
|
-
declare function
|
|
73
|
+
declare function deepMerge<T>(target: T, source: T): T;
|
|
75
74
|
|
|
76
|
-
|
|
75
|
+
declare function defineConfig(options?: OptionsConfig & TypedFlatConfigItem$1, ...userConfigs: TypedFlatConfigItem$1[]): eslint_flat_config_utils.FlatConfigComposer<TypedFlatConfigItem$1, _antfu_eslint_config.ConfigNames>;
|
|
76
|
+
|
|
77
|
+
export { deepMerge, defineConfig as default, defineConfig };
|
package/dist/index.js
CHANGED
|
@@ -9,11 +9,11 @@ var GLOB_PINIA_TS = `**/stores/${GLOB_TS}`;
|
|
|
9
9
|
async function pinia(options = {}) {
|
|
10
10
|
const {
|
|
11
11
|
files = [GLOB_PINIA_JS, GLOB_PINIA_TS],
|
|
12
|
-
overrides = {}
|
|
12
|
+
overrides: overrides2 = {}
|
|
13
13
|
} = options;
|
|
14
14
|
return [
|
|
15
15
|
{
|
|
16
|
-
name: "
|
|
16
|
+
name: "vida/pinia/rules",
|
|
17
17
|
files,
|
|
18
18
|
plugins: {
|
|
19
19
|
pinia: await interopDefault(import("eslint-plugin-pinia"))
|
|
@@ -27,7 +27,7 @@ async function pinia(options = {}) {
|
|
|
27
27
|
}],
|
|
28
28
|
"pinia/require-setup-store-properties-export": "warn",
|
|
29
29
|
"pinia/no-duplicate-store-ids": "error",
|
|
30
|
-
...
|
|
30
|
+
...overrides2
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
];
|
|
@@ -40,6 +40,12 @@ var javascript = {
|
|
|
40
40
|
"require-atomic-updates": ["error", { allowProperties: true }]
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
// src/overrides/stylistic.ts
|
|
44
|
+
var stylistic = {
|
|
45
|
+
"style/arrow-parens": ["error", "always"],
|
|
46
|
+
"style/brace-style": ["error", "1tbs", { allowSingleLine: true }]
|
|
47
|
+
};
|
|
48
|
+
|
|
43
49
|
// src/overrides/vue.ts
|
|
44
50
|
var vue = {
|
|
45
51
|
"vue/max-attributes-per-line": ["error", {
|
|
@@ -48,9 +54,30 @@ var vue = {
|
|
|
48
54
|
}]
|
|
49
55
|
};
|
|
50
56
|
|
|
57
|
+
// src/overrides/index.ts
|
|
58
|
+
var overrides = {
|
|
59
|
+
javascript,
|
|
60
|
+
stylistic,
|
|
61
|
+
vue
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/utils.ts
|
|
65
|
+
function deepMerge(target, source) {
|
|
66
|
+
for (const key in source) {
|
|
67
|
+
if (Object.hasOwnProperty.call(source, key)) {
|
|
68
|
+
if (source[key] instanceof Object && target[key] instanceof Object) {
|
|
69
|
+
target[key] = deepMerge(target[key], source[key]);
|
|
70
|
+
} else {
|
|
71
|
+
target[key] = source[key];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return target;
|
|
76
|
+
}
|
|
77
|
+
|
|
51
78
|
// src/index.ts
|
|
52
79
|
export * from "@antfu/eslint-config";
|
|
53
|
-
function
|
|
80
|
+
function defineConfig(options = {}, ...userConfigs) {
|
|
54
81
|
const {
|
|
55
82
|
pinia: enablePinia = isPackageExists("pinia")
|
|
56
83
|
} = options;
|
|
@@ -62,30 +89,29 @@ function vida(options = {}, ...userConfigs) {
|
|
|
62
89
|
indent: 2,
|
|
63
90
|
quotes: "single",
|
|
64
91
|
semi: false,
|
|
65
|
-
overrides:
|
|
66
|
-
"style/arrow-parens": ["error", "always"],
|
|
67
|
-
"style/brace-style": ["error", "1tbs", { allowSingleLine: true }]
|
|
68
|
-
}
|
|
92
|
+
overrides: overrides.stylistic
|
|
69
93
|
},
|
|
70
94
|
javascript: {
|
|
71
|
-
overrides: javascript
|
|
95
|
+
overrides: overrides.javascript
|
|
72
96
|
},
|
|
73
97
|
vue: {
|
|
74
|
-
overrides: vue
|
|
75
|
-
}
|
|
76
|
-
jsx: false
|
|
98
|
+
overrides: overrides.vue
|
|
99
|
+
}
|
|
77
100
|
};
|
|
78
101
|
return antfu(
|
|
79
|
-
|
|
80
|
-
...antfuConfig,
|
|
81
|
-
...options
|
|
82
|
-
},
|
|
102
|
+
deepMerge(antfuConfig, options),
|
|
83
103
|
...configs,
|
|
84
104
|
...userConfigs
|
|
85
|
-
)
|
|
105
|
+
).prepend({
|
|
106
|
+
name: "vida/imports/setup",
|
|
107
|
+
settings: {
|
|
108
|
+
"import-x/resolver": "oxc"
|
|
109
|
+
}
|
|
110
|
+
});
|
|
86
111
|
}
|
|
87
|
-
var src_default =
|
|
112
|
+
var src_default = defineConfig;
|
|
88
113
|
export {
|
|
114
|
+
deepMerge,
|
|
89
115
|
src_default as default,
|
|
90
|
-
|
|
116
|
+
defineConfig
|
|
91
117
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vida0905/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.2",
|
|
5
5
|
"packageManager": "pnpm@9.5.0",
|
|
6
6
|
"description": "Vida Xie's ESLint Config",
|
|
7
7
|
"author": "Vida Xie <vida_2020@163.com> (https://github.com/9romise/)",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@antfu/eslint-config": "^2.22.4",
|
|
58
|
+
"eslint-import-resolver-oxc": "^0.2.0",
|
|
58
59
|
"eslint-plugin-pinia": "^0.2.0",
|
|
59
60
|
"local-pkg": "^0.5.0"
|
|
60
61
|
},
|