@fast-china/eslint-config 1.0.48 → 1.1.0

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.d.ts CHANGED
@@ -1,19 +1,57 @@
1
1
  import * as eslint_config from 'eslint/config';
2
+ export { R as RuleOptions, d as defineRules } from './define-rules-CSwQ8C1q.js';
3
+ import 'eslint';
2
4
 
3
5
  /**
4
6
  * 公共配置
5
7
  * @description 最佳实践
6
8
  */
9
+ declare const createCommonConfigs: (files?: readonly string[]) => eslint_config.Config[];
7
10
  declare const commonConfigs: eslint_config.Config[];
8
11
 
12
+ type RuntimeEnvironment = "browser" | "node" | "universal";
13
+ /**
14
+ * 创建运行时环境相关的 ESLint 配置。
15
+ *
16
+ * 用于为应用源码配置对应运行环境的全局变量,
17
+ * 同时为 Node.js 工程脚本单独启用 Node.js 全局变量。
18
+ *
19
+ * @param environment 运行时环境,默认为浏览器环境
20
+ * @param files 应用源码匹配规则,默认为所有代码文件
21
+ * @returns ESLint Flat Config 配置数组
22
+ */
23
+ declare const createEnvironmentConfigs: (environment?: RuntimeEnvironment, files?: readonly string[]) => eslint_config.Config[];
24
+ /**
25
+ * 浏览器应用环境配置。
26
+ *
27
+ * 适用于普通 Vue、React 等浏览器端项目。
28
+ */
29
+ declare const browserConfigs: eslint_config.Config[];
30
+ /**
31
+ * Node.js 应用环境配置。
32
+ *
33
+ * 适用于 Node.js 服务、CLI 工具等项目。
34
+ */
35
+ declare const nodeConfigs: eslint_config.Config[];
36
+ /**
37
+ * 通用运行环境配置。
38
+ *
39
+ * 同时启用浏览器和 Node.js 全局变量,
40
+ * 适用于 SSR、同构应用或跨运行时共享代码。
41
+ */
42
+ declare const universalConfigs: eslint_config.Config[];
43
+
9
44
  /**
10
45
  * 忽略配置
11
46
  */
47
+ declare const globalIgnoresConfigs: eslint_config.Config[];
48
+ declare const gitignoreConfigs: eslint_config.Config[];
12
49
  declare const ignoresConfigs: eslint_config.Config[];
13
50
 
14
51
  /**
15
52
  * import配置
16
53
  */
54
+ declare const createImportConfigs: (files?: readonly string[]) => eslint_config.Config[];
17
55
  declare const importConfigs: eslint_config.Config[];
18
56
 
19
57
  /**
@@ -39,6 +77,7 @@ declare const prettierConfigs: eslint_config.Config[];
39
77
  /**
40
78
  * regexp配置
41
79
  */
80
+ declare const createRegexpConfigs: (files?: readonly string[]) => eslint_config.Config[];
42
81
  declare const regexpConfigs: eslint_config.Config[];
43
82
 
44
83
  /**
@@ -51,19 +90,32 @@ declare const packageJsonSortConfigs: eslint_config.Config[];
51
90
  */
52
91
  declare const tsconfigJsonSortConfigs: eslint_config.Config[];
53
92
 
93
+ interface TypeScriptConfigOptions {
94
+ typeChecked?: boolean;
95
+ }
54
96
  /**
55
97
  * TypeScript 核心配置
56
98
  */
99
+ declare const createTypeScriptCoreConfigs: ({ typeChecked }?: TypeScriptConfigOptions) => eslint_config.Config[];
57
100
  declare const typescriptCoreConfigs: eslint_config.Config[];
58
101
  /**
59
102
  * TypeScript配置
60
103
  */
104
+ declare const createTypeScriptConfigs: (options?: TypeScriptConfigOptions) => eslint_config.Config[];
61
105
  declare const typescriptConfigs: eslint_config.Config[];
106
+ declare const typescriptTypeCheckedConfigs: eslint_config.Config[];
62
107
 
108
+ interface VueConfigOptions {
109
+ typeChecked?: boolean;
110
+ version?: 2 | 3;
111
+ }
63
112
  /**
64
113
  * vue配置
65
114
  */
115
+ declare const createVueConfigs: ({ typeChecked, version }?: VueConfigOptions) => eslint_config.Config[];
66
116
  declare const vueConfigs: eslint_config.Config[];
117
+ declare const vue2Configs: eslint_config.Config[];
118
+ declare const vueTypeCheckedConfigs: eslint_config.Config[];
67
119
 
68
120
  /**
69
121
  * JS
@@ -112,11 +164,11 @@ declare const CONST_YAML = "**/*.y?(a)ml";
112
164
  /**
113
165
  * node_modules
114
166
  */
115
- declare const CONST_NODE_MODULES = "**/node_modules";
167
+ declare const CONST_NODE_MODULES = "**/node_modules/**";
116
168
  /**
117
169
  * 打包目录 dist
118
170
  */
119
- declare const CONST_DIST = "**/dist";
171
+ declare const CONST_DIST = "**/dist/**";
120
172
  /**
121
173
  * 包管理 lock 文件
122
174
  */
@@ -129,6 +181,54 @@ declare const CONST_PUBLIC = "**/public";
129
181
  * TS 配置文件
130
182
  */
131
183
  declare const CONST_TSCONFIG: string[];
184
+ /** JavaScript 文件 */
185
+ declare const GLOB_JAVASCRIPT: readonly ["**/*.?([cm])js", "**/*.?([cm])jsx"];
186
+ /** TypeScript 文件 */
187
+ declare const GLOB_TYPESCRIPT: readonly ["**/*.?([cm])ts", "**/*.?([cm])tsx"];
188
+ /** ESLint 可处理的源码文件 */
189
+ declare const GLOB_CODE: readonly ["**/*.?([cm])js", "**/*.?([cm])jsx", "**/*.?([cm])ts", "**/*.?([cm])tsx", "**/*.vue"];
190
+ /** 默认按 Node.js 环境处理的工程文件 */
191
+ declare const GLOB_NODE: readonly ["**/*.{config,setup}.{js,cjs,mjs,ts,cts,mts}", "**/{scripts,bin}/**/*.{js,cjs,mjs,ts,cts,mts}", "**/{test,tests}/**/*.{js,cjs,mjs,ts,cts,mts}", "**/cli.{js,cjs,mjs,ts,cts,mts}"];
192
+
193
+ interface FastConfigOptions {
194
+ /** 运行时全局变量。Vue/Vite 应用通常使用 browser。 */
195
+ environment?: RuntimeEnvironment;
196
+ /** 是否读取项目根目录的 .gitignore。 */
197
+ gitignore?: boolean;
198
+ /** 额外的全局忽略模式。 */
199
+ ignores?: string[];
200
+ /** 是否启用 import-x 规则。 */
201
+ imports?: boolean;
202
+ /** 是否启用 JSON、JSONC、JSON5 规则及常用清单排序。 */
203
+ json?: boolean;
204
+ /** 是否启用 Markdown 规则。 */
205
+ markdown?: boolean;
206
+ /** 是否在末尾关闭与 Prettier 冲突的格式规则。 */
207
+ prettier?: boolean;
208
+ /** 是否启用正则表达式规则。 */
209
+ regexp?: boolean;
210
+ /** TypeScript 支持;传入对象可开启类型感知规则。 */
211
+ typescript?: boolean | TypeScriptConfigOptions;
212
+ /** Vue 支持;默认 Vue 3,也可显式选择 Vue 2。 */
213
+ vue?: boolean | 2 | 3 | VueConfigOptions;
214
+ }
215
+ declare const defaultOptions: Readonly<{
216
+ environment: "browser";
217
+ gitignore: true;
218
+ imports: true;
219
+ json: true;
220
+ markdown: true;
221
+ prettier: true;
222
+ regexp: true;
223
+ typescript: true;
224
+ vue: 3;
225
+ }>;
226
+ /**
227
+ * 创建可组合的 ESLint Flat Config。
228
+ *
229
+ * 返回普通配置数组,可直接展开,也可继续通过 defineConfig 追加项目规则。
230
+ */
231
+ declare const createConfig: (options?: FastConfigOptions) => eslint_config.Config[];
132
232
 
133
233
  /**
134
234
  * JavaScript 预置配置
@@ -140,6 +240,11 @@ declare const PresetJavascriptConfigs: eslint_config.Config[];
140
240
  * JSON 预置配置
141
241
  */
142
242
  declare const PresetJsonConfigs: eslint_config.Config[];
243
+ /**
244
+ * TypeScript 预置配置(不包含 Vue、JSON 和 Markdown)。
245
+ */
246
+ declare const PresetTypescriptConfigs: eslint_config.Config[];
247
+ declare const PresetTypeScriptConfigs: eslint_config.Config[];
143
248
  /**
144
249
  * 基础预置配置
145
250
  *
@@ -147,8 +252,8 @@ declare const PresetJsonConfigs: eslint_config.Config[];
147
252
  */
148
253
  declare const PresetBasicConfigs: eslint_config.Config[];
149
254
  /**
150
- * 默认最全的配置
255
+ * Vue 3 + TypeScript 完整预置配置。
151
256
  */
152
- declare const _default: eslint_config.Config[];
257
+ declare const PresetVueConfigs: eslint_config.Config[];
153
258
 
154
- export { CONST_DIST, CONST_DTS, CONST_JS, CONST_JSON, CONST_JSON5, CONST_JSONC, CONST_JSX, CONST_LOCKFILE, CONST_MD, CONST_NODE_MODULES, CONST_PUBLIC, CONST_TS, CONST_TSCONFIG, CONST_TSX, CONST_VUE, CONST_YAML, PresetBasicConfigs, PresetJavascriptConfigs, PresetJsonConfigs, commonConfigs, _default as default, ignoresConfigs, importConfigs, javascriptConfigs, jsonConfigs, markdownConfigs, packageJsonSortConfigs, prettierConfigs, regexpConfigs, tsconfigJsonSortConfigs, typescriptConfigs, typescriptCoreConfigs, vueConfigs };
259
+ export { CONST_DIST, CONST_DTS, CONST_JS, CONST_JSON, CONST_JSON5, CONST_JSONC, CONST_JSX, CONST_LOCKFILE, CONST_MD, CONST_NODE_MODULES, CONST_PUBLIC, CONST_TS, CONST_TSCONFIG, CONST_TSX, CONST_VUE, CONST_YAML, type FastConfigOptions, GLOB_CODE, GLOB_JAVASCRIPT, GLOB_NODE, GLOB_TYPESCRIPT, PresetBasicConfigs, PresetJavascriptConfigs, PresetJsonConfigs, PresetTypeScriptConfigs, PresetTypescriptConfigs, PresetVueConfigs, type RuntimeEnvironment, type TypeScriptConfigOptions, type VueConfigOptions, browserConfigs, commonConfigs, createCommonConfigs, createConfig, createEnvironmentConfigs, createImportConfigs, createRegexpConfigs, createTypeScriptConfigs, createTypeScriptCoreConfigs, createVueConfigs, PresetVueConfigs as default, defaultOptions, gitignoreConfigs, globalIgnoresConfigs, ignoresConfigs, importConfigs, javascriptConfigs, jsonConfigs, markdownConfigs, nodeConfigs, packageJsonSortConfigs, prettierConfigs, regexpConfigs, tsconfigJsonSortConfigs, typescriptConfigs, typescriptCoreConfigs, typescriptTypeCheckedConfigs, universalConfigs, vue2Configs, vueConfigs, vueTypeCheckedConfigs };