@truenine/eslint9-config 1.0.19 → 1.0.20
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/defaults/index.cjs +200 -0
- package/dist/defaults/index.cjs.map +1 -0
- package/dist/defaults/index.d.cts +40 -0
- package/dist/defaults/index.d.cts.map +1 -0
- package/dist/index.cjs +44 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +24 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +46 -0
- package/dist/types/index.d.cts.map +1 -0
- package/package.json +19 -22
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/defaults/index.ts
|
|
3
|
+
const defaultUnocssConfig = {
|
|
4
|
+
attributify: true,
|
|
5
|
+
strict: true
|
|
6
|
+
};
|
|
7
|
+
const defaultVueConfig = {
|
|
8
|
+
vueVersion: 3,
|
|
9
|
+
overrides: {
|
|
10
|
+
"vue/html-self-closing": ["error", { html: {
|
|
11
|
+
void: "always",
|
|
12
|
+
normal: "always",
|
|
13
|
+
component: "always"
|
|
14
|
+
} }],
|
|
15
|
+
"vue/html-comment-content-spacing": [
|
|
16
|
+
"error",
|
|
17
|
+
"always",
|
|
18
|
+
{ exceptions: [] }
|
|
19
|
+
],
|
|
20
|
+
"vue/html-comment-indent": ["error", 2],
|
|
21
|
+
"vue/html-indent": [
|
|
22
|
+
"error",
|
|
23
|
+
2,
|
|
24
|
+
{
|
|
25
|
+
baseIndent: 0,
|
|
26
|
+
alignAttributesVertically: true
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"vue/define-emits-declaration": ["error", "type-literal"],
|
|
30
|
+
"vue/define-props-declaration": ["error", "type-based"],
|
|
31
|
+
"vue/define-macros-order": ["error", {
|
|
32
|
+
order: [
|
|
33
|
+
"defineProps",
|
|
34
|
+
"defineEmits",
|
|
35
|
+
"defineModel",
|
|
36
|
+
"defineSlots"
|
|
37
|
+
],
|
|
38
|
+
defineExposeLast: true
|
|
39
|
+
}],
|
|
40
|
+
"vue/block-order": ["error", { order: [
|
|
41
|
+
"script",
|
|
42
|
+
"template",
|
|
43
|
+
"style"
|
|
44
|
+
] }],
|
|
45
|
+
"vue/attributes-order": ["error", { order: [
|
|
46
|
+
"DEFINITION",
|
|
47
|
+
"LIST_RENDERING",
|
|
48
|
+
"CONDITIONALS",
|
|
49
|
+
"RENDER_MODIFIERS",
|
|
50
|
+
"GLOBAL",
|
|
51
|
+
"UNIQUE",
|
|
52
|
+
"TWO_WAY_BINDING",
|
|
53
|
+
"OTHER_DIRECTIVES",
|
|
54
|
+
"OTHER_ATTR",
|
|
55
|
+
"EVENTS",
|
|
56
|
+
"CONTENT"
|
|
57
|
+
] }],
|
|
58
|
+
"vue/v-on-event-hyphenation": [
|
|
59
|
+
"error",
|
|
60
|
+
"never",
|
|
61
|
+
{ autofix: true }
|
|
62
|
+
],
|
|
63
|
+
"vue/attribute-hyphenation": [
|
|
64
|
+
"error",
|
|
65
|
+
"never",
|
|
66
|
+
{ ignoreTags: [
|
|
67
|
+
"i-",
|
|
68
|
+
"v-",
|
|
69
|
+
"v-bind"
|
|
70
|
+
] }
|
|
71
|
+
],
|
|
72
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
73
|
+
"vue/component-name-in-template-casing": [
|
|
74
|
+
"error",
|
|
75
|
+
"PascalCase",
|
|
76
|
+
{
|
|
77
|
+
ignores: [
|
|
78
|
+
"router-view",
|
|
79
|
+
"router-link",
|
|
80
|
+
"scroll-view"
|
|
81
|
+
],
|
|
82
|
+
registeredComponentsOnly: false
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const defaultJsConfig = { overrides: {
|
|
88
|
+
"no-inline-comments": "error",
|
|
89
|
+
"unicorn/no-useless-spread": "error",
|
|
90
|
+
"curly": ["error", "all"],
|
|
91
|
+
"no-undefined": "error",
|
|
92
|
+
"no-cond-assign": ["error", "always"],
|
|
93
|
+
"no-constant-condition": "error",
|
|
94
|
+
"no-restricted-syntax": "error",
|
|
95
|
+
"no-global-assign": "error",
|
|
96
|
+
"no-unused-vars": "error",
|
|
97
|
+
"no-var": "error",
|
|
98
|
+
"prefer-const": ["error", {
|
|
99
|
+
destructuring: "any",
|
|
100
|
+
ignoreReadBeforeAssign: false
|
|
101
|
+
}]
|
|
102
|
+
} };
|
|
103
|
+
const defaultTsConfig = { overrides: {
|
|
104
|
+
"ts/no-unsafe-assignment": "off",
|
|
105
|
+
"ts/no-unsafe-call": "off",
|
|
106
|
+
"ts/no-unsafe-argument": "off",
|
|
107
|
+
"ts/no-unsafe-return": "off",
|
|
108
|
+
"ts/member-ordering": ["error"],
|
|
109
|
+
"ts/no-extra-non-null-assertion": "error",
|
|
110
|
+
"ts/no-non-null-assertion": "error",
|
|
111
|
+
"ts/no-explicit-any": ["error", {
|
|
112
|
+
fixToUnknown: true,
|
|
113
|
+
ignoreRestArgs: true
|
|
114
|
+
}],
|
|
115
|
+
"ts/no-namespace": "error",
|
|
116
|
+
"ts/no-unused-vars": ["error", {
|
|
117
|
+
vars: "all",
|
|
118
|
+
args: "after-used",
|
|
119
|
+
ignoreRestSiblings: false
|
|
120
|
+
}]
|
|
121
|
+
} };
|
|
122
|
+
const defaultFormatterConfig = {
|
|
123
|
+
css: "prettier",
|
|
124
|
+
html: "prettier",
|
|
125
|
+
prettierOptions: {
|
|
126
|
+
printWidth: 160,
|
|
127
|
+
tabWidth: 2,
|
|
128
|
+
arrowParens: "always",
|
|
129
|
+
vueIndentScriptAndStyle: true,
|
|
130
|
+
useTabs: false,
|
|
131
|
+
singleQuote: true,
|
|
132
|
+
jsxSingleQuote: true,
|
|
133
|
+
trailingComma: "all",
|
|
134
|
+
bracketSpacing: true
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* 严格 ts 模式 的默认配置
|
|
139
|
+
*
|
|
140
|
+
* 这些配置需要 配置 parserOptions 和 tsconfigPath 等
|
|
141
|
+
* @see https://typescript-eslint.io/getting-started/typed-linting
|
|
142
|
+
*/
|
|
143
|
+
const defaultStrictTsConfig = { overrides: {
|
|
144
|
+
"ts/no-unsafe-assignment": "off",
|
|
145
|
+
"ts/no-unsafe-call": "off",
|
|
146
|
+
"ts/no-unsafe-argument": "off",
|
|
147
|
+
"ts/no-unsafe-return": "off",
|
|
148
|
+
"ts/no-floating-promises": "error"
|
|
149
|
+
} };
|
|
150
|
+
const defaultStylisticConfig = {
|
|
151
|
+
jsx: true,
|
|
152
|
+
indent: 2,
|
|
153
|
+
quotes: "single",
|
|
154
|
+
semi: false,
|
|
155
|
+
overrides: {
|
|
156
|
+
"style/no-multiple-empty-lines": ["error", {
|
|
157
|
+
max: 1,
|
|
158
|
+
maxBOF: 0,
|
|
159
|
+
maxEOF: 0
|
|
160
|
+
}],
|
|
161
|
+
"style/brace-style": ["error", "1tbs"],
|
|
162
|
+
"style/arrow-parens": ["error", "always"]
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
const defaultTestConfig = { overrides: {
|
|
166
|
+
"no-console": "off",
|
|
167
|
+
"ts/unbound-method": "off",
|
|
168
|
+
"ts/no-unsafe-argument": "off",
|
|
169
|
+
"ts/no-unsafe-assignment": "off",
|
|
170
|
+
"ts/no-unsafe-member-access": "off",
|
|
171
|
+
"ts/no-unsafe-call": "off",
|
|
172
|
+
"ts/no-unsafe-return": "off"
|
|
173
|
+
} };
|
|
174
|
+
function mergeWithDefaults(value, defaults) {
|
|
175
|
+
if (defaults === false || defaults === null || defaults === void 0) {
|
|
176
|
+
if (value === true) return true;
|
|
177
|
+
if (value === false || value === null) return false;
|
|
178
|
+
return value;
|
|
179
|
+
}
|
|
180
|
+
if (value === void 0) return defaults;
|
|
181
|
+
if (value === false || value === null) return false;
|
|
182
|
+
if (value === true) return defaults;
|
|
183
|
+
if (typeof value === "object" && typeof defaults === "object") return {
|
|
184
|
+
...defaults,
|
|
185
|
+
...value
|
|
186
|
+
};
|
|
187
|
+
return value;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
//#endregion
|
|
191
|
+
exports.defaultFormatterConfig = defaultFormatterConfig;
|
|
192
|
+
exports.defaultJsConfig = defaultJsConfig;
|
|
193
|
+
exports.defaultStrictTsConfig = defaultStrictTsConfig;
|
|
194
|
+
exports.defaultStylisticConfig = defaultStylisticConfig;
|
|
195
|
+
exports.defaultTestConfig = defaultTestConfig;
|
|
196
|
+
exports.defaultTsConfig = defaultTsConfig;
|
|
197
|
+
exports.defaultUnocssConfig = defaultUnocssConfig;
|
|
198
|
+
exports.defaultVueConfig = defaultVueConfig;
|
|
199
|
+
exports.mergeWithDefaults = mergeWithDefaults;
|
|
200
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["defaultUnocssConfig: AntFuUnocssConfig","defaultVueConfig: AntFuVueConfig","defaultJsConfig: AntFuJsConfig","defaultTsConfig: AntFuTsConfig","defaultFormatterConfig: AntFuFormatterConfig","defaultStrictTsConfig: AntFuTsConfig","defaultStylisticConfig: AntFuStylisticConfig","defaultTestConfig: AntFuTestConfig"],"sources":["../../src/defaults/index.ts"],"sourcesContent":["import type { AntFuFormatterConfig, AntFuJsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig } from '../types'\n\nexport const defaultUnocssConfig: AntFuUnocssConfig = {\n attributify: true,\n strict: true,\n}\n\nexport const defaultVueConfig: AntFuVueConfig = {\n vueVersion: 3,\n overrides: {\n 'vue/html-self-closing': ['error', {\n html: {\n void: 'always',\n normal: 'always',\n component: 'always',\n },\n }],\n 'vue/html-comment-content-spacing': ['error', 'always', { exceptions: [] }],\n 'vue/html-comment-indent': ['error', 2],\n 'vue/html-indent': ['error', 2, {\n baseIndent: 0,\n alignAttributesVertically: true,\n }],\n 'vue/define-emits-declaration': ['error', 'type-literal'],\n 'vue/define-props-declaration': ['error', 'type-based'],\n 'vue/define-macros-order': [\n 'error',\n {\n order: [\n 'defineProps',\n 'defineEmits',\n 'defineModel',\n 'defineSlots',\n ],\n defineExposeLast: true,\n },\n ],\n 'vue/block-order': [\n 'error',\n {\n order: ['script', 'template', 'style'],\n },\n ],\n 'vue/attributes-order': [\n 'error',\n {\n order: ['DEFINITION', 'LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'OTHER_DIRECTIVES', 'OTHER_ATTR', 'EVENTS', 'CONTENT'],\n },\n ],\n 'vue/v-on-event-hyphenation': [\n 'error',\n 'never',\n {\n autofix: true,\n },\n ],\n 'vue/attribute-hyphenation': [\n 'error',\n 'never',\n {\n ignoreTags: ['i-', 'v-', 'v-bind'],\n },\n ],\n 'vue/prop-name-casing': ['error', 'camelCase'],\n 'vue/component-name-in-template-casing': [\n 'error',\n 'PascalCase',\n {\n ignores: ['router-view', 'router-link', 'scroll-view'],\n registeredComponentsOnly: false,\n },\n ],\n },\n}\n\nexport const defaultJsConfig: AntFuJsConfig = {\n overrides: {\n 'no-inline-comments': 'error',\n 'unicorn/no-useless-spread': 'error',\n\n 'curly': ['error', 'all'],\n 'no-undefined': 'error',\n 'no-cond-assign': ['error', 'always'],\n 'no-constant-condition': 'error',\n 'no-restricted-syntax': 'error',\n 'no-global-assign': 'error',\n 'no-unused-vars': 'error',\n 'no-var': 'error',\n 'prefer-const': [\n 'error',\n {\n destructuring: 'any',\n ignoreReadBeforeAssign: false,\n },\n ],\n },\n}\n\nexport const defaultTsConfig: AntFuTsConfig = {\n overrides: {\n 'ts/no-unsafe-assignment': 'off',\n 'ts/no-unsafe-call': 'off',\n 'ts/no-unsafe-argument': 'off',\n 'ts/no-unsafe-return': 'off',\n 'ts/member-ordering': ['error'],\n 'ts/no-extra-non-null-assertion': 'error',\n 'ts/no-non-null-assertion': 'error',\n 'ts/no-explicit-any': ['error', {\n fixToUnknown: true,\n ignoreRestArgs: true,\n }],\n 'ts/no-namespace': 'error',\n 'ts/no-unused-vars': [\n 'error',\n {\n vars: 'all',\n args: 'after-used',\n ignoreRestSiblings: false,\n },\n ],\n },\n}\n\nexport const defaultFormatterConfig: AntFuFormatterConfig = {\n css: 'prettier',\n html: 'prettier',\n prettierOptions: {\n printWidth: 160,\n tabWidth: 2,\n arrowParens: 'always',\n vueIndentScriptAndStyle: true,\n useTabs: false,\n singleQuote: true,\n jsxSingleQuote: true,\n trailingComma: 'all',\n bracketSpacing: true,\n },\n}\n\n/**\n * 严格 ts 模式 的默认配置\n *\n * 这些配置需要 配置 parserOptions 和 tsconfigPath 等\n * @see https://typescript-eslint.io/getting-started/typed-linting\n */\nexport const defaultStrictTsConfig: AntFuTsConfig = {\n overrides: {\n 'ts/no-unsafe-assignment': 'off',\n 'ts/no-unsafe-call': 'off',\n 'ts/no-unsafe-argument': 'off',\n 'ts/no-unsafe-return': 'off',\n 'ts/no-floating-promises': 'error',\n },\n}\n\nexport const defaultStylisticConfig: AntFuStylisticConfig = {\n jsx: true,\n indent: 2,\n quotes: 'single',\n semi: false,\n overrides: {\n 'style/no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],\n 'style/brace-style': ['error', '1tbs'],\n 'style/arrow-parens': ['error', 'always'],\n },\n}\n\nexport const defaultTestConfig: AntFuTestConfig = {\n overrides: {\n 'no-console': 'off',\n 'ts/unbound-method': 'off',\n 'ts/no-unsafe-argument': 'off',\n 'ts/no-unsafe-assignment': 'off',\n 'ts/no-unsafe-member-access': 'off',\n 'ts/no-unsafe-call': 'off',\n 'ts/no-unsafe-return': 'off',\n },\n}\n\n/**\n * 合并配置项,支持以下场景:\n * 1. 布尔值与对象配置的混合\n * 2. 使用 vite 的 mergeConfig 进行对象合并\n * 3. 处理 undefined 和 null 的默认值\n *\n * @example\n * ```ts\n * // 场景1: 布尔值转换为默认对象\n * mergeWithDefaults(true, { foo: 'bar' }) // => { foo: 'bar' }\n *\n * // 场景2: vite配置合并\n * mergeWithDefaults({ plugins: [vue()] }, { plugins: [unocss()] })\n *\n * // 场景3: undefined/null/false 处理\n * mergeWithDefaults(false, true) // => false\n * ```\n */\nexport function mergeWithDefaults<T extends object>(\n value?: boolean | T | null,\n defaults?: T,\n): T\nexport function mergeWithDefaults<T extends object>(\n value?: boolean | T | null,\n defaults?: boolean,\n): boolean | T\nexport function mergeWithDefaults<T extends object>(\n value?: boolean | T | null,\n defaults?: boolean | T | null,\n): boolean | T {\n // 处理无默认值的情况\n if (defaults === false || defaults === null || defaults === void 0) {\n if (value === true) {\n return true\n }\n if (value === false || value === null) {\n return false\n }\n return value as T\n }\n\n // 处理 value 为 undefined 的情况\n if (value === void 0) {\n return defaults\n }\n\n // 处理 value 为 false/null 的情况\n if (value === false || value === null) {\n return false\n }\n\n // 处理 value 为 true 的情况\n if (value === true) {\n return defaults\n }\n\n // 如果都是对象,使用 vite 的 mergeConfig 进行合并\n if (typeof value === 'object' && typeof defaults === 'object') {\n return {\n ...defaults,\n ...value,\n }\n }\n\n // 其他情况返回 value\n return value\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AntFuFormatterConfig, AntFuJsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig } from "../types/index.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/defaults/index.d.ts
|
|
4
|
+
declare const defaultUnocssConfig: AntFuUnocssConfig;
|
|
5
|
+
declare const defaultVueConfig: AntFuVueConfig;
|
|
6
|
+
declare const defaultJsConfig: AntFuJsConfig;
|
|
7
|
+
declare const defaultTsConfig: AntFuTsConfig;
|
|
8
|
+
declare const defaultFormatterConfig: AntFuFormatterConfig;
|
|
9
|
+
/**
|
|
10
|
+
* 严格 ts 模式 的默认配置
|
|
11
|
+
*
|
|
12
|
+
* 这些配置需要 配置 parserOptions 和 tsconfigPath 等
|
|
13
|
+
* @see https://typescript-eslint.io/getting-started/typed-linting
|
|
14
|
+
*/
|
|
15
|
+
declare const defaultStrictTsConfig: AntFuTsConfig;
|
|
16
|
+
declare const defaultStylisticConfig: AntFuStylisticConfig;
|
|
17
|
+
declare const defaultTestConfig: AntFuTestConfig;
|
|
18
|
+
/**
|
|
19
|
+
* 合并配置项,支持以下场景:
|
|
20
|
+
* 1. 布尔值与对象配置的混合
|
|
21
|
+
* 2. 使用 vite 的 mergeConfig 进行对象合并
|
|
22
|
+
* 3. 处理 undefined 和 null 的默认值
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // 场景1: 布尔值转换为默认对象
|
|
27
|
+
* mergeWithDefaults(true, { foo: 'bar' }) // => { foo: 'bar' }
|
|
28
|
+
*
|
|
29
|
+
* // 场景2: vite配置合并
|
|
30
|
+
* mergeWithDefaults({ plugins: [vue()] }, { plugins: [unocss()] })
|
|
31
|
+
*
|
|
32
|
+
* // 场景3: undefined/null/false 处理
|
|
33
|
+
* mergeWithDefaults(false, true) // => false
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function mergeWithDefaults<T extends object>(value?: boolean | T | null, defaults?: T): T;
|
|
37
|
+
declare function mergeWithDefaults<T extends object>(value?: boolean | T | null, defaults?: boolean): boolean | T;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { defaultFormatterConfig, defaultJsConfig, defaultStrictTsConfig, defaultStylisticConfig, defaultTestConfig, defaultTsConfig, defaultUnocssConfig, defaultVueConfig, mergeWithDefaults };
|
|
40
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["defaultUnocssConfig: AntFuUnocssConfig","defaultVueConfig: AntFuVueConfig","defaultJsConfig: AntFuJsConfig","defaultTsConfig: AntFuTsConfig","defaultFormatterConfig: AntFuFormatterConfig","defaultStrictTsConfig: AntFuTsConfig","defaultStylisticConfig: AntFuStylisticConfig","defaultTestConfig: AntFuTestConfig"],"sources":["../../src/defaults/index.ts"],"sourcesContent":[],"mappings":";;;cAEaA,qBAAqB;cAKrBC,kBAAkB;AALlBD,cAyEAE,eAzEqB,EAyEJ,aAzEI;AAKrBD,cA2FAE,eA3FkB,EA2FD,aA3FC;AAoElBD,cAgDAE,sBAhDiB,EAgDO,oBAhDP;AAuB9B;AAyBA;AAsBA;AAUA;AAYA;AA8BA;AACoB,cArDPC,qBAqDO,EArDgB,aAqDhB;AACP,cA5CAC,sBA4CA,EA5CwB,oBA4CxB;AACV,cAjCUC,iBAiCV,EAjC6B,eAiC7B;;AACH;;;;;;;;;;;;;;;;;iBAJgB,sDACI,qBACP,IACV;iBACa,sDACI,yCAEP"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_defaults_index = require('./defaults/index.cjs');
|
|
3
|
+
let __antfu_eslint_config = require("@antfu/eslint-config");
|
|
4
|
+
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
async function applyPreset(options = {}) {
|
|
7
|
+
return eslint9(options);
|
|
8
|
+
}
|
|
9
|
+
async function eslint9(options = {}) {
|
|
10
|
+
const { type = "lib", ignores = [], test = true, nextjs = false, react = false, unocss = false, vue = false, jsx = false, pnpm = false, stylistic = true, javascript = require_defaults_index.defaultJsConfig, typescript = require_defaults_index.defaultTsConfig, formatters = false } = options;
|
|
11
|
+
const _test = require_defaults_index.mergeWithDefaults(test, require_defaults_index.defaultTestConfig);
|
|
12
|
+
const _unocss = require_defaults_index.mergeWithDefaults(unocss, require_defaults_index.defaultUnocssConfig);
|
|
13
|
+
const _vue = require_defaults_index.mergeWithDefaults(vue, require_defaults_index.defaultVueConfig);
|
|
14
|
+
const _javascript = require_defaults_index.mergeWithDefaults(javascript, require_defaults_index.defaultJsConfig);
|
|
15
|
+
const _stylistic = require_defaults_index.mergeWithDefaults(stylistic, require_defaults_index.defaultStylisticConfig);
|
|
16
|
+
const _formatters = require_defaults_index.mergeWithDefaults(formatters, require_defaults_index.defaultFormatterConfig);
|
|
17
|
+
let _typescript = typescript;
|
|
18
|
+
let _pnpm = pnpm;
|
|
19
|
+
if (type === "app") _pnpm = false;
|
|
20
|
+
if (_typescript !== null && typeof _typescript === "object" && "strictTypescriptEslint" in _typescript && _typescript.strictTypescriptEslint === true) {
|
|
21
|
+
_typescript = require_defaults_index.mergeWithDefaults(typescript, require_defaults_index.defaultStrictTsConfig);
|
|
22
|
+
if (typeof _typescript === "object" && "tsconfigPath" in _typescript) _typescript.parserOptions = { projectService: true };
|
|
23
|
+
}
|
|
24
|
+
return (0, __antfu_eslint_config.antfu)({
|
|
25
|
+
type,
|
|
26
|
+
ignores,
|
|
27
|
+
pnpm: _pnpm,
|
|
28
|
+
test: _test,
|
|
29
|
+
unocss: _unocss,
|
|
30
|
+
vue: _vue,
|
|
31
|
+
nextjs,
|
|
32
|
+
react,
|
|
33
|
+
jsx,
|
|
34
|
+
typescript: _typescript,
|
|
35
|
+
javascript: _javascript,
|
|
36
|
+
stylistic: _stylistic,
|
|
37
|
+
formatters: _formatters
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.applyPreset = applyPreset;
|
|
43
|
+
exports.default = eslint9;
|
|
44
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["defaultJsConfig","defaultTsConfig","mergeWithDefaults","defaultTestConfig","defaultUnocssConfig","defaultVueConfig","defaultStylisticConfig","defaultFormatterConfig","defaultStrictTsConfig"],"sources":["../src/index.ts"],"sourcesContent":["import type { OptionsTypeScriptParserOptions } from '@antfu/eslint-config'\nimport type { AntFuFormatterConfig, AntFuJsConfig, AntFuStrictTsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig } from './types/index'\nimport { antfu } from '@antfu/eslint-config'\nimport { defaultFormatterConfig, defaultJsConfig, defaultStrictTsConfig, defaultStylisticConfig, defaultTestConfig, defaultTsConfig, defaultUnocssConfig, defaultVueConfig, mergeWithDefaults } from './defaults/index'\n\nexport interface ConfigOptions {\n type?: 'app' | 'lib'\n pnpm?: boolean\n test?: boolean | AntFuTestConfig\n ignores?: string[]\n jsx?: boolean\n nextjs?: boolean\n react?: boolean\n vue?: boolean | AntFuVueConfig\n formatters?: boolean | AntFuFormatterConfig\n javascript?: AntFuJsConfig\n typescript?: boolean | AntFuStrictTsConfig | AntFuTsConfig\n unocss?: boolean | AntFuUnocssConfig\n stylistic?: boolean | AntFuStylisticConfig\n}\n\nexport async function applyPreset(options: ConfigOptions = {}): Promise<ReturnType<typeof antfu>> {\n return eslint9(options)\n}\n\nexport default async function eslint9(options: ConfigOptions = {}): Promise<ReturnType<typeof antfu>> {\n const {\n type = 'lib',\n ignores = [],\n test = true,\n nextjs = false,\n react = false,\n unocss = false,\n vue = false,\n jsx = false,\n pnpm = false,\n stylistic = true,\n javascript = defaultJsConfig,\n typescript = defaultTsConfig,\n formatters = false,\n } = options\n\n const _test = mergeWithDefaults(test, defaultTestConfig)\n const _unocss = mergeWithDefaults(unocss, defaultUnocssConfig)\n const _vue = mergeWithDefaults(vue, defaultVueConfig)\n const _javascript = mergeWithDefaults(javascript, defaultJsConfig)\n const _stylistic = mergeWithDefaults(stylistic, defaultStylisticConfig)\n const _formatters = mergeWithDefaults(formatters, defaultFormatterConfig)\n let _typescript = typescript\n\n // 如果 type 为 'app',强制 pnpm 为 false\n let _pnpm = pnpm\n if (type === 'app') {\n _pnpm = false\n }\n\n // 严格 ts 模式\n if (\n _typescript !== null\n && typeof _typescript === 'object'\n && 'strictTypescriptEslint' in _typescript\n && _typescript.strictTypescriptEslint === true\n ) {\n _typescript = mergeWithDefaults(typescript, defaultStrictTsConfig)\n if (typeof _typescript === 'object' && 'tsconfigPath' in _typescript) {\n (_typescript as OptionsTypeScriptParserOptions).parserOptions = {\n projectService: true,\n }\n }\n }\n\n return antfu({\n type,\n ignores,\n pnpm: _pnpm,\n test: _test,\n unocss: _unocss,\n vue: _vue,\n nextjs,\n react,\n jsx,\n typescript: _typescript,\n javascript: _javascript,\n stylistic: _stylistic,\n formatters: _formatters,\n })\n}\n"],"mappings":";;;;;AAqBA,eAAsB,YAAY,UAAyB,EAAE,EAAqC;AAChG,QAAO,QAAQ,QAAQ;;AAGzB,eAA8B,QAAQ,UAAyB,EAAE,EAAqC;CACpG,MAAM,EACJ,OAAO,OACP,UAAU,EAAE,EACZ,OAAO,MACP,SAAS,OACT,QAAQ,OACR,SAAS,OACT,MAAM,OACN,MAAM,OACN,OAAO,OACP,YAAY,MACZ,aAAaA,wCACb,aAAaC,wCACb,aAAa,UACX;CAEJ,MAAM,QAAQC,yCAAkB,MAAMC,yCAAkB;CACxD,MAAM,UAAUD,yCAAkB,QAAQE,2CAAoB;CAC9D,MAAM,OAAOF,yCAAkB,KAAKG,wCAAiB;CACrD,MAAM,cAAcH,yCAAkB,YAAYF,uCAAgB;CAClE,MAAM,aAAaE,yCAAkB,WAAWI,8CAAuB;CACvE,MAAM,cAAcJ,yCAAkB,YAAYK,8CAAuB;CACzE,IAAI,cAAc;CAGlB,IAAI,QAAQ;AACZ,KAAI,SAAS,MACX,SAAQ;AAIV,KACE,gBAAgB,QACb,OAAO,gBAAgB,YACvB,4BAA4B,eAC5B,YAAY,2BAA2B,MAC1C;AACA,gBAAcL,yCAAkB,YAAYM,6CAAsB;AAClE,MAAI,OAAO,gBAAgB,YAAY,kBAAkB,YACvD,CAAC,YAA+C,gBAAgB,EAC9D,gBAAgB,MACjB;;AAIL,yCAAa;EACX;EACA;EACA,MAAM;EACN,MAAM;EACN,QAAQ;EACR,KAAK;EACL;EACA;EACA;EACA,YAAY;EACZ,YAAY;EACZ,WAAW;EACX,YAAY;EACb,CAAC"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AntFuFormatterConfig, AntFuJsConfig, AntFuStrictTsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig } from "./types/index.cjs";
|
|
2
|
+
import { antfu } from "@antfu/eslint-config";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
interface ConfigOptions {
|
|
6
|
+
type?: "app" | "lib";
|
|
7
|
+
pnpm?: boolean;
|
|
8
|
+
test?: boolean | AntFuTestConfig;
|
|
9
|
+
ignores?: string[];
|
|
10
|
+
jsx?: boolean;
|
|
11
|
+
nextjs?: boolean;
|
|
12
|
+
react?: boolean;
|
|
13
|
+
vue?: boolean | AntFuVueConfig;
|
|
14
|
+
formatters?: boolean | AntFuFormatterConfig;
|
|
15
|
+
javascript?: AntFuJsConfig;
|
|
16
|
+
typescript?: boolean | AntFuStrictTsConfig | AntFuTsConfig;
|
|
17
|
+
unocss?: boolean | AntFuUnocssConfig;
|
|
18
|
+
stylistic?: boolean | AntFuStylisticConfig;
|
|
19
|
+
}
|
|
20
|
+
declare function applyPreset(options?: ConfigOptions): Promise<ReturnType<typeof antfu>>;
|
|
21
|
+
declare function eslint9(options?: ConfigOptions): Promise<ReturnType<typeof antfu>>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ConfigOptions, applyPreset, eslint9 as default };
|
|
24
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;UAKiB,aAAA;;EAAjB,IAAiB,CAAA,EAAA,OAAA;EAGE,IAAA,CAAA,EAAA,OAAA,GAAA,eAAA;EAKD,OAAA,CAAA,EAAA,MAAA,EAAA;EACO,GAAA,CAAA,EAAA,OAAA;EACV,MAAA,CAAA,EAAA,OAAA;EACU,KAAA,CAAA,EAAA,OAAA;EAAsB,GAAA,CAAA,EAAA,OAAA,GAH7B,cAG6B;EAC1B,UAAA,CAAA,EAAA,OAAA,GAHI,oBAGJ;EACG,UAAA,CAAA,EAHT,aAGS;EAAA,UAAA,CAAA,EAAA,OAAA,GAFC,mBAED,GAFuB,aAEvB;EAGxB,MAAsB,CAAA,EAAA,OAAA,GAJD,iBAIC;EAAqB,SAAA,CAAA,EAAA,OAAA,GAHnB,oBAGmB;;AAA6B,iBAAlD,WAAA,CAAkD,OAAA,CAAA,EAA7B,aAA6B,CAAA,EAAR,OAAQ,CAAA,UAAA,CAAA,OAAkB,KAAlB,CAAA,CAAA;AAAR,iBAIlC,OAAA,CAJkC,OAAA,CAAA,EAIjB,aAJiB,CAAA,EAII,OAJJ,CAIY,UAJZ,CAAA,OAI8B,KAJ9B,CAAA,CAAA"}
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import antfu$1 from "@antfu/eslint-config";
|
|
2
|
+
|
|
3
|
+
//#region src/types/index.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* AntFu Config
|
|
7
|
+
*/
|
|
8
|
+
type AntFuConfig = NonNullable<Parameters<typeof antfu$1>[0]>;
|
|
9
|
+
/**
|
|
10
|
+
* typescript config options
|
|
11
|
+
*/
|
|
12
|
+
type AntFuTsConfig = Exclude<AntFuConfig["typescript"], boolean | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* javascript config options
|
|
15
|
+
*/
|
|
16
|
+
type AntFuJsConfig = Exclude<AntFuConfig["javascript"], boolean | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* vue config options
|
|
19
|
+
*/
|
|
20
|
+
type AntFuVueConfig = Exclude<AntFuConfig["vue"], boolean | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* unocss config options
|
|
23
|
+
*/
|
|
24
|
+
type AntFuUnocssConfig = Exclude<AntFuConfig["unocss"], boolean | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* stylistic config options
|
|
27
|
+
*/
|
|
28
|
+
type AntFuStylisticConfig = Exclude<AntFuConfig["stylistic"], boolean | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* formatter config options
|
|
31
|
+
*/
|
|
32
|
+
type AntFuFormatterConfig = Exclude<AntFuConfig["formatters"], boolean | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* test config options
|
|
35
|
+
*/
|
|
36
|
+
type AntFuTestConfig = Exclude<AntFuConfig["test"], boolean | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* 严格的 typescript config
|
|
39
|
+
*/
|
|
40
|
+
type AntFuStrictTsConfig = AntFuTsConfig & {
|
|
41
|
+
strictTypescriptEslint: true;
|
|
42
|
+
tsconfigPath: string;
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { AntFuConfig, AntFuFormatterConfig, AntFuJsConfig, AntFuStrictTsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig };
|
|
46
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAAwD,KAA5C,WAAA,GAAc,WAA8B,CAAlB,UAAkB,CAAA,OAAA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;;AAK5C,KAAA,aAAA,GAAgB,OAAQ,CAAA,WAAR,CAAA,YAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;AAK5B;AAKA;AAKA;AAKY,KAfA,aAAA,GAAgB,OAehB,CAfwB,WAeO,CAAA,YAAR,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;AAKnC;AAKA;AAIA;KAxBY,cAAA,GAAiB,QAAQ;;;;KAKzB,iBAAA,GAAoB,QAAQ;;;;KAK5B,oBAAA,GAAuB,QAAQ;;;;KAK/B,oBAAA,GAAuB,QAAQ;;;;KAK/B,eAAA,GAAkB,QAAQ;;;;KAI1B,mBAAA,GAAsB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truenine/eslint9-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.20",
|
|
5
5
|
"description": "ESLint 9 configuration package for Compose Client projects with TypeScript, Vue, and modern JavaScript support",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "TrueNine",
|
|
@@ -48,41 +48,38 @@
|
|
|
48
48
|
"README.md",
|
|
49
49
|
"dist"
|
|
50
50
|
],
|
|
51
|
-
"engines": {
|
|
52
|
-
"node": ">=18.0.0"
|
|
53
|
-
},
|
|
54
51
|
"publishConfig": {
|
|
55
52
|
"access": "public",
|
|
56
53
|
"registry": "https://registry.npmjs.org/"
|
|
57
54
|
},
|
|
58
55
|
"peerDependencies": {
|
|
59
|
-
"@antfu/eslint-config": "^6.
|
|
60
|
-
"@eslint/js": "^9.39.
|
|
61
|
-
"@next/eslint-plugin-next": "^16.0.
|
|
62
|
-
"@unocss/eslint-config": "^66.5.
|
|
56
|
+
"@antfu/eslint-config": "^6.7.1",
|
|
57
|
+
"@eslint/js": "^9.39.2",
|
|
58
|
+
"@next/eslint-plugin-next": "^16.0.10",
|
|
59
|
+
"@unocss/eslint-config": "^66.5.10",
|
|
63
60
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
64
61
|
"@vue/eslint-config-typescript": "^14.6.0",
|
|
65
|
-
"eslint": "^9.39.
|
|
66
|
-
"eslint-plugin-format": "^1.0
|
|
62
|
+
"eslint": "^9.39.2",
|
|
63
|
+
"eslint-plugin-format": "^1.1.0",
|
|
67
64
|
"eslint-plugin-prettier": "^5.5.4",
|
|
68
|
-
"eslint-plugin-vue": "^10.
|
|
69
|
-
"prettier": "^3.
|
|
70
|
-
"typescript-eslint": "^8.
|
|
65
|
+
"eslint-plugin-vue": "^10.6.2",
|
|
66
|
+
"prettier": "^3.7.4",
|
|
67
|
+
"typescript-eslint": "^8.50.0"
|
|
71
68
|
},
|
|
72
69
|
"dependencies": {
|
|
73
|
-
"@antfu/eslint-config": "^6.
|
|
74
|
-
"@eslint/js": "^9.39.
|
|
75
|
-
"@next/eslint-plugin-next": "^16.0.
|
|
76
|
-
"@unocss/eslint-config": "^66.5.
|
|
70
|
+
"@antfu/eslint-config": "^6.7.1",
|
|
71
|
+
"@eslint/js": "^9.39.2",
|
|
72
|
+
"@next/eslint-plugin-next": "^16.0.10",
|
|
73
|
+
"@unocss/eslint-config": "^66.5.10",
|
|
77
74
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
78
75
|
"@vue/eslint-config-typescript": "^14.6.0",
|
|
79
|
-
"eslint": "^9.39.
|
|
80
|
-
"eslint-plugin-format": "^1.0
|
|
76
|
+
"eslint": "^9.39.2",
|
|
77
|
+
"eslint-plugin-format": "^1.1.0",
|
|
81
78
|
"eslint-plugin-prettier": "^5.5.4",
|
|
82
|
-
"eslint-plugin-vue": "^10.
|
|
83
|
-
"prettier": "^3.
|
|
79
|
+
"eslint-plugin-vue": "^10.6.2",
|
|
80
|
+
"prettier": "^3.7.4",
|
|
84
81
|
"typescript": "^5.9.3",
|
|
85
|
-
"typescript-eslint": "^8.
|
|
82
|
+
"typescript-eslint": "^8.50.0"
|
|
86
83
|
},
|
|
87
84
|
"scripts": {
|
|
88
85
|
"build": "tsdown",
|