@longzai-intelligence-oxlint/presets 0.1.47 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.d.ts +2 -1
- package/dist/base.entry-CKst6rs9.js +1 -0
- package/dist/{base.entry-B8xoqv2v.d.ts → base.entry-CejDIGVV.d.ts} +4 -3
- package/dist/base.js +1 -1
- package/dist/dist-CskvMq7J.js +1 -0
- package/dist/electron.d.ts +5 -4
- package/dist/electron.entry-D826gIzo.js +1 -0
- package/dist/electron.js +1 -1
- package/dist/elysia.d.ts +5 -4
- package/dist/elysia.js +1 -1
- package/dist/expo.d.ts +3 -1
- package/dist/expo.js +1 -1
- package/dist/fumadocs.d.ts +2 -1
- package/dist/{fumadocs.entry-Dc9xyNem.d.ts → fumadocs.entry-C7QzCdVJ.d.ts} +4 -3
- package/dist/fumadocs.entry-Dgs-WlgF.js +1 -0
- package/dist/fumadocs.js +1 -1
- package/dist/hono.d.ts +3 -2
- package/dist/hono.js +1 -1
- package/dist/index-eNRova_s.d.ts +68 -0
- package/dist/index.d.ts +10 -13
- package/dist/index.js +1 -1
- package/dist/library.d.ts +5 -4
- package/dist/library.entry-mehEApZl.js +1 -0
- package/dist/library.js +1 -1
- package/dist/mcp.d.ts +3 -2
- package/dist/mcp.js +1 -1
- package/dist/nest.d.ts +5 -4
- package/dist/nest.entry-Ch6PVI2A.js +1 -0
- package/dist/nest.js +1 -1
- package/dist/next.d.ts +2 -1
- package/dist/next.entry-B3GfPoY8.js +1 -0
- package/dist/{next.entry-BqOxjajB.d.ts → next.entry-moZEmUkw.d.ts} +4 -3
- package/dist/next.js +1 -1
- package/dist/node.d.ts +3 -1
- package/dist/node.js +1 -1
- package/dist/plugins/architecture-core.js +1 -0
- package/dist/plugins/architecture-electron.js +1 -0
- package/dist/plugins/architecture-library.js +1 -0
- package/dist/plugins/code-style.js +1 -0
- package/dist/plugins/composer.js +1 -0
- package/dist/plugins/design-rules.js +4 -0
- package/dist/plugins/elysia-route.js +1 -0
- package/dist/plugins/eslint-config.js +1 -0
- package/dist/plugins/file-naming.js +1 -0
- package/dist/plugins/lzi-builder-config.js +1 -0
- package/dist/plugins/lzi-config.js +1 -0
- package/dist/plugins/nestjs-route.js +1 -0
- package/dist/plugins/package-json.js +1 -0
- package/dist/plugins/perfectionist.js +1 -0
- package/dist/plugins/react.js +1 -0
- package/dist/plugins/schema-type-separation.js +1 -0
- package/dist/plugins/stylistic.js +9 -0
- package/dist/plugins/tsconfig.js +1 -0
- package/dist/plugins/tsdoc.js +13 -0
- package/dist/plugins/tsdown-config.js +1 -0
- package/dist/plugins/tsup-config.js +1 -0
- package/dist/plugins/typeorm.js +1 -0
- package/dist/plugins/typescript-eslint.js +1 -0
- package/dist/plugins/vitest-config.js +1 -0
- package/dist/plugins/zod.js +1 -0
- package/dist/{index-Cu6dVxg4.d.ts → preset-options.types-Czyi-DdY.d.ts} +1 -1
- package/dist/react.d.ts +5 -4
- package/dist/react.js +1 -1
- package/dist/rolldown-runtime-BqT_7tdF-BT7sSRF3.js +1 -0
- package/dist/rolldown-runtime-BqT_7tdF-BqT_7tdF.js +1 -0
- package/dist/rolldown-runtime-BqT_7tdF-DsHBzDG-.js +1 -0
- package/dist/rolldown-runtime-BqT_7tdF.js +1 -0
- package/dist/rules.d.ts +2 -1
- package/dist/rules.js +1 -1
- package/dist/taro.d.ts +2 -1
- package/dist/taro.entry-DV-L1NDJ.js +1 -0
- package/dist/{taro.entry-BrMnYd7F.d.ts → taro.entry-DuohnWen.d.ts} +4 -3
- package/dist/taro.js +1 -1
- package/dist/typescript-eslint.rules-j0Y80OGu.js +1 -0
- package/dist/unicorn.rules-0a_FuIjL.js +1 -0
- package/dist/{unicorn.rules-BzgL7xpu.d.ts → unicorn.rules-CoZq5SQL.d.ts} +3 -3
- package/package.json +32 -30
- package/dist/base.entry-BsfLhCnW.js +0 -1
- package/dist/electron.entry-BSUbv_kx.js +0 -1
- package/dist/fumadocs.entry-D2EXMqvE.js +0 -1
- package/dist/library.entry-CMq8a1Dq.js +0 -1
- package/dist/nest.entry-D1JfdqzR.js +0 -1
- package/dist/next.entry-BCVfEuLq.js +0 -1
- package/dist/taro.entry-B0YhHlhV.js +0 -1
- package/dist/typescript-eslint.rules-W6xcPWv3.js +0 -1
- package/dist/unicorn.rules-EOaLfd_c.js +0 -1
package/dist/base.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-eNRova_s.js";
|
|
2
|
+
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-CejDIGVV.js";
|
|
2
3
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintBaseConfig as default, defineConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import"./rolldown-runtime-BqT_7tdF-BqT_7tdF.js";import"./rolldown-runtime-BqT_7tdF-DsHBzDG-.js";import"./rolldown-runtime-BqT_7tdF-BT7sSRF3.js";import{i as e,n as t}from"./typescript-eslint.rules-j0Y80OGu.js";import{existsSync as n,readFileSync as r}from"node:fs";import{dirname as i,join as a}from"node:path";import{fileURLToPath as o}from"node:url";import{VITEST_CONFIG_EXPORT_NAMES as s}from"@longzai-intelligence-vitest/config/meta";const c=[`!lzi-*.config.ts`,`!lzi-*.config.mts`];function l(e){return[...e.filter(e=>!c.includes(e)),...c]}const u=[{files:[`**/*.d.ts`],rules:{"typescript/consistent-type-definitions":`off`}},{files:[`**/*.tsx`],rules:{"max-lines-per-function":[`error`,{max:100,skipBlankLines:!0,skipComments:!0}]}},{files:[`**/*.test.ts`,`**/*.test.tsx`,`**/*.spec.ts`,`**/*.spec.tsx`,`test/**/*.ts`,`test/**/*.tsx`,`**/__tests__/**/*.ts`,`**/__tests__/**/*.tsx`,`**/__mocks__/**/*.ts`,`**/__mocks__/**/*.tsx`,`**/vitest.setup.ts`],rules:{"max-lines":[`error`,{max:750,skipBlankLines:!0,skipComments:!0}],"max-lines-per-function":`off`,"@longzai-intelligence-oxlint/typescript-eslint-plugin/consistent-type-assertions":`off`,"typescript/no-non-null-assertion":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-tsdoc":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-param":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-returns":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-description":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-param-description":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-returns-description":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-type-param":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/no-description-tag":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/param-hyphen-format":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-blank-line-before-tags":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/separator-format":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/todo-format":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-throws":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-throws-type":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-deprecated-alternative":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/no-legacy-jsdoc-tags":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/no-placeholder-description":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/no-commented-code":`off`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-multiline-property-comment":`off`}},{files:[`**/lzi-kol-markdown.config.ts`,`**/lzi-rss-markdown.config.ts`,`**/lzi-nation-data.config.ts`,`**/lzi-youtube.config.ts`,`**/lzi-task.config.ts`,`**/lzi-okr.config.ts`,`**/lzi-roadmap.config.ts`],rules:{"@longzai-intelligence-oxlint/lzi-config-plugin/require-define-config":`off`}},{files:[`**/__tests__/helpers/setup.ts`],rules:{"@longzai-intelligence-oxlint/file-naming-plugin/require-type-suffix":`off`}},{files:[`**/scripts/**`],rules:{"@longzai-intelligence-oxlint/file-naming-plugin/require-type-suffix":`off`}}],d=[{shortName:`code-style`,packageName:`@longzai-intelligence-oxlint/code-style-plugin`},{shortName:`composer`,packageName:`@longzai-intelligence-oxlint/composer-plugin`},{shortName:`design-rules`,packageName:`@longzai-intelligence-oxlint/design-rules-plugin`},{shortName:`package-json`,packageName:`@longzai-intelligence-oxlint/package-json-plugin`},{shortName:`schema-type-separation`,packageName:`@longzai-intelligence-oxlint/schema-type-separation-plugin`},{shortName:`architecture-core`,packageName:`@longzai-intelligence-oxlint/architecture-core-plugin`},{shortName:`architecture-library`,packageName:`@longzai-intelligence-oxlint/architecture-library-plugin`},{shortName:`react`,packageName:`@longzai-intelligence-oxlint/react-plugin`},{shortName:`tsdoc`,packageName:`@longzai-intelligence-oxlint/tsdoc-plugin`},{shortName:`stylistic`,packageName:`@longzai-intelligence-oxlint/stylistic-plugin`},{shortName:`perfectionist`,packageName:`@longzai-intelligence-oxlint/perfectionist-plugin`},{shortName:`typescript-eslint`,packageName:`@longzai-intelligence-oxlint/typescript-eslint-plugin`},{shortName:`typeorm`,packageName:`@longzai-intelligence-oxlint/typeorm-plugin`},{shortName:`zod`,packageName:`@longzai-intelligence-oxlint/zod-plugin`},{shortName:`file-naming`,packageName:`@longzai-intelligence-oxlint/file-naming-plugin`},{shortName:`tsconfig`,packageName:`@longzai-intelligence-oxlint/tsconfig-plugin`},{shortName:`eslint-config`,packageName:`@longzai-intelligence-oxlint/eslint-config-plugin`},{shortName:`lzi-builder-config`,packageName:`@longzai-intelligence-oxlint/lzi-builder-config-plugin`},{shortName:`lzi-config`,packageName:`@longzai-intelligence-oxlint/lzi-config-plugin`},{shortName:`tsdown-config`,packageName:`@longzai-intelligence-oxlint/tsdown-config-plugin`},{shortName:`tsup-config`,packageName:`@longzai-intelligence-oxlint/tsup-config-plugin`},{shortName:`vitest-config`,packageName:`@longzai-intelligence-oxlint/vitest-config-plugin`},{shortName:`architecture-electron`,packageName:`@longzai-intelligence-oxlint/architecture-electron-plugin`},{shortName:`elysia-route`,packageName:`@longzai-intelligence-oxlint/elysia-route-plugin`},{shortName:`nestjs-route`,packageName:`@longzai-intelligence-oxlint/nestjs-route-plugin`}],f=[`code-style`,`composer`,`design-rules`,`package-json`,`schema-type-separation`,`architecture-core`,`architecture-library`,`react`,`tsdoc`,`stylistic`,`perfectionist`,`typescript-eslint`,`typeorm`,`zod`,`file-naming`,`tsconfig`,`eslint-config`,`lzi-builder-config`,`lzi-config`,`tsdown-config`,`tsup-config`,`vitest-config`],p=`@longzai-intelligence-oxlint/presets`;function m(e){let t=i(o(e));for(;;){let e=a(t,`package.json`);if(n(e))try{if(JSON.parse(r(e,`utf8`)).name===p)return t}catch{}let o=i(t);if(o===t)throw Error(`未能定位 \`${p}\` 包根,内置插件路径解析失败`);t=o}}const h=m(import.meta.url);function g(e){if(!d.some(t=>t.shortName===e))throw Error(`未登记的内置插件短名 \`${e}\`,请先补录 bundled-plugins 清单`);return a(h,`dist`,`plugins`,`${e}.js`)}function _(){return f.map(e=>g(e))}const v=_(),y={"import/no-relative-parent-imports":`error`},b={"@longzai-intelligence-oxlint/tsup-config-plugin/require-tsup-config-import":[`error`,{configPackagePath:`@longzai-intelligence-config/core/tsup`}],"@longzai-intelligence-oxlint/tsdown-config-plugin/require-tsdown-config-import":[`error`,{configPackagePath:`@longzai-intelligence-tsdown/core`,correctPresetNames:[`defineDomainImplementationConfig`,`defineDomainContractConfig`,`defineSharedKernelConfig`,`defineReactComponentsConfig`,`defineConfigPackageConfig`,`definePackageConfig`]}],"@longzai-intelligence-oxlint/vitest-config-plugin/require-vitest-config-import":[`error`,{configPackagePaths:[`@longzai-intelligence-config/core/vitest`,`@longzai-intelligence-vitest/config`],allowedExportNames:s,forbiddenExportNames:[`defineConfig`],excludedPaths:[`infrastructure/configs/vitest/vitest.config.ts`]}],"@longzai-intelligence-oxlint/eslint-config-plugin/require-eslint-config-import":[`error`,{configPackagePath:`@longzai-intelligence-config/core/eslint`,allowedCreateFunctions:[`createLibraryConfig`,`createDomainConfig`,`createReactConfig`,`createReactPluginConfig`,`createElectronConfig`,`createNextConfig`,`createNodeConfig`,`createMcpConfig`,`createNestConfig`,`createHonoConfig`,`createExpoConfig`],forbiddenDefaultExports:[`coreConfig`,`createCoreConfig`,`libraryConfig`,`domainConfig`,`reactConfig`,`electronConfig`,`nextConfig`,`nodeConfig`,`mcpConfig`,`nestConfig`,`honoConfig`,`expoConfig`]}]},x={"@longzai-intelligence-oxlint/architecture-core-plugin/business-leak":`off`,"@longzai-intelligence-oxlint/architecture-core-plugin/no-cross-package-relative-import":`error`,"@longzai-intelligence-oxlint/architecture-core-plugin/implementation-export-control":`error`,"@longzai-intelligence-oxlint/architecture-core-plugin/no-implementation-import-in-apps":`error`,"@longzai-intelligence-oxlint/architecture-core-plugin/domain-export-compliance":`error`,"@longzai-intelligence-oxlint/architecture-core-plugin/dependency-direction":`error`},S={"@longzai-intelligence-oxlint/code-style-plugin/no-inline-type-definition":`error`,"@longzai-intelligence-oxlint/code-style-plugin/prefer-split-export-const":`off`,"@longzai-intelligence-oxlint/code-style-plugin/require-interface-naming":`off`,"@longzai-intelligence-oxlint/code-style-plugin/require-dto-naming":`error`,"@longzai-intelligence-oxlint/code-style-plugin/require-class-suffix":`error`,"@longzai-intelligence-oxlint/code-style-plugin/no-class-suffix-alias":`error`,"@longzai-intelligence-oxlint/code-style-plugin/no-console":`error`,"@longzai-intelligence-oxlint/code-style-plugin/no-handwritten-shebang":`error`},C={"@longzai-intelligence-oxlint/composer-plugin/define-capability-validity":`error`,"@longzai-intelligence-oxlint/composer-plugin/inject-graph-acyclic":`error`},w={"@longzai-intelligence-oxlint/design-rules-plugin/no-hardcoded-color":`error`,"@longzai-intelligence-oxlint/design-rules-plugin/no-hardcoded-spacing":`error`,"@longzai-intelligence-oxlint/design-rules-plugin/no-magic-z-index":`error`},T={"@longzai-intelligence-oxlint/eslint-config-plugin/require-eslint-config-import":`error`},E={"@longzai-intelligence-oxlint/file-naming-plugin/file-naming":`error`,"@longzai-intelligence-oxlint/file-naming-plugin/require-type-naming":`error`,"@longzai-intelligence-oxlint/file-naming-plugin/require-type-suffix":`error`},D={"@longzai-intelligence-oxlint/lzi-builder-config-plugin/require-bin-banner":`error`,"@longzai-intelligence-oxlint/lzi-builder-config-plugin/require-version-injection":`error`},O={"@longzai-intelligence-oxlint/lzi-config-plugin/no-empty-define-config":`error`,"@longzai-intelligence-oxlint/lzi-config-plugin/require-define-config":`error`},k={"@longzai-intelligence-oxlint/package-json-plugin/no-app-infrastructure-dependency":`error`,"@longzai-intelligence-oxlint/package-json-plugin/no-bare-tsgo-invocation":`warn`,"@longzai-intelligence-oxlint/package-json-plugin/no-domain-layer-subpath-export":`error`,"@longzai-intelligence-oxlint/package-json-plugin/no-hoistable-dev-dependency":`error`,"@longzai-intelligence-oxlint/package-json-plugin/no-mit-license":`error`,"@longzai-intelligence-oxlint/package-json-plugin/no-sibling-implementation-dependency":`error`,"@longzai-intelligence-oxlint/package-json-plugin/no-src-exports":`warn`,"@longzai-intelligence-oxlint/package-json-plugin/no-ui-domain-package-dependency":`error`,"@longzai-intelligence-oxlint/package-json-plugin/require-full-project-bin-name":`warn`},A={"@longzai-intelligence-oxlint/perfectionist-plugin/sort-imports":`error`,"@longzai-intelligence-oxlint/perfectionist-plugin/sort-named-imports":`error`},j={"@longzai-intelligence-oxlint/react-plugin/no-incorrect-hook-naming":`error`},M={"@longzai-intelligence-oxlint/schema-type-separation-plugin/no-type-in-schema":`off`,"@longzai-intelligence-oxlint/schema-type-separation-plugin/no-schema-in-types":`off`},N={"@longzai-intelligence-oxlint/stylistic-plugin/multiline-comment-style":`error`,"@longzai-intelligence-oxlint/stylistic-plugin/lines-around-comment":[`error`,{beforeBlockComment:!0,beforeLineComment:!1,allowBlockStart:!0,allowBlockEnd:!0,allowObjectStart:!0,allowObjectEnd:!0,allowArrayStart:!0,allowArrayEnd:!0,allowClassStart:!0,allowClassEnd:!0,allowInterfaceStart:!0,allowInterfaceEnd:!0,allowTypeStart:!0,allowTypeEnd:!0,allowEnumStart:!0,allowEnumEnd:!0,allowModuleStart:!0,allowModuleEnd:!0}],"@longzai-intelligence-oxlint/stylistic-plugin/padding-line-between-statements":`error`},P={"@longzai-intelligence-oxlint/tsconfig-plugin/tsconfig-references":`error`},F={"@longzai-intelligence-oxlint/tsdoc-plugin/require-tsdoc":[`error`,{checkAllVariables:!0}],"@longzai-intelligence-oxlint/tsdoc-plugin/require-param":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-returns":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-description":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-param-description":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-returns-description":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-type-param":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/no-description-tag":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/param-hyphen-format":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-blank-line-before-tags":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/separator-format":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/todo-format":`warn`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-throws":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-throws-type":`warn`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-deprecated-alternative":`warn`,"@longzai-intelligence-oxlint/tsdoc-plugin/no-legacy-jsdoc-tags":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/no-placeholder-description":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/no-commented-code":`warn`,"@longzai-intelligence-oxlint/tsdoc-plugin/no-extra-param":`error`,"@longzai-intelligence-oxlint/tsdoc-plugin/require-multiline-property-comment":`error`},I={"@longzai-intelligence-oxlint/tsdown-config-plugin/require-tsdown-config-import":`error`},L={"@longzai-intelligence-oxlint/tsup-config-plugin/require-tsup-config-import":`error`},R={"@longzai-intelligence-oxlint/typeorm-plugin/no-string-entity-ref":`error`,"@longzai-intelligence-oxlint/typeorm-plugin/require-take-with-skip":`error`},z={"@longzai-intelligence-oxlint/typescript-eslint-plugin/consistent-type-assertions":`error`},B={"@longzai-intelligence-oxlint/vitest-config-plugin/require-vitest-config-import":`error`},V={"@longzai-intelligence-oxlint/zod-plugin/prefer-top-level-string-formats":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-number-schema-with-int":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-number-schema-with-finite":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-number-schema-with-safe":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-number-schema-with-step":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-number-schema-with-is-finite":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-number-schema-with-is-int":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-record-single-arg":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-deprecated-error-params":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-deprecated-format-methods":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-merge-method":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-superrefine":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-errors-property":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-deprecated-object-methods":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-native-enum":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-deep-partial":`error`,"@longzai-intelligence-oxlint/zod-plugin/no-promise-schema":`error`,"@longzai-intelligence-oxlint/zod-plugin/prefer-error-param":`error`,"@longzai-intelligence-oxlint/zod-plugin/prefer-zod-namespace":`warn`,"@longzai-intelligence-oxlint/zod-plugin/consistent-schema-var-name":`warn`,"@longzai-intelligence-oxlint/zod-plugin/no-any-schema":`warn`,"@longzai-intelligence-oxlint/zod-plugin/no-throw-in-refine":`warn`,"@longzai-intelligence-oxlint/zod-plugin/prefer-safe-parse":`warn`,"@longzai-intelligence-oxlint/zod-plugin/prefer-meta":`warn`,"@longzai-intelligence-oxlint/zod-plugin/require-error-message":`warn`,"@longzai-intelligence-oxlint/zod-plugin/no-optional-and-default-together":`error`,"@longzai-intelligence-oxlint/zod-plugin/prefer-enum-over-literal-union":`error`},H={...S,...C,...w,...k,...M,...x,...j,...F,...N,...A,...z,...R,...V,...E,...P,...T,...D,...O,...I,...L,...B},U={"@longzai-intelligence-oxlint/perfectionist-plugin/sort-imports":`off`,"@longzai-intelligence-oxlint/perfectionist-plugin/sort-named-imports":`off`,"@longzai-intelligence-oxlint/file-naming-plugin/require-type-suffix":`error`,"@longzai-intelligence-oxlint/zod-plugin/prefer-top-level-string-formats":`off`,"@longzai-intelligence-oxlint/zod-plugin/no-number-schema-with-int":`off`},W={...t,...y,...H,...b,...U};function G(t){return e({rules:{...W,...t?.rules},overrides:[...u,...t?.overrides??[]],jsPlugins:[...v],ignorePatterns:l(t?.ignorePatterns??[])})}const K=G();export{g as a,H as i,K as n,l as o,W as r,G as t};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Czyi-DdY.js";
|
|
3
4
|
//#region src/entries/base.entry.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* 创建 Oxlint Base 配置
|
|
@@ -13,4 +14,4 @@ declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
|
13
14
|
*/
|
|
14
15
|
declare const oxlintBaseConfig: OxlintConfig;
|
|
15
16
|
//#endregion
|
|
16
|
-
export { oxlintBaseConfig as
|
|
17
|
+
export { oxlintBaseConfig as n, defineConfig as t };
|
package/dist/base.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{n as default,t as defineConfig}from"./base.entry-
|
|
1
|
+
export{n as default,t as defineConfig}from"./base.entry-CKst6rs9.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:path";import*as e from"zod/mini";e.object({id:e.object({name:e.string()}),type:e.string()}),e.object({id:e.object({name:e.string(),range:e.tuple([e.number(),e.number()])}),type:e.string()});const t=e.object({type:e.enum([`ImportSpecifier`,`ImportDefaultSpecifier`,`ImportNamespaceSpecifier`]),imported:e.object({name:e.string()}),local:e.object({name:e.string()})});e.object({type:e.literal(`ImportDeclaration`),source:e.object({value:e.string()}),specifiers:e.array(t)}),e.object({type:e.literal(`ExportDefaultDeclaration`),declaration:e.object({type:e.string(),name:e.optional(e.string()),callee:e.optional(e.object({name:e.optional(e.string())})),properties:e.optional(e.array(e.unknown()))})}),e.object({type:e.literal(`CallExpression`),callee:e.object({name:e.union([e.string(),e.undefined()])})}),e.object({type:e.literal(`ObjectExpression`)});const n=e.object({name:e.string()});e.object({meta:n});function r(e){return/^I[A-Z]/.test(e)}function i(e){return e.endsWith(`DTO`)}function a(e){return e.endsWith(`Dto`)}export{r as n,a as r,i as t};
|
package/dist/electron.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Czyi-DdY.js";
|
|
3
4
|
//#region src/entries/electron.entry.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* 创建 Oxlint Electron 配置
|
|
@@ -7,10 +8,10 @@ import { OxlintConfig, OxlintConfig as OxlintConfig$1, OxlintConfigOverride } fr
|
|
|
7
8
|
* @param options - 预设选项,包含额外的规则、覆盖和忽略模式
|
|
8
9
|
* @returns 包含 Electron 架构插件和专用覆盖的 Oxlint 配置对象
|
|
9
10
|
*/
|
|
10
|
-
declare function defineConfig(options?: PresetOptions): OxlintConfig
|
|
11
|
+
declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
11
12
|
/**
|
|
12
13
|
* 默认 Oxlint Electron 配置实例
|
|
13
14
|
*/
|
|
14
|
-
declare const oxlintElectronConfig: OxlintConfig
|
|
15
|
+
declare const oxlintElectronConfig: OxlintConfig;
|
|
15
16
|
//#endregion
|
|
16
17
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintElectronConfig as default, defineConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{a as e,o as t}from"./base.entry-CKst6rs9.js";import{defineConfig as n}from"./react.js";const r=[{files:[`**/*.ts`],rules:{"@longzai-intelligence-oxlint/architecture-electron-plugin/no-custom-ipc-utility":`error`,"@longzai-intelligence-oxlint/architecture-electron-plugin/no-implementation-in-renderer":`error`,"@longzai-intelligence-oxlint/architecture-electron-plugin/platform-leak":`error`}}];function i(i){let a=n();return{extends:[a],jsPlugins:[e(`architecture-electron`)],overrides:[...r,...i?.overrides??[]],...i?.rules?{rules:i.rules}:{},ignorePatterns:t([...a.ignorePatterns??[],...i?.ignorePatterns??[]])}}const a=i();export{a as n,i as t};
|
package/dist/electron.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./react.js";export{n as default,t as defineConfig}from"./electron.entry-
|
|
1
|
+
import"./react.js";export{n as default,t as defineConfig}from"./electron.entry-D826gIzo.js";
|
package/dist/elysia.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Czyi-DdY.js";
|
|
3
4
|
//#region src/entries/elysia.entry.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* 创建 Oxlint Elysia 配置
|
|
@@ -7,10 +8,10 @@ import { OxlintConfig, OxlintConfig as OxlintConfig$1, OxlintConfigOverride } fr
|
|
|
7
8
|
* @param options - 预设选项,包含额外的规则、覆盖和忽略模式
|
|
8
9
|
* @returns 包含 Elysia 路由契约绑定规则的 Oxlint 配置对象
|
|
9
10
|
*/
|
|
10
|
-
declare function defineConfig(options?: PresetOptions): OxlintConfig
|
|
11
|
+
declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
11
12
|
/**
|
|
12
13
|
* 默认 Oxlint Elysia 配置实例
|
|
13
14
|
*/
|
|
14
|
-
declare const oxlintElysiaConfig: OxlintConfig
|
|
15
|
+
declare const oxlintElysiaConfig: OxlintConfig;
|
|
15
16
|
//#endregion
|
|
16
17
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintElysiaConfig as default, defineConfig };
|
package/dist/elysia.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,t}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{a as e,o as t,t as n}from"./base.entry-CKst6rs9.js";import"./node.js";const r=[{files:[`**/*.ts`],rules:{"@longzai-intelligence-oxlint/elysia-route-plugin/no-bare-route-path":`error`}}];function i(i){let a=n();return{extends:[a],jsPlugins:[e(`elysia-route`)],overrides:[...r,...i?.overrides??[]],...i?.rules?{rules:i.rules}:{},ignorePatterns:t([...a.ignorePatterns??[],...i?.ignorePatterns??[]])}}const a=i();export{a as default,i as defineConfig};
|
package/dist/expo.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-CejDIGVV.js";
|
|
2
4
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintBaseConfig as default, defineConfig };
|
package/dist/expo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{n as default,t as defineConfig}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";export{n as default,t as defineConfig}from"./base.entry-CKst6rs9.js";
|
package/dist/fumadocs.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-eNRova_s.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-C7QzCdVJ.js";
|
|
2
3
|
export { FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS, FUMADOCS_SPECIAL_FILE_PATTERNS, type OxlintConfig, type OxlintConfigOverride, oxFumadocsConfig as default, defineConfig };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Czyi-DdY.js";
|
|
3
4
|
//#region src/defaults/fumadocs.patterns.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* fumadocs 预设 - 文档站底座约定文件模式
|
|
@@ -57,4 +58,4 @@ declare function defineConfig(options?: FumadocsPresetOptions): OxlintConfig;
|
|
|
57
58
|
*/
|
|
58
59
|
declare const oxFumadocsConfig: OxlintConfig;
|
|
59
60
|
//#endregion
|
|
60
|
-
export {
|
|
61
|
+
export { FUMADOCS_SPECIAL_FILE_PATTERNS as i, oxFumadocsConfig as n, FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS as r, defineConfig as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{o as e}from"./base.entry-CKst6rs9.js";import{defineConfig as t}from"./react.js";const n=[`app/routes.ts`,`app/routes/**`],r=[`app/root.tsx`,`app/routes/**`];function i(i){let a=[...i?.typeSuffixBaseSkipPatterns??[],...n],o=[...i?.fileNamingBaseSkipPatterns??[],...r],s={files:[`**/*.ts`],rules:{"@longzai-intelligence-oxlint/file-naming-plugin/require-type-suffix":[`error`,{skipPatterns:a}]}},c={files:[`**/*.tsx`],rules:{"@longzai-intelligence-oxlint/file-naming-plugin/file-naming":[`error`,{skipPatterns:o}]}},l=t();return{extends:[l],overrides:[s,c,...i?.overrides??[]],...i?.rules?{rules:i.rules}:{},ignorePatterns:e([...l.ignorePatterns??[],...i?.ignorePatterns??[]])}}const a=i();export{n as i,a as n,r,i as t};
|
package/dist/fumadocs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./react.js";export{r as FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS,i as FUMADOCS_SPECIAL_FILE_PATTERNS,n as default,t as defineConfig}from"./fumadocs.entry-
|
|
1
|
+
import"./react.js";export{r as FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS,i as FUMADOCS_SPECIAL_FILE_PATTERNS,n as default,t as defineConfig}from"./fumadocs.entry-Dgs-WlgF.js";
|
package/dist/hono.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-CejDIGVV.js";
|
|
3
4
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintBaseConfig as default, defineConfig };
|
package/dist/hono.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{n as default,t as defineConfig}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";export{n as default,t as defineConfig}from"./base.entry-CKst6rs9.js";import"./node.js";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region ../core/dist/index.d.ts
|
|
2
|
+
//#region src/types/config.types.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Oxlint 核心类型定义
|
|
5
|
+
*
|
|
6
|
+
* 提供所有 oxlint 相关包共享的类型定义。
|
|
7
|
+
* 仅包含有消费者的类型。
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Oxlint 规则严重级别
|
|
11
|
+
*/
|
|
12
|
+
type OxlintSeverity = 'off' | 'warn' | 'error';
|
|
13
|
+
/**
|
|
14
|
+
* Oxlint 规则配置项
|
|
15
|
+
*
|
|
16
|
+
* 单条规则的配置,支持仅严重级别或带选项的配置
|
|
17
|
+
*/
|
|
18
|
+
type OxlintRuleConfig = OxlintSeverity | [OxlintSeverity, ...unknown[]];
|
|
19
|
+
/**
|
|
20
|
+
* Oxlint 规则集
|
|
21
|
+
*
|
|
22
|
+
* 规则名到配置项的映射
|
|
23
|
+
*/
|
|
24
|
+
type OxlintRules = Record<string, OxlintRuleConfig>;
|
|
25
|
+
/**
|
|
26
|
+
* Oxlint 配置覆盖项
|
|
27
|
+
*/
|
|
28
|
+
type OxlintConfigOverride = {
|
|
29
|
+
/**
|
|
30
|
+
* 匹配的文件模式数组
|
|
31
|
+
*/
|
|
32
|
+
files: string[];
|
|
33
|
+
/**
|
|
34
|
+
* 应用于匹配文件的规则配置
|
|
35
|
+
*/
|
|
36
|
+
rules?: OxlintRules;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Oxlint 配置选项
|
|
40
|
+
*/
|
|
41
|
+
type OxlintConfig = {
|
|
42
|
+
/**
|
|
43
|
+
* 继承的配置列表
|
|
44
|
+
*/
|
|
45
|
+
extends?: OxlintConfig[];
|
|
46
|
+
/**
|
|
47
|
+
* Rust 插件列表
|
|
48
|
+
*/
|
|
49
|
+
plugins?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* JavaScript 插件列表
|
|
52
|
+
*/
|
|
53
|
+
jsPlugins?: string[];
|
|
54
|
+
/**
|
|
55
|
+
* 规则配置
|
|
56
|
+
*/
|
|
57
|
+
rules?: OxlintRules;
|
|
58
|
+
/**
|
|
59
|
+
* 针对特定文件的配置覆盖
|
|
60
|
+
*/
|
|
61
|
+
overrides?: OxlintConfigOverride[];
|
|
62
|
+
/**
|
|
63
|
+
* 忽略的文件模式列表
|
|
64
|
+
*/
|
|
65
|
+
ignorePatterns?: string[];
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { OxlintRules as i, OxlintConfigOverride as n, OxlintRuleConfig as r, OxlintConfig as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { r as
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { i as OxlintRules, n as OxlintConfigOverride, r as OxlintRuleConfig, t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Czyi-DdY.js";
|
|
4
|
+
import { t as defineConfig } from "./base.entry-CejDIGVV.js";
|
|
3
5
|
import { defineConfig as defineConfig$1 } from "./electron.js";
|
|
4
|
-
import "./
|
|
5
|
-
import { a as FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS, o as FUMADOCS_SPECIAL_FILE_PATTERNS, r as defineConfig$2 } from "./fumadocs.entry-Dc9xyNem.js";
|
|
6
|
-
import "./node.js";
|
|
7
|
-
import "./hono.js";
|
|
6
|
+
import { i as FUMADOCS_SPECIAL_FILE_PATTERNS, r as FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS, t as defineConfig$2 } from "./fumadocs.entry-C7QzCdVJ.js";
|
|
8
7
|
import { defineConfig as defineConfig$3 } from "./library.js";
|
|
9
|
-
import "./mcp.js";
|
|
10
8
|
import { defineConfig as defineConfig$4 } from "./nest.js";
|
|
11
|
-
import {
|
|
9
|
+
import { r as NEXTJS_SPECIAL_FILE_PATTERNS, t as defineConfig$5 } from "./next.entry-moZEmUkw.js";
|
|
12
10
|
import { defineConfig as defineConfig$6 } from "./react.js";
|
|
13
|
-
import {
|
|
14
|
-
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-
|
|
15
|
-
import { OxlintConfig, OxlintConfigOverride, OxlintRuleConfig, OxlintRules, OxlintRules as OxlintRules$1 } from "@longzai-intelligence-oxlint/core";
|
|
11
|
+
import { t as defineConfig$7 } from "./taro.entry-DuohnWen.js";
|
|
12
|
+
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-CoZq5SQL.js";
|
|
16
13
|
//#region src/defaults/base.rules.d.ts
|
|
17
14
|
/**
|
|
18
15
|
* 合并后的插件推荐配置
|
|
19
16
|
*
|
|
20
17
|
* 每个插件的推荐配置由插件包自身的 configs/recommended 导出提供
|
|
21
18
|
*/
|
|
22
|
-
declare const PLUGIN_DEFAULTS: OxlintRules
|
|
19
|
+
declare const PLUGIN_DEFAULTS: OxlintRules;
|
|
23
20
|
/**
|
|
24
21
|
* 合并后的完整规则配置
|
|
25
22
|
*
|
|
26
23
|
* 合并顺序:原生规则 -> 插件推荐配置 -> LZI 生态规则选项 -> 预设调整。
|
|
27
24
|
* 生态层覆盖插件 recommended 的无选项形态,require-* 规则由此获得选项默认值
|
|
28
25
|
*/
|
|
29
|
-
declare const ALL_RULES: OxlintRules
|
|
26
|
+
declare const ALL_RULES: OxlintRules;
|
|
30
27
|
//#endregion
|
|
31
28
|
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, 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 defineTaroConfig };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{n as e,r as t,t as n}from"./typescript-eslint.rules-j0Y80OGu.js";import{i as r,r as i,t as a}from"./base.entry-CKst6rs9.js";import"./node.js";import{defineConfig as o}from"./react.js";import"./hono.js";import"./mcp.js";import{r as s,t as c}from"./next.entry-B3GfPoY8.js";import{t as l}from"./taro.entry-DV-L1NDJ.js";import{i as u,r as d,t as f}from"./fumadocs.entry-Dgs-WlgF.js";import"./expo.js";import{t as p}from"./nest.entry-Ch6PVI2A.js";import{t as m}from"./electron.entry-D826gIzo.js";import{t as h}from"./library.entry-mehEApZl.js";import{n as g,t as _}from"./unicorn.rules-0a_FuIjL.js";export{i as ALL_RULES,g as ESLINT_CORE_RULES,n as ESLINT_RECOMMENDED_RULES,d as FUMADOCS_FILE_NAMING_EXEMPT_PATTERNS,u as FUMADOCS_SPECIAL_FILE_PATTERNS,s as NEXTJS_SPECIAL_FILE_PATTERNS,r as PLUGIN_DEFAULTS,e as TYPESCRIPT_PROJECT_RULES,t as TYPESCRIPT_RECOMMENDED_RULES,_ as UNICORN_RULES,a as defineBaseConfig,a as defineExpoConfig,a as defineHonoConfig,a as defineMcpConfig,a as defineNodeConfig,m as defineElectronConfig,f as defineFumadocsConfig,h as defineLibraryConfig,p as defineNestConfig,c as defineNextConfig,o as defineReactConfig,l as defineTaroConfig};
|
package/dist/library.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Czyi-DdY.js";
|
|
3
4
|
//#region src/entries/library.entry.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* 创建 Oxlint Library 配置
|
|
@@ -7,10 +8,10 @@ import { OxlintConfig, OxlintConfig as OxlintConfig$1, OxlintConfigOverride } fr
|
|
|
7
8
|
* @param options - 预设选项,包含额外的规则和覆盖配置
|
|
8
9
|
* @returns 包含 Library 架构插件和推荐规则的 Oxlint 配置对象
|
|
9
10
|
*/
|
|
10
|
-
declare function defineConfig(options?: PresetOptions): OxlintConfig
|
|
11
|
+
declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
11
12
|
/**
|
|
12
13
|
* 默认 Oxlint Library 配置实例
|
|
13
14
|
*/
|
|
14
|
-
declare const oxlintLibraryConfig: OxlintConfig
|
|
15
|
+
declare const oxlintLibraryConfig: OxlintConfig;
|
|
15
16
|
//#endregion
|
|
16
17
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintLibraryConfig as default, defineConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{a as e,o as t,t as n}from"./base.entry-CKst6rs9.js";const r={"@longzai-intelligence-oxlint/architecture-library-plugin/test-file-placement":`error`,"@longzai-intelligence-oxlint/architecture-library-plugin/no-non-test-files-in-tests-directory":`error`,"@longzai-intelligence-oxlint/architecture-library-plugin/test-file-matches-source":`error`},i={"@longzai-intelligence-oxlint/architecture-library-plugin/test-file-matches-source":[`error`,{testTypeSubdirs:[`unit`,`integration`,`e2e`],enableGlobalSearch:!0}]};function a(a){let o={files:[`**/*.ts`],rules:{...r,...i,...a?.rules}},s=n();return{extends:[s],jsPlugins:[e(`architecture-library`)],overrides:[o,...a?.overrides??[]],ignorePatterns:t([...s.ignorePatterns??[],...a?.ignorePatterns??[]])}}const o=a();export{o as n,a as t};
|
package/dist/library.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{n as default,t as defineConfig}from"./library.entry-
|
|
1
|
+
export{n as default,t as defineConfig}from"./library.entry-mehEApZl.js";
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-CejDIGVV.js";
|
|
3
4
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintBaseConfig as default, defineConfig };
|
package/dist/mcp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{n as default,t as defineConfig}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";export{n as default,t as defineConfig}from"./base.entry-CKst6rs9.js";import"./node.js";
|
package/dist/nest.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Czyi-DdY.js";
|
|
3
4
|
//#region src/entries/nest.entry.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* 创建 Oxlint Nest 配置
|
|
@@ -7,10 +8,10 @@ import { OxlintConfig, OxlintConfig as OxlintConfig$1, OxlintConfigOverride } fr
|
|
|
7
8
|
* @param options - 预设选项,包含额外的规则、覆盖和忽略模式
|
|
8
9
|
* @returns 包含 NestJS 路由插件和服务层架构约束的 Oxlint 配置对象
|
|
9
10
|
*/
|
|
10
|
-
declare function defineConfig(options?: PresetOptions): OxlintConfig
|
|
11
|
+
declare function defineConfig(options?: PresetOptions): OxlintConfig;
|
|
11
12
|
/**
|
|
12
13
|
* 默认 Oxlint Nest 配置实例
|
|
13
14
|
*/
|
|
14
|
-
declare const oxlintNestConfig: OxlintConfig
|
|
15
|
+
declare const oxlintNestConfig: OxlintConfig;
|
|
15
16
|
//#endregion
|
|
16
17
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintNestConfig as default, defineConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{a as e,o as t,t as n}from"./base.entry-CKst6rs9.js";import"./node.js";const r=[{files:[`**/*.ts`],rules:{"@longzai-intelligence-oxlint/nestjs-route-plugin/order":`error`,"@longzai-intelligence-oxlint/nestjs-route-plugin/no-duplicates":`error`,"@longzai-intelligence-oxlint/nestjs-route-plugin/require-route-constant":`error`,"@longzai-intelligence-oxlint/nestjs-route-plugin/prefer-typed-controller":`warn`,"@longzai-intelligence-oxlint/nestjs-route-plugin/require-typed-response":`error`,"@longzai-intelligence-oxlint/nestjs-route-plugin/enforce-typed-handler-return":`error`,"@longzai-intelligence-oxlint/architecture-core-plugin/no-restricted-import-in-paths":[`error`,{restrictions:[{importSource:`@nestjs/common`,importNames:[`BadRequestException`,`NotFoundException`,`ForbiddenException`,`UnauthorizedException`,`ConflictException`,`HttpException`],forbiddenPaths:[`*.service.ts`],message:`Service 层禁止导入 NestJS HTTP 异常,请使用 Result<T, DomainError> 透传领域错误,由 Handler 层解包`}]}]}}];function i(i){let a=n();return{extends:[a],jsPlugins:[e(`nestjs-route`)],overrides:[...r,...i?.overrides??[]],...i?.rules?{rules:i.rules}:{},ignorePatterns:t([...a.ignorePatterns??[],...i?.ignorePatterns??[]])}}const a=i();export{a as n,i as t};
|
package/dist/nest.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./node.js";export{n as default,t as defineConfig}from"./nest.entry-
|
|
1
|
+
import"./node.js";export{n as default,t as defineConfig}from"./nest.entry-Ch6PVI2A.js";
|
package/dist/next.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-eNRova_s.js";
|
|
2
|
+
import { n as oxlintNextConfig, r as NEXTJS_SPECIAL_FILE_PATTERNS, t as defineConfig } from "./next.entry-moZEmUkw.js";
|
|
2
3
|
export { NEXTJS_SPECIAL_FILE_PATTERNS, type OxlintConfig, type OxlintConfigOverride, oxlintNextConfig as default, defineConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{o as e}from"./base.entry-CKst6rs9.js";import{defineConfig as t}from"./react.js";const n=[`**/page.ts`,`**/layout.ts`,`**/loading.ts`,`**/error.ts`,`**/not-found.ts`,`**/template.ts`,`**/default.ts`,`**/global-error.ts`,`**/middleware.ts`,`**/route.ts`,`**/instrumentation.ts`],r=[`**/page.tsx`,`**/layout.tsx`,`**/loading.tsx`,`**/error.tsx`,`**/not-found.tsx`,`**/template.tsx`,`**/default.tsx`,`**/global-error.tsx`],i=[...n,...r];function a(n){let r=[...n?.typeSuffixBaseSkipPatterns??[],...i],a=[...n?.fileNamingBaseSkipPatterns??[],...i],o={files:[`**/*.ts`],rules:{"@longzai-intelligence-oxlint/file-naming-plugin/require-type-suffix":[`error`,{skipPatterns:r}]}},s={files:[`**/*.tsx`],rules:{"@longzai-intelligence-oxlint/file-naming-plugin/file-naming":[`error`,{skipPatterns:a}]}},c=t();return{extends:[c],plugins:[`nextjs`],overrides:[o,s,...n?.overrides??[]],...n?.rules?{rules:n.rules}:{},ignorePatterns:e([...c.ignorePatterns??[],...n?.ignorePatterns??[]])}}const o=a();export{o as n,i as r,a as t};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { t as PresetOptions } from "./preset-options.types-Czyi-DdY.js";
|
|
3
4
|
//#region src/defaults/next.patterns.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* Next.js App Router 约定文件模式全集
|
|
@@ -38,4 +39,4 @@ declare function defineConfig(options?: NextPresetOptions): OxlintConfig;
|
|
|
38
39
|
*/
|
|
39
40
|
declare const oxlintNextConfig: OxlintConfig;
|
|
40
41
|
//#endregion
|
|
41
|
-
export {
|
|
42
|
+
export { oxlintNextConfig as n, NEXTJS_SPECIAL_FILE_PATTERNS as r, defineConfig as t };
|
package/dist/next.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./react.js";export{r as NEXTJS_SPECIAL_FILE_PATTERNS,n as default,t as defineConfig}from"./next.entry-
|
|
1
|
+
import"./react.js";export{r as NEXTJS_SPECIAL_FILE_PATTERNS,n as default,t as defineConfig}from"./next.entry-B3GfPoY8.js";
|
package/dist/node.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import { n as OxlintConfigOverride, t as OxlintConfig } from "./index-eNRova_s.js";
|
|
3
|
+
import { n as oxlintBaseConfig, t as defineConfig } from "./base.entry-CejDIGVV.js";
|
|
2
4
|
export { type OxlintConfig, type OxlintConfigOverride, oxlintBaseConfig as default, defineConfig };
|
package/dist/node.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{n as default,t as defineConfig}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";export{n as default,t as defineConfig}from"./base.entry-CKst6rs9.js";
|
|
@@ -0,0 +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 u(e,t){return t.some(t=>t.test(e))}const te=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`&&u(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)`},f=new Set(Object.keys(d)),p={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`}]},m=[{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。`}],re=[`-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 f.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??p.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 y(e,t){for(let n of t)if(e.endsWith(n))return n;return null}function b(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 x(e,t,n){return e.find(e=>e.from===t&&e.to===n)??null}function S(e){let t=e.match(/^\/(.+)\/([gimsuvy]*)$/);return t?.[1]?new RegExp(t[1],t[2]??``):new RegExp(e)}function C(e){let t={};if(e.pathPatterns&&(t.pathPatterns=e.pathPatterns.reduce((e,{pattern:t,layer:n})=>(g(n)&&e.push({pattern:S(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 w(e){return typeof e==`object`&&!!e}function T(e){let t=C(w(e)?e:{});return{pathPatterns:t.pathPatterns??p.pathPatterns,packagePrefix:t.packagePrefix??p.packagePrefix,specialPackageMappings:t.specialPackageMappings??p.specialPackageMappings,packageSuffixMappings:t.packageSuffixMappings??p.packageSuffixMappings,forbiddenLayerPairs:[...m,...t.forbiddenLayerPairs??[]],forbiddenPackageSuffixes:[...re,...t.forbiddenPackageSuffixes??[]]}}const E=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=T(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=y(a,t.forbiddenPackageSuffixes??[]);if(n){e.report({node:r,message:`禁止导入已禁用的 ${n} 门面包,门面包统一使用 -domain 后缀。`});return}}let o=b(i,t);if(!o)return;let s=x(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 D(e){let t=e.replace(/\\/g,`/`);return t.includes(`/domains/`)&&t.includes(`/implementation/src/index.ts`)}function O(e){return e.endsWith(`Entity`)}function k(e){return e.endsWith(`Repository`)&&!e.startsWith(`I`)}function A(e){return e.endsWith(`OrmEntity`)}function j(e){return e.endsWith(`_ORM_ENTITIES`)}function M(e){return e.endsWith(`OrmMapper`)}function N(e){return e.endsWith(`Schema`)}function P(e){return`exportKind`in e&&typeof e.exportKind==`string`?e.exportKind===`value`:!0}function F(e){return e.exported.type===`Identifier`?e.exported.name:e.exported.type===`Literal`&&typeof e.exported.value==`string`?e.exported.value:null}function I(e,t,n){O(e)&&P(t)?n.report({node:t,message:`禁止从主入口值导出 Entity 类 "${e}"。请改为类型导出或移除导出。`}):k(e)?n.report({node:t,message:`禁止导出 Repository 类型 "${e}"。Repository 是内部实现,不应暴露给外部。`}):A(e)?n.report({node:t,message:`禁止从主入口导出 ORM 实体 "${e}"。请创建 src/typeorm.ts 入口文件,从该入口导出。`}):j(e)?n.report({node:t,message:`禁止从主入口导出 ORM 实体集合 "${e}"。请创建 src/typeorm.ts 入口文件,从该入口导出。`}):M(e)?n.report({node:t,message:`禁止导出 ORM Mapper "${e}"。ORM Mapper 是基础设施实现细节,不应暴露给外部。`}):N(e)&&n.report({node:t,message:`禁止导出 Schema 定义 "${e}"。Schema 是实现细节,应仅导出推断类型。`})}const L=e({meta:{type:`problem`,docs:{description:`检查 Domain Implementation 包的导出是否符合规范`}},createOnce(e){return{before(){let t=e.filename;if(!D(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=F(n);t&&I(t,n,e)}}}}});function R(e){let t=e.replace(/\\/g,`/`);return t.includes(`/domains/`)&&t.includes(`/implementation/src/index.ts`)}const z=[/\.\/typeorm/,/\.\/typeorm'/,/\.\/typeorm"/],B=[{pattern:/OrmEntity$/,message:`禁止从主入口导出 ORM 实体。应使用 typeorm 入口导出。`},{pattern:/Entity$/,message:`禁止从主入口导出 Entity 类。Entity 是内部实现,应使用 contract 包的 DTO。`},{pattern:/UseCase$/,message:`禁止导出 UseCase 类。UseCase 是内部实现,应通过 Port 接口访问。`},{pattern:/^I[A-Z].*Repository$/,message:`禁止导出 Repository 接口。Repository 是内部接口,外部应通过 Port 访问。`},{pattern:/^create[A-Za-z]+Repository$/,message:`禁止导出 Repository 工厂函数。外部应使用 PortAdapter 工厂函数。`},{pattern:/Repository/,message:`禁止导出 Repository 实现类。应使用工厂函数或 Port 接口。`},{pattern:/Schema$/,message:`禁止导出 Schema 定义。Schema 是实现细节,应导出推断类型。`},{pattern:/_ORM_ENTITIES$/,message:`禁止从主入口导出实体集合。应使用 typeorm 入口导出。`},{pattern:/OrmMapper$/,message:`禁止导出 ORM Mapper。这是基础设施实现细节。`},{pattern:/Table$/,message:`禁止导出数据库表定义。这是数据存储细节。`}];function V(e){return z.some(t=>t.test(e))}function H(e){for(let{pattern:t,message:n}of B)if(t.test(e))return n;return null}function U(e,t){if(e.source){let n=e.source.type===`Literal`&&typeof e.source.value==`string`?e.source.value:null;if(n&&V(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=H(e);r&&t.report({node:n,message:`${e}: ${r}`})}}}e.declaration&&K(e.declaration,t.report)}function W(e,t){if(e.source){let n=e.source.type===`Literal`&&typeof e.source.value==`string`?e.source.value:null;if(n&&V(n)){t.report({node:e,message:`禁止从主入口重新导出 typeorm.ts 的内容。typeorm.ts 是专门的持久化入口。`});return}}t.report({node:e,message:`禁止使用 export *。请使用显式导出,明确导出内容。`})}function G(e,t){q(e.declaration)&&K(e.declaration,t.report)}function K(e,t){if(e.type===`ClassDeclaration`&&e.id){let n=e.id.name,r=H(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=H(e);r&&t({node:n,message:`${e}: ${r}`})}}else if(e.type===`FunctionDeclaration`&&e.id){let n=e.id.name,r=H(n);r&&t({node:e,message:`${n}: ${r}`})}}function q(e){return e.type===`ClassDeclaration`||e.type===`FunctionDeclaration`||e.type===`VariableDeclaration`}const J=e({meta:{type:`problem`,docs:{description:`Implementation 包导出控制:禁止从主入口导出内部实现`}},createOnce(e){return{before(){let t=e.filename;if(!R(t))return!1},ExportNamedDeclaration(t){U(t,e)},ExportAllDeclaration(t){W(t,e)},ExportDefaultDeclaration(t){G(t,e)}}}}),oe=[{alias:`@main`,pathPattern:`src/main`},{alias:`@preload`,pathPattern:`src/preload`},{alias:`@renderer`,pathPattern:`src/renderer/src`},{alias:`@shared`,pathPattern:`src/shared`}];function se(e){return typeof e==`object`&&!!e&&`packageBoundaries`in e}function Y(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 ce(e,t,n){if(!t.startsWith(`.`))return null;let r=e.replace(/\\/g,`/`),i=r.lastIndexOf(`/`);return Y(le(i>0?r.substring(0,i):``,t),n)}function le(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 ue(e){return e.startsWith(`./`)||e.startsWith(`../`)}const de=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=se(r)&&Array.isArray(r.packageBoundaries)?r.packageBoundaries:oe}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||!ue(i))return;let a=Y(r,n());if(!a)return;let o=ce(r,i,n());o&&a!==o&&e.report({node:t,message:`禁止使用相对路径跨包导入。当前文件位于 "${a}" 包,目标位于 "${o}" 包。请使用别名导入:${o}/...`})}}}});function fe(e){return e.replace(/\\/g,`/`).includes(`/apps/`)}function pe(e){return/-implementation(\/|$)/.test(e)}function me(e){return e.endsWith(`Entity`)}function he(e){return e.endsWith(`UseCase`)}function ge(e){return[/PortAdapter$/,/_TOKEN$/,/^create\w+Repository$/,/^create\w+Adapter$/].some(t=>t.test(e))}const _e=e({meta:{type:`problem`,docs:{description:`禁止在 apps 层导入 implementation 包的 Entity 和 UseCase`}},createOnce(e){return{before(){let t=e.filename;if(!fe(t))return!1},ImportDeclaration(t){let n=t.source.type===`Literal`&&typeof t.source.value==`string`?t.source.value:null;if(n&&pe(n))for(let n of t.specifiers){if(n.type!==`ImportSpecifier`)continue;let t=n.imported.type===`Identifier`?n.imported.name:null;t&&(me(t)?e.report({node:n,message:`禁止在 apps 层导入 Entity 类 "${t}"。请使用 contract 包的 Port 接口进行操作。`}):he(t)?e.report({node:n,message:`禁止在 apps 层导入 UseCase 类 "${t}"。请使用 contract 包的 Port 接口进行操作。`}):ge(t)||e.report({node:n,message:`禁止在 apps 层从 implementation 包导入 "${t}"。请使用 contract 包的 Port 接口。`}))}}}}}),ve=n.object({functionName:n.string(),forbiddenPaths:n.array(n.string()),message:n.optional(n.string())}),ye=n.object({restrictions:n.array(ve)});function X(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 be(e,t){return t.some(t=>X(e,t))}function xe(e){let t=ye.safeParse(e);return t.success?t.data.restrictions:[]}function Se(e){return e.type===`Identifier`?e.name:e.type===`MemberExpression`&&e.property&&!e.computed&&e.property.type===`Identifier`?e.property.name:null}const Ce=e({meta:{type:`problem`,docs:{description:`禁止在指定路径中调用特定函数,强制架构约束`}},createOnce(e){let t=[],n=/* @__PURE__ */ new Set;return{before(){let r=e.options?.[0];if(t=xe(r),t.length===0)return!1;n=/* @__PURE__ */ new Set;for(let r=0;r<t.length;r++){let i=t[r];i&&be(e.filename,i.forbiddenPaths)&&n.add(r)}if(n.size===0)return!1},CallExpression(r){let i=Se(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})}}}}}),we=n.object({importSource:n.string(),importNames:n.optional(n.array(n.string())),forbiddenPaths:n.array(n.string()),message:n.optional(n.string())}),Te=n.object({restrictions:n.array(we)});function Z(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 Ee(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 De(e){let t=Te.safeParse(e);return t.success?t.data.restrictions:[]}function Oe(e,t){return t.some(t=>X(e,t))}const Q={"dependency-direction":E,"business-leak":te,"no-cross-package-relative-import":de,"domain-export-compliance":L,"implementation-export-control":J,"no-implementation-import-in-apps":_e,"no-restricted-call-in-paths":Ce,"no-restricted-import-in-paths":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=De(r),t.length===0)return!1;n=/* @__PURE__ */ new Set;for(let r=0;r<t.length;r++){let i=t[r];i&&Oe(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=Ee(r.specifiers??[]);for(let o of n){let n=t[o];if(!n||!Z(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})}}}}}})},$=t({meta:{name:`@longzai-intelligence-oxlint/architecture-core-plugin`},rules:Q});export{$ as architectureCorePlugin,$ as default,Q as coreRules};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=`createTyped`;function r(e,t){let n=e.replace(/\\/g,`/`);return n.includes(t)&&!n.includes(`.test.`)}function i(e){let t=Array.isArray(e.options)?e.options[0]:void 0,r=t&&typeof t==`object`?t:{};return{preloadUtilsPath:`preloadUtilsPath`in r&&typeof r.preloadUtilsPath==`string`?r.preloadUtilsPath:`/src/preload/utils/`,ipcUtilityPrefix:`ipcUtilityPrefix`in r&&typeof r.ipcUtilityPrefix==`string`?r.ipcUtilityPrefix:n}}const a=e({meta:{type:`problem`,docs:{description:`禁止自定义 IPC 工具函数,应从标准库重新导出`}},createOnce(e){let t=!1,a=n;return{before(){let{preloadUtilsPath:n,ipcUtilityPrefix:o}=i(e);if(a=o,t=r(e.filename,n),!t)return!1},FunctionDeclaration(n){t&&n.id&&n.id.name.startsWith(a)&&e.report({node:n,message:`禁止自定义 IPC 工具函数 "${n.id.name}"。应从标准库重新导出。`})},VariableDeclaration(n){if(t)for(let t of n.declarations)t.id.type===`Identifier`&&t.id.name.startsWith(a)&&(t.init?.type===`FunctionExpression`||t.init?.type===`ArrowFunctionExpression`)&&e.report({node:t,message:`禁止自定义 IPC 工具函数 "${t.id.name}"。应从标准库重新导出。`})}}}});function o(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/src/preload/utils/`)&&!t.includes(`.test.`)}const s=e({meta:{type:`problem`,docs:{description:`禁止在 Preload 中直接调用 ipcRenderer`}},createOnce(e){return{before(){if(!o(e.filename))return!1},CallExpression(t){t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`ipcRenderer`&&t.callee.property.type===`Identifier`&&e.report({node:t,message:`禁止直接调用 ipcRenderer.${t.callee.property.name}()。请使用 createTypedAPI 或 invoke 封装。`})}}}}),c=/* @__PURE__ */ new Set([`on`,`send`,`invoke`]);function l(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`.test.`)}function u(e){for(let t of e)if(typeof t==`object`&&t&&`key`in t&&t.key!==null&&typeof t.key==`object`&&`name`in t.key&&typeof t.key.name==`string`&&c.has(t.key.name))return!0;return!1}const d=e({meta:{type:`problem`,docs:{description:`禁止暴露包含通用 IPC 方法的桥接对象`}},createOnce(e){return{before(){if(!l(e.filename))return!1},Property(t){t.key.type===`Identifier`&&t.key.name===`ipc`&&t.value.type===`ObjectExpression`&&u(t.value.properties)&&e.report({node:t,message:`禁止暴露包含 on/send/invoke 方法的 ipc 对象。请使用领域 API 替代通用 IPC 方法。`})}}}}),f=[`/src/renderer/`];function p(e,t){let n=e.replace(/\\/g,`/`);return t.some(e=>n.includes(e))}function m(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function g(e,t,n){return m(e[t])?e[t]:n}function _(e,t,n){return typeof e[t]==`string`?e[t]:n}const v={},y=e({meta:{type:`problem`,docs:{description:`禁止在 Renderer 进程导入 Implementation 包`}},createOnce(e){let t=f,n=``,r=`-implementation`;return{before(){let i=e.options?.[0],a=h(i)?i:v;if(t=g(a,`rendererPatterns`,f),n=_(a,`packageScope`,``),r=_(a,`implementationSuffix`,`-implementation`),!p(e.filename,t))return!1},ImportDeclaration(t){let i=t.source.type===`Literal`&&typeof t.source.value==`string`?t.source.value:null;i&&(!n||i.startsWith(n))&&i.endsWith(r)&&e.report({node:t,message:`Renderer 进程禁止导入 Implementation 包 "${i}"。请使用 Contract 包替代。`})}}}});function b(e,t){if(e.callee.type!==`MemberExpression`||e.callee.object.type!==`Identifier`||e.callee.object.name!==`contextBridge`||e.callee.property.type!==`Identifier`||e.callee.property.name!==`exposeInMainWorld`||e.arguments.length<2)return;let n=e.arguments[0];if(n?.type===`Literal`&&n.value===`electron`){let n=e.arguments[1];n?.type===`Identifier`&&n.name===`electronAPI`&&t(e,`禁止使用 contextBridge.exposeInMainWorld("electron", electronAPI) 暴露全部 Electron API。请使用领域 API 替代。`)}}function x(e,t){e.left.type===`MemberExpression`&&e.left.object.type===`Identifier`&&e.left.object.name===`window`&&e.left.property.type===`Identifier`&&e.left.property.name===`electron`&&e.right.type===`Identifier`&&e.right.name===`electronAPI`&&t(e,`禁止通过 window.electron = electronAPI 暴露全部 Electron API。请使用领域 API 替代。`)}const S=e({meta:{type:`problem`,docs:{description:`禁止直接暴露 electronAPI 给渲染进程`}},createOnce(e){return{ImportDeclaration(t){if(t.source.type===`Literal`&&t.source.value===`@electron-toolkit/preload`)for(let n of t.specifiers)n.type===`ImportSpecifier`&&n.imported.type===`Identifier`&&n.imported.name===`electronAPI`&&e.report({node:n,message:`禁止导入 electronAPI 并直接暴露给渲染进程。请使用领域 API 替代。`})},CallExpression(t){b(t,(t,n)=>{e.report({node:t,message:n})})},AssignmentExpression(t){x(t,(t,n)=>{e.report({node:t,message:n})})}}}}),C=/* @__PURE__ */ new Set(/* @__PURE__ */ `fs.path.os.crypto.stream.http.https.net.tls.child_process.cluster.dgram.dns.domain.events.punycode.querystring.readline.repl.string_decoder.timers.tty.url.util.v8.vm.worker_threads.zlib.fs/promises.stream/promises.stream/consumers.stream/web.node:fs.node:path.node:os.node:crypto.node:stream.node:http.node:https.node:net.node:tls.node:child_process.node:cluster.node:dgram.node:dns.node:events.node:punycode.node:querystring.node:readline.node:repl.node:string_decoder.node:timers.node:tty.node:url.node:util.node:v8.node:vm.node:worker_threads.node:zlib.node:fs/promises`.split(`.`)),w=/* @__PURE__ */ new Set([`window`,`document`,`navigator`,`localStorage`,`sessionStorage`,`fetch`,`XMLHttpRequest`,`WebSocket`,`Worker`,`Blob`,`File`,`FileReader`,`URL`,`URLSearchParams`,`FormData`,`Headers`,`Request`,`Response`,`History`,`Location`,`Screen`]),T=/* @__PURE__ */ new Set([`ipcRenderer`,`ipcMain`,`BrowserWindow`,`app`,`Menu`,`MenuItem`,`dialog`,`shell`,`clipboard`,`nativeImage`,`Tray`,`webContents`,`session`,`protocol`,`net`,`powerMonitor`,`powerSaveBlocker`,`screen`,`systemPreferences`,`TouchBar`,`crashReporter`]),E=[`/domains/shared-kernel/`];function D(e,t){let n=e.replace(/\\/g,`/`);return t.some(e=>n.includes(e))}function O(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function k(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function A(e){if(O(e)&&`domainLayerPatterns`in e){let t=e.domainLayerPatterns;if(k(t))return t}return E}function j(e,t){let n=e.source.type===`Literal`&&typeof e.source.value==`string`?e.source.value:null;n&&(C.has(n)||n.startsWith(`node:`))&&t(e,`域层禁止导入 Node.js 核心模块 "${n}"。域层应保持平台无关性。`)}function M(e,t){if(e.object.type!==`Identifier`)return;let n=e.object.name;w.has(n)&&t(e,`域层禁止使用浏览器 API "${n}"。域层应保持平台无关性。`),T.has(n)&&t(e,`域层禁止使用 Electron API "${n}"。域层应保持平台无关性。`)}function N(e,t){(w.has(e.name)||T.has(e.name))&&(e.parent?.type!==`MemberExpression`||e.parent.object!==e)&&t(e,`域层禁止直接引用平台 API "${e.name}"。域层应保持平台无关性。`)}const P=e({meta:{type:`problem`,docs:{description:`禁止在业务域层使用平台特定 API(Node.js / Browser / Electron)`}},createOnce(e){let t=null;return{before(){if(t===null){let n=e.options?.[0];t=A(n)}let n=e.filename;if(!D(n,t))return!1},ImportDeclaration(t){j(t,(t,n)=>{e.report({node:t,message:n})})},MemberExpression(t){M(t,(t,n)=>{e.report({node:t,message:n})})},Identifier(t){N(t,(t,n)=>{e.report({node:t,message:n})})}}}});function F(e){let t=e.replace(/\\/g,`/`);return t.endsWith(`/src/preload/index.ts`)&&!t.includes(`.test.`)}const I=e({meta:{type:`problem`,docs:{description:`强制使用 exposeSafeAPI 暴露 API`}},createOnce(e){return{before(){if(!F(e.filename))return!1},CallExpression(t){t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`contextBridge`&&t.callee.property.type===`Identifier`&&t.callee.property.name===`exposeInMainWorld`&&e.report({node:t,message:`禁止直接调用 contextBridge.exposeInMainWorld。请使用 exposeSafeAPI 进行 API 暴露。`})}}}});function L(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`.test.`)}const R=e({meta:{type:`problem`,docs:{description:`禁止使用字符串字面量作为 IPC 通道名`}},createOnce(e){return{before(){if(!L(e.filename))return!1},CallExpression(t){if(t.callee.type!==`Identifier`||t.callee.name!==`invoke`||t.arguments.length===0)return;let n=t.arguments[0];n?.type===`Literal`&&typeof n.value==`string`&&e.report({node:n,message:`禁止使用字符串字面量 "${n.value}" 作为 IPC 通道名。请使用常量引用。`})},ObjectExpression(t){if(t.parent?.type===`CallExpression`&&t.parent.callee.type===`Identifier`&&t.parent.callee.name===`createTypedAPI`)for(let n of t.properties)n.type===`Property`&&n.value.type===`Literal`&&typeof n.value.value==`string`&&e.report({node:n.value,message:`禁止在 createTypedAPI 配置中使用字符串字面量 "${n.value.value}" 作为 IPC 通道名。请使用常量引用。`})}}}});function z(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/renderer/`)&&!t.includes(`.test.`)}function B(e){return e.callee.type!==`MemberExpression`||e.callee.object.type!==`MemberExpression`?!1:e.callee.object.object.type===`Identifier`&&e.callee.object.object.name===`window`}function V(e){return typeof e==`object`&&!!e&&`type`in e&&`callee`in e}function H(e){return typeof e==`object`&&!!e&&`parent`in e}function U(e){let t=e;for(;t&&H(t);){let e=t.parent;if(V(e)&&e.callee){if(e.callee.type===`Identifier`&&(e.callee.name===`unwrap`||e.callee.name===`unwrapIPCResult`))return!0;if(e.callee.type===`Identifier`)return!1}t=e}return!1}const W={"platform-leak":P,"no-implementation-in-renderer":y,"no-unsafe-electron-api-exposure":S,"no-generic-ipc-bridge-exposure":d,"no-direct-ipcrenderer-in-preload":s,"require-typed-ipc-channel":R,"require-expose-safe-api":I,"no-custom-ipc-utility":a,"require-unwrap-ipc-result":e({meta:{type:`problem`,docs:{description:`渲染层调用 IPC API 时必须使用 unwrap 解包结果`}},createOnce(e){return{before(){if(!z(e.filename))return!1},CallExpression(t){B(t)&&(U(t)||e.report({node:t,message:`渲染层调用 IPC API 时必须使用 unwrap 或 unwrapIPCResult 解包结果。请使用 unwrap(window.xxx.method())。`}))}}}})},G=t({meta:{name:`@longzai-intelligence-oxlint/architecture-electron-plugin`},rules:W});export{G as architectureElectronPlugin,G as default,W as electronRules};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import n,{existsSync as r}from"node:fs";import i from"node:path";const a=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/],o=[`/node_modules/`,`/dist/`,`/out/`,`/.bun/`];function s(e){return e.replace(/\\/g,`/`)}function c(e){return a.some(t=>t.test(e))}function l(e){let t=s(e);return o.some(e=>t.includes(e))}const u=[{segment:`/src/main/`,process:`main`},{segment:`/src/renderer/`,process:`renderer`},{segment:`/src/preload/`,process:`preload`},{segment:`/src/shared/`,process:`shared`}];function d(e){let t=i.dirname(e);for(;;){let n=i.join(t,`package.json`);if(r(n))return t;let a=i.dirname(t);if(a===t)return i.dirname(e);t=a}}const f={name:`electron-process`,detect(e){let t=s(e);for(let n of u)if(t.includes(n.segment)){let r=s(d(e)),i=p(t,n.segment);return{type:`apps`,isElectron:!0,electronProcess:n.process,srcRoot:i,projectRoot:r}}return null}};function p(e,t){let n=e.indexOf(t);return e.slice(0,n+t.length-1)}const m={name:`package-json`,detect(e){let t=h(e);if(!t)return null;let n=s(t),r=s(g(t));return{type:_(n),isElectron:!1,srcRoot:r,projectRoot:n}}};function h(e){let t=i.dirname(e);for(;;){let e=i.join(t,`package.json`);if(r(e))return t;let n=i.dirname(t);if(n===t)return null;t=n}}function g(e){let t=i.join(e,`src`);return r(t)?t:e}function _(e){let t=s(e);return t.includes(`/packages/`)?`packages`:t.includes(`/domains/`)?`domains`:t.includes(`/apps/`)?`apps`:t.includes(`/infrastructure/`)?`infrastructure`:t.includes(`/templates/`)?`templates`:t.includes(`/database/`)?`database`:`unknown`}function v(){let e=[];return{detectors:e,addDetector(t){return e.push(t),this},detect(t){for(let n of e){let e=n.detect(t);if(e)return e}return null}}}const y=v().addDetector(f).addDetector(m),b=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/],x=[`.ts`,`.tsx`],S=/* @__PURE__ */ new Set([`node_modules`,`dist`,`out`,`.bun`,`.turbo`,`.cache`,`generated`]),C=/* @__PURE__ */ new Set([`bun`,`vitest`]),w=/* @__PURE__ */ new Set([`unit`,`integration`,`e2e`]),T=/* @__PURE__ */ new Map;function E(e,t){let r;try{r=n.readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of r){let r=i.join(e,n.name);if(n.isDirectory()){if(S.has(n.name))continue;E(r,t)}else n.isFile()&&t(r)}}function D(e){for(let t of b)if(t.test(e))return e.replace(t,``);return e}function ee(e){let t=[],n=e;for(;n.includes(`.`);){let e=n.lastIndexOf(`.`);n=n.substring(0,e),t.push(n)}return t}function te(e){let t=s(e),n=t.indexOf(`/__tests__/`);return n===-1?i.dirname(e):t.substring(0,n)}function O(e,t,n){let r=s(e),a=r.indexOf(`/__tests__/`);if(a===-1)return null;let o=r.substring(a+11).split(`/`);if(o.length<2)return null;let c=o[0];if(!c)return null;let l=C.has(c),u=n?n.includes(c):w.has(c),d=l||u?o.slice(1,-1).join(`/`):o.slice(0,-1).join(`/`);return d?i.join(t,d):t}function k(e,t){for(let r of x){let a=i.join(t,e+r);if(n.existsSync(a))return a}return null}function A(e,t){let r=i.join(t,e);try{if(n.existsSync(r)&&n.statSync(r).isDirectory())return r}catch{return null}return null}function j(e,t){let r=i.join(t,e);try{if(!n.existsSync(r)||!n.statSync(r).isDirectory())return null}catch{return null}for(let e of x){let t=i.join(r,`index`+e);if(n.existsSync(t))return t}return null}function M(e){let t=T.get(e);if(t)return t;let n=[];return E(e,e=>n.push(e)),T.set(e,n),n}function N(e,t){for(let n of t){let t=k(e,n);if(t)return t}return null}function P(e,t){for(let n of t){let t=A(e,n);if(t)return t}return null}function F(e,t){for(let n of t){let t=j(e,n);if(t)return t}return null}function I(e,t,r,a){let o=[e,...t];for(let e of r){if(!n.existsSync(e))continue;let t=M(e);for(let e of t){let t=i.basename(e);if(!c(t)){for(let n of o)for(let r of x)if(t===n+r)return e;if(a){let n=t;for(let e of x)if(t.endsWith(e)){n=t.slice(0,-e.length);break}for(let t of o)if(t.includes(n)||n.includes(t))return e}}}}return null}function L(e,t,n,r){let a=i.dirname(t),o=i.dirname(a),s=[a,o],c=O(t,n,r?.testTypeSubdirs),l=c?[c,n,o]:[n,o];if(c){let t=k(e,c);if(t)return t;let n=A(e,c);if(n)return n;let r=j(e,c);if(r)return r}let u=N(e,s);if(u)return u;let d=P(e,l);if(d)return d;let f=F(e,l);if(f)return f;let p=ee(e),m=c?[c,...s]:s;for(let e of p){let t=N(e,m);if(t)return t;let n=P(e,l);if(n)return n;let r=F(e,l);if(r)return r}return r?.enableGlobalSearch?I(e,p,[n,a],r?.enableGlobalSearch):null}function R(e,t){return L(D(i.basename(e)),e,te(e),t)?{isMatch:!0}:{isMatch:!1}}function z(e){let t=i.basename(e);return c(t)&&!l(e)&&!t.endsWith(`.d.ts`)}const B=[`**/vitest.setup.ts`,`**/jest.setup.ts`,`**/fixtures/**`,`**/helpers/**`,`**/mocks/**`,`**/__mocks__/**`,`**/*.d.ts`,`**/bun/**`,`**/vitest/**`];function V(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function H(e){if(typeof e!=`object`||!e)return!1;if(!(`allowPatterns`in e))return!0;let t=e.allowPatterns;return Array.isArray(t)&&V(t)}function U(e){let t=Array.isArray(e)?e[0]:e;return!H(t)||!t.allowPatterns?{allowPatterns:[...B]}:{allowPatterns:[...B,...t.allowPatterns]}}function W(e){return a.some(t=>t.test(e))}function G(e,t){let n=t.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*\*/g,`{{DOUBLE_STAR}}`).replace(/\*/g,`[^/]*`).replace(/{{DOUBLE_STAR}}/g,`.*`);return RegExp(`^${n}$`).test(e)}function K(e,t){return t.some(t=>G(e,t))}const q=e({meta:{type:`problem`,docs:{description:`禁止在 __tests__ 目录下放置非测试文件`}},createOnce(e){return{before(){let t=U(e.options),n=e.filename,r=s(n);if(!r.includes(`/__tests__/`)||W(i.basename(n))||K(r,t.allowPatterns))return!1},Program(t){let n=e.filename,r=i.basename(n);e.report({node:t,message:`文件 "${r}" 位于 __tests__ 目录下但不是测试文件。测试目录应仅包含测试文件(*.test.ts, *.spec.ts)。如果是辅助文件,请移动到 src/test-helpers/ 或 src/testing/ 目录。`})}}}});function J(e){if(typeof e!=`object`||!e)return!1;if(`testTypeSubdirs`in e){let{testTypeSubdirs:t}=e;if(t!==void 0&&!Array.isArray(t))return!1}if(`enableGlobalSearch`in e){let{enableGlobalSearch:t}=e;if(t!==void 0&&typeof t!=`boolean`)return!1}return!0}const Y=e({meta:{type:`problem`,docs:{description:`确保测试文件集中放置于 __tests__/ 下,且文件名与被测源文件名或目录名保持一致`},schema:[{type:`object`,properties:{testTypeSubdirs:{type:`array`,items:{type:`string`}},enableGlobalSearch:{type:`boolean`}},additionalProperties:!1}]},createOnce(e){let t=J(e.options?.[0])?e.options[0]:void 0;return{before(){let t=e.filename;if(!z(t))return!1},Program(n){let r=e.filename,a=i.basename(r);R(r,t).isMatch||e.report({node:n,message:`测试文件 "${a}" 未找到匹配的源文件。测试文件应集中放置在 __tests__/ 目录下(可按 unit/integration/e2e 或 bun/vitest 分子目录组织),文件名与源文件名或目录名保持一致,例如 src/user.service.ts -> src/__tests__/user.service.test.ts、src/bridge/ -> src/__tests__/bridge.test.ts。同一源文件拆分多个测试时,用点号分隔拆分标识(如 src/comment.orm-repository.ts -> src/__tests__/comment.orm-repository.query.test.ts,而非 comment.orm-repository-query.test.ts)`})}}}});function X(e){return e.isElectron&&e.electronProcess?`src/${e.electronProcess}/__tests__`:`src/__tests__`}function Z(e,t){return s(e).startsWith(`${t.srcRoot}/__tests__/`)}function ne(e,t){let n=s(e),r=i.basename(e),a=n.indexOf(`/src/`);if(a===-1)return`${t.srcRoot}/__tests__/${r}`;let o=n.slice(a+5).split(`/`);if(o.length>1&&o.pop(),t.isElectron&&t.electronProcess){let e=o.indexOf(t.electronProcess);e!==-1&&o.splice(e,1)}let c=o.indexOf(`__tests__`);c!==-1&&o.splice(c,1);let l=o.join(`/`),u=X(t);return l?`${u}/${l}/${r}`:`${u}/${r}`}const Q={"test-file-placement":e({meta:{type:`problem`,docs:{description:`强制测试文件放置在 src/__tests__ 目录下`}},createOnce(e){return{before(){let t=e.filename,n=i.basename(t);if(!c(n)||l(t)||n.endsWith(`.d.ts`))return!1;let r=y.detect(t);if(!r||r.type===`unknown`||Z(t,r))return!1},Program(t){let n=e.filename,r=i.basename(n),a=y.detect(n);if(!a)return;let o=X(a),s=ne(n,a);e.report({node:t,message:`测试文件 "${r}" 必须放置在 ${o} 目录下。当前路径: "${n}"。建议路径: "${s}"`})}}}}),"no-non-test-files-in-tests-directory":q,"test-file-matches-source":Y},$=t({meta:{name:`@longzai-intelligence-oxlint/architecture-library-plugin`},rules:Q});export{$ as architectureLibraryPlugin,$ as default,Q as libraryRules};
|
|
@@ -0,0 +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 _={noHandwrittenShebang:`入口源码手写 shebang 属被裁定的错误方式,bin 产物首行 shebang 应由 "lzi-builder.config.ts" 的 banner 在构建期注入。请删除源码首行的 "#!" 行并补 banner 配置。`},v=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:_.noHandwrittenShebang})}}}}),y=s.object({type:s.literal(`TSTypeLiteral`)}),b=s.object({type:s.literal(`TSFunctionType`)}),x=s.object({type:s.literal(`TSUnionType`),types:s.array(s.unknown())}),oe=s.object({type:s.literal(`TSIntersectionType`),types:s.array(s.unknown())}),se=s.object({type:s.literal(`Identifier`),name:s.string()}),ce=s.object({type:s.literal(`RestElement`),argument:s.object({name:s.string()})}),le=s.union([se,ce]),S=s.object({typeAnnotation:s.unknown()}),ue=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([S,s.null()]))}),kind:s.enum([`method`,`constructor`,`get`,`set`])}),de=s.object({returnType:S}),fe=s.object({id:s.optional(s.object({name:s.optional(s.string())})),params:s.optional(s.array(s.unknown())),returnType:s.optional(s.unknown())}),pe=s.object({params:s.optional(s.array(s.unknown()))});function C(e){return y.safeParse(e).success}function w(e){return b.safeParse(e).success}function T(e){return x.safeParse(e).success}function E(e){return oe.safeParse(e).success}function D(e){return le.safeParse(e).success}function O(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 k(e){return ue.safeParse(e).success}function A(e){return de.safeParse(e).success}function j(e){return fe.safeParse(e).success}function M(e){return pe.safeParse(e).success}function N(e){return C(e)||w(e)?!0:T(e)||E(e)?e.types.some(N):!1}function P(e){return C(e)?`对象类型`:w(e)?`函数类型`:`内联类型`}function F(e){return D(e)?e.type===`Identifier`?e.name:e.type===`RestElement`?e.argument.name:null:null}function I(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 L(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 R(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;N(a)&&I(t,n,F(e)??`未知参数`,P(a),r,i)}function z(e,t,n,r,i){for(let a of e)R(a,t,n,i??!1,r)}function B(e,t,n,r,i){if(typeof e!=`object`||!e||!(`typeAnnotation`in e))return;let a=e.typeAnnotation;N(a)&&L(t,n,P(a),r,i)}function V(e,t){if(!O(e)||!j(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),M(e)&&z(e.params??[],t,e),A(e)&&B(e.returnType,t,e,n??void 0)}function me(e,t){O(e)&&M(e)&&(M(e)&&z(e.params??[],t,e),A(e)&&B(e.returnType,t,e))}function he(e,t){if(!k(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)&&z(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;B(n,t,e,void 0,r)}}const H=r({meta:{type:`suggestion`,docs:{description:`禁止在函数参数和返回值中使用内联类型定义,强制使用具名类型`}},createOnce(e){return{FunctionDeclaration(t){V(t,e)},FunctionExpression(t){V(t,e)},ArrowFunctionExpression(t){me(t,e)},MethodDefinition(t){he(t,e)}}}});function ge(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 U=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(...ge(e.id));r.length!==0&&e.report({node:t,message:`应将 \`export ${n.kind} ${r.join(`, `)}\` 拆分为独立的声明和导出语句`})}}}}),W=[{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 G(e){for(let t of W)if(e.endsWith(t.suffix))return t;return null}function K(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 q(e){return e.isPrefix&&e.isInterface?e.classSuffix?`I${e.classSuffix}(如 IUser${e.classSuffix})`:`I 前缀(如 IUser)`:e.isPrefix?`I 前缀(如 IUser)`:`${e.classSuffix} 后缀`}const J=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`)||!G(t))return!1},ClassDeclaration(t){let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=G(n);if(!r||r.isInterface||!t.id)return;let i=t.id.name;K(i,r)||e.report({node:t,message:`类名 "${i}" 不符合命名规范。文件 "${n}" 中的类应使用 ${q(r)}`})},TSInterfaceDeclaration(t){let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=G(n);if(!r||!r.isInterface)return;let i=t.id.name;K(i,r)||e.report({node:t,message:`接口名 "${i}" 不符合命名规范。文件 "${n}" 中的接口应使用 ${q(r)}`})}}}});function Y(e){return e.endsWith(`.dto.ts`)}function X(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`)||!Y(t))return!1},TSInterfaceDeclaration(n){let r=n.id.name;X(r)?e.report({node:n,message:`接口名 "${r}" 后缀应使用 Dto(驼峰式)而非 DTO(全大写)`}):t(r)||e.report({node:n,message:`DTO 文件中的接口名 "${r}" 应以 Dto 结尾(如 UserResponseDto)`})}}}}),_e=[`types.ts`,`types.d.ts`],ve=[`.port.interface.ts`,`.repository.interface.ts`,`.types.ts`,`.types.d.ts`,`.events.ts`,`.d.ts`];function ye(t,r){return e(t)?!1:!r.endsWith(`.dto.ts`)||n(t)}function be(e){return e.endsWith(`.dto.ts`)?`DTO 后缀(如 UserDTO),禁止 I 前缀`:`PascalCase(如 User、UserRepository),禁止 I 前缀`}function xe(e){if(_e.includes(e))return!0;for(let t of ve)if(e.endsWith(t))return!0;return!1}function Se(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`)||xe(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;ye(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}" 不符合命名规范。接口名应使用 ${be(r)}`})),!i&&!r.endsWith(`.dto.ts`)&&!r.endsWith(`.tsx`)&&t.report({node:n,message:`包含接口 "${a}" 的文件 "${r}" 应命名为 "${Se(r)}"`})}}}}),$=i({meta:{name:`@longzai-intelligence-oxlint/code-style-plugin`},rules:{"no-console":f,"no-inline-type-definition":H,"prefer-split-export-const":U,"require-interface-naming":Q,"require-dto-naming":Z,"require-class-suffix":J,"no-class-suffix-alias":l,"no-handwritten-shebang":v}});export{W as SUFFIX_MAPPINGS,$ as codeStylePlugin,$ as default,P as getInlineTypeDescription,F as getParamName,e as hasIPrefix,N as hasInlineType,Y as isDtoFile,O as isFunctionNode,k as isMethodDefinition,w as isTSFunctionType,E as isTSIntersectionType,C as isTSTypeLiteral,T as isTSUnionType,l as noClassSuffixAliasRule,f as noConsoleRule,v as noHandwrittenShebangRule,H as noInlineTypeDefinitionRule,U as preferSplitExportConstRule,J as requireClassSuffixRule,Z as requireDtoNamingRule,Q as requireInterfaceNamingRule};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";function n(e){return e.type===`Literal`}function r(e){return e.type===`FunctionExpression`||e.type===`ArrowFunctionExpression`}const i=e({meta:{type:`problem`,docs:{description:`校验 defineCapability 声明结构:provides/inject 必须是 ServiceToken,factory 必须是函数`}},createOnce(e){return{CallExpression(t){if(t.callee.type===`Identifier`&&t.callee.name===`defineCapability`){let i=t.arguments[0];if(!i||i.type!==`ObjectExpression`)e.report({node:t,message:`defineCapability 的首参必须是对象字面量`});else{let a=!1;for(let t of i.properties)if(t.type===`Property`&&t.key.type===`Identifier`){if(t.key.name===`provides`)a=!0,n(t.value)&&e.report({node:t,message:`provides 必须是 ServiceToken(createServiceToken 产物),禁止使用裸字符串`});else if(t.key.name===`factory`)r(t.value)||e.report({node:t,message:`factory 必须是函数`});else if(t.key.name===`inject`&&t.value.type===`ObjectExpression`)for(let r of t.value.properties)r.type===`Property`&&n(r.value)&&e.report({node:r,message:`inject 值必须是 ServiceToken,禁止使用裸字符串`})}a||e.report({node:t,message:`defineCapability 声明必须包含 provides`})}}}}}});function a(e,t){if(e.type===`Identifier`)return t.get(e.name)??e.name;if(e.type===`CallExpression`&&e.callee.type===`Identifier`&&e.callee.name===`createServiceToken`){let t=e.arguments[0];if(t&&t.type===`Literal`&&typeof t.value==`string`)return t.value}return null}function o(e){let t=/* @__PURE__ */ new Map,n=[],r=null;for(let n of e.keys())t.set(n,0);let i=a=>{t.set(a,1),n.push(a);for(let o of e.get(a)??[]){let e=t.get(o);if(e===1){let e=n.indexOf(o);return r=[...n.slice(e),o],!0}if(e===0&&i(o))return!0}return n.pop(),t.set(a,2),!1};for(let n of e.keys())if(t.get(n)===0&&i(n))return r;return null}const s={"define-capability-validity":i,"inject-graph-acyclic":e({meta:{type:`problem`,docs:{description:`检测同文件内 defineCapability 的 inject 依赖环`}},createOnce(e){let t=/* @__PURE__ */ new Map,n=[];return{Program(){t.clear(),n.length=0},VariableDeclaration(e){for(let n of e.declarations)if(n.id.type===`Identifier`&&n.init&&n.init.type===`CallExpression`&&n.init.callee.type===`Identifier`&&n.init.callee.name===`createServiceToken`){let e=n.init.arguments[0];e&&e.type===`Literal`&&typeof e.value==`string`&&t.set(n.id.name,e.value)}},CallExpression(e){if(e.callee.type===`Identifier`&&e.callee.name===`defineCapability`){let r=e.arguments[0];if(r&&r.type===`ObjectExpression`){let i=null,o=[];for(let e of r.properties)if(e.type===`Property`&&e.key.type===`Identifier`){if(e.key.name===`provides`)i=a(e.value,t);else if(e.key.name===`inject`&&e.value.type===`ObjectExpression`){for(let n of e.value.properties)if(n.type===`Property`){let e=a(n.value,t);e&&o.push(e)}}}i&&n.push({provideId:i,depIds:o,node:e})}}},"Program:exit"(){let t=new Set(n.map(e=>e.provideId)),r=/* @__PURE__ */ new Map;for(let e of n)r.set(e.provideId,e.depIds.filter(e=>t.has(e)));let i=o(r);if(i){let t=n.find(e=>e.provideId===i[0]);t&&e.report({node:t.node,message:`检测到能力依赖环:${i.join(` → `)}`})}}}}})},c=t({meta:{name:`@longzai-intelligence-oxlint/composer-plugin`},rules:s});export{c as composerPlugin,c as default,s as composerRules};
|