@longzai-intelligence-oxlint/core 0.0.36 → 0.0.38

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.cts CHANGED
@@ -1,45 +1,180 @@
1
1
  //#region src/types/config.types.d.ts
2
+ /**
3
+ * Oxlint 核心类型定义
4
+ *
5
+ * 提供所有 oxlint 相关包共享的类型定义。
6
+ * 仅包含有消费者的类型。
7
+ */
8
+ /**
9
+ * Oxlint 规则严重级别
10
+ */
2
11
  type OxlintSeverity = 'off' | 'warn' | 'error';
12
+ /**
13
+ * Oxlint 规则配置项
14
+ *
15
+ * 单条规则的配置,支持仅严重级别或带选项的配置
16
+ */
3
17
  type OxlintRuleConfig = OxlintSeverity | [OxlintSeverity, ...unknown[]];
18
+ /**
19
+ * Oxlint 规则集
20
+ *
21
+ * 规则名到配置项的映射
22
+ */
4
23
  type OxlintRules = Record<string, OxlintRuleConfig>;
24
+ /**
25
+ * Oxlint 配置覆盖项
26
+ */
5
27
  type OxlintConfigOverride = {
28
+ /**
29
+ * 匹配的文件模式数组
30
+ */
6
31
  files: string[];
32
+ /**
33
+ * 应用于匹配文件的规则配置
34
+ */
7
35
  rules?: OxlintRules;
8
36
  };
37
+ /**
38
+ * Oxlint 配置选项
39
+ */
9
40
  type OxlintConfig = {
41
+ /**
42
+ * 继承的配置列表
43
+ */
10
44
  extends?: OxlintConfig[];
45
+ /**
46
+ * Rust 插件列表
47
+ */
11
48
  plugins?: string[];
49
+ /**
50
+ * JavaScript 插件列表
51
+ */
12
52
  jsPlugins?: string[];
53
+ /**
54
+ * 规则配置
55
+ */
13
56
  rules?: OxlintRules;
57
+ /**
58
+ * 针对特定文件的配置覆盖
59
+ */
14
60
  overrides?: OxlintConfigOverride[];
61
+ /**
62
+ * 忽略的文件模式列表
63
+ */
15
64
  ignorePatterns?: string[];
16
65
  };
66
+ /**
67
+ * defineOxlintConfig 工厂函数的选项参数
68
+ *
69
+ * 所有字段均为可选,工厂函数内部提供完整的默认值。
70
+ * 传入的值会与默认值合并,不会替换。
71
+ */
17
72
  type OxlintConfigOptions = {
73
+ /**
74
+ * 额外的规则配置,与默认规则合并
75
+ */
18
76
  rules?: OxlintRules;
77
+ /**
78
+ * 额外的文件覆盖配置,追加到默认覆盖之后
79
+ */
19
80
  overrides?: OxlintConfigOverride[];
81
+ /**
82
+ * 额外的忽略模式,追加到默认忽略模式之后
83
+ */
20
84
  ignorePatterns?: string[];
85
+ /**
86
+ * 额外的 Rust 插件,追加到默认插件列表之后
87
+ */
21
88
  plugins?: string[];
89
+ /**
90
+ * JS 插件列表,替代默认的 JS 插件列表
91
+ */
22
92
  jsPlugins?: string[];
23
93
  };
24
94
  //#endregion
25
95
  //#region src/defaults/define-oxlint-config.config.d.ts
96
+ /**
97
+ * 创建 Oxlint 配置
98
+ *
99
+ * 工厂函数内部自动组装所有默认规则、默认覆盖、默认忽略模式和默认插件。
100
+ * 调用方只需传入项目特定参数,传入的值会与默认值合并而非替换。
101
+ *
102
+ * @param options - 配置选项,所有字段均为可选
103
+ * @returns Oxlint 配置对象
104
+ */
26
105
  declare function defineOxlintConfig(options?: OxlintConfigOptions): OxlintConfig;
27
106
  //#endregion
28
107
  //#region src/defaults/oxlint-defaults.config.d.ts
108
+ /**
109
+ * Oxlint 原生规则默认配置
110
+ *
111
+ * 明文列出 oxlint 原生规则的默认值,作为组织级共享配置的配置源。
112
+ * 配置参考:https://oxc.rs/docs/guide/usage/linter/rules.html
113
+ */
29
114
  declare const oxlintDefaults: Record<string, OxlintRuleConfig>;
30
115
  //#endregion
31
116
  //#region src/defaults/typescript-eslint-defaults.config.d.ts
117
+ /**
118
+ * Oxlint 原生规则默认配置 - typescript-eslint 推荐规则
119
+ *
120
+ * typescript-eslint/recommended 中 Oxlint 原生支持的规则默认值,
121
+ * 作为组织级共享配置的配置源。
122
+ * Oxlint 中 typescript 规则带 typescript/ 前缀。
123
+ */
32
124
  declare const typescriptEslintRecommendedDefaults: Record<string, OxlintRuleConfig>;
125
+ /**
126
+ * typescript-eslint 默认覆盖配置
127
+ *
128
+ * 核心规则的文件级豁免,确保共享包出厂配置即可正确处理各文件类型。
129
+ */
33
130
  declare const typescriptEslintDefaultOverrides: OxlintConfigOverride[];
34
131
  //#endregion
35
132
  //#region src/defaults/unicorn-defaults.config.d.ts
133
+ /**
134
+ * Oxlint 原生规则默认配置 - unicorn 规则
135
+ *
136
+ * 明文列出 oxlint unicorn 插件规则的默认值,作为组织级共享配置的配置源。
137
+ * 配置参考:https://oxc.rs/docs/guide/usage/linter/rules.html
138
+ */
36
139
  declare const unicornDefaults: Record<string, OxlintRuleConfig>;
37
140
  //#endregion
38
141
  //#region src/utils/infer-caller-dir.utils.d.ts
142
+ /**
143
+ * 从堆栈行中提取文件路径
144
+ *
145
+ * @param line - 堆栈行
146
+ * @returns 文件路径,无法提取时返回 null
147
+ */
39
148
  declare function extractFilePathFromStackLine(line: string): string | null;
149
+ /**
150
+ * 检查文件路径是否为 oxlint 配置文件
151
+ *
152
+ * @param filePath - 文件路径
153
+ * @returns 是否为 oxlint 配置文件
154
+ */
40
155
  declare function isOxlintConfigPath(filePath: string): boolean;
156
+ /**
157
+ * 从文件路径提取目录路径
158
+ *
159
+ * @param filePath - 文件路径
160
+ * @returns 目录路径
161
+ */
41
162
  declare function extractDirFromFilePath(filePath: string): string;
163
+ /**
164
+ * 从堆栈字符串中推断 oxlint 配置文件所在目录
165
+ *
166
+ * @param stack - 堆栈字符串
167
+ * @returns 目录路径,无法推断时返回 undefined
168
+ */
42
169
  declare function inferDirFromStack(stack: string): string | undefined;
170
+ /**
171
+ * 通过调用栈推断调用者目录
172
+ *
173
+ * 该函数解析 Error.stack 获取调用配置函数的文件路径
174
+ * 支持 V8 引擎 (Node.js/Bun/Chrome) 的堆栈格式
175
+ *
176
+ * @returns 调用者文件所在目录,推断失败时返回 undefined
177
+ */
43
178
  declare function inferCallerDir(): string | undefined;
44
179
  //#endregion
45
180
  export { OxlintConfig, OxlintConfigOptions, OxlintConfigOverride, OxlintRuleConfig, OxlintRules, OxlintSeverity, defineOxlintConfig, extractDirFromFilePath, extractFilePathFromStackLine, inferCallerDir, inferDirFromStack, isOxlintConfigPath, oxlintDefaults, typescriptEslintDefaultOverrides, typescriptEslintRecommendedDefaults, unicornDefaults };
package/dist/index.d.mts CHANGED
@@ -1,45 +1,180 @@
1
1
  //#region src/types/config.types.d.ts
2
+ /**
3
+ * Oxlint 核心类型定义
4
+ *
5
+ * 提供所有 oxlint 相关包共享的类型定义。
6
+ * 仅包含有消费者的类型。
7
+ */
8
+ /**
9
+ * Oxlint 规则严重级别
10
+ */
2
11
  type OxlintSeverity = 'off' | 'warn' | 'error';
12
+ /**
13
+ * Oxlint 规则配置项
14
+ *
15
+ * 单条规则的配置,支持仅严重级别或带选项的配置
16
+ */
3
17
  type OxlintRuleConfig = OxlintSeverity | [OxlintSeverity, ...unknown[]];
18
+ /**
19
+ * Oxlint 规则集
20
+ *
21
+ * 规则名到配置项的映射
22
+ */
4
23
  type OxlintRules = Record<string, OxlintRuleConfig>;
24
+ /**
25
+ * Oxlint 配置覆盖项
26
+ */
5
27
  type OxlintConfigOverride = {
28
+ /**
29
+ * 匹配的文件模式数组
30
+ */
6
31
  files: string[];
32
+ /**
33
+ * 应用于匹配文件的规则配置
34
+ */
7
35
  rules?: OxlintRules;
8
36
  };
37
+ /**
38
+ * Oxlint 配置选项
39
+ */
9
40
  type OxlintConfig = {
41
+ /**
42
+ * 继承的配置列表
43
+ */
10
44
  extends?: OxlintConfig[];
45
+ /**
46
+ * Rust 插件列表
47
+ */
11
48
  plugins?: string[];
49
+ /**
50
+ * JavaScript 插件列表
51
+ */
12
52
  jsPlugins?: string[];
53
+ /**
54
+ * 规则配置
55
+ */
13
56
  rules?: OxlintRules;
57
+ /**
58
+ * 针对特定文件的配置覆盖
59
+ */
14
60
  overrides?: OxlintConfigOverride[];
61
+ /**
62
+ * 忽略的文件模式列表
63
+ */
15
64
  ignorePatterns?: string[];
16
65
  };
66
+ /**
67
+ * defineOxlintConfig 工厂函数的选项参数
68
+ *
69
+ * 所有字段均为可选,工厂函数内部提供完整的默认值。
70
+ * 传入的值会与默认值合并,不会替换。
71
+ */
17
72
  type OxlintConfigOptions = {
73
+ /**
74
+ * 额外的规则配置,与默认规则合并
75
+ */
18
76
  rules?: OxlintRules;
77
+ /**
78
+ * 额外的文件覆盖配置,追加到默认覆盖之后
79
+ */
19
80
  overrides?: OxlintConfigOverride[];
81
+ /**
82
+ * 额外的忽略模式,追加到默认忽略模式之后
83
+ */
20
84
  ignorePatterns?: string[];
85
+ /**
86
+ * 额外的 Rust 插件,追加到默认插件列表之后
87
+ */
21
88
  plugins?: string[];
89
+ /**
90
+ * JS 插件列表,替代默认的 JS 插件列表
91
+ */
22
92
  jsPlugins?: string[];
23
93
  };
24
94
  //#endregion
25
95
  //#region src/defaults/define-oxlint-config.config.d.ts
96
+ /**
97
+ * 创建 Oxlint 配置
98
+ *
99
+ * 工厂函数内部自动组装所有默认规则、默认覆盖、默认忽略模式和默认插件。
100
+ * 调用方只需传入项目特定参数,传入的值会与默认值合并而非替换。
101
+ *
102
+ * @param options - 配置选项,所有字段均为可选
103
+ * @returns Oxlint 配置对象
104
+ */
26
105
  declare function defineOxlintConfig(options?: OxlintConfigOptions): OxlintConfig;
27
106
  //#endregion
28
107
  //#region src/defaults/oxlint-defaults.config.d.ts
108
+ /**
109
+ * Oxlint 原生规则默认配置
110
+ *
111
+ * 明文列出 oxlint 原生规则的默认值,作为组织级共享配置的配置源。
112
+ * 配置参考:https://oxc.rs/docs/guide/usage/linter/rules.html
113
+ */
29
114
  declare const oxlintDefaults: Record<string, OxlintRuleConfig>;
30
115
  //#endregion
31
116
  //#region src/defaults/typescript-eslint-defaults.config.d.ts
117
+ /**
118
+ * Oxlint 原生规则默认配置 - typescript-eslint 推荐规则
119
+ *
120
+ * typescript-eslint/recommended 中 Oxlint 原生支持的规则默认值,
121
+ * 作为组织级共享配置的配置源。
122
+ * Oxlint 中 typescript 规则带 typescript/ 前缀。
123
+ */
32
124
  declare const typescriptEslintRecommendedDefaults: Record<string, OxlintRuleConfig>;
125
+ /**
126
+ * typescript-eslint 默认覆盖配置
127
+ *
128
+ * 核心规则的文件级豁免,确保共享包出厂配置即可正确处理各文件类型。
129
+ */
33
130
  declare const typescriptEslintDefaultOverrides: OxlintConfigOverride[];
34
131
  //#endregion
35
132
  //#region src/defaults/unicorn-defaults.config.d.ts
133
+ /**
134
+ * Oxlint 原生规则默认配置 - unicorn 规则
135
+ *
136
+ * 明文列出 oxlint unicorn 插件规则的默认值,作为组织级共享配置的配置源。
137
+ * 配置参考:https://oxc.rs/docs/guide/usage/linter/rules.html
138
+ */
36
139
  declare const unicornDefaults: Record<string, OxlintRuleConfig>;
37
140
  //#endregion
38
141
  //#region src/utils/infer-caller-dir.utils.d.ts
142
+ /**
143
+ * 从堆栈行中提取文件路径
144
+ *
145
+ * @param line - 堆栈行
146
+ * @returns 文件路径,无法提取时返回 null
147
+ */
39
148
  declare function extractFilePathFromStackLine(line: string): string | null;
149
+ /**
150
+ * 检查文件路径是否为 oxlint 配置文件
151
+ *
152
+ * @param filePath - 文件路径
153
+ * @returns 是否为 oxlint 配置文件
154
+ */
40
155
  declare function isOxlintConfigPath(filePath: string): boolean;
156
+ /**
157
+ * 从文件路径提取目录路径
158
+ *
159
+ * @param filePath - 文件路径
160
+ * @returns 目录路径
161
+ */
41
162
  declare function extractDirFromFilePath(filePath: string): string;
163
+ /**
164
+ * 从堆栈字符串中推断 oxlint 配置文件所在目录
165
+ *
166
+ * @param stack - 堆栈字符串
167
+ * @returns 目录路径,无法推断时返回 undefined
168
+ */
42
169
  declare function inferDirFromStack(stack: string): string | undefined;
170
+ /**
171
+ * 通过调用栈推断调用者目录
172
+ *
173
+ * 该函数解析 Error.stack 获取调用配置函数的文件路径
174
+ * 支持 V8 引擎 (Node.js/Bun/Chrome) 的堆栈格式
175
+ *
176
+ * @returns 调用者文件所在目录,推断失败时返回 undefined
177
+ */
43
178
  declare function inferCallerDir(): string | undefined;
44
179
  //#endregion
45
180
  export { OxlintConfig, OxlintConfigOptions, OxlintConfigOverride, OxlintRuleConfig, OxlintRules, OxlintSeverity, defineOxlintConfig, extractDirFromFilePath, extractFilePathFromStackLine, inferCallerDir, inferDirFromStack, isOxlintConfigPath, oxlintDefaults, typescriptEslintDefaultOverrides, typescriptEslintRecommendedDefaults, unicornDefaults };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-oxlint/core",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist"