@mionjs/devtools 0.8.10 → 0.13.2
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/LICENSE +1 -1
- package/README.md +34 -0
- package/dist/core/apply-edits.d.ts +8 -0
- package/dist/core/apply-edits.js +24 -0
- package/dist/core/apply-edits.js.map +1 -0
- package/dist/core/bundledApiStub.d.ts +4 -0
- package/dist/core/bundledApiStub.js +4 -0
- package/dist/core/bundledApiStub.js.map +1 -0
- package/dist/core/devReporter.d.ts +19 -0
- package/dist/core/devReporter.js +91 -0
- package/dist/core/devReporter.js.map +1 -0
- package/dist/core/diagnosticCatalog.d.ts +5 -0
- package/dist/core/diagnosticCatalog.js +18 -0
- package/dist/core/diagnosticCatalog.js.map +1 -0
- package/dist/core/downgradeErrors.d.ts +11 -0
- package/dist/core/downgradeErrors.js +34 -0
- package/dist/core/downgradeErrors.js.map +1 -0
- package/dist/core/edit-buffer.d.ts +26 -0
- package/dist/core/edit-buffer.js +209 -0
- package/dist/core/edit-buffer.js.map +1 -0
- package/dist/core/go-generated/diagnosticCatalog.generated.d.ts +9 -0
- package/dist/core/go-generated/diagnosticCatalog.generated.js +1008 -0
- package/dist/core/go-generated/diagnosticCatalog.generated.js.map +1 -0
- package/dist/core/go-generated/reflectionKind.generated.d.ts +60 -0
- package/dist/core/go-generated/reflectionKind.generated.js +60 -0
- package/dist/core/go-generated/reflectionKind.generated.js.map +1 -0
- package/dist/core/go-generated/runtypes-constants.generated.d.ts +197 -0
- package/dist/core/go-generated/runtypes-constants.generated.js +110 -0
- package/dist/core/go-generated/runtypes-constants.generated.js.map +1 -0
- package/dist/core/go-generated/tsconfig-plugin-keys.generated.d.ts +3 -0
- package/dist/core/go-generated/tsconfig-plugin-keys.generated.js +23 -0
- package/dist/core/go-generated/tsconfig-plugin-keys.generated.js.map +1 -0
- package/dist/core/groupedLog.d.ts +6 -0
- package/dist/core/groupedLog.js +163 -0
- package/dist/core/groupedLog.js.map +1 -0
- package/dist/core/levels.d.ts +6 -0
- package/dist/core/levels.js +22 -0
- package/dist/core/levels.js.map +1 -0
- package/dist/core/markerImports.d.ts +8 -0
- package/dist/core/markerImports.js +149 -0
- package/dist/core/markerImports.js.map +1 -0
- package/dist/core/option-guards.d.ts +4 -0
- package/dist/core/option-guards.js +12 -0
- package/dist/core/option-guards.js.map +1 -0
- package/dist/core/plugin-option-keys.d.ts +3 -0
- package/dist/core/plugin-option-keys.js +35 -0
- package/dist/core/plugin-option-keys.js.map +1 -0
- package/dist/core/protocol.d.ts +244 -0
- package/dist/core/protocol.js +23 -0
- package/dist/core/protocol.js.map +1 -0
- package/dist/core/resolver-client.d.ts +160 -0
- package/dist/core/resolver-client.js +354 -0
- package/dist/core/resolver-client.js.map +1 -0
- package/dist/core/scan-batcher.d.ts +6 -0
- package/dist/core/scan-batcher.js +36 -0
- package/dist/core/scan-batcher.js.map +1 -0
- package/dist/core/surface.d.ts +23 -0
- package/dist/core/surface.js +77 -0
- package/dist/core/surface.js.map +1 -0
- package/dist/core/type-deps.d.ts +11 -0
- package/dist/core/type-deps.js +72 -0
- package/dist/core/type-deps.js.map +1 -0
- package/dist/core/types.d.ts +13 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/typescript-floor.d.ts +5 -0
- package/dist/core/typescript-floor.js +33 -0
- package/dist/core/typescript-floor.js.map +1 -0
- package/dist/core/unplugin.d.ts +67 -0
- package/dist/core/unplugin.js +636 -0
- package/dist/core/unplugin.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/lint/diagnosticRouting.d.ts +28 -0
- package/dist/lint/diagnosticRouting.js +74 -0
- package/dist/lint/diagnosticRouting.js.map +1 -0
- package/dist/lint/index.d.ts +49 -0
- package/dist/lint/index.js +96 -0
- package/dist/lint/index.js.map +1 -0
- package/dist/lint/lint-worker.d.ts +2 -0
- package/dist/lint/lint-worker.js +116 -0
- package/dist/lint/lint-worker.js.map +1 -0
- package/dist/lint/prefilter.d.ts +7 -0
- package/dist/lint/prefilter.js +31 -0
- package/dist/lint/prefilter.js.map +1 -0
- package/dist/lint/session-protocol.d.ts +38 -0
- package/dist/lint/session-protocol.js +11 -0
- package/dist/lint/session-protocol.js.map +1 -0
- package/dist/lint/session.d.ts +27 -0
- package/dist/lint/session.js +149 -0
- package/dist/lint/session.js.map +1 -0
- package/dist/lint/spawn-shim.d.ts +2 -0
- package/dist/lint/spawn-shim.js +23 -0
- package/dist/lint/spawn-shim.js.map +1 -0
- package/dist/next/index.d.ts +11 -0
- package/dist/next/index.js +17 -0
- package/dist/next/index.js.map +1 -0
- package/dist/options.d.ts +29 -0
- package/dist/options.js +36 -0
- package/dist/options.js.map +1 -0
- package/dist/runtypes/bun.d.ts +25 -0
- package/dist/runtypes/bun.js +62 -0
- package/dist/runtypes/bun.js.map +1 -0
- package/dist/runtypes/esbuild.d.ts +4 -0
- package/dist/runtypes/esbuild.js +4 -0
- package/dist/runtypes/esbuild.js.map +1 -0
- package/dist/runtypes/next/broker.d.ts +15 -0
- package/dist/runtypes/next/broker.js +316 -0
- package/dist/runtypes/next/broker.js.map +1 -0
- package/dist/runtypes/next/index.d.ts +30 -0
- package/dist/runtypes/next/index.js +57 -0
- package/dist/runtypes/next/index.js.map +1 -0
- package/dist/runtypes/next/loader.d.ts +13 -0
- package/dist/runtypes/next/loader.js +64 -0
- package/dist/runtypes/next/loader.js.map +1 -0
- package/dist/runtypes/next/wire.d.ts +17 -0
- package/dist/runtypes/next/wire.js +15 -0
- package/dist/runtypes/next/wire.js.map +1 -0
- package/dist/runtypes/rolldown.d.ts +4 -0
- package/dist/runtypes/rolldown.js +4 -0
- package/dist/runtypes/rolldown.js.map +1 -0
- package/dist/runtypes/rollup.d.ts +4 -0
- package/dist/runtypes/rollup.js +4 -0
- package/dist/runtypes/rollup.js.map +1 -0
- package/dist/runtypes/rspack.d.ts +4 -0
- package/dist/runtypes/rspack.js +4 -0
- package/dist/runtypes/rspack.js.map +1 -0
- package/dist/runtypes/vite.d.ts +4 -0
- package/dist/runtypes/vite.js +4 -0
- package/dist/runtypes/vite.js.map +1 -0
- package/dist/runtypes/webpack.d.ts +4 -0
- package/dist/runtypes/webpack.js +4 -0
- package/dist/runtypes/webpack.js.map +1 -0
- package/dist/vite/buildEntries.d.ts +2 -0
- package/dist/vite/buildEntries.js +28 -0
- package/dist/vite/buildEntries.js.map +1 -0
- package/dist/vite/cjsPackageJsonPlugin.d.ts +3 -0
- package/dist/vite/cjsPackageJsonPlugin.js +12 -0
- package/dist/vite/cjsPackageJsonPlugin.js.map +1 -0
- package/dist/vite/index.d.ts +6 -0
- package/dist/vite/index.js +5 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/vite/middlewareMode.d.ts +10 -0
- package/dist/vite/middlewareMode.js +227 -0
- package/dist/vite/middlewareMode.js.map +1 -0
- package/dist/vite/mionVitePlugin.d.ts +23 -0
- package/dist/vite/mionVitePlugin.js +115 -0
- package/dist/vite/mionVitePlugin.js.map +1 -0
- package/dist/vite/nodeWebBridge.d.ts +5 -0
- package/dist/vite/nodeWebBridge.js +59 -0
- package/dist/vite/nodeWebBridge.js.map +1 -0
- package/dist/vite/sfcTransform.d.ts +8 -0
- package/dist/vite/sfcTransform.js +142 -0
- package/dist/vite/sfcTransform.js.map +1 -0
- package/oxlint-recommended.json +11 -0
- package/package.json +91 -56
- package/build/eslint/cjs/index.cjs +0 -41
- package/build/eslint/cjs/index.cjs.map +0 -1
- package/build/eslint/cjs/package.json +0 -1
- package/build/eslint/cjs/src/eslint/index.cjs +0 -13
- package/build/eslint/cjs/src/eslint/index.cjs.map +0 -1
- package/build/eslint/cjs/src/eslint/index.d.ts +0 -4
- package/build/eslint/cjs/src/eslint/index.d.ts.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/enforce-type-imports.cjs +0 -121
- package/build/eslint/cjs/src/eslint/rules/enforce-type-imports.cjs.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/enforce-type-imports.d.ts +0 -8
- package/build/eslint/cjs/src/eslint/rules/enforce-type-imports.d.ts.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/formatTypeNames.cjs +0 -71
- package/build/eslint/cjs/src/eslint/rules/formatTypeNames.cjs.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/formatTypeNames.d.ts +0 -4
- package/build/eslint/cjs/src/eslint/rules/formatTypeNames.d.ts.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/no-mixed-union-properties.cjs +0 -220
- package/build/eslint/cjs/src/eslint/rules/no-mixed-union-properties.cjs.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/no-mixed-union-properties.d.ts +0 -4
- package/build/eslint/cjs/src/eslint/rules/no-mixed-union-properties.d.ts.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/no-type-imports.cjs +0 -251
- package/build/eslint/cjs/src/eslint/rules/no-type-imports.cjs.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/no-type-imports.d.ts +0 -4
- package/build/eslint/cjs/src/eslint/rules/no-type-imports.d.ts.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/no-typeof-runtype.cjs +0 -72
- package/build/eslint/cjs/src/eslint/rules/no-typeof-runtype.cjs.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/no-typeof-runtype.d.ts +0 -4
- package/build/eslint/cjs/src/eslint/rules/no-typeof-runtype.d.ts.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/no-unreachable-union-types.cjs +0 -220
- package/build/eslint/cjs/src/eslint/rules/no-unreachable-union-types.cjs.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/no-unreachable-union-types.d.ts +0 -4
- package/build/eslint/cjs/src/eslint/rules/no-unreachable-union-types.d.ts.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/no-vite-client.cjs +0 -71
- package/build/eslint/cjs/src/eslint/rules/no-vite-client.cjs.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/no-vite-client.d.ts +0 -5
- package/build/eslint/cjs/src/eslint/rules/no-vite-client.d.ts.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/pure-functions.cjs +0 -346
- package/build/eslint/cjs/src/eslint/rules/pure-functions.cjs.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/pure-functions.d.ts +0 -5
- package/build/eslint/cjs/src/eslint/rules/pure-functions.d.ts.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/strong-typed-routes.cjs +0 -328
- package/build/eslint/cjs/src/eslint/rules/strong-typed-routes.cjs.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/strong-typed-routes.d.ts +0 -5
- package/build/eslint/cjs/src/eslint/rules/strong-typed-routes.d.ts.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/type-formats-imports.cjs +0 -52
- package/build/eslint/cjs/src/eslint/rules/type-formats-imports.cjs.map +0 -1
- package/build/eslint/cjs/src/eslint/rules/type-formats-imports.d.ts +0 -4
- package/build/eslint/cjs/src/eslint/rules/type-formats-imports.d.ts.map +0 -1
- package/build/eslint/cjs/src/pureFns/purityRules.cjs +0 -67
- package/build/eslint/cjs/src/pureFns/purityRules.cjs.map +0 -1
- package/build/eslint/cjs/src/pureFns/purityRules.d.ts +0 -5
- package/build/eslint/cjs/src/pureFns/purityRules.d.ts.map +0 -1
- package/build/eslint/esm/index.js +0 -42
- package/build/eslint/esm/index.js.map +0 -1
- package/build/eslint/esm/src/eslint/index.d.ts +0 -4
- package/build/eslint/esm/src/eslint/index.d.ts.map +0 -1
- package/build/eslint/esm/src/eslint/index.js +0 -14
- package/build/eslint/esm/src/eslint/index.js.map +0 -1
- package/build/eslint/esm/src/eslint/rules/enforce-type-imports.d.ts +0 -8
- package/build/eslint/esm/src/eslint/rules/enforce-type-imports.d.ts.map +0 -1
- package/build/eslint/esm/src/eslint/rules/enforce-type-imports.js +0 -122
- package/build/eslint/esm/src/eslint/rules/enforce-type-imports.js.map +0 -1
- package/build/eslint/esm/src/eslint/rules/formatTypeNames.d.ts +0 -4
- package/build/eslint/esm/src/eslint/rules/formatTypeNames.d.ts.map +0 -1
- package/build/eslint/esm/src/eslint/rules/formatTypeNames.js +0 -71
- package/build/eslint/esm/src/eslint/rules/formatTypeNames.js.map +0 -1
- package/build/eslint/esm/src/eslint/rules/no-mixed-union-properties.d.ts +0 -4
- package/build/eslint/esm/src/eslint/rules/no-mixed-union-properties.d.ts.map +0 -1
- package/build/eslint/esm/src/eslint/rules/no-mixed-union-properties.js +0 -221
- package/build/eslint/esm/src/eslint/rules/no-mixed-union-properties.js.map +0 -1
- package/build/eslint/esm/src/eslint/rules/no-type-imports.d.ts +0 -4
- package/build/eslint/esm/src/eslint/rules/no-type-imports.d.ts.map +0 -1
- package/build/eslint/esm/src/eslint/rules/no-type-imports.js +0 -252
- package/build/eslint/esm/src/eslint/rules/no-type-imports.js.map +0 -1
- package/build/eslint/esm/src/eslint/rules/no-typeof-runtype.d.ts +0 -4
- package/build/eslint/esm/src/eslint/rules/no-typeof-runtype.d.ts.map +0 -1
- package/build/eslint/esm/src/eslint/rules/no-typeof-runtype.js +0 -73
- package/build/eslint/esm/src/eslint/rules/no-typeof-runtype.js.map +0 -1
- package/build/eslint/esm/src/eslint/rules/no-unreachable-union-types.d.ts +0 -4
- package/build/eslint/esm/src/eslint/rules/no-unreachable-union-types.d.ts.map +0 -1
- package/build/eslint/esm/src/eslint/rules/no-unreachable-union-types.js +0 -221
- package/build/eslint/esm/src/eslint/rules/no-unreachable-union-types.js.map +0 -1
- package/build/eslint/esm/src/eslint/rules/no-vite-client.d.ts +0 -5
- package/build/eslint/esm/src/eslint/rules/no-vite-client.d.ts.map +0 -1
- package/build/eslint/esm/src/eslint/rules/no-vite-client.js +0 -72
- package/build/eslint/esm/src/eslint/rules/no-vite-client.js.map +0 -1
- package/build/eslint/esm/src/eslint/rules/pure-functions.d.ts +0 -5
- package/build/eslint/esm/src/eslint/rules/pure-functions.d.ts.map +0 -1
- package/build/eslint/esm/src/eslint/rules/pure-functions.js +0 -347
- package/build/eslint/esm/src/eslint/rules/pure-functions.js.map +0 -1
- package/build/eslint/esm/src/eslint/rules/strong-typed-routes.d.ts +0 -5
- package/build/eslint/esm/src/eslint/rules/strong-typed-routes.d.ts.map +0 -1
- package/build/eslint/esm/src/eslint/rules/strong-typed-routes.js +0 -329
- package/build/eslint/esm/src/eslint/rules/strong-typed-routes.js.map +0 -1
- package/build/eslint/esm/src/eslint/rules/type-formats-imports.d.ts +0 -4
- package/build/eslint/esm/src/eslint/rules/type-formats-imports.d.ts.map +0 -1
- package/build/eslint/esm/src/eslint/rules/type-formats-imports.js +0 -53
- package/build/eslint/esm/src/eslint/rules/type-formats-imports.js.map +0 -1
- package/build/eslint/esm/src/pureFns/purityRules.d.ts +0 -5
- package/build/eslint/esm/src/pureFns/purityRules.d.ts.map +0 -1
- package/build/eslint/esm/src/pureFns/purityRules.js +0 -67
- package/build/eslint/esm/src/pureFns/purityRules.js.map +0 -1
- package/build/vite-plugin/cjs/index.cjs +0 -13
- package/build/vite-plugin/cjs/index.cjs.map +0 -1
- package/build/vite-plugin/cjs/package.json +0 -1
- package/build/vite-plugin/cjs/src/pureFns/purityRules.cjs +0 -65
- package/build/vite-plugin/cjs/src/pureFns/purityRules.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/pureFns/purityRules.d.ts +0 -5
- package/build/vite-plugin/cjs/src/pureFns/purityRules.d.ts.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/aotCacheGenerator.cjs +0 -271
- package/build/vite-plugin/cjs/src/vite-plugin/aotCacheGenerator.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/aotCacheGenerator.d.ts +0 -32
- package/build/vite-plugin/cjs/src/vite-plugin/aotCacheGenerator.d.ts.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/aotDiskCache.cjs +0 -135
- package/build/vite-plugin/cjs/src/vite-plugin/aotDiskCache.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/aotDiskCache.d.ts +0 -7
- package/build/vite-plugin/cjs/src/vite-plugin/aotDiskCache.d.ts.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/cjsPackageJsonPlugin.cjs +0 -15
- package/build/vite-plugin/cjs/src/vite-plugin/cjsPackageJsonPlugin.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/cjsPackageJsonPlugin.d.ts +0 -3
- package/build/vite-plugin/cjs/src/vite-plugin/cjsPackageJsonPlugin.d.ts.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/constants.cjs +0 -29
- package/build/vite-plugin/cjs/src/vite-plugin/constants.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/constants.d.ts +0 -13
- package/build/vite-plugin/cjs/src/vite-plugin/constants.d.ts.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/extractPureFn.cjs +0 -628
- package/build/vite-plugin/cjs/src/vite-plugin/extractPureFn.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/extractPureFn.d.ts +0 -14
- package/build/vite-plugin/cjs/src/vite-plugin/extractPureFn.d.ts.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/index.cjs +0 -13
- package/build/vite-plugin/cjs/src/vite-plugin/index.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/index.d.ts +0 -6
- package/build/vite-plugin/cjs/src/vite-plugin/index.d.ts.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/mionVitePlugin.cjs +0 -511
- package/build/vite-plugin/cjs/src/vite-plugin/mionVitePlugin.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/mionVitePlugin.d.ts +0 -37
- package/build/vite-plugin/cjs/src/vite-plugin/mionVitePlugin.d.ts.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/resolveModule.cjs +0 -55
- package/build/vite-plugin/cjs/src/vite-plugin/resolveModule.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/resolveModule.d.ts +0 -2
- package/build/vite-plugin/cjs/src/vite-plugin/resolveModule.d.ts.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/transformers.cjs +0 -166
- package/build/vite-plugin/cjs/src/vite-plugin/transformers.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/transformers.d.ts +0 -11
- package/build/vite-plugin/cjs/src/vite-plugin/transformers.d.ts.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/types.cjs +0 -2
- package/build/vite-plugin/cjs/src/vite-plugin/types.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/types.d.ts +0 -60
- package/build/vite-plugin/cjs/src/vite-plugin/types.d.ts.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/virtual-modules.d.cjs +0 -2
- package/build/vite-plugin/cjs/src/vite-plugin/virtual-modules.d.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/virtualModule.cjs +0 -69
- package/build/vite-plugin/cjs/src/vite-plugin/virtualModule.cjs.map +0 -1
- package/build/vite-plugin/cjs/src/vite-plugin/virtualModule.d.ts +0 -3
- package/build/vite-plugin/cjs/src/vite-plugin/virtualModule.d.ts.map +0 -1
- package/build/vite-plugin/esm/index.js +0 -13
- package/build/vite-plugin/esm/index.js.map +0 -1
- package/build/vite-plugin/esm/src/pureFns/purityRules.d.ts +0 -5
- package/build/vite-plugin/esm/src/pureFns/purityRules.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/pureFns/purityRules.js +0 -65
- package/build/vite-plugin/esm/src/pureFns/purityRules.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/aotCacheGenerator.d.ts +0 -32
- package/build/vite-plugin/esm/src/vite-plugin/aotCacheGenerator.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/aotCacheGenerator.js +0 -271
- package/build/vite-plugin/esm/src/vite-plugin/aotCacheGenerator.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/aotDiskCache.d.ts +0 -7
- package/build/vite-plugin/esm/src/vite-plugin/aotDiskCache.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/aotDiskCache.js +0 -134
- package/build/vite-plugin/esm/src/vite-plugin/aotDiskCache.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/cjsPackageJsonPlugin.d.ts +0 -3
- package/build/vite-plugin/esm/src/vite-plugin/cjsPackageJsonPlugin.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/cjsPackageJsonPlugin.js +0 -15
- package/build/vite-plugin/esm/src/vite-plugin/cjsPackageJsonPlugin.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/constants.d.ts +0 -13
- package/build/vite-plugin/esm/src/vite-plugin/constants.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/constants.js +0 -29
- package/build/vite-plugin/esm/src/vite-plugin/constants.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/extractPureFn.d.ts +0 -14
- package/build/vite-plugin/esm/src/vite-plugin/extractPureFn.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/extractPureFn.js +0 -611
- package/build/vite-plugin/esm/src/vite-plugin/extractPureFn.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/index.d.ts +0 -6
- package/build/vite-plugin/esm/src/vite-plugin/index.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/index.js +0 -13
- package/build/vite-plugin/esm/src/vite-plugin/index.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/mionVitePlugin.d.ts +0 -37
- package/build/vite-plugin/esm/src/vite-plugin/mionVitePlugin.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/mionVitePlugin.js +0 -493
- package/build/vite-plugin/esm/src/vite-plugin/mionVitePlugin.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/resolveModule.d.ts +0 -2
- package/build/vite-plugin/esm/src/vite-plugin/resolveModule.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/resolveModule.js +0 -33
- package/build/vite-plugin/esm/src/vite-plugin/resolveModule.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/transformers.d.ts +0 -11
- package/build/vite-plugin/esm/src/vite-plugin/transformers.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/transformers.js +0 -149
- package/build/vite-plugin/esm/src/vite-plugin/transformers.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/types.d.ts +0 -60
- package/build/vite-plugin/esm/src/vite-plugin/types.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/types.js +0 -2
- package/build/vite-plugin/esm/src/vite-plugin/types.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/virtual-modules.d.js +0 -2
- package/build/vite-plugin/esm/src/vite-plugin/virtual-modules.d.js.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/virtualModule.d.ts +0 -3
- package/build/vite-plugin/esm/src/vite-plugin/virtualModule.d.ts.map +0 -1
- package/build/vite-plugin/esm/src/vite-plugin/virtualModule.js +0 -69
- package/build/vite-plugin/esm/src/vite-plugin/virtualModule.js.map +0 -1
- package/src/eslint/index.ts +0 -53
- package/src/eslint/rules/enforce-type-imports.ts +0 -157
- package/src/eslint/rules/formatTypeNames.ts +0 -92
- package/src/eslint/rules/no-mixed-union-properties.ts +0 -276
- package/src/eslint/rules/no-type-imports.ts +0 -386
- package/src/eslint/rules/no-typeof-runtype.ts +0 -112
- package/src/eslint/rules/no-unreachable-union-types.ts +0 -357
- package/src/eslint/rules/no-vite-client.ts +0 -101
- package/src/eslint/rules/pure-functions.ts +0 -523
- package/src/eslint/rules/strong-typed-routes.ts +0 -537
- package/src/eslint/rules/type-formats-imports.ts +0 -73
- package/src/pureFns/purityRules.ts +0 -76
- package/src/vite-plugin/README.md +0 -399
- package/src/vite-plugin/aotCacheGenerator.ts +0 -397
- package/src/vite-plugin/aotDiskCache.ts +0 -193
- package/src/vite-plugin/cjsPackageJsonPlugin.ts +0 -21
- package/src/vite-plugin/constants.ts +0 -50
- package/src/vite-plugin/extractPureFn.ts +0 -845
- package/src/vite-plugin/index.ts +0 -27
- package/src/vite-plugin/mionVitePlugin.ts +0 -738
- package/src/vite-plugin/resolveModule.ts +0 -50
- package/src/vite-plugin/transformers.ts +0 -209
- package/src/vite-plugin/types.ts +0 -182
- package/src/vite-plugin/virtual-modules.d.ts +0 -48
- package/src/vite-plugin/virtualModule.ts +0 -94
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const RUN_TYPES_FORMAT_TYPES = /* @__PURE__ */ new Set(["TypeFormat"]);
|
|
4
|
-
const TYPE_FORMATS_FORMAT_TYPES = /* @__PURE__ */ new Set([
|
|
5
|
-
// Number formats (numberFormat.runtype.ts + defaultNumberFormats.ts)
|
|
6
|
-
"FormatNumber",
|
|
7
|
-
"FormatInteger",
|
|
8
|
-
"FormatFloat",
|
|
9
|
-
"FormatPositive",
|
|
10
|
-
"FormatNegative",
|
|
11
|
-
"FormatPositiveInt",
|
|
12
|
-
"FormatNegativeInt",
|
|
13
|
-
"FormatInt8",
|
|
14
|
-
"FormatInt16",
|
|
15
|
-
"FormatInt32",
|
|
16
|
-
"FormatUInt8",
|
|
17
|
-
"FormatUInt16",
|
|
18
|
-
"FormatUInt32",
|
|
19
|
-
// BigInt formats (bigIntFormat.runtype.ts + defaultBigNumberFormats.ts)
|
|
20
|
-
"FormatBigInt",
|
|
21
|
-
"FormatBigPositive",
|
|
22
|
-
"FormatBigNegative",
|
|
23
|
-
"FormatBigPositiveInt",
|
|
24
|
-
"FormatBigNegativeInt",
|
|
25
|
-
"FormatBigInt64",
|
|
26
|
-
"FormatBigUInt64",
|
|
27
|
-
// String format base (stringFormat.runtype.ts)
|
|
28
|
-
"FormatString",
|
|
29
|
-
// Date/Time formats (date.runtype.ts, time.runtype.ts, dateTime.runtype.ts)
|
|
30
|
-
"FormatStringDate",
|
|
31
|
-
"FormatStringTime",
|
|
32
|
-
"FormatStringDateTime",
|
|
33
|
-
// Email formats (email.runtype.ts)
|
|
34
|
-
"FormatEmail",
|
|
35
|
-
"FormatEmailStrict",
|
|
36
|
-
"FormatEmailPattern",
|
|
37
|
-
"FormatEmailPunycode",
|
|
38
|
-
// Domain formats (domain.runtype.ts)
|
|
39
|
-
"FormatDomain",
|
|
40
|
-
"FormatDomainStrict",
|
|
41
|
-
// URL formats (url.runtype.ts)
|
|
42
|
-
"FormatUrl",
|
|
43
|
-
"FormatUrlFile",
|
|
44
|
-
"FormatUrlHttp",
|
|
45
|
-
"FormatUrlSocialMedia",
|
|
46
|
-
// IP formats (ip.runtype.ts)
|
|
47
|
-
"FormatIP",
|
|
48
|
-
"FormatIPv4",
|
|
49
|
-
"FormatIPv6",
|
|
50
|
-
"FormatIPWithPort",
|
|
51
|
-
"FormatIPv4WithPort",
|
|
52
|
-
"FormatIPv6WithPort",
|
|
53
|
-
// UUID formats (uuid.runtype.ts)
|
|
54
|
-
"FormatUUIDv4",
|
|
55
|
-
"FormatUUIDv7",
|
|
56
|
-
// Default string formats (defaultStringFormats.runtype.ts)
|
|
57
|
-
"FormatAlphaNumeric",
|
|
58
|
-
"FormatAlpha",
|
|
59
|
-
"FormatNumeric",
|
|
60
|
-
"FormatLowercase",
|
|
61
|
-
"FormatUppercase",
|
|
62
|
-
"FormatCapitalize"
|
|
63
|
-
]);
|
|
64
|
-
const FORMAT_TYPES_BY_PACKAGE = /* @__PURE__ */ new Map([
|
|
65
|
-
["@mionjs/run-types", RUN_TYPES_FORMAT_TYPES],
|
|
66
|
-
["@mionjs/type-formats", TYPE_FORMATS_FORMAT_TYPES]
|
|
67
|
-
]);
|
|
68
|
-
exports.FORMAT_TYPES_BY_PACKAGE = FORMAT_TYPES_BY_PACKAGE;
|
|
69
|
-
exports.RUN_TYPES_FORMAT_TYPES = RUN_TYPES_FORMAT_TYPES;
|
|
70
|
-
exports.TYPE_FORMATS_FORMAT_TYPES = TYPE_FORMATS_FORMAT_TYPES;
|
|
71
|
-
//# sourceMappingURL=formatTypeNames.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatTypeNames.cjs","sources":["../../../../../../src/eslint/rules/formatTypeNames.ts"],"sourcesContent":["/* ########\n * 2026 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\n/**\n * Single source of truth for all TypeFormat type names that must NOT use `import type`.\n * Deepkit's type compiler needs actual imports to preserve type metadata for runtime reflection.\n * When new format types are added to @mionjs/type-formats or @mionjs/run-types, update this file.\n */\n\n/** Format type names from @mionjs/run-types that must not use `import type` */\nexport const RUN_TYPES_FORMAT_TYPES = new Set(['TypeFormat']);\n\n/** Format type names from @mionjs/type-formats that must not use `import type` */\nexport const TYPE_FORMATS_FORMAT_TYPES = new Set([\n // Number formats (numberFormat.runtype.ts + defaultNumberFormats.ts)\n 'FormatNumber',\n 'FormatInteger',\n 'FormatFloat',\n 'FormatPositive',\n 'FormatNegative',\n 'FormatPositiveInt',\n 'FormatNegativeInt',\n 'FormatInt8',\n 'FormatInt16',\n 'FormatInt32',\n 'FormatUInt8',\n 'FormatUInt16',\n 'FormatUInt32',\n\n // BigInt formats (bigIntFormat.runtype.ts + defaultBigNumberFormats.ts)\n 'FormatBigInt',\n 'FormatBigPositive',\n 'FormatBigNegative',\n 'FormatBigPositiveInt',\n 'FormatBigNegativeInt',\n 'FormatBigInt64',\n 'FormatBigUInt64',\n\n // String format base (stringFormat.runtype.ts)\n 'FormatString',\n\n // Date/Time formats (date.runtype.ts, time.runtype.ts, dateTime.runtype.ts)\n 'FormatStringDate',\n 'FormatStringTime',\n 'FormatStringDateTime',\n\n // Email formats (email.runtype.ts)\n 'FormatEmail',\n 'FormatEmailStrict',\n 'FormatEmailPattern',\n 'FormatEmailPunycode',\n\n // Domain formats (domain.runtype.ts)\n 'FormatDomain',\n 'FormatDomainStrict',\n\n // URL formats (url.runtype.ts)\n 'FormatUrl',\n 'FormatUrlFile',\n 'FormatUrlHttp',\n 'FormatUrlSocialMedia',\n\n // IP formats (ip.runtype.ts)\n 'FormatIP',\n 'FormatIPv4',\n 'FormatIPv6',\n 'FormatIPWithPort',\n 'FormatIPv4WithPort',\n 'FormatIPv6WithPort',\n\n // UUID formats (uuid.runtype.ts)\n 'FormatUUIDv4',\n 'FormatUUIDv7',\n\n // Default string formats (defaultStringFormats.runtype.ts)\n 'FormatAlphaNumeric',\n 'FormatAlpha',\n 'FormatNumeric',\n 'FormatLowercase',\n 'FormatUppercase',\n 'FormatCapitalize',\n]);\n\n/** Maps a source package prefix to the set of format type names from that package */\nexport const FORMAT_TYPES_BY_PACKAGE = new Map<string, Set<string>>([\n ['@mionjs/run-types', RUN_TYPES_FORMAT_TYPES],\n ['@mionjs/type-formats', TYPE_FORMATS_FORMAT_TYPES],\n]);\n"],"names":[],"mappings":";;AAcO,MAAM,yBAAyB,oBAAI,IAAI,CAAC,YAAY,CAAC;AAGrD,MAAM,gDAAgC,IAAI;AAAA;AAAA,EAE7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAGM,MAAM,8CAA8B,IAAyB;AAAA,EAChE,CAAC,qBAAqB,sBAAsB;AAAA,EAC5C,CAAC,wBAAwB,yBAAyB;AACtD,CAAC;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatTypeNames.d.ts","sourceRoot":"","sources":["../../../../../../src/eslint/rules/formatTypeNames.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,sBAAsB,aAA0B,CAAC;AAG9D,eAAO,MAAM,yBAAyB,aAoEpC,CAAC;AAGH,eAAO,MAAM,uBAAuB,0BAGlC,CAAC"}
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const utils = require("@typescript-eslint/utils");
|
|
3
|
-
function getObjectTypeProperties(node) {
|
|
4
|
-
if (node.type === utils.AST_NODE_TYPES.TSTypeLiteral) {
|
|
5
|
-
const props = [];
|
|
6
|
-
for (const member of node.members) {
|
|
7
|
-
if (member.type === utils.AST_NODE_TYPES.TSPropertySignature && member.key.type === utils.AST_NODE_TYPES.Identifier) {
|
|
8
|
-
props.push({ name: member.key.name, isOptional: !!member.optional });
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return props;
|
|
12
|
-
}
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
function getUnionObjectTypes(unionNode) {
|
|
16
|
-
const types = [];
|
|
17
|
-
for (const typeNode of unionNode.types) {
|
|
18
|
-
const props = getObjectTypeProperties(typeNode);
|
|
19
|
-
if (props && props.length > 0) {
|
|
20
|
-
types.push({ node: typeNode, properties: props });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return types;
|
|
24
|
-
}
|
|
25
|
-
function getObjectLiteralPropertyNames(node) {
|
|
26
|
-
const names = [];
|
|
27
|
-
for (const prop of node.properties) {
|
|
28
|
-
if (prop.type === utils.AST_NODE_TYPES.Property && prop.key.type === utils.AST_NODE_TYPES.Identifier) {
|
|
29
|
-
names.push(prop.key.name);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return names;
|
|
33
|
-
}
|
|
34
|
-
function getMatchingUnionTypes(objectProps, unionTypes) {
|
|
35
|
-
const matchingIndices = [];
|
|
36
|
-
for (let i = 0; i < unionTypes.length; i++) {
|
|
37
|
-
const unionPropNames = new Set(unionTypes[i].properties.map((p) => p.name));
|
|
38
|
-
if (objectProps.some((prop) => unionPropNames.has(prop))) {
|
|
39
|
-
matchingIndices.push(i);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return matchingIndices;
|
|
43
|
-
}
|
|
44
|
-
function getUniquePropertiesPerType(unionTypes) {
|
|
45
|
-
const allProps = /* @__PURE__ */ new Map();
|
|
46
|
-
for (let i = 0; i < unionTypes.length; i++) {
|
|
47
|
-
for (const prop of unionTypes[i].properties) {
|
|
48
|
-
const existing = allProps.get(prop.name) || [];
|
|
49
|
-
existing.push(i);
|
|
50
|
-
allProps.set(prop.name, existing);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const uniqueProps = /* @__PURE__ */ new Map();
|
|
54
|
-
for (let i = 0; i < unionTypes.length; i++) {
|
|
55
|
-
const unique = /* @__PURE__ */ new Set();
|
|
56
|
-
for (const prop of unionTypes[i].properties) {
|
|
57
|
-
if ((allProps.get(prop.name) || []).length === 1) {
|
|
58
|
-
unique.add(prop.name);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
uniqueProps.set(i, unique);
|
|
62
|
-
}
|
|
63
|
-
return uniqueProps;
|
|
64
|
-
}
|
|
65
|
-
function resolveTypeReference(node, context) {
|
|
66
|
-
if (node.type !== utils.AST_NODE_TYPES.TSTypeReference) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
if (node.typeName.type !== utils.AST_NODE_TYPES.Identifier) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
const typeName = node.typeName.name;
|
|
73
|
-
const sourceCode = context.sourceCode;
|
|
74
|
-
const program = sourceCode.ast;
|
|
75
|
-
for (const statement of program.body) {
|
|
76
|
-
if (statement.type === utils.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
77
|
-
if (statement.id.name === typeName && statement.typeAnnotation.type === utils.AST_NODE_TYPES.TSUnionType) {
|
|
78
|
-
return statement.typeAnnotation;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
function getReturnTypeAnnotation(func, context) {
|
|
85
|
-
const returnType = func.returnType?.typeAnnotation;
|
|
86
|
-
if (!returnType) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
if (returnType.type === utils.AST_NODE_TYPES.TSUnionType) {
|
|
90
|
-
return returnType;
|
|
91
|
-
}
|
|
92
|
-
if (returnType.type === utils.AST_NODE_TYPES.TSTypeReference) {
|
|
93
|
-
return resolveTypeReference(returnType, context);
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
function findReturnStatements(func) {
|
|
98
|
-
const returns = [];
|
|
99
|
-
if (func.type === utils.AST_NODE_TYPES.ArrowFunctionExpression && func.expression && func.body.type !== utils.AST_NODE_TYPES.BlockStatement) {
|
|
100
|
-
returns.push(func.body);
|
|
101
|
-
return returns;
|
|
102
|
-
}
|
|
103
|
-
if (func.body.type === utils.AST_NODE_TYPES.BlockStatement) {
|
|
104
|
-
findReturnsInBlock(func.body, returns);
|
|
105
|
-
}
|
|
106
|
-
return returns;
|
|
107
|
-
}
|
|
108
|
-
function findReturnsInBlock(block, returns) {
|
|
109
|
-
for (const statement of block.body) {
|
|
110
|
-
if (statement.type === utils.AST_NODE_TYPES.ReturnStatement && statement.argument) {
|
|
111
|
-
returns.push(statement.argument);
|
|
112
|
-
} else if (statement.type === utils.AST_NODE_TYPES.IfStatement) {
|
|
113
|
-
if (statement.consequent.type === utils.AST_NODE_TYPES.BlockStatement) {
|
|
114
|
-
findReturnsInBlock(statement.consequent, returns);
|
|
115
|
-
} else if (statement.consequent.type === utils.AST_NODE_TYPES.ReturnStatement && statement.consequent.argument) {
|
|
116
|
-
returns.push(statement.consequent.argument);
|
|
117
|
-
}
|
|
118
|
-
if (statement.alternate?.type === utils.AST_NODE_TYPES.BlockStatement) {
|
|
119
|
-
findReturnsInBlock(statement.alternate, returns);
|
|
120
|
-
} else if (statement.alternate?.type === utils.AST_NODE_TYPES.ReturnStatement && statement.alternate.argument) {
|
|
121
|
-
returns.push(statement.alternate.argument);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function getConflictDescription(objectProps, unionTypes, matchingIndices) {
|
|
127
|
-
const uniqueProps = getUniquePropertiesPerType(unionTypes);
|
|
128
|
-
const conflicts = [];
|
|
129
|
-
for (const idx of matchingIndices) {
|
|
130
|
-
const unique = uniqueProps.get(idx) || /* @__PURE__ */ new Set();
|
|
131
|
-
const matchingProps = objectProps.filter((p) => unique.has(p));
|
|
132
|
-
if (matchingProps.length > 0) {
|
|
133
|
-
conflicts.push(`'${matchingProps.join("', '")}' from type ${idx + 1}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return conflicts.join(" and ");
|
|
137
|
-
}
|
|
138
|
-
function isRouterFunction(node, context) {
|
|
139
|
-
let current = node;
|
|
140
|
-
while (current) {
|
|
141
|
-
if (current.type === utils.AST_NODE_TYPES.CallExpression) {
|
|
142
|
-
return isRouterFunctionCall(current, context);
|
|
143
|
-
}
|
|
144
|
-
current = current.parent;
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
function isRouterFunctionCall(node, context) {
|
|
149
|
-
const routerFunctions = ["route", "middleFn", "headersFn"];
|
|
150
|
-
if (node.callee.type !== utils.AST_NODE_TYPES.Identifier || !routerFunctions.includes(node.callee.name)) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
return isImportedFromMionRouter(node.callee.name, context);
|
|
154
|
-
}
|
|
155
|
-
function isImportedFromMionRouter(name, context) {
|
|
156
|
-
const sourceCode = context.sourceCode;
|
|
157
|
-
const program = sourceCode.ast;
|
|
158
|
-
for (const statement of program.body) {
|
|
159
|
-
if (statement.type === utils.AST_NODE_TYPES.ImportDeclaration) {
|
|
160
|
-
const source = statement.source.value;
|
|
161
|
-
if (source === "@mionjs/router" || source === "@mionjs/router/") {
|
|
162
|
-
for (const specifier of statement.specifiers) {
|
|
163
|
-
if (specifier.type === utils.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === utils.AST_NODE_TYPES.Identifier && specifier.imported.name === name) {
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
function checkFunction(func, context) {
|
|
173
|
-
if (!isRouterFunction(func, context)) return;
|
|
174
|
-
const unionType = getReturnTypeAnnotation(func, context);
|
|
175
|
-
if (!unionType) return;
|
|
176
|
-
const unionTypes = getUnionObjectTypes(unionType);
|
|
177
|
-
if (unionTypes.length < 2) return;
|
|
178
|
-
const returnStatements = findReturnStatements(func);
|
|
179
|
-
for (const returnNode of returnStatements) {
|
|
180
|
-
if (returnNode.type !== utils.AST_NODE_TYPES.ObjectExpression) continue;
|
|
181
|
-
const objectProps = getObjectLiteralPropertyNames(returnNode);
|
|
182
|
-
if (objectProps.length === 0) continue;
|
|
183
|
-
const matchingIndices = getMatchingUnionTypes(objectProps, unionTypes);
|
|
184
|
-
const uniqueProps = getUniquePropertiesPerType(unionTypes);
|
|
185
|
-
const typesWithUniqueMatches = matchingIndices.filter((idx) => {
|
|
186
|
-
const unique = uniqueProps.get(idx) || /* @__PURE__ */ new Set();
|
|
187
|
-
return objectProps.some((prop) => unique.has(prop));
|
|
188
|
-
});
|
|
189
|
-
if (typesWithUniqueMatches.length > 1) {
|
|
190
|
-
const conflicts = getConflictDescription(objectProps, unionTypes, typesWithUniqueMatches);
|
|
191
|
-
context.report({ node: returnNode, messageId: "mixedUnionProperties", data: { conflicts } });
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
const rule = {
|
|
196
|
-
meta: {
|
|
197
|
-
type: "problem",
|
|
198
|
-
docs: { description: "Detect object literals with properties from multiple union types in router handlers" },
|
|
199
|
-
messages: {
|
|
200
|
-
mixedUnionProperties: "Object literal has properties from multiple union types: {{conflicts}}. With loose union matching, only the first matching type will be used for serialization."
|
|
201
|
-
},
|
|
202
|
-
schema: []
|
|
203
|
-
},
|
|
204
|
-
defaultOptions: [],
|
|
205
|
-
create(context) {
|
|
206
|
-
return {
|
|
207
|
-
ArrowFunctionExpression(node) {
|
|
208
|
-
checkFunction(node, context);
|
|
209
|
-
},
|
|
210
|
-
FunctionExpression(node) {
|
|
211
|
-
checkFunction(node, context);
|
|
212
|
-
},
|
|
213
|
-
FunctionDeclaration(node) {
|
|
214
|
-
checkFunction(node, context);
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
module.exports = rule;
|
|
220
|
-
//# sourceMappingURL=no-mixed-union-properties.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-mixed-union-properties.cjs","sources":["../../../../../../src/eslint/rules/no-mixed-union-properties.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport {TSESTree, TSESLint, AST_NODE_TYPES} from '@typescript-eslint/utils';\n\ntype PropertyInfo = {name: string; isOptional: boolean};\ntype UnionTypeInfo = {node: TSESTree.TypeNode; properties: PropertyInfo[]};\n\nfunction getObjectTypeProperties(node: TSESTree.TypeNode): PropertyInfo[] | null {\n if (node.type === AST_NODE_TYPES.TSTypeLiteral) {\n const props: PropertyInfo[] = [];\n for (const member of node.members) {\n if (member.type === AST_NODE_TYPES.TSPropertySignature && member.key.type === AST_NODE_TYPES.Identifier) {\n props.push({name: member.key.name, isOptional: !!member.optional});\n }\n }\n return props;\n }\n return null;\n}\n\nfunction getUnionObjectTypes(unionNode: TSESTree.TSUnionType): UnionTypeInfo[] {\n const types: UnionTypeInfo[] = [];\n for (const typeNode of unionNode.types) {\n const props = getObjectTypeProperties(typeNode);\n if (props && props.length > 0) {\n types.push({node: typeNode, properties: props});\n }\n }\n return types;\n}\n\nfunction getObjectLiteralPropertyNames(node: TSESTree.ObjectExpression): string[] {\n const names: string[] = [];\n for (const prop of node.properties) {\n if (prop.type === AST_NODE_TYPES.Property && prop.key.type === AST_NODE_TYPES.Identifier) {\n names.push(prop.key.name);\n }\n }\n return names;\n}\n\nfunction getMatchingUnionTypes(objectProps: string[], unionTypes: UnionTypeInfo[]): number[] {\n const matchingIndices: number[] = [];\n for (let i = 0; i < unionTypes.length; i++) {\n const unionPropNames = new Set(unionTypes[i].properties.map((p) => p.name));\n if (objectProps.some((prop) => unionPropNames.has(prop))) {\n matchingIndices.push(i);\n }\n }\n return matchingIndices;\n}\n\nfunction getUniquePropertiesPerType(unionTypes: UnionTypeInfo[]): Map<number, Set<string>> {\n const allProps = new Map<string, number[]>();\n for (let i = 0; i < unionTypes.length; i++) {\n for (const prop of unionTypes[i].properties) {\n const existing = allProps.get(prop.name) || [];\n existing.push(i);\n allProps.set(prop.name, existing);\n }\n }\n const uniqueProps = new Map<number, Set<string>>();\n for (let i = 0; i < unionTypes.length; i++) {\n const unique = new Set<string>();\n for (const prop of unionTypes[i].properties) {\n if ((allProps.get(prop.name) || []).length === 1) {\n unique.add(prop.name);\n }\n }\n uniqueProps.set(i, unique);\n }\n return uniqueProps;\n}\n\n/**\n * Resolves a type reference to its actual union type definition\n */\nfunction resolveTypeReference(node: TSESTree.TypeNode, context: TSESLint.RuleContext<any, any>): TSESTree.TSUnionType | null {\n if (node.type !== AST_NODE_TYPES.TSTypeReference) {\n return null;\n }\n\n // Get the type name\n if (node.typeName.type !== AST_NODE_TYPES.Identifier) {\n return null;\n }\n\n const typeName = node.typeName.name;\n const sourceCode = context.sourceCode;\n const program = sourceCode.ast;\n\n // Find the type alias declaration\n for (const statement of program.body) {\n if (statement.type === AST_NODE_TYPES.TSTypeAliasDeclaration) {\n if (statement.id.name === typeName && statement.typeAnnotation.type === AST_NODE_TYPES.TSUnionType) {\n return statement.typeAnnotation;\n }\n }\n }\n\n return null;\n}\n\nfunction getReturnTypeAnnotation(\n func: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.FunctionDeclaration,\n context: TSESLint.RuleContext<any, any>\n): TSESTree.TSUnionType | null {\n const returnType = func.returnType?.typeAnnotation;\n if (!returnType) {\n return null;\n }\n\n // Direct union type\n if (returnType.type === AST_NODE_TYPES.TSUnionType) {\n return returnType;\n }\n\n // Type reference that might resolve to a union type\n if (returnType.type === AST_NODE_TYPES.TSTypeReference) {\n return resolveTypeReference(returnType, context);\n }\n\n return null;\n}\n\nfunction findReturnStatements(\n func: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.FunctionDeclaration\n): TSESTree.Node[] {\n const returns: TSESTree.Node[] = [];\n if (\n func.type === AST_NODE_TYPES.ArrowFunctionExpression &&\n func.expression &&\n func.body.type !== AST_NODE_TYPES.BlockStatement\n ) {\n returns.push(func.body);\n return returns;\n }\n if (func.body.type === AST_NODE_TYPES.BlockStatement) {\n findReturnsInBlock(func.body, returns);\n }\n return returns;\n}\n\nfunction findReturnsInBlock(block: TSESTree.BlockStatement, returns: TSESTree.Node[]): void {\n for (const statement of block.body) {\n if (statement.type === AST_NODE_TYPES.ReturnStatement && statement.argument) {\n returns.push(statement.argument);\n } else if (statement.type === AST_NODE_TYPES.IfStatement) {\n if (statement.consequent.type === AST_NODE_TYPES.BlockStatement) {\n findReturnsInBlock(statement.consequent, returns);\n } else if (statement.consequent.type === AST_NODE_TYPES.ReturnStatement && statement.consequent.argument) {\n returns.push(statement.consequent.argument);\n }\n if (statement.alternate?.type === AST_NODE_TYPES.BlockStatement) {\n findReturnsInBlock(statement.alternate, returns);\n } else if (statement.alternate?.type === AST_NODE_TYPES.ReturnStatement && statement.alternate.argument) {\n returns.push(statement.alternate.argument);\n }\n }\n }\n}\n\nfunction getConflictDescription(objectProps: string[], unionTypes: UnionTypeInfo[], matchingIndices: number[]): string {\n const uniqueProps = getUniquePropertiesPerType(unionTypes);\n const conflicts: string[] = [];\n for (const idx of matchingIndices) {\n const unique = uniqueProps.get(idx) || new Set();\n const matchingProps = objectProps.filter((p) => unique.has(p));\n if (matchingProps.length > 0) {\n conflicts.push(`'${matchingProps.join(\"', '\")}' from type ${idx + 1}`);\n }\n }\n return conflicts.join(' and ');\n}\n\nfunction isRouterFunction(node: TSESTree.Node, context: TSESLint.RuleContext<any, any>): boolean {\n let current: TSESTree.Node | undefined = node;\n while (current) {\n if (current.type === AST_NODE_TYPES.CallExpression) {\n return isRouterFunctionCall(current, context);\n }\n current = current.parent;\n }\n return false;\n}\n\nfunction isRouterFunctionCall(node: TSESTree.CallExpression, context: TSESLint.RuleContext<any, any>): boolean {\n const routerFunctions = ['route', 'middleFn', 'headersFn'];\n if (node.callee.type !== AST_NODE_TYPES.Identifier || !routerFunctions.includes(node.callee.name)) {\n return false;\n }\n return isImportedFromMionRouter(node.callee.name, context);\n}\n\nfunction isImportedFromMionRouter(name: string, context: TSESLint.RuleContext<any, any>): boolean {\n const sourceCode = context.sourceCode;\n const program = sourceCode.ast;\n for (const statement of program.body) {\n if (statement.type === AST_NODE_TYPES.ImportDeclaration) {\n const source = statement.source.value;\n if (source === '@mionjs/router' || source === '@mionjs/router/') {\n for (const specifier of statement.specifiers) {\n if (\n specifier.type === AST_NODE_TYPES.ImportSpecifier &&\n specifier.imported.type === AST_NODE_TYPES.Identifier &&\n specifier.imported.name === name\n ) {\n return true;\n }\n }\n }\n }\n }\n return false;\n}\n\nfunction checkFunction(\n func: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.FunctionDeclaration,\n context: TSESLint.RuleContext<'mixedUnionProperties', []>\n) {\n if (!isRouterFunction(func, context)) return;\n const unionType = getReturnTypeAnnotation(func, context);\n if (!unionType) return;\n const unionTypes = getUnionObjectTypes(unionType);\n if (unionTypes.length < 2) return;\n const returnStatements = findReturnStatements(func);\n for (const returnNode of returnStatements) {\n if (returnNode.type !== AST_NODE_TYPES.ObjectExpression) continue;\n const objectProps = getObjectLiteralPropertyNames(returnNode);\n if (objectProps.length === 0) continue;\n const matchingIndices = getMatchingUnionTypes(objectProps, unionTypes);\n const uniqueProps = getUniquePropertiesPerType(unionTypes);\n const typesWithUniqueMatches = matchingIndices.filter((idx) => {\n const unique = uniqueProps.get(idx) || new Set();\n return objectProps.some((prop) => unique.has(prop));\n });\n if (typesWithUniqueMatches.length > 1) {\n const conflicts = getConflictDescription(objectProps, unionTypes, typesWithUniqueMatches);\n context.report({node: returnNode, messageId: 'mixedUnionProperties', data: {conflicts}});\n }\n }\n}\n\nconst rule: TSESLint.RuleModule<'mixedUnionProperties', []> = {\n meta: {\n type: 'problem',\n docs: {description: 'Detect object literals with properties from multiple union types in router handlers'},\n messages: {\n mixedUnionProperties:\n 'Object literal has properties from multiple union types: {{conflicts}}. ' +\n 'With loose union matching, only the first matching type will be used for serialization.',\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n return {\n ArrowFunctionExpression(node: TSESTree.ArrowFunctionExpression) {\n checkFunction(node, context);\n },\n FunctionExpression(node: TSESTree.FunctionExpression) {\n checkFunction(node, context);\n },\n FunctionDeclaration(node: TSESTree.FunctionDeclaration) {\n checkFunction(node, context);\n },\n };\n },\n};\n\nexport default rule;\n"],"names":["AST_NODE_TYPES"],"mappings":";;AAYA,SAAS,wBAAwB,MAAgD;AAC7E,MAAI,KAAK,SAASA,MAAAA,eAAe,eAAe;AAC5C,UAAM,QAAwB,CAAA;AAC9B,eAAW,UAAU,KAAK,SAAS;AAC/B,UAAI,OAAO,SAASA,MAAAA,eAAe,uBAAuB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cAAc,kBAAkB;AACvC,QAAI,WAAW,SAASA,MAAAA,eAAe,iBAAkB;AACzD,UAAM,cAAc,8BAA8B,UAAU;AAC5D,QAAI,YAAY,WAAW,EAAG;AAC9B,UAAM,kBAAkB,sBAAsB,aAAa,UAAU;AACrE,UAAM,cAAc,2BAA2B,UAAU;AACzD,UAAM,yBAAyB,gBAAgB,OAAO,CAAC,QAAQ;AAC3D,YAAM,SAAS,YAAY,IAAI,GAAG,yBAAS,IAAA;AAC3C,aAAO,YAAY,KAAK,CAAC,SAAS,OAAO,IAAI,IAAI,CAAC;AAAA,IACtD,CAAC;AACD,QAAI,uBAAuB,SAAS,GAAG;AACnC,YAAM,YAAY,uBAAuB,aAAa,YAAY,sBAAsB;AACxF,cAAQ,OAAO,EAAC,MAAM,YAAY,WAAW,wBAAwB,MAAM,EAAC,UAAA,GAAW;AAAA,IAC3F;AAAA,EACJ;AACJ;AAEA,MAAM,OAAwD;AAAA,EAC1D,MAAM;AAAA,IACF,MAAM;AAAA,IACN,MAAM,EAAC,aAAa,sFAAA;AAAA,IACpB,UAAU;AAAA,MACN,sBACI;AAAA,IAAA;AAAA,IAGR,QAAQ,CAAA;AAAA,EAAC;AAAA,EAEb,gBAAgB,CAAA;AAAA,EAChB,OAAO,SAAS;AACZ,WAAO;AAAA,MACH,wBAAwB,MAAwC;AAC5D,sBAAc,MAAM,OAAO;AAAA,MAC/B;AAAA,MACA,mBAAmB,MAAmC;AAClD,sBAAc,MAAM,OAAO;AAAA,MAC/B;AAAA,MACA,oBAAoB,MAAoC;AACpD,sBAAc,MAAM,OAAO;AAAA,MAC/B;AAAA,IAAA;AAAA,EAER;AACJ;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-mixed-union-properties.d.ts","sourceRoot":"","sources":["../../../../../../src/eslint/rules/no-mixed-union-properties.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,QAAQ,EAAiB,MAAM,0BAA0B,CAAC;AAiP5E,QAAA,MAAM,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,sBAAsB,EAAE,EAAE,CAyBzD,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const utils = require("@typescript-eslint/utils");
|
|
3
|
-
const ROUTER_FUNCTIONS = ["route", "middleFn", "headersFn"];
|
|
4
|
-
const HANDLER_TYPES = ["Handler", "HeaderHandler"];
|
|
5
|
-
function buildRouterImportCache(program) {
|
|
6
|
-
const routerFunctions = /* @__PURE__ */ new Set();
|
|
7
|
-
const handlerTypes = /* @__PURE__ */ new Set();
|
|
8
|
-
for (const statement of program.body) {
|
|
9
|
-
if (statement.type === utils.AST_NODE_TYPES.ImportDeclaration) {
|
|
10
|
-
const source = statement.source.value;
|
|
11
|
-
if (source === "@mionjs/router" || source === "@mionjs/router/") {
|
|
12
|
-
for (const specifier of statement.specifiers) {
|
|
13
|
-
if (specifier.type === utils.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === utils.AST_NODE_TYPES.Identifier) {
|
|
14
|
-
const name = specifier.imported.name;
|
|
15
|
-
if (ROUTER_FUNCTIONS.includes(name)) {
|
|
16
|
-
routerFunctions.add(name);
|
|
17
|
-
}
|
|
18
|
-
if (HANDLER_TYPES.includes(name)) {
|
|
19
|
-
handlerTypes.add(name);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return { routerFunctions, handlerTypes };
|
|
27
|
-
}
|
|
28
|
-
function buildTypeOnlyImportCache(program) {
|
|
29
|
-
const typeOnlyImports = /* @__PURE__ */ new Map();
|
|
30
|
-
for (const statement of program.body) {
|
|
31
|
-
if (statement.type === utils.AST_NODE_TYPES.ImportDeclaration) {
|
|
32
|
-
const isTypeOnlyImport = statement.importKind === "type";
|
|
33
|
-
for (const specifier of statement.specifiers) {
|
|
34
|
-
if (specifier.type === utils.AST_NODE_TYPES.ImportSpecifier) {
|
|
35
|
-
const isTypeOnlySpecifier = specifier.importKind === "type";
|
|
36
|
-
if (isTypeOnlyImport || isTypeOnlySpecifier) {
|
|
37
|
-
const localName = specifier.local.name;
|
|
38
|
-
typeOnlyImports.set(localName, statement);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return { typeOnlyImports };
|
|
45
|
-
}
|
|
46
|
-
function getRouterFunctionName(node, importCache) {
|
|
47
|
-
if (node.callee.type !== utils.AST_NODE_TYPES.Identifier) return null;
|
|
48
|
-
const functionName = node.callee.name;
|
|
49
|
-
if (importCache.routerFunctions.has(functionName)) return functionName;
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
function extractTypeReferencesWithNodes(typeNode) {
|
|
53
|
-
if (!typeNode) return [];
|
|
54
|
-
const references = [];
|
|
55
|
-
switch (typeNode.type) {
|
|
56
|
-
case utils.AST_NODE_TYPES.TSTypeReference:
|
|
57
|
-
if (typeNode.typeName.type === utils.AST_NODE_TYPES.Identifier) {
|
|
58
|
-
references.push({ typeName: typeNode.typeName.name, node: typeNode });
|
|
59
|
-
}
|
|
60
|
-
if (typeNode.typeArguments) {
|
|
61
|
-
for (const param of typeNode.typeArguments.params) {
|
|
62
|
-
references.push(...extractTypeReferencesWithNodes(param));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
break;
|
|
66
|
-
case utils.AST_NODE_TYPES.TSUnionType:
|
|
67
|
-
case utils.AST_NODE_TYPES.TSIntersectionType:
|
|
68
|
-
for (const member of typeNode.types) {
|
|
69
|
-
references.push(...extractTypeReferencesWithNodes(member));
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
case utils.AST_NODE_TYPES.TSArrayType:
|
|
73
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.elementType));
|
|
74
|
-
break;
|
|
75
|
-
case utils.AST_NODE_TYPES.TSTupleType:
|
|
76
|
-
for (const element of typeNode.elementTypes) {
|
|
77
|
-
references.push(...extractTypeReferencesWithNodes(element));
|
|
78
|
-
}
|
|
79
|
-
break;
|
|
80
|
-
case utils.AST_NODE_TYPES.TSTypeLiteral:
|
|
81
|
-
for (const member of typeNode.members) {
|
|
82
|
-
if (member.type === utils.AST_NODE_TYPES.TSPropertySignature && member.typeAnnotation) {
|
|
83
|
-
references.push(...extractTypeReferencesWithNodes(member.typeAnnotation.typeAnnotation));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
case utils.AST_NODE_TYPES.TSConditionalType:
|
|
88
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.checkType));
|
|
89
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.extendsType));
|
|
90
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.trueType));
|
|
91
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.falseType));
|
|
92
|
-
break;
|
|
93
|
-
case utils.AST_NODE_TYPES.TSMappedType:
|
|
94
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));
|
|
95
|
-
break;
|
|
96
|
-
case utils.AST_NODE_TYPES.TSIndexedAccessType:
|
|
97
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.objectType));
|
|
98
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.indexType));
|
|
99
|
-
break;
|
|
100
|
-
case utils.AST_NODE_TYPES.TSTypeOperator:
|
|
101
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));
|
|
102
|
-
break;
|
|
103
|
-
case utils.AST_NODE_TYPES.TSRestType:
|
|
104
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));
|
|
105
|
-
break;
|
|
106
|
-
case utils.AST_NODE_TYPES.TSOptionalType:
|
|
107
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));
|
|
108
|
-
break;
|
|
109
|
-
case utils.AST_NODE_TYPES.TSFunctionType:
|
|
110
|
-
case utils.AST_NODE_TYPES.TSConstructorType:
|
|
111
|
-
for (const param of typeNode.params) {
|
|
112
|
-
if ("typeAnnotation" in param && param.typeAnnotation) {
|
|
113
|
-
references.push(...extractTypeReferencesWithNodes(param.typeAnnotation.typeAnnotation));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (typeNode.returnType) {
|
|
117
|
-
references.push(...extractTypeReferencesWithNodes(typeNode.returnType.typeAnnotation));
|
|
118
|
-
}
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
return references;
|
|
122
|
-
}
|
|
123
|
-
function getParamTypeAnnotation(param) {
|
|
124
|
-
if (param.type === utils.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
125
|
-
return param.typeAnnotation.typeAnnotation;
|
|
126
|
-
}
|
|
127
|
-
if (param.type === utils.AST_NODE_TYPES.RestElement && param.typeAnnotation) {
|
|
128
|
-
return param.typeAnnotation.typeAnnotation;
|
|
129
|
-
}
|
|
130
|
-
if (param.type === utils.AST_NODE_TYPES.ArrayPattern && param.typeAnnotation) {
|
|
131
|
-
return param.typeAnnotation.typeAnnotation;
|
|
132
|
-
}
|
|
133
|
-
if (param.type === utils.AST_NODE_TYPES.ObjectPattern && param.typeAnnotation) {
|
|
134
|
-
return param.typeAnnotation.typeAnnotation;
|
|
135
|
-
}
|
|
136
|
-
if (param.type === utils.AST_NODE_TYPES.AssignmentPattern) {
|
|
137
|
-
if (param.typeAnnotation) {
|
|
138
|
-
return param.typeAnnotation.typeAnnotation;
|
|
139
|
-
}
|
|
140
|
-
if (param.left.type === utils.AST_NODE_TYPES.Identifier && param.left.typeAnnotation) {
|
|
141
|
-
return param.left.typeAnnotation.typeAnnotation;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
function extractParamTypeReferencesWithNodes(params) {
|
|
147
|
-
const references = [];
|
|
148
|
-
for (let i = 1; i < params.length; i++) {
|
|
149
|
-
const param = params[i];
|
|
150
|
-
if (param) {
|
|
151
|
-
const typeAnnotation = getParamTypeAnnotation(param);
|
|
152
|
-
if (typeAnnotation) {
|
|
153
|
-
references.push(...extractTypeReferencesWithNodes(typeAnnotation));
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return references;
|
|
158
|
-
}
|
|
159
|
-
function extractReturnTypeReferencesWithNodes(node) {
|
|
160
|
-
if (node.returnType) {
|
|
161
|
-
return extractTypeReferencesWithNodes(node.returnType.typeAnnotation);
|
|
162
|
-
}
|
|
163
|
-
return [];
|
|
164
|
-
}
|
|
165
|
-
const rule = {
|
|
166
|
-
meta: {
|
|
167
|
-
type: "problem",
|
|
168
|
-
docs: {
|
|
169
|
-
description: "Disallow type-only imports for types used in route/middleFn parameters or return types. Type-only imports are erased at runtime, preventing mion from generating validation and serialization functions."
|
|
170
|
-
},
|
|
171
|
-
messages: {
|
|
172
|
-
noTypeImports: 'Type "{{typeName}}" is imported as type-only but is used in a route/middleFn. Remove the "type" keyword from the import to allow runtime type reflection.'
|
|
173
|
-
},
|
|
174
|
-
schema: []
|
|
175
|
-
},
|
|
176
|
-
defaultOptions: [],
|
|
177
|
-
create(context) {
|
|
178
|
-
let routerImportCache = null;
|
|
179
|
-
let typeOnlyImportCache = null;
|
|
180
|
-
function checkTypeReferencesWithNodes(typeRefs) {
|
|
181
|
-
if (!typeOnlyImportCache) return;
|
|
182
|
-
const reportedTypes = /* @__PURE__ */ new Set();
|
|
183
|
-
for (const { typeName, node } of typeRefs) {
|
|
184
|
-
if (reportedTypes.has(typeName)) continue;
|
|
185
|
-
const importDecl = typeOnlyImportCache.typeOnlyImports.get(typeName);
|
|
186
|
-
if (importDecl) {
|
|
187
|
-
reportedTypes.add(typeName);
|
|
188
|
-
context.report({
|
|
189
|
-
node,
|
|
190
|
-
messageId: "noTypeImports",
|
|
191
|
-
data: { typeName }
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
function checkFunctionNode(funcNode) {
|
|
197
|
-
const paramRefs = extractParamTypeReferencesWithNodes(funcNode.params);
|
|
198
|
-
const returnRefs = extractReturnTypeReferencesWithNodes(funcNode);
|
|
199
|
-
const allRefs = [...paramRefs, ...returnRefs];
|
|
200
|
-
checkTypeReferencesWithNodes(allRefs);
|
|
201
|
-
}
|
|
202
|
-
return {
|
|
203
|
-
Program(node) {
|
|
204
|
-
routerImportCache = buildRouterImportCache(node);
|
|
205
|
-
typeOnlyImportCache = buildTypeOnlyImportCache(node);
|
|
206
|
-
},
|
|
207
|
-
CallExpression(node) {
|
|
208
|
-
if (!routerImportCache || !typeOnlyImportCache) return;
|
|
209
|
-
const routerFunctionName = getRouterFunctionName(node, routerImportCache);
|
|
210
|
-
if (!routerFunctionName) return;
|
|
211
|
-
const handler = node.arguments[0];
|
|
212
|
-
if (!handler) return;
|
|
213
|
-
if (handler.type === utils.AST_NODE_TYPES.ArrowFunctionExpression || handler.type === utils.AST_NODE_TYPES.FunctionExpression) {
|
|
214
|
-
checkFunctionNode(handler);
|
|
215
|
-
} else if (handler.type === utils.AST_NODE_TYPES.Identifier) ;
|
|
216
|
-
},
|
|
217
|
-
// Check functions with Handler/HeaderHandler type annotations
|
|
218
|
-
VariableDeclarator(node) {
|
|
219
|
-
if (!routerImportCache || !typeOnlyImportCache) return;
|
|
220
|
-
if (node.id.type === utils.AST_NODE_TYPES.Identifier && node.id.typeAnnotation) {
|
|
221
|
-
const typeAnnotation = node.id.typeAnnotation.typeAnnotation;
|
|
222
|
-
if (typeAnnotation.type === utils.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeName.type === utils.AST_NODE_TYPES.Identifier && routerImportCache.handlerTypes.has(typeAnnotation.typeName.name)) {
|
|
223
|
-
if (node.init && (node.init.type === utils.AST_NODE_TYPES.ArrowFunctionExpression || node.init.type === utils.AST_NODE_TYPES.FunctionExpression)) {
|
|
224
|
-
checkFunctionNode(node.init);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (node.init && node.init.type === utils.AST_NODE_TYPES.TSSatisfiesExpression && node.init.typeAnnotation.type === utils.AST_NODE_TYPES.TSTypeReference && node.init.typeAnnotation.typeName.type === utils.AST_NODE_TYPES.Identifier && routerImportCache.handlerTypes.has(node.init.typeAnnotation.typeName.name)) {
|
|
229
|
-
const expr = node.init.expression;
|
|
230
|
-
if (expr.type === utils.AST_NODE_TYPES.ArrowFunctionExpression || expr.type === utils.AST_NODE_TYPES.FunctionExpression) {
|
|
231
|
-
checkFunctionNode(expr);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
// Check function declarations with JSDoc tags
|
|
236
|
-
FunctionDeclaration(node) {
|
|
237
|
-
if (!routerImportCache || !typeOnlyImportCache) return;
|
|
238
|
-
const sourceCode = context.sourceCode;
|
|
239
|
-
const comments = sourceCode.getCommentsBefore(node);
|
|
240
|
-
for (const comment of comments) {
|
|
241
|
-
if (comment.type === "Block" && (comment.value.includes("@mion:route") || comment.value.includes("@mion:middleFn") || comment.value.includes("@mion:headersFn"))) {
|
|
242
|
-
checkFunctionNode(node);
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
module.exports = rule;
|
|
251
|
-
//# sourceMappingURL=no-type-imports.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-type-imports.cjs","sources":["../../../../../../src/eslint/rules/no-type-imports.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport {TSESTree, TSESLint, AST_NODE_TYPES} from '@typescript-eslint/utils';\n\n/** List of router functions that should have strongly typed handlers */\nconst ROUTER_FUNCTIONS = ['route', 'middleFn', 'headersFn'] as const;\n/** List of handler types that can be used with type annotations */\nconst HANDLER_TYPES = ['Handler', 'HeaderHandler'] as const;\n\n/** Cache for imports from @mionjs/router - computed once per file */\ninterface MionRouterImports {\n /** Set of function names imported from @mionjs/router (route, middleFn, headersFn) */\n routerFunctions: Set<string>;\n /** Set of type names imported from @mionjs/router (Handler, HeaderHandler) */\n handlerTypes: Set<string>;\n}\n\n/** Cache for type-only imports - computed once per file */\ninterface TypeOnlyImports {\n /** Map of type name to import declaration node */\n typeOnlyImports: Map<string, TSESTree.ImportDeclaration>;\n}\n\n/** Type reference with its node for precise error reporting */\ninterface TypeRefWithNode {\n typeName: string;\n node: TSESTree.Node;\n}\n\n/** Builds a cache of all imports from @mionjs/router */\nfunction buildRouterImportCache(program: TSESTree.Program): MionRouterImports {\n const routerFunctions = new Set<string>();\n const handlerTypes = new Set<string>();\n\n for (const statement of program.body) {\n if (statement.type === AST_NODE_TYPES.ImportDeclaration) {\n const source = statement.source.value;\n if (source === '@mionjs/router' || source === '@mionjs/router/') {\n for (const specifier of statement.specifiers) {\n if (\n specifier.type === AST_NODE_TYPES.ImportSpecifier &&\n specifier.imported.type === AST_NODE_TYPES.Identifier\n ) {\n const name = specifier.imported.name;\n if (ROUTER_FUNCTIONS.includes(name as (typeof ROUTER_FUNCTIONS)[number])) {\n routerFunctions.add(name);\n }\n if (HANDLER_TYPES.includes(name as (typeof HANDLER_TYPES)[number])) {\n handlerTypes.add(name);\n }\n }\n }\n }\n }\n }\n\n return {routerFunctions, handlerTypes};\n}\n\n/** Builds a cache of all type-only imports */\nfunction buildTypeOnlyImportCache(program: TSESTree.Program): TypeOnlyImports {\n const typeOnlyImports = new Map<string, TSESTree.ImportDeclaration>();\n\n for (const statement of program.body) {\n if (statement.type === AST_NODE_TYPES.ImportDeclaration) {\n // Check if the entire import is type-only: import type { X } from '...'\n const isTypeOnlyImport = statement.importKind === 'type';\n\n for (const specifier of statement.specifiers) {\n if (specifier.type === AST_NODE_TYPES.ImportSpecifier) {\n // Check if individual specifier is type-only: import { type X } from '...'\n const isTypeOnlySpecifier = specifier.importKind === 'type';\n\n if (isTypeOnlyImport || isTypeOnlySpecifier) {\n const localName = specifier.local.name;\n typeOnlyImports.set(localName, statement);\n }\n }\n }\n }\n }\n\n return {typeOnlyImports};\n}\n\n/** Checks if a call expression is calling router functions from @mionjs/router */\nfunction getRouterFunctionName(node: TSESTree.CallExpression, importCache: MionRouterImports): string | null {\n if (node.callee.type !== AST_NODE_TYPES.Identifier) return null;\n const functionName = node.callee.name;\n if (importCache.routerFunctions.has(functionName)) return functionName;\n return null;\n}\n\n/** Extracts all type references with their nodes from a type node recursively */\nfunction extractTypeReferencesWithNodes(typeNode: TSESTree.TypeNode | null | undefined): TypeRefWithNode[] {\n if (!typeNode) return [];\n\n const references: TypeRefWithNode[] = [];\n\n switch (typeNode.type) {\n case AST_NODE_TYPES.TSTypeReference:\n if (typeNode.typeName.type === AST_NODE_TYPES.Identifier) {\n // Report on the type reference node itself (e.g., \"User\" in \": User\")\n references.push({typeName: typeNode.typeName.name, node: typeNode});\n }\n // Also check type arguments (generics)\n if (typeNode.typeArguments) {\n for (const param of typeNode.typeArguments.params) {\n references.push(...extractTypeReferencesWithNodes(param));\n }\n }\n break;\n\n case AST_NODE_TYPES.TSUnionType:\n case AST_NODE_TYPES.TSIntersectionType:\n for (const member of typeNode.types) {\n references.push(...extractTypeReferencesWithNodes(member));\n }\n break;\n\n case AST_NODE_TYPES.TSArrayType:\n references.push(...extractTypeReferencesWithNodes(typeNode.elementType));\n break;\n\n case AST_NODE_TYPES.TSTupleType:\n for (const element of typeNode.elementTypes) {\n references.push(...extractTypeReferencesWithNodes(element));\n }\n break;\n\n case AST_NODE_TYPES.TSTypeLiteral:\n for (const member of typeNode.members) {\n if (member.type === AST_NODE_TYPES.TSPropertySignature && member.typeAnnotation) {\n references.push(...extractTypeReferencesWithNodes(member.typeAnnotation.typeAnnotation));\n }\n }\n break;\n\n case AST_NODE_TYPES.TSConditionalType:\n references.push(...extractTypeReferencesWithNodes(typeNode.checkType));\n references.push(...extractTypeReferencesWithNodes(typeNode.extendsType));\n references.push(...extractTypeReferencesWithNodes(typeNode.trueType));\n references.push(...extractTypeReferencesWithNodes(typeNode.falseType));\n break;\n\n case AST_NODE_TYPES.TSMappedType:\n references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));\n break;\n\n case AST_NODE_TYPES.TSIndexedAccessType:\n references.push(...extractTypeReferencesWithNodes(typeNode.objectType));\n references.push(...extractTypeReferencesWithNodes(typeNode.indexType));\n break;\n\n case AST_NODE_TYPES.TSTypeOperator:\n references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));\n break;\n\n case AST_NODE_TYPES.TSRestType:\n references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));\n break;\n\n case AST_NODE_TYPES.TSOptionalType:\n references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));\n break;\n\n case AST_NODE_TYPES.TSFunctionType:\n case AST_NODE_TYPES.TSConstructorType:\n // Check parameters\n for (const param of typeNode.params) {\n if ('typeAnnotation' in param && param.typeAnnotation) {\n references.push(...extractTypeReferencesWithNodes(param.typeAnnotation.typeAnnotation));\n }\n }\n // Check return type\n if (typeNode.returnType) {\n references.push(...extractTypeReferencesWithNodes(typeNode.returnType.typeAnnotation));\n }\n break;\n }\n\n return references;\n}\n\n/** Gets type annotation from a parameter if it exists */\nfunction getParamTypeAnnotation(param: TSESTree.Parameter): TSESTree.TypeNode | null {\n if (param.type === AST_NODE_TYPES.Identifier && param.typeAnnotation) {\n return param.typeAnnotation.typeAnnotation;\n }\n if (param.type === AST_NODE_TYPES.RestElement && param.typeAnnotation) {\n return param.typeAnnotation.typeAnnotation;\n }\n if (param.type === AST_NODE_TYPES.ArrayPattern && param.typeAnnotation) {\n return param.typeAnnotation.typeAnnotation;\n }\n if (param.type === AST_NODE_TYPES.ObjectPattern && param.typeAnnotation) {\n return param.typeAnnotation.typeAnnotation;\n }\n if (param.type === AST_NODE_TYPES.AssignmentPattern) {\n // Check if there's a type annotation on the pattern itself\n if (param.typeAnnotation) {\n return param.typeAnnotation.typeAnnotation;\n }\n // Check if there's a type annotation on the left side\n if (param.left.type === AST_NODE_TYPES.Identifier && param.left.typeAnnotation) {\n return param.left.typeAnnotation.typeAnnotation;\n }\n }\n return null;\n}\n\n/** Extracts type references with nodes from function parameters (excluding first ctx parameter) */\nfunction extractParamTypeReferencesWithNodes(params: TSESTree.Parameter[]): TypeRefWithNode[] {\n const references: TypeRefWithNode[] = [];\n\n // Skip first parameter (ctx)\n for (let i = 1; i < params.length; i++) {\n const param = params[i];\n if (param) {\n const typeAnnotation = getParamTypeAnnotation(param);\n if (typeAnnotation) {\n references.push(...extractTypeReferencesWithNodes(typeAnnotation));\n }\n }\n }\n\n return references;\n}\n\n/** Extracts type references with nodes from function return type */\nfunction extractReturnTypeReferencesWithNodes(\n node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.FunctionDeclaration\n): TypeRefWithNode[] {\n if (node.returnType) {\n return extractTypeReferencesWithNodes(node.returnType.typeAnnotation);\n }\n return [];\n}\n\nconst rule: TSESLint.RuleModule<'noTypeImports', []> = {\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Disallow type-only imports for types used in route/middleFn parameters or return types. Type-only imports are erased at runtime, preventing mion from generating validation and serialization functions.',\n },\n messages: {\n noTypeImports:\n 'Type \"{{typeName}}\" is imported as type-only but is used in a route/middleFn. Remove the \"type\" keyword from the import to allow runtime type reflection.',\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n let routerImportCache: MionRouterImports | null = null;\n let typeOnlyImportCache: TypeOnlyImports | null = null;\n\n /** Reports type-only imports used in handler, highlighting the specific type reference */\n function checkTypeReferencesWithNodes(typeRefs: TypeRefWithNode[]): void {\n if (!typeOnlyImportCache) return;\n\n // Track reported types to avoid duplicates\n const reportedTypes = new Set<string>();\n\n for (const {typeName, node} of typeRefs) {\n // Skip if already reported this type\n if (reportedTypes.has(typeName)) continue;\n\n const importDecl = typeOnlyImportCache.typeOnlyImports.get(typeName);\n if (importDecl) {\n reportedTypes.add(typeName);\n context.report({\n node,\n messageId: 'noTypeImports',\n data: {typeName},\n });\n }\n }\n }\n\n /** Checks a function node for type-only imports */\n function checkFunctionNode(\n funcNode: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.FunctionDeclaration\n ): void {\n const paramRefs = extractParamTypeReferencesWithNodes(funcNode.params);\n const returnRefs = extractReturnTypeReferencesWithNodes(funcNode);\n const allRefs = [...paramRefs, ...returnRefs];\n\n checkTypeReferencesWithNodes(allRefs);\n }\n\n return {\n Program(node) {\n routerImportCache = buildRouterImportCache(node);\n typeOnlyImportCache = buildTypeOnlyImportCache(node);\n },\n\n CallExpression(node: TSESTree.CallExpression) {\n if (!routerImportCache || !typeOnlyImportCache) return;\n\n const routerFunctionName = getRouterFunctionName(node, routerImportCache);\n if (!routerFunctionName) return;\n\n // Check the first argument (handler function)\n const handler = node.arguments[0];\n if (!handler) return;\n\n if (\n handler.type === AST_NODE_TYPES.ArrowFunctionExpression ||\n handler.type === AST_NODE_TYPES.FunctionExpression\n ) {\n checkFunctionNode(handler);\n } else if (handler.type === AST_NODE_TYPES.Identifier) {\n // Handler is a reference to a function - we need to find the function declaration\n // This is handled by checking function declarations with Handler/HeaderHandler type annotations\n }\n },\n\n // Check functions with Handler/HeaderHandler type annotations\n VariableDeclarator(node: TSESTree.VariableDeclarator) {\n if (!routerImportCache || !typeOnlyImportCache) return;\n\n // Check if the variable has a Handler or HeaderHandler type annotation\n if (node.id.type === AST_NODE_TYPES.Identifier && node.id.typeAnnotation) {\n const typeAnnotation = node.id.typeAnnotation.typeAnnotation;\n if (\n typeAnnotation.type === AST_NODE_TYPES.TSTypeReference &&\n typeAnnotation.typeName.type === AST_NODE_TYPES.Identifier &&\n routerImportCache.handlerTypes.has(typeAnnotation.typeName.name)\n ) {\n // This is a handler with type annotation\n if (\n node.init &&\n (node.init.type === AST_NODE_TYPES.ArrowFunctionExpression ||\n node.init.type === AST_NODE_TYPES.FunctionExpression)\n ) {\n checkFunctionNode(node.init);\n }\n }\n }\n\n // Check for satisfies expressions\n if (\n node.init &&\n node.init.type === AST_NODE_TYPES.TSSatisfiesExpression &&\n node.init.typeAnnotation.type === AST_NODE_TYPES.TSTypeReference &&\n node.init.typeAnnotation.typeName.type === AST_NODE_TYPES.Identifier &&\n routerImportCache.handlerTypes.has(node.init.typeAnnotation.typeName.name)\n ) {\n const expr = node.init.expression;\n if (expr.type === AST_NODE_TYPES.ArrowFunctionExpression || expr.type === AST_NODE_TYPES.FunctionExpression) {\n checkFunctionNode(expr);\n }\n }\n },\n\n // Check function declarations with JSDoc tags\n FunctionDeclaration(node: TSESTree.FunctionDeclaration) {\n if (!routerImportCache || !typeOnlyImportCache) return;\n\n // Check for JSDoc tags\n const sourceCode = context.sourceCode;\n const comments = sourceCode.getCommentsBefore(node);\n\n for (const comment of comments) {\n if (\n comment.type === 'Block' &&\n (comment.value.includes('@mion:route') ||\n comment.value.includes('@mion:middleFn') ||\n comment.value.includes('@mion:headersFn'))\n ) {\n checkFunctionNode(node);\n break;\n }\n }\n },\n };\n },\n};\n\nexport default rule;\n"],"names":["AST_NODE_TYPES"],"mappings":";;AAUA,MAAM,mBAAmB,CAAC,SAAS,YAAY,WAAW;AAE1D,MAAM,gBAAgB,CAAC,WAAW,eAAe;AAuBjD,SAAS,uBAAuB,SAA8C;AAC1E,QAAM,sCAAsB,IAAA;AAC5B,QAAM,mCAAmB,IAAA;AAEzB,aAAW,aAAa,QAAQ,MAAM;AAClC,QAAI,UAAU,SAASA,MAAAA,eAAe,mBAAmB;AACrD,YAAM,SAAS,UAAU,OAAO;AAChC,UAAI,WAAW,oBAAoB,WAAW,mBAAmB;AAC7D,mBAAW,aAAa,UAAU,YAAY;AAC1C,cACI,UAAU,SAASA,MAAAA,eAAe,mBAClC,UAAU,SAAS,SAASA,MAAAA,eAAe,YAC7C;AACE,kBAAM,OAAO,UAAU,SAAS;AAChC,gBAAI,iBAAiB,SAAS,I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