@longzai-intelligence-oxlint/presets 0.2.9 → 0.2.11
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/base.d.ts +2 -2
- package/dist/{base.entry-CejDIGVV.d.ts → base.entry-DB5ATUd4.d.ts} +2 -4
- package/dist/electron.d.ts +2 -4
- package/dist/elysia.d.ts +2 -4
- package/dist/expo.d.ts +2 -2
- package/dist/fumadocs.d.ts +2 -2
- package/dist/{fumadocs.entry-C7QzCdVJ.d.ts → fumadocs.entry-DI6V68LH.d.ts} +2 -6
- package/dist/hono.d.ts +2 -2
- package/dist/{index-eNRova_s.d.ts → index-7B-WMfha.d.ts} +0 -2
- package/dist/index.d.ts +8 -10
- package/dist/library.d.ts +2 -4
- package/dist/mcp.d.ts +2 -2
- package/dist/nest.d.ts +2 -4
- package/dist/next.d.ts +2 -2
- package/dist/{next.entry-moZEmUkw.d.ts → next.entry-flJkkYfV.d.ts} +2 -6
- package/dist/node.d.ts +2 -2
- package/dist/plugins/architecture-core.js +1 -1
- package/dist/plugins/code-style.js +1 -1
- package/dist/plugins/stylistic.js +1 -1
- package/dist/{preset-options.types-Czyi-DdY.d.ts → preset-options.types-Ch-eTtkd.d.ts} +1 -3
- package/dist/react.d.ts +2 -4
- package/dist/root.d.ts +2 -2
- package/dist/{root.entry-D3HRGFNj.d.ts → root.entry-DW6F5jjU.d.ts} +2 -6
- package/dist/rules.d.ts +1 -1
- package/dist/taro.d.ts +2 -2
- package/dist/{taro.entry-DuohnWen.d.ts → taro.entry-DQK7ypZY.d.ts} +2 -6
- package/dist/{unicorn.rules-CoZq5SQL.d.ts → unicorn.rules-DgKAk9wi.d.ts} +1 -7
- package/package.json +28 -28
package/dist/base.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
2
|
-
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-
|
|
1
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
2
|
+
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-DB5ATUd4.js";
|
|
3
3
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintBaseConfig as default, defineConfig };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { t as OxlintConfig } from "./index-
|
|
3
|
-
import { t as PresetOptions } from "./preset-options.types-
|
|
4
|
-
//#region src/entries/base.entry.d.ts
|
|
2
|
+
import { t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Ch-eTtkd.js";
|
|
5
4
|
/**
|
|
6
5
|
* 创建 Oxlint Base 配置
|
|
7
6
|
*
|
|
@@ -13,5 +12,4 @@ declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
|
13
12
|
* 默认 Oxlint Base 配置实例
|
|
14
13
|
*/
|
|
15
14
|
declare const oxlintBaseConfig: OxlintConfig;
|
|
16
|
-
//#endregion
|
|
17
15
|
export { oxlintBaseConfig as n, defineConfig as t };
|
package/dist/electron.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
3
|
-
import { t as PresetOptions } from "./preset-options.types-
|
|
4
|
-
//#region src/entries/electron.entry.d.ts
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Ch-eTtkd.js";
|
|
5
4
|
/**
|
|
6
5
|
* 创建 Oxlint Electron 配置
|
|
7
6
|
*
|
|
@@ -13,5 +12,4 @@ declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
|
13
12
|
* 默认 Oxlint Electron 配置实例
|
|
14
13
|
*/
|
|
15
14
|
declare const oxlintElectronConfig: OxlintConfig;
|
|
16
|
-
//#endregion
|
|
17
15
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintElectronConfig as default, defineConfig };
|
package/dist/elysia.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
3
|
-
import { t as PresetOptions } from "./preset-options.types-
|
|
4
|
-
//#region src/entries/elysia.entry.d.ts
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Ch-eTtkd.js";
|
|
5
4
|
/**
|
|
6
5
|
* 创建 Oxlint Elysia 配置
|
|
7
6
|
*
|
|
@@ -13,5 +12,4 @@ declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
|
13
12
|
* 默认 Oxlint Elysia 配置实例
|
|
14
13
|
*/
|
|
15
14
|
declare const oxlintElysiaConfig: OxlintConfig;
|
|
16
|
-
//#endregion
|
|
17
15
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintElysiaConfig as default, defineConfig };
|
package/dist/expo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
3
|
-
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-DB5ATUd4.js";
|
|
4
4
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintBaseConfig as default, defineConfig };
|
package/dist/fumadocs.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
2
|
-
import { i as FUMADOCS_SPECIAL_FILE_PATTERNS, n as oxFumadocsConfig, r as FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS, t as defineConfig } from "./fumadocs.entry-
|
|
1
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
2
|
+
import { i as FUMADOCS_SPECIAL_FILE_PATTERNS, n as oxFumadocsConfig, r as FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS, t as defineConfig } from "./fumadocs.entry-DI6V68LH.js";
|
|
3
3
|
export { FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS, FUMADOCS_SPECIAL_FILE_PATTERNS, type OxlintConfig, type OxlintConfigOverride, oxFumadocsConfig as default, defineConfig };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { t as OxlintConfig } from "./index-
|
|
3
|
-
import { t as PresetOptions } from "./preset-options.types-
|
|
4
|
-
//#region src/defaults/fumadocs.patterns.d.ts
|
|
2
|
+
import { t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Ch-eTtkd.js";
|
|
5
4
|
/**
|
|
6
5
|
* fumadocs 预设 - 文档站底座约定文件模式
|
|
7
6
|
*
|
|
@@ -27,8 +26,6 @@ declare const FUMADOCS_SPECIAL_FILE_PATTERNS: string[];
|
|
|
27
26
|
* 口径仅限底座约定文件,不随消费方自定义命名扩面
|
|
28
27
|
*/
|
|
29
28
|
declare const FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS: string[];
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/entries/fumadocs.entry.d.ts
|
|
32
29
|
/**
|
|
33
30
|
* fumadocs 预设选项
|
|
34
31
|
*
|
|
@@ -57,5 +54,4 @@ declare function defineConfig(options?: FumadocsPresetOptions): OxlintConfig;
|
|
|
57
54
|
* 默认 Oxlint fumadocs 配置实例
|
|
58
55
|
*/
|
|
59
56
|
declare const oxFumadocsConfig: OxlintConfig;
|
|
60
|
-
//#endregion
|
|
61
57
|
export { FUMADOCS_SPECIAL_FILE_PATTERNS as i, oxFumadocsConfig as n, FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS as r, defineConfig as t };
|
package/dist/hono.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
3
|
-
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-DB5ATUd4.js";
|
|
4
4
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintBaseConfig as default, defineConfig };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region ../core/dist/index.d.ts
|
|
2
1
|
//#region src/types/config.types.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Oxlint 核心类型定义
|
|
@@ -64,5 +63,4 @@ type OxlintConfig = {
|
|
|
64
63
|
*/
|
|
65
64
|
ignorePatterns?: string[];
|
|
66
65
|
};
|
|
67
|
-
//#endregion
|
|
68
66
|
export { OxlintRules as i, OxlintConfigOverride as n, OxlintRuleConfig as r, OxlintConfig as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { i as OxlintRules, n as OxlintConfigOverride, r as OxlintRuleConfig, t as OxlintConfig } from "./index-
|
|
3
|
-
import { t as PresetOptions } from "./preset-options.types-
|
|
4
|
-
import { t as defineConfig } from "./base.entry-
|
|
2
|
+
import { i as OxlintRules, n as OxlintConfigOverride, r as OxlintRuleConfig, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Ch-eTtkd.js";
|
|
4
|
+
import { t as defineConfig } from "./base.entry-DB5ATUd4.js";
|
|
5
5
|
import { defineConfig as defineConfig$1 } from "./electron.js";
|
|
6
|
-
import { i as FUMADOCS_SPECIAL_FILE_PATTERNS, r as FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS, t as defineConfig$2 } from "./fumadocs.entry-
|
|
6
|
+
import { i as FUMADOCS_SPECIAL_FILE_PATTERNS, r as FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS, t as defineConfig$2 } from "./fumadocs.entry-DI6V68LH.js";
|
|
7
7
|
import { defineConfig as defineConfig$3 } from "./library.js";
|
|
8
8
|
import { defineConfig as defineConfig$4 } from "./nest.js";
|
|
9
|
-
import { r as NEXTJS_SPECIAL_FILE_PATTERNS, t as defineConfig$5 } from "./next.entry-
|
|
9
|
+
import { r as NEXTJS_SPECIAL_FILE_PATTERNS, t as defineConfig$5 } from "./next.entry-flJkkYfV.js";
|
|
10
10
|
import { defineConfig as defineConfig$6 } from "./react.js";
|
|
11
|
-
import { r as ROOT_WHITELIST_PATTERNS, t as defineConfig$7 } from "./root.entry-
|
|
12
|
-
import { t as defineConfig$8 } from "./taro.entry-
|
|
13
|
-
import { a as ESLINT_CORE_RULES, i as TYPESCRIPT_RECOMMENDED_RULES, n as ESLINT_RECOMMENDED_RULES, r as TYPESCRIPT_PROJECT_RULES, t as UNICORN_RULES } from "./unicorn.rules-
|
|
14
|
-
//#region src/defaults/base.rules.d.ts
|
|
11
|
+
import { r as ROOT_WHITELIST_PATTERNS, t as defineConfig$7 } from "./root.entry-DW6F5jjU.js";
|
|
12
|
+
import { t as defineConfig$8 } from "./taro.entry-DQK7ypZY.js";
|
|
13
|
+
import { a as ESLINT_CORE_RULES, i as TYPESCRIPT_RECOMMENDED_RULES, n as ESLINT_RECOMMENDED_RULES, r as TYPESCRIPT_PROJECT_RULES, t as UNICORN_RULES } from "./unicorn.rules-DgKAk9wi.js";
|
|
15
14
|
/**
|
|
16
15
|
* 合并后的插件推荐配置
|
|
17
16
|
*
|
|
@@ -25,5 +24,4 @@ declare const PLUGIN_DEFAULTS: OxlintRules;
|
|
|
25
24
|
* 生态层覆盖插件 recommended 的无选项形态,require-* 规则由此获得选项默认值
|
|
26
25
|
*/
|
|
27
26
|
declare const ALL_RULES: OxlintRules;
|
|
28
|
-
//#endregion
|
|
29
27
|
export { ALL_RULES, ESLINT_CORE_RULES, ESLINT_RECOMMENDED_RULES, FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS, FUMADOCS_SPECIAL_FILE_PATTERNS, NEXTJS_SPECIAL_FILE_PATTERNS, type OxlintConfig, type OxlintConfigOverride, type OxlintRuleConfig, type OxlintRules, PLUGIN_DEFAULTS, type PresetOptions, ROOT_WHITELIST_PATTERNS, TYPESCRIPT_PROJECT_RULES, TYPESCRIPT_RECOMMENDED_RULES, UNICORN_RULES, defineConfig as defineBaseConfig, defineConfig as defineExpoConfig, defineConfig as defineHonoConfig, defineConfig as defineMcpConfig, defineConfig as defineNodeConfig, defineConfig$1 as defineElectronConfig, defineConfig$2 as defineFumadocsConfig, defineConfig$3 as defineLibraryConfig, defineConfig$4 as defineNestConfig, defineConfig$5 as defineNextConfig, defineConfig$6 as defineReactConfig, defineConfig$7 as defineRootConfig, defineConfig$8 as defineTaroConfig };
|
package/dist/library.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
3
|
-
import { t as PresetOptions } from "./preset-options.types-
|
|
4
|
-
//#region src/entries/library.entry.d.ts
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Ch-eTtkd.js";
|
|
5
4
|
/**
|
|
6
5
|
* 创建 Oxlint Library 配置
|
|
7
6
|
*
|
|
@@ -13,5 +12,4 @@ declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
|
13
12
|
* 默认 Oxlint Library 配置实例
|
|
14
13
|
*/
|
|
15
14
|
declare const oxlintLibraryConfig: OxlintConfig;
|
|
16
|
-
//#endregion
|
|
17
15
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintLibraryConfig as default, defineConfig };
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
3
|
-
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-DB5ATUd4.js";
|
|
4
4
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintBaseConfig as default, defineConfig };
|
package/dist/nest.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
3
|
-
import { t as PresetOptions } from "./preset-options.types-
|
|
4
|
-
//#region src/entries/nest.entry.d.ts
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Ch-eTtkd.js";
|
|
5
4
|
/**
|
|
6
5
|
* 创建 Oxlint Nest 配置
|
|
7
6
|
*
|
|
@@ -13,5 +12,4 @@ declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
|
13
12
|
* 默认 Oxlint Nest 配置实例
|
|
14
13
|
*/
|
|
15
14
|
declare const oxlintNestConfig: OxlintConfig;
|
|
16
|
-
//#endregion
|
|
17
15
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintNestConfig as default, defineConfig };
|
package/dist/next.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
2
|
-
import { n as oxlintNextConfig, r as NEXTJS_SPECIAL_FILE_PATTERNS, t as defineConfig } from "./next.entry-
|
|
1
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
2
|
+
import { n as oxlintNextConfig, r as NEXTJS_SPECIAL_FILE_PATTERNS, t as defineConfig } from "./next.entry-flJkkYfV.js";
|
|
3
3
|
export { NEXTJS_SPECIAL_FILE_PATTERNS, type OxlintConfig, type OxlintConfigOverride, oxlintNextConfig as default, defineConfig };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { t as OxlintConfig } from "./index-
|
|
3
|
-
import { t as PresetOptions } from "./preset-options.types-
|
|
4
|
-
//#region src/defaults/next.patterns.d.ts
|
|
2
|
+
import { t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Ch-eTtkd.js";
|
|
5
4
|
/**
|
|
6
5
|
* Next.js App Router 约定文件模式全集
|
|
7
6
|
*
|
|
8
7
|
* 作为单一真源同时供两条规则注入,见文件头说明
|
|
9
8
|
*/
|
|
10
9
|
declare const NEXTJS_SPECIAL_FILE_PATTERNS: string[];
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/entries/next.entry.d.ts
|
|
13
10
|
/**
|
|
14
11
|
* Next 预设选项
|
|
15
12
|
*
|
|
@@ -38,5 +35,4 @@ declare function defineConfig(options?: NextPresetOptions): OxlintConfig;
|
|
|
38
35
|
* 默认 Oxlint Next 配置实例
|
|
39
36
|
*/
|
|
40
37
|
declare const oxlintNextConfig: OxlintConfig;
|
|
41
|
-
//#endregion
|
|
42
38
|
export { oxlintNextConfig as n, NEXTJS_SPECIAL_FILE_PATTERNS as r, defineConfig as t };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
3
|
-
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-DB5ATUd4.js";
|
|
4
4
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintBaseConfig as default, defineConfig };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import*as n from"zod/mini";const r=[`/packages/platform/`,`/packages/ui/`,`/packages/ui-kit/`,`/packages/engine/`,`/packages/utils/`,`/packages/types/`],i=[],a=[`^validate`,`^calculate`,`^compute`,`^determine`,`^check`,`^can`,`^should`,`^isAllowed`,`^isPermitted`,`^hasPermission`,`^applyRule`,`^enforce`,`^execute`];function o(e){return typeof e==`object`&&!!e}function s(e){let t=Array.isArray(e)?e[0]:e;return o(t)?{techLayerPatterns:t.techLayerPatterns??r,businessKeywords:t.businessKeywords??i,businessRuleMethods:t.businessRuleMethods??a}:{techLayerPatterns:r,businessKeywords:i,businessRuleMethods:a}}function c(e){return e.map(e=>new RegExp(e))}function ee(e,t){let n=e.replace(/\\/g,`/`);return t.some(e=>e.test(n))}function l(e,t){let n=e.charAt(0).toUpperCase()+e.slice(1);return t.some(e=>n.includes(e))}function te(e,t){return t.some(t=>t.test(e))}const u=e({meta:{type:`suggestion`,docs:{description:`检测技术层中可能存在的业务逻辑`}},createOnce(e){let t=[],n=[],r=[];return{before(){let i=s(e.options);return t=c(i.techLayerPatterns),n=i.businessKeywords,r=c(i.businessRuleMethods),ee(e.filename,t)?void 0:!1},ClassDeclaration(t){t.id&&l(t.id.name,n)&&e.report({node:t,message:`业务逻辑泄漏嫌疑: 技术层发现业务相关类 '${t.id.name}'。业务逻辑应该放在 domains/ 层。`})},MethodDefinition(t){t.key.type===`Identifier`&&te(t.key.name,r)&&e.report({node:t,message:`业务逻辑泄漏嫌疑: 技术层发现业务规则方法 '${t.key.name}'。业务规则应该放在 domains/ 层。`})},TSInterfaceDeclaration(t){l(t.id.name,n)&&e.report({node:t,message:`业务逻辑泄漏嫌疑: 技术层发现业务相关接口 '${t.id.name}'。业务接口应该放在 domains/ 层。`})},TSTypeAliasDeclaration(t){l(t.id.name,n)&&e.report({node:t,message:`业务逻辑泄漏嫌疑: 技术层发现业务相关类型 '${t.id.name}'。业务类型应该放在 domains/ 层。`})}}}}),d={types:0,utils:1,"shared-kernel":2,contract:3,engine:4,platform:5,infrastructure:6,implementation:6,domain:6,capability:7,ui:7,"electron-shared":7,"electron-main":8,"electron-preload":8,"electron-renderer":9},ne={types:`类型层 (Types)`,utils:`工具层 (Utils)`,"shared-kernel":`共享内核层 (Shared Kernel)`,contract:`契约层 (Contract)`,engine:`引擎层 (Engine)`,platform:`平台层 (Platform)`,infrastructure:`基础设施层 (Infrastructure)`,implementation:`实现层 (Implementation)`,domain:`门面层 (Domain Facade)`,capability:`能力装配层 (Capability)`,ui:`UI 表现层`,"electron-shared":`Electron 共享层 (Shared)`,"electron-main":`Electron 主进程 (Main)`,"electron-preload":`Electron 预加载层 (Preload)`,"electron-renderer":`Electron 渲染进程 (Renderer)`},re=new Set(Object.keys(d)),f={pathPatterns:[{pattern:/\/apps\/capabilities\//,layer:`capability`},{pattern:/\/domains\/[^/]+\/implementation\//,layer:`implementation`},{pattern:/\/domains\/[^/]+\/contract\//,layer:`contract`},{pattern:/\/domains\/[^/]+\/ui\//,layer:`ui`},{pattern:/\/domains\/shared-kernel\//,layer:`shared-kernel`},{pattern:/\/infrastructure\//,layer:`infrastructure`}],packagePrefix:``,specialPackageMappings:{},packageSuffixMappings:[{suffix:`-contract`,layer:`contract`},{suffix:`-implementation`,layer:`implementation`},{suffix:`-infrastructure`,layer:`infrastructure`},{suffix:`-domain`,layer:`domain`},{suffix:`-ui`,layer:`ui`},{suffix:`-engine`,layer:`engine`},{suffix:`-runtime`,layer:`engine`}]},p=[{from:`capability`,to:`implementation`},{from:`capability`,to:`infrastructure`},{from:`ui`,to:`domain`,hint:`UI 面禁止经门面包取件,域外依赖唯一指向生成式 sdk 客户端,ADR 0127。`},{from:`ui`,to:`contract`,hint:`contract 为 DDD 主体对 UI 全封闭,类型正源为 sdk 生成契约推断类型,ADR 0127。`},{from:`ui`,to:`implementation`,hint:`UI 面禁止直连实现层,域外依赖唯一指向生成式 sdk 客户端,ADR 0127。`},{from:`ui`,to:`infrastructure`,hint:`UI 面禁止直连基础设施层,域外依赖唯一指向生成式 sdk 客户端,ADR 0127。`}],m=[`-main`],h=[{pattern:/\/src\/domain\//,layer:`contract`},{pattern:/\/src\/engine\//,layer:`engine`},{pattern:/\/src\/platform\//,layer:`platform`},{pattern:/\/src\/infrastructure\//,layer:`infrastructure`},{pattern:/\/src\/shared\//,layer:`shared-kernel`}];function g(e){return re.has(e)}function ie(e,t){return d[e]>=d[t]}function _(e){return ne[e]}function ae(e,t){let n=e.replace(/\\/g,`/`),r=t??f.pathPatterns;if(r){for(let{pattern:e,layer:t}of r)if(e.test(n))return{layer:t,priority:d[t]}}if(n.includes(`/apps/`)){for(let{pattern:e,layer:t}of h)if(e.test(n))return{layer:t,priority:d[t]}}if(n.includes(`/packages/`)){for(let{pattern:e,layer:t}of h)if(e.test(n))return{layer:t,priority:d[t]}}return null}function v(e,t){if(!e.startsWith(t))return null;let n=e.split(`/`),r=n[0]===``?n.slice(1):n;return(r[0]?.startsWith(`@`)?r[1]:r[0])??null}function oe(e,t){for(let n of t)if(e.endsWith(n))return n;return null}function se(e,t){let n=t.packagePrefix??``,r=v(e,n);if(!r)return null;let i=(t.specialPackageMappings??{})[`${n}${r}`];if(i)return{layer:i,priority:d[i]};let a=t.packageSuffixMappings??[];for(let{suffix:e,layer:t}of a)if(r.endsWith(e))return{layer:t,priority:d[t]};return null}function ce(e,t,n){return e.find(e=>e.from===t&&e.to===n)??null}function le(e){let t=e.match(/^\/(.+)\/([gimsuvy]*)$/);return t?.[1]?new RegExp(t[1],t[2]??``):new RegExp(e)}function ue(e){let t={};if(e.pathPatterns&&(t.pathPatterns=e.pathPatterns.reduce((e,{pattern:t,layer:n})=>(g(n)&&e.push({pattern:le(t),layer:n}),e),[])),e.packagePrefix&&(t.packagePrefix=e.packagePrefix),e.specialPackageMappings){let n={};for(let[t,r]of Object.entries(e.specialPackageMappings))g(r)&&(n[t]=r);t.specialPackageMappings=Object.keys(n).length>0?n:void 0}if(e.packageSuffixMappings){let n=[];for(let{suffix:t,layer:r}of e.packageSuffixMappings)g(r)&&n.push({suffix:t,layer:r});t.packageSuffixMappings=n.length>0?n:void 0}if(e.forbiddenLayerPairs){let n=[];for(let{from:t,to:r}of e.forbiddenLayerPairs)g(t)&&g(r)&&n.push({from:t,to:r});t.forbiddenLayerPairs=n.length>0?n:void 0}if(e.forbiddenPackageSuffixes){let n=e.forbiddenPackageSuffixes.filter(e=>e.length>0);t.forbiddenPackageSuffixes=n.length>0?n:void 0}return t}function de(e){return typeof e==`object`&&!!e}function fe(e){let t=ue(de(e)?e:{});return{pathPatterns:t.pathPatterns??f.pathPatterns,packagePrefix:t.packagePrefix??f.packagePrefix,specialPackageMappings:t.specialPackageMappings??f.specialPackageMappings,packageSuffixMappings:t.packageSuffixMappings??f.packageSuffixMappings,forbiddenLayerPairs:[...p,...t.forbiddenLayerPairs??[]],forbiddenPackageSuffixes:[...m,...t.forbiddenPackageSuffixes??[]]}}const pe=e({meta:{type:`problem`,docs:{description:`强制执行 Clean Architecture 的依赖方向规则`},schema:[{type:`object`,properties:{pathPatterns:{type:`array`,items:{type:`object`,properties:{pattern:{type:`string`},layer:{type:`string`}},required:[`pattern`,`layer`],additionalProperties:!1}},packagePrefix:{type:`string`},specialPackageMappings:{type:`object`,additionalProperties:{type:`string`}},packageSuffixMappings:{type:`array`,items:{type:`object`,properties:{suffix:{type:`string`},layer:{type:`string`}},required:[`suffix`,`layer`],additionalProperties:!1}},forbiddenLayerPairs:{type:`array`,items:{type:`object`,properties:{from:{type:`string`},to:{type:`string`}},required:[`from`,`to`],additionalProperties:!1}},forbiddenPackageSuffixes:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){let t=null,n=null;return{before(){return t===null&&(t=fe(e.options?.[0])),n=ae(e.filename,t.pathPatterns),n!==null},ImportDeclaration(r){if(!n||!t)return;let i=r.source.type===`Literal`&&typeof r.source.value==`string`?r.source.value:null;if(!i)return;let a=v(i,t.packagePrefix??``);if(a){let n=oe(a,t.forbiddenPackageSuffixes??[]);if(n){e.report({node:r,message:`禁止导入已禁用的 ${n} 门面包,门面包统一使用 -domain 后缀。`});return}}let o=se(i,t);if(!o)return;let s=ce(t.forbiddenLayerPairs??[],n.layer,o.layer);s?e.report({node:r,message:`依赖方向违规: ${n.layer} (${_(n.layer)}) 不能导入 ${o.layer} (${_(o.layer)})。${s.hint??`域内取件必须经 -domain 门面包。`}`}):ie(n.layer,o.layer)||e.report({node:r,message:`依赖方向违规: ${n.layer} (${_(n.layer)}) 不能导入 ${o.layer} (${_(o.layer)})。依赖应该从外层指向内层。`})}}}});function me(e){let t=e.replace(/\\/g,`/`);return t.includes(`/domains/`)&&t.includes(`/implementation/src/index.ts`)}function y(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function b(e){return y(e)&&e.endsWith(`Entity`)}function x(e){return y(e)&&e.endsWith(`Repository`)&&!e.startsWith(`I`)}function S(e){return y(e)&&e.endsWith(`OrmEntity`)}function C(e){return e.endsWith(`_ORM_ENTITIES`)}function w(e){return y(e)&&e.endsWith(`OrmMapper`)}function T(e){return y(e)&&e.endsWith(`Schema`)}function E(e){return`exportKind`in e&&typeof e.exportKind==`string`?e.exportKind===`value`:!0}function D(e){return e.exported.type===`Identifier`?e.exported.name:e.exported.type===`Literal`&&typeof e.exported.value==`string`?e.exported.value:null}function O(e,t,n){b(e)&&E(t)?n.report({node:t,message:`禁止从主入口值导出 Entity 类 "${e}"。请改为类型导出或移除导出。`}):x(e)?n.report({node:t,message:`禁止导出 Repository 类型 "${e}"。Repository 是内部实现,不应暴露给外部。`}):S(e)?n.report({node:t,message:`禁止从主入口导出 ORM 实体 "${e}"。请创建 src/typeorm.ts 入口文件,从该入口导出。`}):C(e)?n.report({node:t,message:`禁止从主入口导出 ORM 实体集合 "${e}"。请创建 src/typeorm.ts 入口文件,从该入口导出。`}):w(e)?n.report({node:t,message:`禁止导出 ORM Mapper "${e}"。ORM Mapper 是基础设施实现细节,不应暴露给外部。`}):T(e)&&n.report({node:t,message:`禁止导出 Schema 定义 "${e}"。Schema 是实现细节,应仅导出推断类型。`})}const k=e({meta:{type:`problem`,docs:{description:`检查 Domain Implementation 包的导出是否符合规范`}},createOnce(e){return{before(){let t=e.filename;if(!me(t))return!1},ExportNamedDeclaration(t){if(t.source&&t.source.type===`Literal`&&typeof t.source.value==`string`)for(let n of t.specifiers){if(n.type!==`ExportSpecifier`)continue;let t=D(n);t&&O(t,n,e)}}}}});function A(e){let t=e.replace(/\\/g,`/`);return t.includes(`/domains/`)&&t.includes(`/implementation/src/index.ts`)}const j=[/\.\/typeorm/,/\.\/typeorm'/,/\.\/typeorm"/],M=[{pattern:/^[A-Z][a-zA-Z0-9]*OrmEntity$/,message:`禁止从主入口导出 ORM 实体。应使用 typeorm 入口导出。`},{pattern:/^[A-Z][a-zA-Z0-9]*Entity$/,message:`禁止从主入口导出 Entity 类。Entity 是内部实现,应使用 contract 包的 DTO。`},{pattern:/^[A-Z][a-zA-Z0-9]*UseCase$/,message:`禁止导出 UseCase 类。UseCase 是内部实现,应通过 Port 接口访问。`},{pattern:/^I[A-Z].*Repository$/,message:`禁止导出 Repository 接口。Repository 是内部接口,外部应通过 Port 访问。`},{pattern:/^create[A-Za-z]+Repository$/,message:`禁止导出 Repository 工厂函数。外部应使用 PortAdapter 工厂函数。`},{pattern:/^[A-Z][a-zA-Z0-9]*Repository[a-zA-Z0-9]*$/,message:`禁止导出 Repository 实现类。应使用工厂函数或 Port 接口。`},{pattern:/^[A-Z][a-zA-Z0-9]*Schema$/,message:`禁止导出 Schema 定义。Schema 是实现细节,应导出推断类型。`},{pattern:/_ORM_ENTITIES$/,message:`禁止从主入口导出实体集合。应使用 typeorm 入口导出。`},{pattern:/^[A-Z][a-zA-Z0-9]*OrmMapper$/,message:`禁止导出 ORM Mapper。这是基础设施实现细节。`},{pattern:/^[A-Z][a-zA-Z0-9]*Table$/,message:`禁止导出数据库表定义。这是数据存储细节。`}];function N(e){return j.some(t=>t.test(e))}function P(e){for(let{pattern:t,message:n}of M)if(t.test(e))return n;return null}function F(e,t){if(e.source){let n=e.source.type===`Literal`&&typeof e.source.value==`string`?e.source.value:null;if(n&&N(n)){t.report({node:e,message:`禁止从主入口重新导出 typeorm.ts 的内容。typeorm.ts 是专门的持久化入口。`});return}}if(e.specifiers){for(let n of e.specifiers)if(n.type===`ExportSpecifier`){let e=n.exported.type===`Identifier`?n.exported.name:n.exported.type===`Literal`&&typeof n.exported.value==`string`?n.exported.value:null;if(e){let r=P(e);r&&t.report({node:n,message:`${e}: ${r}`})}}}e.declaration&&R(e.declaration,t.report)}function I(e,t){if(e.source){let n=e.source.type===`Literal`&&typeof e.source.value==`string`?e.source.value:null;if(n&&N(n)){t.report({node:e,message:`禁止从主入口重新导出 typeorm.ts 的内容。typeorm.ts 是专门的持久化入口。`});return}}t.report({node:e,message:`禁止使用 export *。请使用显式导出,明确导出内容。`})}function L(e,t){z(e.declaration)&&R(e.declaration,t.report)}function R(e,t){if(e.type===`ClassDeclaration`&&e.id){let n=e.id.name,r=P(n);r&&t({node:e,message:`${n}: ${r}`})}else if(e.type===`VariableDeclaration`){for(let n of e.declarations)if(n.id.type===`Identifier`){let e=n.id.name,r=P(e);r&&t({node:n,message:`${e}: ${r}`})}}else if(e.type===`FunctionDeclaration`&&e.id){let n=e.id.name,r=P(n);r&&t({node:e,message:`${n}: ${r}`})}}function z(e){return e.type===`ClassDeclaration`||e.type===`FunctionDeclaration`||e.type===`VariableDeclaration`}const he=e({meta:{type:`problem`,docs:{description:`Implementation 包导出控制:禁止从主入口导出内部实现`}},createOnce(e){return{before(){let t=e.filename;if(!A(t))return!1},ExportNamedDeclaration(t){F(t,e)},ExportAllDeclaration(t){I(t,e)},ExportDefaultDeclaration(t){L(t,e)}}}}),ge=[{alias:`@main`,pathPattern:`src/main`},{alias:`@preload`,pathPattern:`src/preload`},{alias:`@renderer`,pathPattern:`src/renderer/src`},{alias:`@shared`,pathPattern:`src/shared`}];function _e(e){return typeof e==`object`&&!!e&&`packageBoundaries`in e}function B(e,t){let n=e.replace(/\\/g,`/`);for(let e of t){let t=e.pathPattern.replace(/\\/g,`/`);if(n.includes(`/${t}/`)||n.endsWith(`/${t}`)||n.includes(`/${t}\\`))return e.alias}return null}function ve(e,t,n){if(!t.startsWith(`.`))return null;let r=e.replace(/\\/g,`/`),i=r.lastIndexOf(`/`);return B(ye(i>0?r.substring(0,i):``,t),n)}function ye(e,t){let n=(e+`/`+t).split(`/`),r=[];for(let e of n)e===`..`?r.pop():e!==`.`&&e!==``&&r.push(e);return`/`+r.join(`/`)}function be(e){return e.startsWith(`./`)||e.startsWith(`../`)}const xe=e({meta:{type:`problem`,docs:{description:`禁止使用相对路径穿越不同包范围,强制使用别名导入`}},createOnce(e){let t=null;function n(){if(t===null){let n=e.options?.[0],r=n&&typeof n==`object`?n:{};t=_e(r)&&Array.isArray(r.packageBoundaries)?r.packageBoundaries:ge}return t}return{before(){n()},ImportDeclaration(t){let r=e.filename,i=t.source.type===`Literal`&&typeof t.source.value==`string`?t.source.value:null;if(!i||!be(i))return;let a=B(r,n());if(!a)return;let o=ve(r,i,n());o&&a!==o&&e.report({node:t,message:`禁止使用相对路径跨包导入。当前文件位于 "${a}" 包,目标位于 "${o}" 包。请使用别名导入:${o}/...`})}}}}),Se=[`get-port`,`get-port-plus`,`portfinder`,`detect-port`,`find-free-port`,`tcp-port-used`],Ce=[`getPort`,`getFreePort`,`detectPort`],we=[`findAvailablePort`,`findFreePort`,`getFreePort`,`getAvailablePort`,`isPortAvailable`,`isPortFree`,`checkPort`,`checkPortAvailable`,`detectPort`,`ensurePort`,`portCounter`],Te=[`__tests__/`,`.test.`,`.spec.`,`__mocks__/`],Ee=n.object({extraBannedModules:n.optional(n.array(n.string())),extraBannedImportNames:n.optional(n.array(n.string())),allowIdentifiers:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function V(e){let t=e.replace(/\\/g,`/`);return Te.some(e=>t.includes(e))}function De(e){let t=Ee.safeParse(e),n=t.success?t.data:{},r=new Set(n.allowIdentifiers??[]);return{bannedModules:/* @__PURE__ */ new Set([...Se,...n.extraBannedModules??[]]),bannedImportNames:/* @__PURE__ */ new Set([...Ce,...n.extraBannedImportNames??[]]),probingIdentifiers:new Set([...we].filter(e=>!r.has(e))),ignoreTests:n.ignoreTests??!0}}function H(e){return e.type===`Identifier`?e.name:null}function U(e,t){return`${e===`module`?`禁止引入端口探测库 "${t}"`:e===`importName`?`禁止引入端口探测函数 "${t}"`:`禁止声明端口探测标识符 "${t}"`}。端口获取统一走监听零口回读真实端口并经端口注册表注册,确需向子进程预派端口时以绑零口保留端口惯用法取系统分配口,正线见 ADR 0161。`}const Oe=e({meta:{type:`problem`,docs:{description:`禁止端口探测与避让处理,端口获取统一走端口注册表正线`}},createOnce(e){let t=null,n=!1;return{before(){if(t=De(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},ImportDeclaration(r){if(t&&n){if(t.bannedModules.has(r.source.value))e.report({node:r,message:U(`module`,r.source.value)});else for(let n of r.specifiers){if(n.type!==`ImportSpecifier`)continue;let r=n.imported.type===`Identifier`?n.imported.name:n.local.name;t.bannedImportNames.has(r)&&e.report({node:n,message:U(`importName`,r)})}}},FunctionDeclaration(r){t&&n&&r.id&&t.probingIdentifiers.has(r.id.name)&&e.report({node:r,message:U(`identifier`,r.id.name)})},MethodDefinition(r){if(!t||!n||r.computed)return;let i=H(r.key);i&&t.probingIdentifiers.has(i)&&e.report({node:r,message:U(`identifier`,i)})},PropertyDefinition(r){if(!t||!n||r.computed)return;let i=H(r.key);i&&t.probingIdentifiers.has(i)&&e.report({node:r,message:U(`identifier`,i)})},VariableDeclarator(r){t&&n&&r.id.type===`Identifier`&&t.probingIdentifiers.has(r.id.name)&&e.report({node:r,message:U(`identifier`,r.id.name)})}}}}),W=[`error`],G=[`console`],K=e=>e.type!==`MemberExpression`||e.computed?null:e.property.type===`Identifier`?e.property.name:null,ke=e=>e.type!==`MemberExpression`||e.object.type!==`Identifier`?null:e.object.name,q=(e,t,n)=>{let r=K(e.callee);if(r===null||!t.has(r))return!1;let i=ke(e.callee);return!(i!==null&&n.has(i))},Ae=e=>{let t=K(e.callee);return t!==null&&t.toLowerCase().includes(`flush`)?!0:e.callee.type===`Identifier`&&e.callee.name.toLowerCase().includes(`flush`)},je=e=>e.callee.type!==`MemberExpression`||e.callee.object.type!==`Identifier`||e.callee.object.name!==`process`?!1:K(e.callee)===`exit`,Me=[`Error`],Ne=n.object({errorTypeNames:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function Pe(e){let t=Ne.safeParse(e),n=t.success?t.data:{};return{errorTypeNames:/* @__PURE__ */ new Set([...Me,...n.errorTypeNames??[]]),ignoreTests:n.ignoreTests??!0}}function Fe(e){return typeof e==`object`&&!!e&&`typeAnnotation`in e&&e.typeAnnotation!==null&&typeof e.typeAnnotation==`object`}function Ie(e,t){if(typeof e!=`object`||!e)return!1;let n=`type`in e&&e.type===`TSTypeReference`&&`typeName`in e&&e.typeName!==null?e.typeName:e;return typeof n!=`object`||!n?!1:`name`in n&&typeof n.name==`string`&&t.has(n.name)}const Le=e({meta:{type:`problem`,docs:{description:`禁止 as Error 类型断言,catch 的 unknown 经标准件 ensureError 取错误对象`}},createOnce(e){let t=null,n=!1;return{before(){if(t=Pe(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},TSAsExpression(r){t&&n&&Fe(r)&&Ie(r.typeAnnotation,t.errorTypeNames)&&e.report({node:r,message:`禁止 as Error 类型断言。catch 的 unknown 经标准件 ensureError 取错误对象或消息,正线见 error-handling 台账工作流 001 判据 1 与 ADR 0166。`})}}}}),Re=n.object({methodNames:n.optional(n.array(n.string())),excludedObjects:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function ze(e){let t=Re.safeParse(e),n=t.success?t.data:{};return{methodNames:/* @__PURE__ */ new Set([...W,...n.methodNames??[]]),excludedObjects:/* @__PURE__ */ new Set([...G,...n.excludedObjects??[]]),ignoreTests:n.ignoreTests??!0}}const Be=e({meta:{type:`problem`,docs:{description:`禁止 error 日志后裸 process exit,退出前一律经 flushAndExit 刷缓冲`}},createOnce(e){let t=null,n=!1;return{before(){if(t=ze(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},BlockStatement(r){if(!t||!n)return;let i=!1;for(let n of r.body){if(n.type!==`ExpressionStatement`)continue;let r=n.expression;r.type===`CallExpression`&&(Ae(r)?i=!1:q(r,t.methodNames,t.excludedObjects)?i=!0:je(r)&&i&&e.report({node:n,message:`error 日志后裸调用 process.exit 会吞掉缓冲中的致命日志。退出前一律经 flushAndExit 刷缓冲后退出,正线见 error-handling 台账工作流 002 判据 4。`}))}}}}});function Ve(e){return e.replace(/\\/g,`/`).includes(`/apps/`)}function He(e){return/-implementation(\/|$)/.test(e)}function Ue(e){return e.endsWith(`Entity`)}function We(e){return e.endsWith(`UseCase`)}function Ge(e){return[/PortAdapter$/,/_TOKEN$/,/^create\w+Repository$/,/^create\w+Adapter$/].some(t=>t.test(e))}const Ke=e({meta:{type:`problem`,docs:{description:`禁止在 apps 层导入 implementation 包的 Entity 和 UseCase`}},createOnce(e){return{before(){let t=e.filename;if(!Ve(t))return!1},ImportDeclaration(t){let n=t.source.type===`Literal`&&typeof t.source.value==`string`?t.source.value:null;if(n&&He(n))for(let n of t.specifiers){if(n.type!==`ImportSpecifier`)continue;let t=n.imported.type===`Identifier`?n.imported.name:null;t&&(Ue(t)?e.report({node:n,message:`禁止在 apps 层导入 Entity 类 "${t}"。请使用 contract 包的 Port 接口进行操作。`}):We(t)?e.report({node:n,message:`禁止在 apps 层导入 UseCase 类 "${t}"。请使用 contract 包的 Port 接口进行操作。`}):Ge(t)||e.report({node:n,message:`禁止在 apps 层从 implementation 包导入 "${t}"。请使用 contract 包的 Port 接口。`}))}}}}}),qe=[`Error`],Je=n.object({errorTypeNames:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function Ye(e){let t=Je.safeParse(e),n=t.success?t.data:{};return{errorTypeNames:/* @__PURE__ */ new Set([...qe,...n.errorTypeNames??[]]),ignoreTests:n.ignoreTests??!0}}const Xe=e({meta:{type:`problem`,docs:{description:`禁止内联三元归一化副本,unknown 转 Error 一律经标准件 ensureError`}},createOnce(e){let t=null,n=!1;return{before(){if(t=Ye(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},ConditionalExpression(r){if(!t||!n)return;let i=r.test;i.type===`BinaryExpression`&&i.operator===`instanceof`&&i.right.type===`Identifier`&&t.errorTypeNames.has(i.right.name)&&e.report({node:r,message:`禁止内联三元归一化副本。unknown 转 Error 一律经标准件 ensureError,纯日志位直传 logger 吸收汇,正线见 error-handling 台账工作流 001 判据 1 与判据 2 及 ADR 0166。`})}}}}),Ze=n.object({functionName:n.string(),forbiddenPaths:n.array(n.string()),message:n.optional(n.string())}),Qe=n.object({restrictions:n.array(Ze)});function J(e,t){let n=e.replace(/\\/g,`/`),r=t.replace(/\\/g,`/`);if(!r.includes(`*`))return n.includes(r);let i=r.split(`*`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`[^/]+`);return new RegExp(i).test(n)}function $e(e,t){return t.some(t=>J(e,t))}function et(e){let t=Qe.safeParse(e);return t.success?t.data.restrictions:[]}function tt(e){return e.type===`Identifier`?e.name:e.type===`MemberExpression`&&e.property&&!e.computed&&e.property.type===`Identifier`?e.property.name:null}const nt=e({meta:{type:`problem`,docs:{description:`禁止在指定路径中调用特定函数,强制架构约束`}},createOnce(e){let t=[],n=/* @__PURE__ */ new Set;return{before(){let r=e.options?.[0];if(t=et(r),t.length===0)return!1;n=/* @__PURE__ */ new Set;for(let r=0;r<t.length;r++){let i=t[r];i&&$e(e.filename,i.forbiddenPaths)&&n.add(r)}if(n.size===0)return!1},CallExpression(r){let i=tt(r.callee);if(i)for(let a of n){let n=t[a];if(!n||i!==n.functionName)continue;let o=n.message??`禁止在当前路径中调用 "${n.functionName}"`;e.report({node:r,message:o})}}}}}),rt=[`fetch`,`axios`],it=[`XMLHttpRequest`,`EventSource`,`WebSocket`],at=[`domains/*/ui/`,`packages/ui/`,`packages/*-ui/`],ot=new Set(it),st=[`__tests__/`,`.test.`,`.spec.`,`__mocks__/`],ct=n.object({uiPathPatterns:n.optional(n.array(n.string())),extraFunctionNames:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function lt(e,t){return t.some(t=>J(e,t))}function ut(e){let t=e.replace(/\\/g,`/`);return st.some(e=>t.includes(e))}function dt(e){let t=ct.safeParse(e),n=t.success?t.data:{};return{uiPathPatterns:n.uiPathPatterns??[...at],rawCallNames:/* @__PURE__ */ new Set([...rt,...n.extraFunctionNames??[]]),ignoreTests:n.ignoreTests??!0}}function ft(e,t){return e.type===`Identifier`?t.has(e.name)?e.name:null:e.type===`MemberExpression`&&!e.computed&&e.object.type===`Identifier`&&t.has(e.object.name)?e.property.type===`Identifier`?`${e.object.name}.${e.property.name}`:e.object.name:null}function pt(e){return e.type===`Identifier`&&ot.has(e.name)?e.name:null}function Y(e){return`UI 层禁止手写网络调用 "${e}"。网络消费统一经生成式 sdk 客户端端点加 transport 通道注入,正线见 ADR 0127 与 sdk 治理台账工作流 002。`}const mt=e({meta:{type:`problem`,docs:{description:`禁止 UI 层手写网络调用,消费面统一经生成式 sdk 客户端`}},createOnce(e){let t=null,n=!1;return{before(){if(t=dt(e.options?.[0]),n=!(t.ignoreTests&&ut(e.filename))&<(e.filename,t.uiPathPatterns),!n)return!1},CallExpression(r){if(!t||!n)return;let i=ft(r.callee,t.rawCallNames);i&&e.report({node:r,message:Y(i)})},NewExpression(r){if(!t||!n)return;let i=pt(r.callee);i&&e.report({node:r,message:Y(i)})}}}}),ht=n.object({importSource:n.string(),importNames:n.optional(n.array(n.string())),forbiddenPaths:n.array(n.string()),message:n.optional(n.string())}),gt=n.object({restrictions:n.array(ht)});function _t(e,t,n){return e===n.importSource?!n.importNames||n.importNames.length===0?t.length>0:t.some(e=>n.importNames?.includes(e)??!1):!1}function vt(e){let t=[];for(let n of e)n.type===`ImportSpecifier`&&n.imported.type===`Identifier`?t.push(n.imported.name):n.type===`ImportDefaultSpecifier`&&t.push(n.local.name);return t}function yt(e){let t=gt.safeParse(e);return t.success?t.data.restrictions:[]}function bt(e,t){return t.some(t=>J(e,t))}const xt=e({meta:{type:`problem`,docs:{description:`禁止在指定路径中导入特定模块,强制架构约束`},schema:[{type:`object`,properties:{restrictions:{type:`array`,items:{type:`object`,properties:{importSource:{type:`string`},importNames:{type:`array`,items:{type:`string`}},forbiddenPaths:{type:`array`,items:{type:`string`}},message:{type:`string`}},required:[`importSource`,`forbiddenPaths`],additionalProperties:!1}}},additionalProperties:!1}]},createOnce(e){let t=[],n=/* @__PURE__ */ new Set;return{before(){let r=e.options?.[0];if(t=yt(r),t.length===0)return!1;n=/* @__PURE__ */ new Set;for(let r=0;r<t.length;r++){let i=t[r];i&&bt(e.filename,i.forbiddenPaths)&&n.add(r)}if(n.size===0)return!1},ImportDeclaration(r){let i=r.source.value;if(typeof i!=`string`)return;let a=vt(r.specifiers??[]);for(let o of n){let n=t[o];if(!n||!_t(i,a,n))continue;let s=n.importNames?a.filter(e=>n.importNames?.includes(e)??!1):a;for(let t of s){let i=n.message??`禁止在当前路径中导入 "${t}"(来源:${n.importSource})`;e.report({node:r,message:i})}}}}}}),St=n.object({methodNames:n.optional(n.array(n.string())),excludedObjects:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function X(e){let t=St.safeParse(e),n=t.success?t.data:{};return{methodNames:/* @__PURE__ */ new Set([...W,...n.methodNames??[]]),excludedObjects:/* @__PURE__ */ new Set([...G,...n.excludedObjects??[]]),ignoreTests:n.ignoreTests??!0}}const Ct=e({meta:{type:`problem`,docs:{description:`禁止错误日志模板拼接 message,改为结构化第二参直传错误值`}},createOnce(e){let t=null,n=!1;return{before(){if(t=X(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},CallExpression(r){if(!t||!n||!q(r,t.methodNames,t.excludedObjects))return;let i=r.arguments[0];if(!i||i.type===`SpreadElement`)return;let a=i.type===`TemplateLiteral`&&i.expressions.length>0,o=i.type===`BinaryExpression`&&i.operator===`+`;(a||o)&&e.report({node:r,message:`错误日志禁止模板拼接 message。模板拼接吞掉错误对象的 cause 与 stack 与 code,消息写固定文案并以第二参直传错误值由 logger 吸收汇归一化,正线见 error-handling 台账工作流 002 判据 1 与 ADR 0166。`})}}}}),wt=n.object({methodNames:n.optional(n.array(n.string())),excludedObjects:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function Tt(e){let t=wt.safeParse(e),n=t.success?t.data:{};return{methodNames:/* @__PURE__ */ new Set([...W,...n.methodNames??[]]),excludedObjects:/* @__PURE__ */ new Set([...G,...n.excludedObjects??[]]),ignoreTests:n.ignoreTests??!0}}const Et=e({meta:{type:`problem`,docs:{description:`禁止纯文案错误日志,无底层错误时错误参数位显式传 undefined 并附业务上下文`}},createOnce(e){let t=null,n=!1;return{before(){if(t=Tt(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},CallExpression(r){t&&n&&q(r,t.methodNames,t.excludedObjects)&&r.arguments.length<2&&e.report({node:r,message:`错误日志禁止纯文案形态。无底层错误对象的业务校验场景在错误参数位显式传 undefined 并附业务上下文,正线见 error-handling 台账工作流 002 判据 2 与 ADR 0166。`})}}}}),Dt=[`vite.config.`],Ot=[`portDiscovery`],kt=n.object({viteConfigPatterns:n.optional(n.array(n.string())),registerMarkers:n.optional(n.array(n.string()))});function At(e){let t=kt.safeParse(e),n=t.success?t.data:{};return{viteConfigPatterns:n.viteConfigPatterns??[...Dt],registerMarkers:/* @__PURE__ */ new Set([...Ot,...n.registerMarkers??[]])}}function jt(e,t){let n=e.replace(/\\/g,`/`).split(`/`).pop()??``;return t.some(e=>n.includes(e))}function Z(e){return e.computed||e.key.type!==`Identifier`||e.value.type!==`Literal`?null:{key:e.key.name,value:e.value.value}}function Mt(){return`vite 配置禁止置 strictPort 为 false 依赖占用自动加一。端口面统一置 strictPort 为 true 快速失败,或 port 置 0 配合 portDiscovery 注册,正线见 ADR 0161。`}function Nt(e){return`vite 配置写死端口 ${e} 且未置 strictPort 为 true,占用时将静默改用相邻端口。端口面统一置 strictPort 为 true 快速失败,或 port 置 0 配合 portDiscovery 注册,正线见 ADR 0161。`}const Q={"dependency-direction":pe,"business-leak":u,"no-cross-package-relative-import":xe,"domain-export-compliance":k,"implementation-export-control":he,"no-implementation-import-in-apps":Ke,"no-restricted-call-in-paths":nt,"no-restricted-import-in-paths":xt,"no-raw-network-call-in-ui":mt,"no-port-probing":Oe,"no-vite-port-fallback":e({meta:{type:`problem`,docs:{description:`禁止 vite 配置依赖端口占用自动加一,端口面统一快速失败或注册表注册`}},createOnce(e){let t=null,n=!1,r={hasRegisterMarker:!1,hasStrictPortTrue:!1,strictPortFalseNodes:[],positivePortNodes:[]};return{before(){if(t=At(e.options?.[0]),n=jt(e.filename,t.viteConfigPatterns),r.hasRegisterMarker=!1,r.hasStrictPortTrue=!1,r.strictPortFalseNodes=[],r.positivePortNodes=[],!n)return!1},ImportDeclaration(e){if(t&&n)for(let n of e.specifiers)n.type===`ImportSpecifier`&&n.local.name&&t.registerMarkers.has(n.local.name)&&(r.hasRegisterMarker=!0)},CallExpression(e){t&&n&&e.callee.type===`Identifier`&&t.registerMarkers.has(e.callee.name)&&(r.hasRegisterMarker=!0)},Property(e){if(!t||!n)return;let i=Z(e);i&&(i.key===`strictPort`?i.value===!0?r.hasStrictPortTrue=!0:i.value===!1&&r.strictPortFalseNodes.push(e):i.key===`port`&&typeof i.value==`number`&&i.value>0&&r.positivePortNodes.push(e))},"Program:exit"(){if(t&&n&&!r.hasRegisterMarker){for(let t of r.strictPortFalseNodes)e.report({node:t,message:Mt()});if(!r.hasStrictPortTrue)for(let t of r.positivePortNodes){let n=Z(t);e.report({node:t,message:Nt(typeof n?.value==`number`?n.value:0)})}}}}}}),"no-template-error-log":Ct,"no-text-only-error-log":Et,"no-exit-after-error-log":Be,"no-inline-error-normalization":Xe,"no-error-type-assertion":Le},$=t({meta:{name:`@longzai-intelligence-oxlint/architecture-core-plugin`},rules:Q});export{$ as architectureCorePlugin,$ as default,Q as coreRules};
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import*as n from"zod/mini";const r=[`/packages/platform/`,`/packages/ui/`,`/packages/ui-kit/`,`/packages/engine/`,`/packages/utils/`,`/packages/types/`],i=[],a=[`^validate`,`^calculate`,`^compute`,`^determine`,`^check`,`^can`,`^should`,`^isAllowed`,`^isPermitted`,`^hasPermission`,`^applyRule`,`^enforce`,`^execute`];function o(e){return typeof e==`object`&&!!e}function s(e){let t=Array.isArray(e)?e[0]:e;return o(t)?{techLayerPatterns:t.techLayerPatterns??r,businessKeywords:t.businessKeywords??i,businessRuleMethods:t.businessRuleMethods??a}:{techLayerPatterns:r,businessKeywords:i,businessRuleMethods:a}}function c(e){return e.map(e=>new RegExp(e))}function ee(e,t){let n=e.replace(/\\/g,`/`);return t.some(e=>e.test(n))}function l(e,t){let n=e.charAt(0).toUpperCase()+e.slice(1);return t.some(e=>n.includes(e))}function te(e,t){return t.some(t=>t.test(e))}const u=e({meta:{type:`suggestion`,docs:{description:`检测技术层中可能存在的业务逻辑`}},createOnce(e){let t=[],n=[],r=[];return{before(){let i=s(e.options);return t=c(i.techLayerPatterns),n=i.businessKeywords,r=c(i.businessRuleMethods),ee(e.filename,t)?void 0:!1},ClassDeclaration(t){t.id&&l(t.id.name,n)&&e.report({node:t,message:`业务逻辑泄漏嫌疑: 技术层发现业务相关类 '${t.id.name}'。业务逻辑应该放在 domains/ 层。`})},MethodDefinition(t){t.key.type===`Identifier`&&te(t.key.name,r)&&e.report({node:t,message:`业务逻辑泄漏嫌疑: 技术层发现业务规则方法 '${t.key.name}'。业务规则应该放在 domains/ 层。`})},TSInterfaceDeclaration(t){l(t.id.name,n)&&e.report({node:t,message:`业务逻辑泄漏嫌疑: 技术层发现业务相关接口 '${t.id.name}'。业务接口应该放在 domains/ 层。`})},TSTypeAliasDeclaration(t){l(t.id.name,n)&&e.report({node:t,message:`业务逻辑泄漏嫌疑: 技术层发现业务相关类型 '${t.id.name}'。业务类型应该放在 domains/ 层。`})}}}}),d={types:0,utils:1,"shared-kernel":2,contract:3,engine:4,platform:5,infrastructure:6,implementation:6,domain:6,capability:7,ui:7,"electron-shared":7,"electron-main":8,"electron-preload":8,"electron-renderer":9},ne={types:`类型层 (Types)`,utils:`工具层 (Utils)`,"shared-kernel":`共享内核层 (Shared Kernel)`,contract:`契约层 (Contract)`,engine:`引擎层 (Engine)`,platform:`平台层 (Platform)`,infrastructure:`基础设施层 (Infrastructure)`,implementation:`实现层 (Implementation)`,domain:`门面层 (Domain Facade)`,capability:`能力装配层 (Capability)`,ui:`UI 表现层`,"electron-shared":`Electron 共享层 (Shared)`,"electron-main":`Electron 主进程 (Main)`,"electron-preload":`Electron 预加载层 (Preload)`,"electron-renderer":`Electron 渲染进程 (Renderer)`},re=new Set(Object.keys(d)),f={pathPatterns:[{pattern:/\/apps\/capabilities\//,layer:`capability`},{pattern:/\/domains\/[^/]+\/implementation\//,layer:`implementation`},{pattern:/\/domains\/[^/]+\/contract\//,layer:`contract`},{pattern:/\/domains\/[^/]+\/ui\//,layer:`ui`},{pattern:/\/domains\/shared-kernel\//,layer:`shared-kernel`},{pattern:/\/infrastructure\//,layer:`infrastructure`}],packagePrefix:``,specialPackageMappings:{},packageSuffixMappings:[{suffix:`-contract`,layer:`contract`},{suffix:`-implementation`,layer:`implementation`},{suffix:`-infrastructure`,layer:`infrastructure`},{suffix:`-domain`,layer:`domain`},{suffix:`-ui`,layer:`ui`},{suffix:`-engine`,layer:`engine`},{suffix:`-runtime`,layer:`engine`}]},p=[{from:`capability`,to:`implementation`},{from:`capability`,to:`infrastructure`},{from:`ui`,to:`domain`,hint:`UI 面禁止经门面包取件,域外依赖唯一指向生成式 sdk 客户端,ADR 0127。`},{from:`ui`,to:`contract`,hint:`contract 为 DDD 主体对 UI 全封闭,类型正源为 sdk 生成契约推断类型,ADR 0127。`},{from:`ui`,to:`implementation`,hint:`UI 面禁止直连实现层,域外依赖唯一指向生成式 sdk 客户端,ADR 0127。`},{from:`ui`,to:`infrastructure`,hint:`UI 面禁止直连基础设施层,域外依赖唯一指向生成式 sdk 客户端,ADR 0127。`}],m=[`-main`],h=[{pattern:/\/src\/domain\//,layer:`contract`},{pattern:/\/src\/engine\//,layer:`engine`},{pattern:/\/src\/platform\//,layer:`platform`},{pattern:/\/src\/infrastructure\//,layer:`infrastructure`},{pattern:/\/src\/shared\//,layer:`shared-kernel`}];function g(e){return re.has(e)}function ie(e,t){return d[e]>=d[t]}function _(e){return ne[e]}function ae(e,t){let n=e.replace(/\\/g,`/`),r=t??f.pathPatterns;if(r){for(let{pattern:e,layer:t}of r)if(e.test(n))return{layer:t,priority:d[t]}}if(n.includes(`/apps/`)){for(let{pattern:e,layer:t}of h)if(e.test(n))return{layer:t,priority:d[t]}}if(n.includes(`/packages/`)){for(let{pattern:e,layer:t}of h)if(e.test(n))return{layer:t,priority:d[t]}}return null}function v(e,t){if(!e.startsWith(t))return null;let n=e.split(`/`),r=n[0]===``?n.slice(1):n;return(r[0]?.startsWith(`@`)?r[1]:r[0])??null}function oe(e,t){for(let n of t)if(e.endsWith(n))return n;return null}function se(e,t){let n=t.packagePrefix??``,r=v(e,n);if(!r)return null;let i=(t.specialPackageMappings??{})[`${n}${r}`];if(i)return{layer:i,priority:d[i]};let a=t.packageSuffixMappings??[];for(let{suffix:e,layer:t}of a)if(r.endsWith(e))return{layer:t,priority:d[t]};return null}function ce(e,t,n){return e.find(e=>e.from===t&&e.to===n)??null}function le(e){let t=e.match(/^\/(.+)\/([gimsuvy]*)$/);return t?.[1]?new RegExp(t[1],t[2]??``):new RegExp(e)}function ue(e){let t={};if(e.pathPatterns&&(t.pathPatterns=e.pathPatterns.reduce((e,{pattern:t,layer:n})=>(g(n)&&e.push({pattern:le(t),layer:n}),e),[])),e.packagePrefix&&(t.packagePrefix=e.packagePrefix),e.specialPackageMappings){let n={};for(let[t,r]of Object.entries(e.specialPackageMappings))g(r)&&(n[t]=r);t.specialPackageMappings=Object.keys(n).length>0?n:void 0}if(e.packageSuffixMappings){let n=[];for(let{suffix:t,layer:r}of e.packageSuffixMappings)g(r)&&n.push({suffix:t,layer:r});t.packageSuffixMappings=n.length>0?n:void 0}if(e.forbiddenLayerPairs){let n=[];for(let{from:t,to:r}of e.forbiddenLayerPairs)g(t)&&g(r)&&n.push({from:t,to:r});t.forbiddenLayerPairs=n.length>0?n:void 0}if(e.forbiddenPackageSuffixes){let n=e.forbiddenPackageSuffixes.filter(e=>e.length>0);t.forbiddenPackageSuffixes=n.length>0?n:void 0}return t}function de(e){return typeof e==`object`&&!!e}function fe(e){let t=ue(de(e)?e:{});return{pathPatterns:t.pathPatterns??f.pathPatterns,packagePrefix:t.packagePrefix??f.packagePrefix,specialPackageMappings:t.specialPackageMappings??f.specialPackageMappings,packageSuffixMappings:t.packageSuffixMappings??f.packageSuffixMappings,forbiddenLayerPairs:[...p,...t.forbiddenLayerPairs??[]],forbiddenPackageSuffixes:[...m,...t.forbiddenPackageSuffixes??[]]}}const pe=e({meta:{type:`problem`,docs:{description:`强制执行 Clean Architecture 的依赖方向规则`},schema:[{type:`object`,properties:{pathPatterns:{type:`array`,items:{type:`object`,properties:{pattern:{type:`string`},layer:{type:`string`}},required:[`pattern`,`layer`],additionalProperties:!1}},packagePrefix:{type:`string`},specialPackageMappings:{type:`object`,additionalProperties:{type:`string`}},packageSuffixMappings:{type:`array`,items:{type:`object`,properties:{suffix:{type:`string`},layer:{type:`string`}},required:[`suffix`,`layer`],additionalProperties:!1}},forbiddenLayerPairs:{type:`array`,items:{type:`object`,properties:{from:{type:`string`},to:{type:`string`}},required:[`from`,`to`],additionalProperties:!1}},forbiddenPackageSuffixes:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){let t=null,n=null;return{before(){return t===null&&(t=fe(e.options?.[0])),n=ae(e.filename,t.pathPatterns),n!==null},ImportDeclaration(r){if(!n||!t)return;let i=r.source.type===`Literal`&&typeof r.source.value==`string`?r.source.value:null;if(!i)return;let a=v(i,t.packagePrefix??``);if(a){let n=oe(a,t.forbiddenPackageSuffixes??[]);if(n){e.report({node:r,message:`禁止导入已禁用的 ${n} 门面包,门面包统一使用 -domain 后缀。`});return}}let o=se(i,t);if(!o)return;let s=ce(t.forbiddenLayerPairs??[],n.layer,o.layer);s?e.report({node:r,message:`依赖方向违规: ${n.layer} (${_(n.layer)}) 不能导入 ${o.layer} (${_(o.layer)})。${s.hint??`域内取件必须经 -domain 门面包。`}`}):ie(n.layer,o.layer)||e.report({node:r,message:`依赖方向违规: ${n.layer} (${_(n.layer)}) 不能导入 ${o.layer} (${_(o.layer)})。依赖应该从外层指向内层。`})}}}});function me(e){let t=e.replace(/\\/g,`/`);return t.includes(`/domains/`)&&t.includes(`/implementation/src/index.ts`)}function y(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function b(e){return y(e)&&e.endsWith(`Entity`)}function x(e){return y(e)&&e.endsWith(`Repository`)&&!e.startsWith(`I`)}function S(e){return y(e)&&e.endsWith(`OrmEntity`)}function C(e){return e.endsWith(`_ORM_ENTITIES`)}function w(e){return y(e)&&e.endsWith(`OrmMapper`)}function T(e){return y(e)&&e.endsWith(`Schema`)}function E(e){return`exportKind`in e&&typeof e.exportKind==`string`?e.exportKind===`value`:!0}function D(e){return e.exported.type===`Identifier`?e.exported.name:e.exported.type===`Literal`&&typeof e.exported.value==`string`?e.exported.value:null}function O(e,t,n){b(e)&&E(t)?n.report({node:t,message:`禁止从主入口值导出 Entity 类 "${e}"。请改为类型导出或移除导出。`}):x(e)?n.report({node:t,message:`禁止导出 Repository 类型 "${e}"。Repository 是内部实现,不应暴露给外部。`}):S(e)?n.report({node:t,message:`禁止从主入口导出 ORM 实体 "${e}"。请创建 src/typeorm.ts 入口文件,从该入口导出。`}):C(e)?n.report({node:t,message:`禁止从主入口导出 ORM 实体集合 "${e}"。请创建 src/typeorm.ts 入口文件,从该入口导出。`}):w(e)?n.report({node:t,message:`禁止导出 ORM Mapper "${e}"。ORM Mapper 是基础设施实现细节,不应暴露给外部。`}):T(e)&&n.report({node:t,message:`禁止导出 Schema 定义 "${e}"。Schema 是实现细节,应仅导出推断类型。`})}const k=e({meta:{type:`problem`,docs:{description:`检查 Domain Implementation 包的导出是否符合规范`}},createOnce(e){return{before(){let t=e.filename;if(!me(t))return!1},ExportNamedDeclaration(t){if(t.source&&t.source.type===`Literal`&&typeof t.source.value==`string`)for(let n of t.specifiers){if(n.type!==`ExportSpecifier`)continue;let t=D(n);t&&O(t,n,e)}}}}});function A(e){let t=e.replace(/\\/g,`/`);return t.includes(`/domains/`)&&t.includes(`/implementation/src/index.ts`)}const j=[/\.\/typeorm/,/\.\/typeorm'/,/\.\/typeorm"/],M=[{pattern:/^[A-Z][a-zA-Z0-9]*OrmEntity$/,message:`禁止从主入口导出 ORM 实体。应使用 typeorm 入口导出。`},{pattern:/^[A-Z][a-zA-Z0-9]*Entity$/,message:`禁止从主入口导出 Entity 类。Entity 是内部实现,应使用 contract 包的 DTO。`},{pattern:/^[A-Z][a-zA-Z0-9]*UseCase$/,message:`禁止导出 UseCase 类。UseCase 是内部实现,应通过 Port 接口访问。`},{pattern:/^I[A-Z].*Repository$/,message:`禁止导出 Repository 接口。Repository 是内部接口,外部应通过 Port 访问。`},{pattern:/^create[A-Za-z]+Repository$/,message:`禁止导出 Repository 工厂函数。外部应使用 PortAdapter 工厂函数。`},{pattern:/^[A-Z][a-zA-Z0-9]*Repository[a-zA-Z0-9]*$/,message:`禁止导出 Repository 实现类。应使用工厂函数或 Port 接口。`},{pattern:/^[A-Z][a-zA-Z0-9]*Schema$/,message:`禁止导出 Schema 定义。Schema 是实现细节,应导出推断类型。`},{pattern:/_ORM_ENTITIES$/,message:`禁止从主入口导出实体集合。应使用 typeorm 入口导出。`},{pattern:/^[A-Z][a-zA-Z0-9]*OrmMapper$/,message:`禁止导出 ORM Mapper。这是基础设施实现细节。`},{pattern:/^[A-Z][a-zA-Z0-9]*Table$/,message:`禁止导出数据库表定义。这是数据存储细节。`}];function N(e){return j.some(t=>t.test(e))}function P(e){for(let{pattern:t,message:n}of M)if(t.test(e))return n;return null}function F(e,t){if(e.source){let n=e.source.type===`Literal`&&typeof e.source.value==`string`?e.source.value:null;if(n&&N(n)){t.report({node:e,message:`禁止从主入口重新导出 typeorm.ts 的内容。typeorm.ts 是专门的持久化入口。`});return}}if(e.specifiers){for(let n of e.specifiers)if(n.type===`ExportSpecifier`){let e=n.exported.type===`Identifier`?n.exported.name:n.exported.type===`Literal`&&typeof n.exported.value==`string`?n.exported.value:null;if(e){let r=P(e);r&&t.report({node:n,message:`${e}: ${r}`})}}}e.declaration&&R(e.declaration,t.report)}function I(e,t){if(e.source){let n=e.source.type===`Literal`&&typeof e.source.value==`string`?e.source.value:null;if(n&&N(n)){t.report({node:e,message:`禁止从主入口重新导出 typeorm.ts 的内容。typeorm.ts 是专门的持久化入口。`});return}}t.report({node:e,message:`禁止使用 export *。请使用显式导出,明确导出内容。`})}function L(e,t){z(e.declaration)&&R(e.declaration,t.report)}function R(e,t){if(e.type===`ClassDeclaration`&&e.id){let n=e.id.name,r=P(n);r&&t({node:e,message:`${n}: ${r}`})}else if(e.type===`VariableDeclaration`){for(let n of e.declarations)if(n.id.type===`Identifier`){let e=n.id.name,r=P(e);r&&t({node:n,message:`${e}: ${r}`})}}else if(e.type===`FunctionDeclaration`&&e.id){let n=e.id.name,r=P(n);r&&t({node:e,message:`${n}: ${r}`})}}function z(e){return e.type===`ClassDeclaration`||e.type===`FunctionDeclaration`||e.type===`VariableDeclaration`}const he=e({meta:{type:`problem`,docs:{description:`Implementation 包导出控制:禁止从主入口导出内部实现`}},createOnce(e){return{before(){let t=e.filename;if(!A(t))return!1},ExportNamedDeclaration(t){F(t,e)},ExportAllDeclaration(t){I(t,e)},ExportDefaultDeclaration(t){L(t,e)}}}}),ge=[{alias:`@main`,pathPattern:`src/main`},{alias:`@preload`,pathPattern:`src/preload`},{alias:`@renderer`,pathPattern:`src/renderer/src`},{alias:`@shared`,pathPattern:`src/shared`}];function _e(e){return typeof e==`object`&&!!e&&`packageBoundaries`in e}function B(e,t){let n=e.replace(/\\/g,`/`);for(let e of t){let t=e.pathPattern.replace(/\\/g,`/`);if(n.includes(`/${t}/`)||n.endsWith(`/${t}`)||n.includes(`/${t}\\`))return e.alias}return null}function ve(e,t,n){if(!t.startsWith(`.`))return null;let r=e.replace(/\\/g,`/`),i=r.lastIndexOf(`/`);return B(ye(i>0?r.substring(0,i):``,t),n)}function ye(e,t){let n=(e+`/`+t).split(`/`),r=[];for(let e of n)e===`..`?r.pop():e!==`.`&&e!==``&&r.push(e);return`/`+r.join(`/`)}function be(e){return e.startsWith(`./`)||e.startsWith(`../`)}const xe=e({meta:{type:`problem`,docs:{description:`禁止使用相对路径穿越不同包范围,强制使用别名导入`}},createOnce(e){let t=null;function n(){if(t===null){let n=e.options?.[0],r=n&&typeof n==`object`?n:{};t=_e(r)&&Array.isArray(r.packageBoundaries)?r.packageBoundaries:ge}return t}return{before(){n()},ImportDeclaration(t){let r=e.filename,i=t.source.type===`Literal`&&typeof t.source.value==`string`?t.source.value:null;if(!i||!be(i))return;let a=B(r,n());if(!a)return;let o=ve(r,i,n());o&&a!==o&&e.report({node:t,message:`禁止使用相对路径跨包导入。当前文件位于 "${a}" 包,目标位于 "${o}" 包。请使用别名导入:${o}/...`})}}}}),Se=[`get-port`,`get-port-plus`,`portfinder`,`detect-port`,`find-free-port`,`tcp-port-used`],Ce=[`getPort`,`getFreePort`,`detectPort`],we=[`findAvailablePort`,`findFreePort`,`getFreePort`,`getAvailablePort`,`isPortAvailable`,`isPortFree`,`checkPort`,`checkPortAvailable`,`detectPort`,`ensurePort`,`portCounter`],Te=[`__tests__/`,`.test.`,`.spec.`,`__mocks__/`],Ee=n.object({extraBannedModules:n.optional(n.array(n.string())),extraBannedImportNames:n.optional(n.array(n.string())),allowIdentifiers:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function V(e){let t=e.replace(/\\/g,`/`);return Te.some(e=>t.includes(e))}function De(e){let t=Ee.safeParse(e),n=t.success?t.data:{},r=new Set(n.allowIdentifiers??[]);return{bannedModules:/* @__PURE__ */ new Set([...Se,...n.extraBannedModules??[]]),bannedImportNames:/* @__PURE__ */ new Set([...Ce,...n.extraBannedImportNames??[]]),probingIdentifiers:new Set([...we].filter(e=>!r.has(e))),ignoreTests:n.ignoreTests??!0}}function H(e){return e.type===`Identifier`?e.name:null}function U(e,t){return`${e===`module`?`禁止引入端口探测库 "${t}"`:e===`importName`?`禁止引入端口探测函数 "${t}"`:`禁止声明端口探测标识符 "${t}"`}。端口获取统一走监听零口回读真实端口并经端口注册表注册,确需向子进程预派端口时以绑零口保留端口惯用法取系统分配口,正线见 ADR 0161。`}const Oe=e({meta:{type:`problem`,docs:{description:`禁止端口探测与避让处理,端口获取统一走端口注册表正线`}},createOnce(e){let t=null,n=!1;return{before(){if(t=De(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},ImportDeclaration(r){if(t&&n){if(t.bannedModules.has(r.source.value))e.report({node:r,message:U(`module`,r.source.value)});else for(let n of r.specifiers){if(n.type!==`ImportSpecifier`)continue;let r=n.imported.type===`Identifier`?n.imported.name:n.local.name;t.bannedImportNames.has(r)&&e.report({node:n,message:U(`importName`,r)})}}},FunctionDeclaration(r){t&&n&&r.id&&t.probingIdentifiers.has(r.id.name)&&e.report({node:r,message:U(`identifier`,r.id.name)})},MethodDefinition(r){if(!t||!n||r.computed)return;let i=H(r.key);i&&t.probingIdentifiers.has(i)&&e.report({node:r,message:U(`identifier`,i)})},PropertyDefinition(r){if(!t||!n||r.computed)return;let i=H(r.key);i&&t.probingIdentifiers.has(i)&&e.report({node:r,message:U(`identifier`,i)})},VariableDeclarator(r){t&&n&&r.id.type===`Identifier`&&t.probingIdentifiers.has(r.id.name)&&e.report({node:r,message:U(`identifier`,r.id.name)})}}}}),W=[`error`],G=[`logger`,`log`],K=e=>e.type!==`MemberExpression`||e.computed?null:e.property.type===`Identifier`?e.property.name:null,ke=e=>e.type!==`MemberExpression`||e.object.type!==`Identifier`?null:e.object.name,q=(e,t,n)=>{let r=K(e.callee);if(r===null||!t.has(r))return!1;let i=ke(e.callee);return i!==null&&n.has(i)},Ae=e=>{let t=K(e.callee);return t!==null&&t.toLowerCase().includes(`flush`)?!0:e.callee.type===`Identifier`&&e.callee.name.toLowerCase().includes(`flush`)},je=e=>e.callee.type!==`MemberExpression`||e.callee.object.type!==`Identifier`||e.callee.object.name!==`process`?!1:K(e.callee)===`exit`,Me=[`Error`],Ne=n.object({errorTypeNames:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function Pe(e){let t=Ne.safeParse(e),n=t.success?t.data:{};return{errorTypeNames:/* @__PURE__ */ new Set([...Me,...n.errorTypeNames??[]]),ignoreTests:n.ignoreTests??!0}}function Fe(e){return typeof e==`object`&&!!e&&`typeAnnotation`in e&&e.typeAnnotation!==null&&typeof e.typeAnnotation==`object`}function Ie(e,t){if(typeof e!=`object`||!e)return!1;let n=`type`in e&&e.type===`TSTypeReference`&&`typeName`in e&&e.typeName!==null?e.typeName:e;return typeof n!=`object`||!n?!1:`name`in n&&typeof n.name==`string`&&t.has(n.name)}const Le=e({meta:{type:`problem`,docs:{description:`禁止 as Error 类型断言,catch 的 unknown 经标准件 ensureError 取错误对象`}},createOnce(e){let t=null,n=!1;return{before(){if(t=Pe(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},TSAsExpression(r){t&&n&&Fe(r)&&Ie(r.typeAnnotation,t.errorTypeNames)&&e.report({node:r,message:`禁止 as Error 类型断言。catch 的 unknown 经标准件 ensureError 取错误对象或消息,正线见 error-handling 台账工作流 001 判据 1 与 ADR 0166。`})}}}}),Re=n.object({methodNames:n.optional(n.array(n.string())),objectNames:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function ze(e){let t=Re.safeParse(e),n=t.success?t.data:{};return{methodNames:/* @__PURE__ */ new Set([...W,...n.methodNames??[]]),loggerObjects:/* @__PURE__ */ new Set([...G,...n.objectNames??[]]),ignoreTests:n.ignoreTests??!0}}const Be=e({meta:{type:`problem`,docs:{description:`禁止 error 日志后裸 process exit,退出前一律经 flushAndExit 刷缓冲`}},createOnce(e){let t=null,n=!1;return{before(){if(t=ze(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},BlockStatement(r){if(!t||!n)return;let i=!1;for(let n of r.body){if(n.type!==`ExpressionStatement`)continue;let r=n.expression;r.type===`CallExpression`&&(Ae(r)?i=!1:q(r,t.methodNames,t.loggerObjects)?i=!0:je(r)&&i&&e.report({node:n,message:`error 日志后裸调用 process.exit 会吞掉缓冲中的致命日志。退出前一律经 flushAndExit 刷缓冲后退出,正线见 error-handling 台账工作流 002 判据 4。`}))}}}}});function Ve(e){return e.replace(/\\/g,`/`).includes(`/apps/`)}function He(e){return/-implementation(\/|$)/.test(e)}function Ue(e){return e.endsWith(`Entity`)}function We(e){return e.endsWith(`UseCase`)}function Ge(e){return[/PortAdapter$/,/_TOKEN$/,/^create\w+Repository$/,/^create\w+Adapter$/].some(t=>t.test(e))}const Ke=e({meta:{type:`problem`,docs:{description:`禁止在 apps 层导入 implementation 包的 Entity 和 UseCase`}},createOnce(e){return{before(){let t=e.filename;if(!Ve(t))return!1},ImportDeclaration(t){let n=t.source.type===`Literal`&&typeof t.source.value==`string`?t.source.value:null;if(n&&He(n))for(let n of t.specifiers){if(n.type!==`ImportSpecifier`)continue;let t=n.imported.type===`Identifier`?n.imported.name:null;t&&(Ue(t)?e.report({node:n,message:`禁止在 apps 层导入 Entity 类 "${t}"。请使用 contract 包的 Port 接口进行操作。`}):We(t)?e.report({node:n,message:`禁止在 apps 层导入 UseCase 类 "${t}"。请使用 contract 包的 Port 接口进行操作。`}):Ge(t)||e.report({node:n,message:`禁止在 apps 层从 implementation 包导入 "${t}"。请使用 contract 包的 Port 接口。`}))}}}}}),qe=[`Error`],Je=n.object({errorTypeNames:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function Ye(e){let t=Je.safeParse(e),n=t.success?t.data:{};return{errorTypeNames:/* @__PURE__ */ new Set([...qe,...n.errorTypeNames??[]]),ignoreTests:n.ignoreTests??!0}}const Xe=e({meta:{type:`problem`,docs:{description:`禁止内联三元归一化副本,unknown 转 Error 一律经标准件 ensureError`}},createOnce(e){let t=null,n=!1;return{before(){if(t=Ye(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},ConditionalExpression(r){if(!t||!n)return;let i=r.test;i.type===`BinaryExpression`&&i.operator===`instanceof`&&i.right.type===`Identifier`&&t.errorTypeNames.has(i.right.name)&&e.report({node:r,message:`禁止内联三元归一化副本。unknown 转 Error 一律经标准件 ensureError,纯日志位直传 logger 吸收汇,正线见 error-handling 台账工作流 001 判据 1 与判据 2 及 ADR 0166。`})}}}}),Ze=n.object({functionName:n.string(),forbiddenPaths:n.array(n.string()),message:n.optional(n.string())}),Qe=n.object({restrictions:n.array(Ze)});function J(e,t){let n=e.replace(/\\/g,`/`),r=t.replace(/\\/g,`/`);if(!r.includes(`*`))return n.includes(r);let i=r.split(`*`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`[^/]+`);return new RegExp(i).test(n)}function $e(e,t){return t.some(t=>J(e,t))}function et(e){let t=Qe.safeParse(e);return t.success?t.data.restrictions:[]}function tt(e){return e.type===`Identifier`?e.name:e.type===`MemberExpression`&&e.property&&!e.computed&&e.property.type===`Identifier`?e.property.name:null}const nt=e({meta:{type:`problem`,docs:{description:`禁止在指定路径中调用特定函数,强制架构约束`}},createOnce(e){let t=[],n=/* @__PURE__ */ new Set;return{before(){let r=e.options?.[0];if(t=et(r),t.length===0)return!1;n=/* @__PURE__ */ new Set;for(let r=0;r<t.length;r++){let i=t[r];i&&$e(e.filename,i.forbiddenPaths)&&n.add(r)}if(n.size===0)return!1},CallExpression(r){let i=tt(r.callee);if(i)for(let a of n){let n=t[a];if(!n||i!==n.functionName)continue;let o=n.message??`禁止在当前路径中调用 "${n.functionName}"`;e.report({node:r,message:o})}}}}}),rt=[`fetch`,`axios`],it=[`XMLHttpRequest`,`EventSource`,`WebSocket`],at=[`domains/*/ui/`,`packages/ui/`,`packages/*-ui/`],ot=new Set(it),st=[`__tests__/`,`.test.`,`.spec.`,`__mocks__/`],ct=n.object({uiPathPatterns:n.optional(n.array(n.string())),extraFunctionNames:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function lt(e,t){return t.some(t=>J(e,t))}function ut(e){let t=e.replace(/\\/g,`/`);return st.some(e=>t.includes(e))}function dt(e){let t=ct.safeParse(e),n=t.success?t.data:{};return{uiPathPatterns:n.uiPathPatterns??[...at],rawCallNames:/* @__PURE__ */ new Set([...rt,...n.extraFunctionNames??[]]),ignoreTests:n.ignoreTests??!0}}function ft(e,t){return e.type===`Identifier`?t.has(e.name)?e.name:null:e.type===`MemberExpression`&&!e.computed&&e.object.type===`Identifier`&&t.has(e.object.name)?e.property.type===`Identifier`?`${e.object.name}.${e.property.name}`:e.object.name:null}function pt(e){return e.type===`Identifier`&&ot.has(e.name)?e.name:null}function Y(e){return`UI 层禁止手写网络调用 "${e}"。网络消费统一经生成式 sdk 客户端端点加 transport 通道注入,正线见 ADR 0127 与 sdk 治理台账工作流 002。`}const mt=e({meta:{type:`problem`,docs:{description:`禁止 UI 层手写网络调用,消费面统一经生成式 sdk 客户端`}},createOnce(e){let t=null,n=!1;return{before(){if(t=dt(e.options?.[0]),n=!(t.ignoreTests&&ut(e.filename))&<(e.filename,t.uiPathPatterns),!n)return!1},CallExpression(r){if(!t||!n)return;let i=ft(r.callee,t.rawCallNames);i&&e.report({node:r,message:Y(i)})},NewExpression(r){if(!t||!n)return;let i=pt(r.callee);i&&e.report({node:r,message:Y(i)})}}}}),ht=n.object({importSource:n.string(),importNames:n.optional(n.array(n.string())),forbiddenPaths:n.array(n.string()),message:n.optional(n.string())}),gt=n.object({restrictions:n.array(ht)});function _t(e,t,n){return e===n.importSource?!n.importNames||n.importNames.length===0?t.length>0:t.some(e=>n.importNames?.includes(e)??!1):!1}function vt(e){let t=[];for(let n of e)n.type===`ImportSpecifier`&&n.imported.type===`Identifier`?t.push(n.imported.name):n.type===`ImportDefaultSpecifier`&&t.push(n.local.name);return t}function yt(e){let t=gt.safeParse(e);return t.success?t.data.restrictions:[]}function bt(e,t){return t.some(t=>J(e,t))}const xt=e({meta:{type:`problem`,docs:{description:`禁止在指定路径中导入特定模块,强制架构约束`},schema:[{type:`object`,properties:{restrictions:{type:`array`,items:{type:`object`,properties:{importSource:{type:`string`},importNames:{type:`array`,items:{type:`string`}},forbiddenPaths:{type:`array`,items:{type:`string`}},message:{type:`string`}},required:[`importSource`,`forbiddenPaths`],additionalProperties:!1}}},additionalProperties:!1}]},createOnce(e){let t=[],n=/* @__PURE__ */ new Set;return{before(){let r=e.options?.[0];if(t=yt(r),t.length===0)return!1;n=/* @__PURE__ */ new Set;for(let r=0;r<t.length;r++){let i=t[r];i&&bt(e.filename,i.forbiddenPaths)&&n.add(r)}if(n.size===0)return!1},ImportDeclaration(r){let i=r.source.value;if(typeof i!=`string`)return;let a=vt(r.specifiers??[]);for(let o of n){let n=t[o];if(!n||!_t(i,a,n))continue;let s=n.importNames?a.filter(e=>n.importNames?.includes(e)??!1):a;for(let t of s){let i=n.message??`禁止在当前路径中导入 "${t}"(来源:${n.importSource})`;e.report({node:r,message:i})}}}}}}),St=n.object({methodNames:n.optional(n.array(n.string())),objectNames:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function X(e){let t=St.safeParse(e),n=t.success?t.data:{};return{methodNames:/* @__PURE__ */ new Set([...W,...n.methodNames??[]]),loggerObjects:/* @__PURE__ */ new Set([...G,...n.objectNames??[]]),ignoreTests:n.ignoreTests??!0}}const Ct=e({meta:{type:`problem`,docs:{description:`禁止错误日志模板拼接 message,改为结构化第二参直传错误值`}},createOnce(e){let t=null,n=!1;return{before(){if(t=X(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},CallExpression(r){if(!t||!n||!q(r,t.methodNames,t.loggerObjects))return;let i=r.arguments[0];if(!i||i.type===`SpreadElement`)return;let a=i.type===`TemplateLiteral`&&i.expressions.length>0,o=i.type===`BinaryExpression`&&i.operator===`+`;(a||o)&&e.report({node:r,message:`错误日志禁止模板拼接 message。模板拼接吞掉错误对象的 cause 与 stack 与 code,消息写固定文案并以第二参直传错误值由 logger 吸收汇归一化,正线见 error-handling 台账工作流 002 判据 1 与 ADR 0166。`})}}}}),wt=n.object({methodNames:n.optional(n.array(n.string())),objectNames:n.optional(n.array(n.string())),ignoreTests:n.optional(n.boolean())});function Tt(e){let t=wt.safeParse(e),n=t.success?t.data:{};return{methodNames:/* @__PURE__ */ new Set([...W,...n.methodNames??[]]),loggerObjects:/* @__PURE__ */ new Set([...G,...n.objectNames??[]]),ignoreTests:n.ignoreTests??!0}}const Et=e({meta:{type:`problem`,docs:{description:`禁止纯文案错误日志,无底层错误时错误参数位显式传 undefined 并附业务上下文`}},createOnce(e){let t=null,n=!1;return{before(){if(t=Tt(e.options?.[0]),n=!(t.ignoreTests&&V(e.filename)),!n)return!1},CallExpression(r){t&&n&&q(r,t.methodNames,t.loggerObjects)&&r.arguments.length<2&&e.report({node:r,message:`错误日志禁止纯文案形态。无底层错误对象的业务校验场景在错误参数位显式传 undefined 并附业务上下文,正线见 error-handling 台账工作流 002 判据 2 与 ADR 0166。`})}}}}),Dt=[`vite.config.`],Ot=[`portDiscovery`],kt=n.object({viteConfigPatterns:n.optional(n.array(n.string())),registerMarkers:n.optional(n.array(n.string()))});function At(e){let t=kt.safeParse(e),n=t.success?t.data:{};return{viteConfigPatterns:n.viteConfigPatterns??[...Dt],registerMarkers:/* @__PURE__ */ new Set([...Ot,...n.registerMarkers??[]])}}function jt(e,t){let n=e.replace(/\\/g,`/`).split(`/`).pop()??``;return t.some(e=>n.includes(e))}function Z(e){return e.computed||e.key.type!==`Identifier`||e.value.type!==`Literal`?null:{key:e.key.name,value:e.value.value}}function Mt(){return`vite 配置禁止置 strictPort 为 false 依赖占用自动加一。端口面统一置 strictPort 为 true 快速失败,或 port 置 0 配合 portDiscovery 注册,正线见 ADR 0161。`}function Nt(e){return`vite 配置写死端口 ${e} 且未置 strictPort 为 true,占用时将静默改用相邻端口。端口面统一置 strictPort 为 true 快速失败,或 port 置 0 配合 portDiscovery 注册,正线见 ADR 0161。`}const Q={"dependency-direction":pe,"business-leak":u,"no-cross-package-relative-import":xe,"domain-export-compliance":k,"implementation-export-control":he,"no-implementation-import-in-apps":Ke,"no-restricted-call-in-paths":nt,"no-restricted-import-in-paths":xt,"no-raw-network-call-in-ui":mt,"no-port-probing":Oe,"no-vite-port-fallback":e({meta:{type:`problem`,docs:{description:`禁止 vite 配置依赖端口占用自动加一,端口面统一快速失败或注册表注册`}},createOnce(e){let t=null,n=!1,r={hasRegisterMarker:!1,hasStrictPortTrue:!1,strictPortFalseNodes:[],positivePortNodes:[]};return{before(){if(t=At(e.options?.[0]),n=jt(e.filename,t.viteConfigPatterns),r.hasRegisterMarker=!1,r.hasStrictPortTrue=!1,r.strictPortFalseNodes=[],r.positivePortNodes=[],!n)return!1},ImportDeclaration(e){if(t&&n)for(let n of e.specifiers)n.type===`ImportSpecifier`&&n.local.name&&t.registerMarkers.has(n.local.name)&&(r.hasRegisterMarker=!0)},CallExpression(e){t&&n&&e.callee.type===`Identifier`&&t.registerMarkers.has(e.callee.name)&&(r.hasRegisterMarker=!0)},Property(e){if(!t||!n)return;let i=Z(e);i&&(i.key===`strictPort`?i.value===!0?r.hasStrictPortTrue=!0:i.value===!1&&r.strictPortFalseNodes.push(e):i.key===`port`&&typeof i.value==`number`&&i.value>0&&r.positivePortNodes.push(e))},"Program:exit"(){if(t&&n&&!r.hasRegisterMarker){for(let t of r.strictPortFalseNodes)e.report({node:t,message:Mt()});if(!r.hasStrictPortTrue)for(let t of r.positivePortNodes){let n=Z(t);e.report({node:t,message:Nt(typeof n?.value==`number`?n.value:0)})}}}}}}),"no-template-error-log":Ct,"no-text-only-error-log":Et,"no-exit-after-error-log":Be,"no-inline-error-normalization":Xe,"no-error-type-assertion":Le},$=t({meta:{name:`@longzai-intelligence-oxlint/architecture-core-plugin`},rules:Q});export{$ as architectureCorePlugin,$ as default,Q as coreRules};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../rolldown-runtime-BqT_7tdF.js";import"../rolldown-runtime-BqT_7tdF-BqT_7tdF.js";import{n as e,r as t,t as n}from"../dist-CskvMq7J.js";import{defineRule as r,eslintCompatPlugin as i}from"@oxlint/plugins";import{existsSync as a,readFileSync as ee}from"node:fs";import{dirname as o,join as te}from"node:path";import*as s from"zod/mini";function c(e){return e.endsWith(`Class`)}const l=r({meta:{type:`problem`,docs:{description:`禁止在 import 别名中使用 "Class" 后缀`}},createOnce(e){return{ImportSpecifier(t){let n=t.local.name,r=t.imported.type===`Identifier`?t.imported.name:n;n!==r&&c(n)&&e.report({node:t,message:`导入别名 "${n}" 使用了 "Class" 后缀,这是不允许的命名方式。请使用更具描述性的名称,或直接使用原始名称 "${r}"`})}}}}),u=/* @__PURE__ */ new Set([`console.log`,`console.warn`,`console.error`,`console.info`,`console.debug`,`console.trace`,`console.dir`,`console.table`]);function d(e){let t=e.callee;return t.type===`Identifier`?t.name:t.type===`MemberExpression`&&t.property.type===`Identifier`&&t.object.type===`Identifier`?`${t.object.name}.${t.property.name}`:null}const f=r({meta:{type:`problem`,docs:{description:`禁止使用 console 方法,必须使用 @longzai-intelligence/logger-preset-* 或 react-devtools(ADR 0038)`}},createOnce(e){return{CallExpression(t){if(t.type!==`CallExpression`)return;let n=d(t);n&&u.has(n)&&e.report({node:t,message:`检测到 '${n}' — 必须使用 @longzai-intelligence/logger-preset-* 代替(ADR 0038)`})}}}}),p=/\/src\/(index|main|cli)\.(ts|mts|cts)$/,m=/(^|\/)dist\//;function ne(e){return e.replace(/\\/g,`/`)}function h(e){return typeof e==`object`&&!!e}function re(e){return e.startsWith(`#!`)}function g(e){return p.test(ne(e))}function ie(e){let t=e;for(let e=0;e<4;e+=1){let e=te(t,`package.json`);if(a(e))try{let t=JSON.parse(ee(e,`utf8`));return h(t)?t:null}catch{return null}let n=o(t);if(n===t)break;t=n}return null}function ae(e){let t=e.bin;return(typeof t==`string`?[t]:h(t)?Object.values(t).filter(e=>typeof e==`string`):[]).some(e=>m.test(e.replace(/^\.\//,``)))}const oe={noHandwrittenShebang:`入口源码手写 shebang 属被裁定的错误方式,bin 产物首行 shebang 应由 "lzi-builder.config.ts" 的 banner 在构建期注入。请删除源码首行的 "#!" 行并补 banner 配置。`},_=r({meta:{type:`problem`,docs:{description:`禁止所属包 bin 指向 dist 产物的入口源码手写 shebang`}},createOnce(e){return{before(){let t=e.filename;if(!g(t))return!1},Program(t){let n=e.sourceCode.text;if(!re(n))return;let r=ie(o(o(e.filename)));r!==null&&ae(r)&&e.report({node:t,message:oe.noHandwrittenShebang})}}}}),v=s.object({type:s.literal(`TSTypeLiteral`)}),y=s.object({type:s.literal(`TSFunctionType`)}),b=s.object({type:s.literal(`TSUnionType`),types:s.array(s.unknown())}),se=s.object({type:s.literal(`TSIntersectionType`),types:s.array(s.unknown())}),ce=s.object({type:s.literal(`Identifier`),name:s.string()}),le=s.object({type:s.literal(`RestElement`),argument:s.object({name:s.string()})}),ue=s.union([ce,le]),x=s.object({typeAnnotation:s.unknown()}),de=s.object({type:s.literal(`MethodDefinition`),key:s.object({type:s.string(),name:s.optional(s.string())}),value:s.object({params:s.optional(s.array(s.unknown())),returnType:s.optional(s.union([x,s.null()]))}),kind:s.enum([`method`,`constructor`,`get`,`set`])}),fe=s.object({returnType:x}),pe=s.object({id:s.optional(s.object({name:s.optional(s.string())})),params:s.optional(s.array(s.unknown())),returnType:s.optional(s.unknown())}),me=s.object({params:s.optional(s.array(s.unknown()))});function S(e){return v.safeParse(e).success}function C(e){return y.safeParse(e).success}function w(e){return b.safeParse(e).success}function T(e){return se.safeParse(e).success}function E(e){return ue.safeParse(e).success}function D(e){if(typeof e!=`object`||!e||!(`type`in e))return!1;let t=[`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`MethodDefinition`],n=e.type;return typeof n==`string`&&t.includes(n)}function O(e){return de.safeParse(e).success}function k(e){return fe.safeParse(e).success}function A(e){return pe.safeParse(e).success}function j(e){return me.safeParse(e).success}function M(e){return S(e)||C(e)?!0:w(e)||T(e)?e.types.some(M):!1}function N(e){return S(e)?`对象类型`:C(e)?`函数类型`:`内联类型`}function P(e){return E(e)?e.type===`Identifier`?e.name:e.type===`RestElement`?e.argument.name:null:null}function F(e,t,n,r,i,a){i?e.report({node:t,message:`参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`}):a?e.report({node:t,message:`方法 "${a}" 的参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`}):e.report({node:t,message:`参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`})}function I(e,t,n,r,i){i?e.report({node:t,message:`方法 "${i}" 的返回值使用了内联${n}定义。请将其提取为具名的 type。`}):r?e.report({node:t,message:`函数 "${r}" 的返回值使用了内联${n}定义。请将其提取为具名的 type。`}):e.report({node:t,message:`匿名函数的返回值使用了内联${n}定义。请将其提取为具名的 type。`})}function L(e,t,n,r,i){if(typeof e!=`object`||!e||!(`typeAnnotation`in e)||e.typeAnnotation===null||typeof e.typeAnnotation!=`object`||!(`typeAnnotation`in e.typeAnnotation))return;let a=e.typeAnnotation.typeAnnotation;M(a)&&F(t,n,P(e)??`未知参数`,N(a),r,i)}function R(e,t,n,r,i){for(let a of e)L(a,t,n,i??!1,r)}function z(e,t,n,r,i){if(typeof e!=`object`||!e||!(`typeAnnotation`in e))return;let a=e.typeAnnotation;M(a)&&I(t,n,N(a),r,i)}function B(e,t){if(!D(e)||!A(e))return;let n=null;`id`in e&&e.id!==null&&typeof e.id==`object`&&`name`in e.id&&typeof e.id.name==`string`&&(n=e.id.name),j(e)&&R(e.params??[],t,e),k(e)&&z(e.returnType,t,e,n??void 0)}function he(e,t){D(e)&&j(e)&&(j(e)&&R(e.params??[],t,e),k(e)&&z(e.returnType,t,e))}function ge(e,t){if(!O(e))return;let n=e.key,r=n&&`name`in n&&typeof n.name==`string`?n.name:`未知方法`,i=e.value;if(i&&`params`in i&&Array.isArray(i.params)&&R(i.params,t,e,r,e.kind===`constructor`),i&&`returnType`in i&&i.returnType&&typeof i.returnType==`object`&&`typeAnnotation`in i.returnType){let n=i.returnType;z(n,t,e,void 0,r)}}const V=r({meta:{type:`suggestion`,docs:{description:`禁止在函数参数和返回值中使用内联类型定义,强制使用具名类型`}},createOnce(e){return{FunctionDeclaration(t){B(t,e)},FunctionExpression(t){B(t,e)},ArrowFunctionExpression(t){he(t,e)},MethodDefinition(t){ge(t,e)}}}}),H=/^(?:eslint-disable(?:-next-line|-line)?|eslint-enable|oxlint-disable(?:-next-line|-line)?|oxlint-enable|biome-ignore|stylelint-disable(?:-next-line|-line)?|stylelint-enable|@ts-ignore|@ts-nocheck)(?=[\s,]|$)/;function _e(e){let t=e.trimStart();return H.exec(t)?.[0]??null}const U=r({meta:{type:`problem`,docs:{description:`禁止 eslint-disable、oxlint-disable、biome-ignore、stylelint-disable、@ts-ignore、@ts-nocheck 等抑制注释`}},createOnce(e){return{Program(){let t=e.sourceCode.getAllComments();for(let n of t){if(n.type===`Shebang`)continue;let t=_e(n.value);t!==null&&e.report({node:n,message:`检测到抑制指令 ${t},抑制注释不是合法豁免手段,请从源头消除违例或在包级 oxlint.config.ts 的 ignorePatterns 登记路径豁免`})}}}}});function ve(e){let t=[];if(e.type===`Identifier`&&t.push(e.name),e.type===`ObjectPattern`)for(let n of e.properties)n.type===`Property`&&`value`in n?n.value.type===`Identifier`&&t.push(n.value.name):n.type===`RestElement`&&n.argument.type===`Identifier`&&t.push(n.argument.name);if(e.type===`ArrayPattern`)for(let n of e.elements)n&&n.type===`Identifier`&&t.push(n.name);return t}const W=r({meta:{type:`suggestion`,docs:{description:`将 export const/let/var 拆分为独立的声明和导出语句`}},createOnce(e){return{ExportNamedDeclaration(t){if(!t.declaration||t.declaration.type!==`VariableDeclaration`)return;let n=t.declaration;if(n.kind!==`const`&&n.kind!==`let`&&n.kind!==`var`||n.declarations.length===0)return;let r=[];for(let e of n.declarations)r.push(...ve(e.id));r.length!==0&&e.report({node:t,message:`应将 \`export ${n.kind} ${r.join(`, `)}\` 拆分为独立的声明和导出语句`})}}}}),G=[{suffix:`.service.drizzle.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.memory.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.controller.ts`,classSuffix:`Controller`,isInterface:!1,isPrefix:!1},{suffix:`.module.ts`,classSuffix:`Module`,isInterface:!1,isPrefix:!1},{suffix:`.repository.drizzle.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.memory.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.interface.ts`,classSuffix:`Repository`,isInterface:!0,isPrefix:!0},{suffix:`.repository.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.entity.ts`,classSuffix:`Entity`,isInterface:!1,isPrefix:!1},{suffix:`.orm-entity.ts`,classSuffix:`OrmEntity`,isInterface:!1,isPrefix:!1},{suffix:`.dto.ts`,classSuffix:`DTO`,isInterface:!1,isPrefix:!1},{suffix:`.port.interface.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!0},{suffix:`.interface.ts`,classSuffix:``,isInterface:!0,isPrefix:!0},{suffix:`.port.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!1},{suffix:`.port.adapter.ts`,classSuffix:`PortAdapter`,isInterface:!1,isPrefix:!1},{suffix:`.adapter.ts`,classSuffix:`Adapter`,isInterface:!1,isPrefix:!1},{suffix:`.events.ts`,classSuffix:`Event`,isInterface:!1,isPrefix:!1},{suffix:`.mapper.ts`,classSuffix:`Mapper`,isInterface:!1,isPrefix:!1},{suffix:`.vo.ts`,classSuffix:`VO`,isInterface:!1,isPrefix:!1},{suffix:`.usecase.ts`,classSuffix:`UseCase`,isInterface:!1,isPrefix:!1},{suffix:`.errors.ts`,classSuffix:`Error`,isInterface:!1,isPrefix:!1}];function K(e){for(let t of G)if(e.endsWith(t.suffix))return t;return null}function q(e,t){if(t.isPrefix&&t.isInterface){if(t.classSuffix){let n=t.classSuffix;return e.startsWith(`I`)&&e.endsWith(n)&&e.length>1+n.length}return e.startsWith(`I`)&&e.length>1}return t.isPrefix?e.startsWith(`I`)&&e.length>1:e.endsWith(t.classSuffix)&&e.length>t.classSuffix.length}function J(e){return e.isPrefix&&e.isInterface?e.classSuffix?`I${e.classSuffix}(如 IUser${e.classSuffix})`:`I 前缀(如 IUser)`:e.isPrefix?`I 前缀(如 IUser)`:`${e.classSuffix} 后缀`}const Y=r({meta:{type:`problem`,docs:{description:`强制执行类名与文件类型后缀的一致性`}},createOnce(e){return{before(){let t=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)||!K(t))return!1},ClassDeclaration(t){let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=K(n);if(!r||r.isInterface||!t.id)return;let i=t.id.name;q(i,r)||e.report({node:t,message:`类名 "${i}" 不符合命名规范。文件 "${n}" 中的类应使用 ${J(r)}`})},TSInterfaceDeclaration(t){let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=K(n);if(!r||!r.isInterface)return;let i=t.id.name;q(i,r)||e.report({node:t,message:`接口名 "${i}" 不符合命名规范。文件 "${n}" 中的接口应使用 ${J(r)}`})}}}});function X(e){return e.endsWith(`.dto.ts`)}function ye(e){return e.endsWith(`DTO`)}const Z=r({meta:{type:`problem`,docs:{description:`强制执行 DTO 文件中的接口命名规范(Dto 后缀,驼峰式)`}},createOnce(e){return{before(){let t=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)||!X(t))return!1},TSInterfaceDeclaration(n){let r=n.id.name;ye(r)?e.report({node:n,message:`接口名 "${r}" 后缀应使用 Dto(驼峰式)而非 DTO(全大写)`}):t(r)||e.report({node:n,message:`DTO 文件中的接口名 "${r}" 应以 Dto 结尾(如 UserResponseDto)`})}}}}),be=[`types.ts`,`types.d.ts`],xe=[`.port.interface.ts`,`.repository.interface.ts`,`.types.ts`,`.types.d.ts`,`.events.ts`,`.d.ts`];function Se(t,r){return e(t)?!1:!r.endsWith(`.dto.ts`)||n(t)}function Ce(e){return e.endsWith(`.dto.ts`)?`DTO 后缀(如 UserDTO),禁止 I 前缀`:`PascalCase(如 User、UserRepository),禁止 I 前缀`}function we(e){if(be.includes(e))return!0;for(let t of xe)if(e.endsWith(t))return!0;return!1}function Te(e){return e.endsWith(`.port.ts`)?e.replace(`.port.ts`,`.port.interface.ts`):e.endsWith(`.repository.ts`)?e.replace(`.repository.ts`,`.repository.interface.ts`):e.replace(`.ts`,`.interface.ts`)}const Q=r({meta:{type:`problem`,docs:{description:`强制执行接口命名规范(禁止 I 前缀,使用 PascalCase)和文件命名规范`}},createOnce(t){return{before(){let e=t.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(e.endsWith(`.test.ts`)||e.endsWith(`.spec.ts`)||we(e))return!1},TSInterfaceDeclaration(n){let r=t.filename.replace(/\\/g,`/`).split(`/`).pop()??``,i=r.endsWith(`.interface.ts`)||r.endsWith(`.interface.tsx`),a=n.id.name;Se(a,r)||(e(a)?t.report({node:n,message:`接口名 "${a}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "${a.substring(1)}"`}):r.endsWith(`.dto.ts`)&&a.endsWith(`Dto`)?t.report({node:n,message:`接口名 "${a}" 后缀应使用 DTO(全大写)而非 Dto(驼峰式)`}):t.report({node:n,message:`接口名 "${a}" 不符合命名规范。接口名应使用 ${Ce(r)}`})),!i&&!r.endsWith(`.dto.ts`)&&!r.endsWith(`.tsx`)&&t.report({node:n,message:`包含接口 "${a}" 的文件 "${r}" 应命名为 "${Te(r)}"`})}}}}),$=i({meta:{name:`@longzai-intelligence-oxlint/code-style-plugin`},rules:{"no-console":f,"no-inline-type-definition":V,"prefer-split-export-const":W,"require-interface-naming":Q,"require-dto-naming":Z,"require-class-suffix":Y,"no-class-suffix-alias":l,"no-handwritten-shebang":_,"no-lint-suppression":U}});export{G as SUFFIX_MAPPINGS,$ as codeStylePlugin,$ as default,N as getInlineTypeDescription,P as getParamName,e as hasIPrefix,M as hasInlineType,X as isDtoFile,D as isFunctionNode,O as isMethodDefinition,C as isTSFunctionType,T as isTSIntersectionType,S as isTSTypeLiteral,w as isTSUnionType,l as noClassSuffixAliasRule,f as noConsoleRule,_ as noHandwrittenShebangRule,V as noInlineTypeDefinitionRule,U as noLintSuppressionRule,W as preferSplitExportConstRule,Y as requireClassSuffixRule,Z as requireDtoNamingRule,Q as requireInterfaceNamingRule};
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";import"../rolldown-runtime-BqT_7tdF-BqT_7tdF.js";import{n as e,r as t,t as n}from"../dist-CskvMq7J.js";import{defineRule as r,eslintCompatPlugin as i}from"@oxlint/plugins";import{existsSync as a,readFileSync as ee}from"node:fs";import{dirname as o,join as te}from"node:path";import*as s from"zod/mini";function c(e){return e.endsWith(`Class`)}const l=r({meta:{type:`problem`,docs:{description:`禁止在 import 别名中使用 "Class" 后缀`}},createOnce(e){return{ImportSpecifier(t){let n=t.local.name,r=t.imported.type===`Identifier`?t.imported.name:n;n!==r&&c(n)&&e.report({node:t,message:`导入别名 "${n}" 使用了 "Class" 后缀,这是不允许的命名方式。请使用更具描述性的名称,或直接使用原始名称 "${r}"`})}}}}),u=/* @__PURE__ */ new Set([`console.log`,`console.warn`,`console.error`,`console.info`,`console.debug`,`console.trace`,`console.dir`,`console.table`]);function d(e){let t=e.callee;return t.type===`Identifier`?t.name:t.type===`MemberExpression`&&t.property.type===`Identifier`&&t.object.type===`Identifier`?`${t.object.name}.${t.property.name}`:null}const f=r({meta:{type:`problem`,docs:{description:`禁止使用 console 方法,必须使用 @longzai-intelligence/logger-preset-* 或 react-devtools(ADR 0038)`}},createOnce(e){return{CallExpression(t){if(t.type!==`CallExpression`)return;let n=d(t);n&&u.has(n)&&e.report({node:t,message:`检测到 '${n}' — 必须使用 @longzai-intelligence/logger-preset-* 代替(ADR 0038)`})}}}}),p=/\/src\/(index|main|cli)\.(ts|mts|cts)$/,m=/(^|\/)dist\//;function ne(e){return e.replace(/\\/g,`/`)}function h(e){return typeof e==`object`&&!!e}function re(e){return e.startsWith(`#!`)}function g(e){return p.test(ne(e))}function ie(e){let t=e;for(let e=0;e<4;e+=1){let e=te(t,`package.json`);if(a(e))try{let t=JSON.parse(ee(e,`utf8`));return h(t)?t:null}catch{return null}let n=o(t);if(n===t)break;t=n}return null}function ae(e){let t=e.bin;return(typeof t==`string`?[t]:h(t)?Object.values(t).filter(e=>typeof e==`string`):[]).some(e=>m.test(e.replace(/^\.\//,``)))}const oe={noHandwrittenShebang:`入口源码手写 shebang 属被裁定的错误方式,bin 产物首行 shebang 应由 "lzi-builder.config.ts" 的 banner 在构建期注入。请删除源码首行的 "#!" 行并补 banner 配置。`},_=r({meta:{type:`problem`,docs:{description:`禁止所属包 bin 指向 dist 产物的入口源码手写 shebang`}},createOnce(e){return{before(){let t=e.filename;if(!g(t))return!1},Program(t){let n=e.sourceCode.text;if(!re(n))return;let r=ie(o(o(e.filename)));r!==null&&ae(r)&&e.report({node:t,message:oe.noHandwrittenShebang})}}}}),v=s.object({type:s.literal(`TSTypeLiteral`)}),y=s.object({type:s.literal(`TSFunctionType`)}),b=s.object({type:s.literal(`TSUnionType`),types:s.array(s.unknown())}),se=s.object({type:s.literal(`TSIntersectionType`),types:s.array(s.unknown())}),ce=s.object({type:s.literal(`Identifier`),name:s.string()}),le=s.object({type:s.literal(`RestElement`),argument:s.object({name:s.string()})}),ue=s.union([ce,le]),x=s.object({typeAnnotation:s.unknown()}),de=s.object({type:s.literal(`MethodDefinition`),key:s.object({type:s.string(),name:s.optional(s.string())}),value:s.object({params:s.optional(s.array(s.unknown())),returnType:s.optional(s.union([x,s.null()]))}),kind:s.enum([`method`,`constructor`,`get`,`set`])}),fe=s.object({returnType:x}),pe=s.object({id:s.optional(s.object({name:s.optional(s.string())})),params:s.optional(s.array(s.unknown())),returnType:s.optional(s.unknown())}),me=s.object({params:s.optional(s.array(s.unknown()))});function S(e){return v.safeParse(e).success}function C(e){return y.safeParse(e).success}function w(e){return b.safeParse(e).success}function T(e){return se.safeParse(e).success}function E(e){return ue.safeParse(e).success}function D(e){if(typeof e!=`object`||!e||!(`type`in e))return!1;let t=[`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`MethodDefinition`],n=e.type;return typeof n==`string`&&t.includes(n)}function O(e){return de.safeParse(e).success}function k(e){return fe.safeParse(e).success}function A(e){return pe.safeParse(e).success}function j(e){return me.safeParse(e).success}function M(e){return S(e)||C(e)?!0:w(e)||T(e)?e.types.some(M):!1}function N(e){return S(e)?`对象类型`:C(e)?`函数类型`:`内联类型`}function P(e){return E(e)?e.type===`Identifier`?e.name:e.type===`RestElement`?e.argument.name:null:null}function F(e,t,n,r,i,a){i?e.report({node:t,message:`参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`}):a?e.report({node:t,message:`方法 "${a}" 的参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`}):e.report({node:t,message:`参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`})}function I(e,t,n,r,i){i?e.report({node:t,message:`方法 "${i}" 的返回值使用了内联${n}定义。请将其提取为具名的 type。`}):r?e.report({node:t,message:`函数 "${r}" 的返回值使用了内联${n}定义。请将其提取为具名的 type。`}):e.report({node:t,message:`匿名函数的返回值使用了内联${n}定义。请将其提取为具名的 type。`})}function L(e,t,n,r,i){if(typeof e!=`object`||!e||!(`typeAnnotation`in e)||e.typeAnnotation===null||typeof e.typeAnnotation!=`object`||!(`typeAnnotation`in e.typeAnnotation))return;let a=e.typeAnnotation.typeAnnotation;M(a)&&F(t,n,P(e)??`未知参数`,N(a),r,i)}function R(e,t,n,r,i){for(let a of e)L(a,t,n,i??!1,r)}function z(e,t,n,r,i){if(typeof e!=`object`||!e||!(`typeAnnotation`in e))return;let a=e.typeAnnotation;M(a)&&I(t,n,N(a),r,i)}function B(e,t){if(!D(e)||!A(e))return;let n=null;`id`in e&&e.id!==null&&typeof e.id==`object`&&`name`in e.id&&typeof e.id.name==`string`&&(n=e.id.name),j(e)&&R(e.params??[],t,e),k(e)&&z(e.returnType,t,e,n??void 0)}function he(e,t){D(e)&&j(e)&&(j(e)&&R(e.params??[],t,e),k(e)&&z(e.returnType,t,e))}function ge(e,t){if(!O(e))return;let n=e.key,r=n&&`name`in n&&typeof n.name==`string`?n.name:`未知方法`,i=e.value;if(i&&`params`in i&&Array.isArray(i.params)&&R(i.params,t,e,r,e.kind===`constructor`),i&&`returnType`in i&&i.returnType&&typeof i.returnType==`object`&&`typeAnnotation`in i.returnType){let n=i.returnType;z(n,t,e,void 0,r)}}const V=r({meta:{type:`suggestion`,docs:{description:`禁止在函数参数和返回值中使用内联类型定义,强制使用具名类型`}},createOnce(e){return{FunctionDeclaration(t){B(t,e)},FunctionExpression(t){B(t,e)},ArrowFunctionExpression(t){he(t,e)},MethodDefinition(t){ge(t,e)}}}}),H=/^(?:eslint-disable(?:-next-line|-line)?|eslint-enable|oxlint-disable(?:-next-line|-line)?|oxlint-enable|biome-ignore|stylelint-disable(?:-next-line|-line)?|stylelint-enable|@ts-ignore|@ts-nocheck)(?=[\s,]|$)/;function _e(e){let t=e.trimStart();return H.exec(t)?.[0]??null}const U=r({meta:{type:`problem`,docs:{description:`禁止 eslint-disable、oxlint-disable、biome-ignore、stylelint-disable、@ts-ignore、@ts-nocheck 等抑制注释`}},createOnce(e){return{Program(){let t=e.sourceCode.getAllComments();for(let n of t){if(n.type===`Shebang`)continue;let t=_e(n.value);t!==null&&e.report({node:n,message:`检测到抑制指令 ${t},抑制注释不是合法豁免手段,请从源头消除违例或在包级 oxlint.config.ts 的 ignorePatterns 登记路径豁免`})}}}}});function ve(e){let t=[];if(e.type===`Identifier`&&t.push(e.name),e.type===`ObjectPattern`)for(let n of e.properties)n.type===`Property`&&`value`in n?n.value.type===`Identifier`&&t.push(n.value.name):n.type===`RestElement`&&n.argument.type===`Identifier`&&t.push(n.argument.name);if(e.type===`ArrayPattern`)for(let n of e.elements)n&&n.type===`Identifier`&&t.push(n.name);return t}const W=r({meta:{type:`suggestion`,docs:{description:`将 export const/let/var 拆分为独立的声明和导出语句`}},createOnce(e){return{ExportNamedDeclaration(t){if(!t.declaration||t.declaration.type!==`VariableDeclaration`)return;let n=t.declaration;if(n.kind!==`const`&&n.kind!==`let`&&n.kind!==`var`||n.declarations.length===0)return;let r=[];for(let e of n.declarations)r.push(...ve(e.id));r.length!==0&&e.report({node:t,message:`应将 \`export ${n.kind} ${r.join(`, `)}\` 拆分为独立的声明和导出语句`})}}}}),G=[{suffix:`.service.drizzle.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.memory.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.controller.ts`,classSuffix:`Controller`,isInterface:!1,isPrefix:!1},{suffix:`.module.ts`,classSuffix:`Module`,isInterface:!1,isPrefix:!1},{suffix:`.repository.drizzle.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.memory.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.interface.ts`,classSuffix:`Repository`,isInterface:!0,isPrefix:!0},{suffix:`.repository.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.entity.ts`,classSuffix:`Entity`,isInterface:!1,isPrefix:!1},{suffix:`.orm-entity.ts`,classSuffix:`OrmEntity`,isInterface:!1,isPrefix:!1},{suffix:`.dto.ts`,classSuffix:`DTO`,isInterface:!1,isPrefix:!1},{suffix:`.port.interface.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!0},{suffix:`.interface.ts`,classSuffix:``,isInterface:!0,isPrefix:!0},{suffix:`.port.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!1},{suffix:`.port.adapter.ts`,classSuffix:`PortAdapter`,isInterface:!1,isPrefix:!1},{suffix:`.adapter.ts`,classSuffix:`Adapter`,isInterface:!1,isPrefix:!1},{suffix:`.events.ts`,classSuffix:`Event`,isInterface:!1,isPrefix:!1},{suffix:`.mapper.ts`,classSuffix:`Mapper`,isInterface:!1,isPrefix:!1},{suffix:`.vo.ts`,classSuffix:`VO`,isInterface:!1,isPrefix:!1},{suffix:`.usecase.ts`,classSuffix:`UseCase`,isInterface:!1,isPrefix:!1},{suffix:`.errors.ts`,classSuffix:`Error`,isInterface:!1,isPrefix:!1}];function K(e){for(let t of G)if(e.endsWith(t.suffix))return t;return null}function q(e,t){if(t.isPrefix&&t.isInterface){if(t.classSuffix){let n=t.classSuffix;return e.startsWith(`I`)&&e.endsWith(n)&&e.length>1+n.length}return e.startsWith(`I`)&&e.length>1}return t.isPrefix?e.startsWith(`I`)&&e.length>1:e.endsWith(t.classSuffix)&&e.length>t.classSuffix.length}function J(e){return e.isPrefix&&e.isInterface?e.classSuffix?`I${e.classSuffix}(如 IUser${e.classSuffix})`:`I 前缀(如 IUser)`:e.isPrefix?`I 前缀(如 IUser)`:`${e.classSuffix} 后缀`}const Y=r({meta:{type:`problem`,docs:{description:`强制执行类名与文件类型后缀的一致性`}},createOnce(e){return{before(){let t=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)||!K(t))return!1},ClassDeclaration(t){let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=K(n);if(!r||r.isInterface||!t.id)return;let i=t.id.name;q(i,r)||e.report({node:t,message:`类名 "${i}" 不符合命名规范。文件 "${n}" 中的类应使用 ${J(r)}`})},TSInterfaceDeclaration(t){let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=K(n);if(!r||!r.isInterface)return;let i=t.id.name;q(i,r)||e.report({node:t,message:`接口名 "${i}" 不符合命名规范。文件 "${n}" 中的接口应使用 ${J(r)}`})}}}});function X(e){return e.endsWith(`.dto.ts`)}function ye(e){return e.endsWith(`DTO`)}const Z=r({meta:{type:`problem`,docs:{description:`强制执行 DTO 文件中的接口命名规范(Dto 后缀,驼峰式)`}},createOnce(e){return{before(){let t=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)||!X(t))return!1},TSInterfaceDeclaration(n){let r=n.id.name;ye(r)?e.report({node:n,message:`接口名 "${r}" 后缀应使用 Dto(驼峰式)而非 DTO(全大写)`}):t(r)||e.report({node:n,message:`DTO 文件中的接口名 "${r}" 应以 Dto 结尾(如 UserResponseDto)`})}}}}),be=[`types.ts`,`types.d.ts`],xe=[`.port.interface.ts`,`.repository.interface.ts`,`.types.ts`,`.types.d.ts`,`.events.ts`,`.d.ts`];function Se(t,r){return e(t)?!1:!r.endsWith(`.dto.ts`)||n(t)}function Ce(e){return e.endsWith(`.dto.ts`)?`DTO 后缀(如 UserDTO),禁止 I 前缀`:`PascalCase(如 User、UserRepository),禁止 I 前缀`}function we(e){if(be.includes(e))return!0;for(let t of xe)if(e.endsWith(t))return!0;return!1}function Te(e){return e.endsWith(`.port.ts`)?e.replace(`.port.ts`,`.port.interface.ts`):e.endsWith(`.repository.ts`)?e.replace(`.repository.ts`,`.repository.interface.ts`):e.replace(`.ts`,`.interface.ts`)}const Q=r({meta:{type:`problem`,docs:{description:`强制执行接口命名规范(禁止 I 前缀,使用 PascalCase)和文件命名规范`}},createOnce(t){return{before(){let e=t.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(e.endsWith(`.test.ts`)||e.endsWith(`.spec.ts`)||we(e))return!1},TSInterfaceDeclaration(n){let r=t.filename.replace(/\\/g,`/`).split(`/`).pop()??``,i=r.endsWith(`.interface.ts`)||r.endsWith(`.interface.tsx`),a=n.id.name;Se(a,r)||(e(a)?t.report({node:n,message:`接口名 "${a}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "${a.substring(1)}"`}):r.endsWith(`.dto.ts`)&&a.endsWith(`Dto`)?t.report({node:n,message:`接口名 "${a}" 后缀应使用 DTO(全大写)而非 Dto(驼峰式)`}):t.report({node:n,message:`接口名 "${a}" 不符合命名规范。接口名应使用 ${Ce(r)}`})),i||r.endsWith(`.dto.ts`)||r.endsWith(`.tsx`)||t.report({node:n,message:`包含接口 "${a}" 的文件 "${r}" 应命名为 "${Te(r)}"`})}}}}),$=i({meta:{name:`@longzai-intelligence-oxlint/code-style-plugin`},rules:{"no-console":f,"no-inline-type-definition":V,"prefer-split-export-const":W,"require-interface-naming":Q,"require-dto-naming":Z,"require-class-suffix":Y,"no-class-suffix-alias":l,"no-handwritten-shebang":_,"no-lint-suppression":U}});export{G as SUFFIX_MAPPINGS,$ as codeStylePlugin,$ as default,N as getInlineTypeDescription,P as getParamName,e as hasIPrefix,M as hasInlineType,X as isDtoFile,D as isFunctionNode,O as isMethodDefinition,C as isTSFunctionType,T as isTSIntersectionType,S as isTSTypeLiteral,w as isTSUnionType,l as noClassSuffixAliasRule,f as noConsoleRule,_ as noHandwrittenShebangRule,V as noInlineTypeDefinitionRule,U as noLintSuppressionRule,W as preferSplitExportConstRule,Y as requireClassSuffixRule,Z as requireDtoNamingRule,Q as requireInterfaceNamingRule};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import"../rolldown-runtime-BqT_7tdF.js";import{parseSeparatorComment as e}from"./tsdoc.js";import{defineRule as t,eslintCompatPlugin as n}from"@oxlint/plugins";function r(){return{isBlockStart:!1,isBlockEnd:!1,isObjectStart:!1,isObjectEnd:!1,isArrayStart:!1,isArrayEnd:!1,isClassStart:!1,isClassEnd:!1,isInterfaceStart:!1,isInterfaceEnd:!1,isTypeStart:!1,isTypeEnd:!1,isEnumStart:!1,isEnumEnd:!1,isModuleStart:!1,isModuleEnd:!1,isFunctionStart:!1,isFunctionEnd:!1}}function i(e){return!!(e.includes(`type `)||e.includes(`extends {`)||e.includes(`type{`)||e.includes(`Array<{`)||e.includes(`Promise<{`)||e.includes(`<{`)||e.includes(`| {`)||e.includes(`as {`)||e.includes(`Record<{`)||e.includes(`Partial<{`)||e.includes(`Required<{`)||e.includes(`Pick<{`)||e.includes(`Omit<{`)||e.includes(`& {`))}function a(e,t){for(let n=2;n<=5&&t>n;n++){let r=e[t-n-1];if(r){let e=r.trimEnd();if(e.includes(`Record<{`)||e.includes(`Partial<{`)||e.includes(`Required<{`)||e.includes(`Pick<{`)||e.includes(`Omit<{`)||e.includes(`Array<{`)||e.includes(`Promise<{`)||e.includes(`type `)||e.includes(`interface `))return!0}}return!1}function o(e){return e.endsWith(`) {`)||e.endsWith(`){`)||/\)\s*(?::\s*[^{]+)?\{/.test(e)||e.includes(`=> {`)}function s(e){return!!(e.endsWith(`) {`)||e.endsWith(`){`)||e===`{`||/: [^{]+ \{$/.test(e)||/\)\s*(?::\s*[^{]+)?\{/.test(e)||e.endsWith(`}> {`)||e===`> {`||e.includes(`try {`)||e.includes(`catch {`)||e.includes(`finally {`)||e.includes(`=> {`)||e.includes(`else {`)||/^\w+\s*\{$/.test(e)||/^\| .+ \{$/.test(e))}function c(e){let t=e.includes(`namespace `)||e.includes(`namespace{`),n=e.startsWith(`declare global`)||e.startsWith(`declare module`);return e.includes(`module `)||e.includes(`module{`)||t||n}function l(e,t){for(let n=2;n<=10&&t>n;n++){let r=e[t-n-1];if(r){let e=r.trim();if(e.includes(`class `)||e.includes(`class{`))return!0}}return!1}function u(e){let t=/\w\(\{$/.test(e),n=e.endsWith(`, {`),r=/=>\s*\(\{$/.test(e),i=e.includes(`export default {`);return e.includes(`: {`)||e.endsWith(`= {`)||t||n||r||i}function d(e,t,n,r){i(t)?e.isTypeStart=!0:t.trim()===`{`?e[a(n,r)?`isTypeStart`:`isBlockStart`]=!0:t.includes(`interface `)||t.includes(`interface{`)?e.isInterfaceStart=!0:t.includes(`enum `)||t.includes(`enum{`)?e.isEnumStart=!0:c(t)?e.isModuleStart=!0:t.includes(`class `)||t.includes(`class{`)||t===`> {`?e.isClassStart=!0:s(t)?(e.isBlockStart=!0,o(t)&&(e.isFunctionStart=!0)):u(t)?e.isObjectStart=!0:t.includes(`: [`)||t.endsWith(`= [`)||t.endsWith(`[`)?e.isArrayStart=!0:l(n,r)&&(e.isClassStart=!0)}function f(e,t,n){if(t<=1)return;let r=t-2;for(;r>=0;){let e=n[r];if(e&&e.trim().length>0)break;r--}if(r<0)return;let i=n[r];if(!i)return;let a=i.trim();a.endsWith(`{`)||/>+\s*\{\s*$/.test(a)?d(e,a,n,t):a.endsWith(`(`)||a.endsWith(`>`)?e.isBlockStart=!0:a.endsWith(`[`)&&(e.isArrayStart=!0)}function p(e,t,n){if(t>=n.length)return;let r=n[t];if(!r)return;let i=r.trimStart();i===`}`||i===`};`?(e.isBlockEnd=!0,e.isObjectEnd=!0,e.isClassEnd=!0,e.isInterfaceEnd=!0,e.isTypeEnd=!0,e.isEnumEnd=!0,e.isModuleEnd=!0,e.isFunctionEnd=!0):i.startsWith(`];`)&&(e.isArrayEnd=!0)}function m(e,t){let n=r(),i=e.loc.start.line,a=e.loc.end.line;return f(n,i,t),p(n,a,t),n}const h={beforeBlockComment:!0,afterBlockComment:!1,beforeLineComment:!1,afterLineComment:!1,allowBlockStart:!1,allowBlockEnd:!1,allowObjectStart:!1,allowObjectEnd:!1,allowArrayStart:!1,allowArrayEnd:!1,allowClassStart:!1,allowClassEnd:!1,allowInterfaceStart:!1,allowInterfaceEnd:!1,allowTypeStart:!1,allowTypeEnd:!1,allowEnumStart:!1,allowEnumEnd:!1,allowModuleStart:!1,allowModuleEnd:!1,allowFunctionStart:!1,allowFunctionEnd:!1,ignorePattern:void 0,applyDefaultIgnorePatterns:!0};function ee(e,t){if(e.loc.start.line<=1)return!1;let n=g(e.loc.start.line,t);return n?/\w+=\{$/.test(n):!1}function te(e,t){if(e.loc.start.line<=1)return!1;let n=g(e.loc.start.line,t);if(!n||!(n===`}`||/^\w+=("[^"]*"|'[^']*')$/.test(n)||/^\w+=\{.+\}$/.test(n)||/^<[A-Z]\w*$/.test(n)||/^\w+:$/.test(n)))return!1;let r=_(e.loc.end.line,t);return r?/^\w+=/.test(r)||/^\/?>$/.test(r)||r.startsWith(`/>`)||r.startsWith(`(`)||r.startsWith(`<`):!1}const ne=/(?:,|:|\?|=>|&&|\|\||=|[+*/%&|^<-])$/u;function re(e,t){if(e.loc.start.line<=1)return!1;let n=y(e.loc.start.line,t);return n?ne.test(n):!1}function g(e,t){let n=e-2;for(;n>=0;){let e=t[n];if(e&&e.trim().length>0)return e.trim();n--}return null}function _(e,t){let n=e;for(;n<t.length;){let e=t[n];if(e&&e.trim().length>0)return e.trim();n++}return null}function v(e){return e.startsWith(`//`)||e.startsWith(`/*`)||e.startsWith(`*`)}function y(e,t){let n=e-2;for(;n>=0;){let e=t[n];if(e&&e.trim().length>0&&!v(e.trim()))return e.trim();n--}return null}function b(e,t){let n=t[e.loc.start.line-1];return n?n.slice(0,e.loc.start.column).trim().length>0:!1}function x(e,t){if(t.length===0)return!1;let n=t[t.length-1];return n?n.loc.end.line+1>=e.loc.start.line:!1}const S=[/^eslint/i,/^jshint/i,/^jslint/i,/^istanbul/i,/^global/i,/^exported/i,/^jscs/i];function C(e,t){let n=e.value.trim();if(t.applyDefaultIgnorePatterns!==!1){for(let e of S)if(e.test(n))return!0}return!!(t.ignorePattern&&new RegExp(t.ignorePattern,`u`).test(n))}function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e,t,n){let r=t[n];typeof r==`boolean`&&(e[n]=r)}function E(e,t){T(e,t,`beforeBlockComment`),T(e,t,`afterBlockComment`),T(e,t,`beforeLineComment`),T(e,t,`afterLineComment`),T(e,t,`allowBlockStart`),T(e,t,`allowBlockEnd`),T(e,t,`allowObjectStart`),T(e,t,`allowObjectEnd`),T(e,t,`allowArrayStart`),T(e,t,`allowArrayEnd`),T(e,t,`allowClassStart`),T(e,t,`allowClassEnd`),T(e,t,`allowInterfaceStart`),T(e,t,`allowInterfaceEnd`),T(e,t,`allowTypeStart`),T(e,t,`allowTypeEnd`),T(e,t,`allowEnumStart`),T(e,t,`allowEnumEnd`),T(e,t,`allowModuleStart`),T(e,t,`allowModuleEnd`),T(e,t,`allowFunctionStart`),T(e,t,`allowFunctionEnd`),T(e,t,`applyDefaultIgnorePatterns`)}function D(e,t,n){let r=t[n];typeof r==`string`&&(e[n]=r)}function O(e){let t={...h};return w(e)&&(E(t,e),D(t,e,`ignorePattern`)),t}function k(e,t){return e<=1||t[e-2]?.trim()===``}function A(e,t){return e>=t.length||t[e]?.trim()===``}function j(e,t){return e.isBlockStart&&(t.allowBlockStart??!1)||e.isObjectStart&&(t.allowObjectStart??!1)||e.isArrayStart&&(t.allowArrayStart??!1)||e.isClassStart&&(t.allowClassStart??!1)||e.isInterfaceStart&&(t.allowInterfaceStart??!1)||e.isTypeStart&&(t.allowTypeStart??!1)||e.isEnumStart&&(t.allowEnumStart??!1)||e.isModuleStart&&(t.allowModuleStart??!1)||e.isFunctionStart&&(t.allowFunctionStart??!1)}function M(e,t){return e.isBlockEnd&&(t.allowBlockEnd??!1)||e.isObjectEnd&&(t.allowObjectEnd??!1)||e.isArrayEnd&&(t.allowArrayEnd??!1)||e.isClassEnd&&(t.allowClassEnd??!1)||e.isInterfaceEnd&&(t.allowInterfaceEnd??!1)||e.isTypeEnd&&(t.allowTypeEnd??!1)||e.isEnumEnd&&(t.allowEnumEnd??!1)||e.isModuleEnd&&(t.allowModuleEnd??!1)||e.isFunctionEnd&&(t.allowFunctionEnd??!1)}function N(e,t,n,r,i){let a=e.type===`Block`;if(a&&n.beforeBlockComment||!a&&n.beforeLineComment){if(j(i,n))return;let o=e.loc.start.line;k(o,t)||r.report({loc:{start:e.loc.start,end:e.loc.start},message:a?`块注释前需要空行`:`行注释前需要空行`,fix:n=>{let r=0;for(let n=0;n<e.loc.start.line-1;n++)r+=(t[n]?.length??0)+1;return n.insertTextBeforeRange([r,r],`
|
|
2
2
|
`)}})}}function P(e,t,n,r,i){let a=e.type===`Block`;if(a&&n.afterBlockComment||!a&&n.afterLineComment){if(M(i,n))return;let o=e.loc.end.line;A(o,t)||r.report({loc:{start:e.loc.end,end:e.loc.end},message:a?`块注释后需要空行`:`行注释后需要空行`,fix:t=>t.insertTextAfterRange([e.range[1],e.range[1]],`
|
|
3
|
-
`)})}}function F(e,t,n,r,i=[],a=!1,o=!1){if(b(e,t)||C(e,n))return;let s=x(e,i),c=m(e,t),l=ee(e,t)||te(e,t),u=re(e,t)
|
|
3
|
+
`)})}}function F(e,t,n,r,i=[],a=!1,o=!1){if(b(e,t)||C(e,n))return;let s=x(e,i),c=m(e,t),l=ee(e,t)||te(e,t),u=re(e,t);a||s||l||u||N(e,t,n,r,c),o||P(e,t,n,r,c)}const ie=t({meta:{type:`layout`,fixable:`whitespace`,docs:{description:`要求在注释前后有空行`},schema:[{type:`object`,properties:{beforeBlockComment:{type:`boolean`},afterBlockComment:{type:`boolean`},beforeLineComment:{type:`boolean`},afterLineComment:{type:`boolean`},allowBlockStart:{type:`boolean`},allowBlockEnd:{type:`boolean`},allowObjectStart:{type:`boolean`},allowObjectEnd:{type:`boolean`},allowArrayStart:{type:`boolean`},allowArrayEnd:{type:`boolean`},allowClassStart:{type:`boolean`},allowClassEnd:{type:`boolean`},allowInterfaceStart:{type:`boolean`},allowInterfaceEnd:{type:`boolean`},allowTypeStart:{type:`boolean`},allowTypeEnd:{type:`boolean`},allowEnumStart:{type:`boolean`},allowEnumEnd:{type:`boolean`},allowModuleStart:{type:`boolean`},allowModuleEnd:{type:`boolean`},allowFunctionStart:{type:`boolean`},allowFunctionEnd:{type:`boolean`},ignorePattern:{type:`string`},applyDefaultIgnorePatterns:{type:`boolean`}},additionalProperties:!1}]},createOnce(e){let t=[],n=[];return{Program(){let r=O(e.options?.[0]);t=e.sourceCode.text.split(`
|
|
4
4
|
`),n=[];let i=e.sourceCode.getAllComments();for(let a=0;a<i.length;a++){let o=i[a];if(!o)continue;let s=i[a+1],c=s!==void 0&&s.loc.start.line<=o.loc.end.line+1;F(o,t,r,e,n,!1,c),n.push(o)}}}}}),I=[`eslint`,`oxlint`,`jshint`,`jslint`,`tslint`,`istanbul`,`global`,`exported`,`jscs`],L=[`<reference`,`<amd-module`,`<amd-dependency`,`@ts-`],R=/^\*?\s*$/u,z=/^\s*$/u,B=`禁止双斜杠注释,只允许多行块注释`;function V(e){let t=e.value.trim(),n=t.replace(/^\/+/u,``).trim();return I.some(e=>t.startsWith(e))||L.some(e=>n.startsWith(e))}function H(t){return t.type===`Line`&&e(t.value)!==null}function U(e,t){let n=t[e.loc.start.line-1];if(!n)return` `.repeat(e.loc.start.column);let r=n.slice(0,e.loc.start.column);return r.trim().length>0?` `.repeat(e.loc.start.column):r}function W(e){let t=[];for(let n of e){let e=t[t.length-1];if(e){let t=e[e.length-1];if(t&&t.loc.end.line===n.loc.start.line-1){e.push(n);continue}}t.push([n])}return t}function G(e){return e.map(e=>e.value)}function K(e,t){return`/*\n${e.map(e=>{let n=e.trim();return n?`${t} * ${n}`:`${t} *`}).join(`
|
|
5
5
|
`)}\n${t} */`}function q(e,t){let n=e.trim(),r=n.startsWith(`*`),i=r?n.slice(1).trim():n,a=r?`/**`:`/*`;return i?`${a}\n${t} * ${i}\n${t} */`:`${a}\n${t} */`}function J(e,t){let n=e.value.split(`
|
|
6
6
|
`),r=0;for(let e=0;e<t;e++)r+=(n[e]?.length??0)+1;return e.range[0]+2+r}function Y(e,t){let n=[],r=[];for(let i of e)b(i,t)?n.push({message:B,loc:{start:{...i.loc.start},end:{...i.loc.end}}}):r.push(i);for(let e of W(r)){let r=e[0],i=e[e.length-1];if(!r||!i)continue;let a=U(r,t),o=G(e),s=o.some(e=>e.trim().startsWith(`/`));n.push({message:B,loc:{start:{...r.loc.start},end:{...i.loc.end}},fix:s?void 0:{range:[r.range[0],i.range[1]],text:K(o,a)}})}return n}function ae(e,t){let n=[],r=e.value.split(`
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { i as OxlintRules, n as OxlintConfigOverride } from "./index-
|
|
2
|
-
//#region src/types/preset-options.types.d.ts
|
|
1
|
+
import { i as OxlintRules, n as OxlintConfigOverride } from "./index-7B-WMfha.js";
|
|
3
2
|
/**
|
|
4
3
|
* 预设选项
|
|
5
4
|
*
|
|
@@ -21,5 +20,4 @@ type PresetOptions = {
|
|
|
21
20
|
*/
|
|
22
21
|
ignorePatterns?: string[];
|
|
23
22
|
};
|
|
24
|
-
//#endregion
|
|
25
23
|
export { PresetOptions as t };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
3
|
-
import { t as PresetOptions } from "./preset-options.types-
|
|
4
|
-
//#region src/entries/react.entry.d.ts
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Ch-eTtkd.js";
|
|
5
4
|
/**
|
|
6
5
|
* 创建 Oxlint React 配置
|
|
7
6
|
*
|
|
@@ -13,5 +12,4 @@ declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
|
13
12
|
* 默认 Oxlint React 配置实例
|
|
14
13
|
*/
|
|
15
14
|
declare const oxlintReactConfig: OxlintConfig;
|
|
16
|
-
//#endregion
|
|
17
15
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintReactConfig as default, defineConfig };
|
package/dist/root.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
2
|
-
import { n as oxlintRootConfig, r as ROOT_WHITELIST_PATTERNS, t as defineConfig } from "./root.entry-
|
|
1
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
2
|
+
import { n as oxlintRootConfig, r as ROOT_WHITELIST_PATTERNS, t as defineConfig } from "./root.entry-DW6F5jjU.js";
|
|
3
3
|
export { type OxlintConfig, type OxlintConfigOverride, ROOT_WHITELIST_PATTERNS, oxlintRootConfig as default, defineConfig };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { t as OxlintConfig } from "./index-
|
|
3
|
-
import { t as PresetOptions } from "./preset-options.types-
|
|
4
|
-
//#region src/defaults/root.patterns.d.ts
|
|
2
|
+
import { t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Ch-eTtkd.js";
|
|
5
4
|
/**
|
|
6
5
|
* monorepo 根目录白名单忽略模式全集
|
|
7
6
|
*
|
|
@@ -10,8 +9,6 @@ import { t as PresetOptions } from "./preset-options.types-Czyi-DdY.js";
|
|
|
10
9
|
* lzi 模式串复用强制包含单一真源,入口拉平时统一归一化落尾
|
|
11
10
|
*/
|
|
12
11
|
declare const ROOT_WHITELIST_PATTERNS: readonly string[];
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/entries/root.entry.d.ts
|
|
15
12
|
/**
|
|
16
13
|
* 创建 Oxlint Root 配置
|
|
17
14
|
*
|
|
@@ -23,5 +20,4 @@ declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
|
23
20
|
* 默认 Oxlint Root 配置实例
|
|
24
21
|
*/
|
|
25
22
|
declare const oxlintRootConfig: OxlintConfig;
|
|
26
|
-
//#endregion
|
|
27
23
|
export { oxlintRootConfig as n, ROOT_WHITELIST_PATTERNS as r, defineConfig as t };
|
package/dist/rules.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { a as ESLINT_CORE_RULES, i as TYPESCRIPT_RECOMMENDED_RULES, n as ESLINT_RECOMMENDED_RULES, r as TYPESCRIPT_PROJECT_RULES, t as UNICORN_RULES } from "./unicorn.rules-
|
|
2
|
+
import { a as ESLINT_CORE_RULES, i as TYPESCRIPT_RECOMMENDED_RULES, n as ESLINT_RECOMMENDED_RULES, r as TYPESCRIPT_PROJECT_RULES, t as UNICORN_RULES } from "./unicorn.rules-DgKAk9wi.js";
|
|
3
3
|
export { ESLINT_CORE_RULES, ESLINT_RECOMMENDED_RULES, TYPESCRIPT_PROJECT_RULES, TYPESCRIPT_RECOMMENDED_RULES, UNICORN_RULES };
|
package/dist/taro.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-
|
|
2
|
-
import { i as TARO_SPECIAL_FILE_PATTERNS, n as oxlintTaroConfig, r as TARO_FILE_NAMING_EXEMPT_PATTERNS, t as defineConfig } from "./taro.entry-
|
|
1
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
2
|
+
import { i as TARO_SPECIAL_FILE_PATTERNS, n as oxlintTaroConfig, r as TARO_FILE_NAMING_EXEMPT_PATTERNS, t as defineConfig } from "./taro.entry-DQK7ypZY.js";
|
|
3
3
|
export { type OxlintConfig, type OxlintConfigOverride, TARO_FILE_NAMING_EXEMPT_PATTERNS, TARO_SPECIAL_FILE_PATTERNS, oxlintTaroConfig as default, defineConfig };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { t as OxlintConfig } from "./index-
|
|
3
|
-
import { t as PresetOptions } from "./preset-options.types-
|
|
4
|
-
//#region src/defaults/taro.patterns.d.ts
|
|
2
|
+
import { t as OxlintConfig } from "./index-7B-WMfha.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Ch-eTtkd.js";
|
|
5
4
|
/**
|
|
6
5
|
* Taro 预设 - 框架约定文件模式
|
|
7
6
|
*
|
|
@@ -27,8 +26,6 @@ declare const TARO_SPECIAL_FILE_PATTERNS: string[];
|
|
|
27
26
|
* 口径仅限框架约定的应用入口,不随消费仓自定义命名扩面
|
|
28
27
|
*/
|
|
29
28
|
declare const TARO_FILE_NAMING_EXEMPT_PATTERNS: string[];
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/entries/taro.entry.d.ts
|
|
32
29
|
/**
|
|
33
30
|
* Taro 预设选项
|
|
34
31
|
*
|
|
@@ -57,5 +54,4 @@ declare function defineConfig(options?: TaroPresetOptions): OxlintConfig;
|
|
|
57
54
|
* 默认 Oxlint Taro 配置实例
|
|
58
55
|
*/
|
|
59
56
|
declare const oxlintTaroConfig: OxlintConfig;
|
|
60
|
-
//#endregion
|
|
61
57
|
export { TARO_SPECIAL_FILE_PATTERNS as i, oxlintTaroConfig as n, TARO_FILE_NAMING_EXEMPT_PATTERNS as r, defineConfig as t };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { i as OxlintRules, r as OxlintRuleConfig } from "./index-
|
|
2
|
-
//#region src/rules/eslint-core.rules.d.ts
|
|
1
|
+
import { i as OxlintRules, r as OxlintRuleConfig } from "./index-7B-WMfha.js";
|
|
3
2
|
/**
|
|
4
3
|
* Oxlint 原生规则配置 - eslint-core 规则
|
|
5
4
|
*
|
|
@@ -16,8 +15,6 @@ import { i as OxlintRules, r as OxlintRuleConfig } from "./index-eNRova_s.js";
|
|
|
16
15
|
* 默认值来源:@longzai-intelligence-oxlint/core 的 oxlintDefaults
|
|
17
16
|
*/
|
|
18
17
|
declare const ESLINT_CORE_RULES: Record<string, OxlintRuleConfig>;
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/rules/typescript-eslint.rules.d.ts
|
|
21
18
|
/**
|
|
22
19
|
* eslint/recommended 中 Oxlint 原生支持的规则(21 条)
|
|
23
20
|
*
|
|
@@ -40,8 +37,6 @@ declare const TYPESCRIPT_RECOMMENDED_RULES: OxlintRules;
|
|
|
40
37
|
* 注意:no-unused-vars 在 Oxlint 中是 eslint 内置规则,不带 typescript/ 前缀。
|
|
41
38
|
*/
|
|
42
39
|
declare const TYPESCRIPT_PROJECT_RULES: OxlintRules;
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/rules/unicorn.rules.d.ts
|
|
45
40
|
/**
|
|
46
41
|
* Oxlint 原生规则配置 - unicorn 规则
|
|
47
42
|
*
|
|
@@ -58,5 +53,4 @@ declare const TYPESCRIPT_PROJECT_RULES: OxlintRules;
|
|
|
58
53
|
* 默认值来源:@longzai-intelligence-oxlint/core 的 unicornDefaults
|
|
59
54
|
*/
|
|
60
55
|
declare const UNICORN_RULES: Record<string, OxlintRuleConfig>;
|
|
61
|
-
//#endregion
|
|
62
56
|
export { ESLINT_CORE_RULES as a, TYPESCRIPT_RECOMMENDED_RULES as i, ESLINT_RECOMMENDED_RULES as n, TYPESCRIPT_PROJECT_RULES as r, UNICORN_RULES as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-oxlint/presets",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "Longzai Intelligence oxlint 配置预设",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
@@ -104,33 +104,33 @@
|
|
|
104
104
|
"zod": "^4.6.7"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@longzai-intelligence-oxlint/architecture-core-plugin": "0.2.
|
|
108
|
-
"@longzai-intelligence-oxlint/architecture-electron-plugin": "0.2.
|
|
109
|
-
"@longzai-intelligence-oxlint/architecture-library-plugin": "0.2.
|
|
110
|
-
"@longzai-intelligence-oxlint/code-style-plugin": "0.2.
|
|
111
|
-
"@longzai-intelligence-oxlint/composer-plugin": "0.2.
|
|
112
|
-
"@longzai-intelligence-oxlint/core": "0.2.
|
|
113
|
-
"@longzai-intelligence-oxlint/design-rules-plugin": "0.2.
|
|
114
|
-
"@longzai-intelligence-oxlint/elysia-route-plugin": "0.2.
|
|
115
|
-
"@longzai-intelligence-oxlint/eslint-config-plugin": "0.2.
|
|
116
|
-
"@longzai-intelligence-oxlint/file-naming-plugin": "0.2.
|
|
117
|
-
"@longzai-intelligence-oxlint/lzi-builder-config-plugin": "0.2.
|
|
118
|
-
"@longzai-intelligence-oxlint/lzi-config-plugin": "0.2.
|
|
119
|
-
"@longzai-intelligence-oxlint/nestjs-route-plugin": "0.2.
|
|
120
|
-
"@longzai-intelligence-oxlint/package-json-plugin": "0.2.
|
|
121
|
-
"@longzai-intelligence-oxlint/perfectionist-plugin": "0.2.
|
|
122
|
-
"@longzai-intelligence-oxlint/react-plugin": "0.2.
|
|
123
|
-
"@longzai-intelligence-oxlint/schema-type-separation-plugin": "0.2.
|
|
124
|
-
"@longzai-intelligence-oxlint/stylistic-plugin": "0.2.
|
|
125
|
-
"@longzai-intelligence-oxlint/tsconfig-plugin": "0.2.
|
|
126
|
-
"@longzai-intelligence-oxlint/tsdoc-plugin": "0.2.
|
|
127
|
-
"@longzai-intelligence-oxlint/tsdown-config-plugin": "0.2.
|
|
128
|
-
"@longzai-intelligence-oxlint/tsup-config-plugin": "0.2.
|
|
129
|
-
"@longzai-intelligence-oxlint/typeorm-plugin": "0.2.
|
|
130
|
-
"@longzai-intelligence-oxlint/typescript-eslint-plugin": "0.2.
|
|
131
|
-
"@longzai-intelligence-oxlint/utils": "0.2.
|
|
132
|
-
"@longzai-intelligence-oxlint/vitest-config-plugin": "0.2.
|
|
133
|
-
"@longzai-intelligence-oxlint/zod-plugin": "0.2.
|
|
107
|
+
"@longzai-intelligence-oxlint/architecture-core-plugin": "0.2.11",
|
|
108
|
+
"@longzai-intelligence-oxlint/architecture-electron-plugin": "0.2.11",
|
|
109
|
+
"@longzai-intelligence-oxlint/architecture-library-plugin": "0.2.11",
|
|
110
|
+
"@longzai-intelligence-oxlint/code-style-plugin": "0.2.11",
|
|
111
|
+
"@longzai-intelligence-oxlint/composer-plugin": "0.2.11",
|
|
112
|
+
"@longzai-intelligence-oxlint/core": "0.2.11",
|
|
113
|
+
"@longzai-intelligence-oxlint/design-rules-plugin": "0.2.11",
|
|
114
|
+
"@longzai-intelligence-oxlint/elysia-route-plugin": "0.2.11",
|
|
115
|
+
"@longzai-intelligence-oxlint/eslint-config-plugin": "0.2.11",
|
|
116
|
+
"@longzai-intelligence-oxlint/file-naming-plugin": "0.2.11",
|
|
117
|
+
"@longzai-intelligence-oxlint/lzi-builder-config-plugin": "0.2.11",
|
|
118
|
+
"@longzai-intelligence-oxlint/lzi-config-plugin": "0.2.11",
|
|
119
|
+
"@longzai-intelligence-oxlint/nestjs-route-plugin": "0.2.11",
|
|
120
|
+
"@longzai-intelligence-oxlint/package-json-plugin": "0.2.11",
|
|
121
|
+
"@longzai-intelligence-oxlint/perfectionist-plugin": "0.2.11",
|
|
122
|
+
"@longzai-intelligence-oxlint/react-plugin": "0.2.11",
|
|
123
|
+
"@longzai-intelligence-oxlint/schema-type-separation-plugin": "0.2.11",
|
|
124
|
+
"@longzai-intelligence-oxlint/stylistic-plugin": "0.2.11",
|
|
125
|
+
"@longzai-intelligence-oxlint/tsconfig-plugin": "0.2.11",
|
|
126
|
+
"@longzai-intelligence-oxlint/tsdoc-plugin": "0.2.11",
|
|
127
|
+
"@longzai-intelligence-oxlint/tsdown-config-plugin": "0.2.11",
|
|
128
|
+
"@longzai-intelligence-oxlint/tsup-config-plugin": "0.2.11",
|
|
129
|
+
"@longzai-intelligence-oxlint/typeorm-plugin": "0.2.11",
|
|
130
|
+
"@longzai-intelligence-oxlint/typescript-eslint-plugin": "0.2.11",
|
|
131
|
+
"@longzai-intelligence-oxlint/utils": "0.2.11",
|
|
132
|
+
"@longzai-intelligence-oxlint/vitest-config-plugin": "0.2.11",
|
|
133
|
+
"@longzai-intelligence-oxlint/zod-plugin": "0.2.11",
|
|
134
134
|
"@vitest/coverage-v8": "^4.1.10"
|
|
135
135
|
},
|
|
136
136
|
"peerDependencies": {
|