cvx-kit 0.1.35 → 2.0.0-beta.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/README.md +92 -49
- package/dist/agent-tools.d.mts +21 -25
- package/dist/agent-tools.mjs +1 -1
- package/dist/agent-tools.mjs.map +1 -1
- package/dist/auth.d.mts +20 -14
- package/dist/auth.mjs +1 -1
- package/dist/auth.mjs.map +1 -1
- package/dist/components/approvals/_generated/api.d.mts +4 -5
- package/dist/components/approvals/_generated/api.mjs.map +1 -1
- package/dist/components/approvals/_generated/component.d.mts +0 -2
- package/dist/components/approvals/_generated/dataModel.d.mts +1 -3
- package/dist/components/approvals/_generated/server.d.mts +0 -2
- package/dist/components/approvals/_generated/server.mjs.map +1 -1
- package/dist/components/approvals/audit.d.mts +0 -1
- package/dist/components/approvals/audit.mjs +1 -1
- package/dist/components/approvals/audit.mjs.map +1 -1
- package/dist/components/approvals/client.d.mts +0 -1
- package/dist/components/approvals/client.mjs +1 -1
- package/dist/components/approvals/client.mjs.map +1 -1
- package/dist/components/approvals/constants.d.mts +0 -1
- package/dist/components/approvals/constants.mjs.map +1 -1
- package/dist/components/approvals/convex.config.d.mts +0 -2
- package/dist/components/approvals/convex.config.mjs.map +1 -1
- package/dist/components/approvals/decisions.d.mts +1 -4
- package/dist/components/approvals/decisions.mjs +1 -1
- package/dist/components/approvals/decisions.mjs.map +1 -1
- package/dist/components/approvals/functions.d.mts +0 -1
- package/dist/components/approvals/functions.mjs.map +1 -1
- package/dist/components/approvals/health.d.mts +0 -1
- package/dist/components/approvals/health.mjs.map +1 -1
- package/dist/components/approvals/requests.d.mts +106 -123
- package/dist/components/approvals/requests.mjs +1 -1
- package/dist/components/approvals/requests.mjs.map +1 -1
- package/dist/components/approvals/schema.d.ts +106 -315
- package/dist/components/approvals/schema.js +1 -1
- package/dist/components/approvals/validators.d.mts +321 -393
- package/dist/components/approvals/validators.mjs +1 -1
- package/dist/components/approvals/validators.mjs.map +1 -1
- package/dist/components/approvals/workflow.d.mts +0 -1
- package/dist/components/approvals/workflow.mjs +1 -1
- package/dist/components/approvals/workflow.mjs.map +1 -1
- package/dist/components/approvals/workflow_steps.d.mts +1 -2
- package/dist/components/approvals/workflow_steps.mjs.map +1 -1
- package/dist/components/foundation/_generated/api.d.mts +3 -4
- package/dist/components/foundation/_generated/api.mjs.map +1 -1
- package/dist/components/foundation/_generated/component.d.mts +0 -2
- package/dist/components/foundation/_generated/dataModel.d.mts +1 -3
- package/dist/components/foundation/_generated/server.d.mts +0 -2
- package/dist/components/foundation/_generated/server.mjs.map +1 -1
- package/dist/components/foundation/client.d.mts +0 -1
- package/dist/components/foundation/client.mjs +1 -1
- package/dist/components/foundation/client.mjs.map +1 -1
- package/dist/components/foundation/convex.config.d.mts +0 -2
- package/dist/components/foundation/convex.config.mjs.map +1 -1
- package/dist/components/foundation/functions.d.mts +0 -1
- package/dist/components/foundation/functions.mjs.map +1 -1
- package/dist/components/foundation/modules/command/command.d.mts +0 -1
- package/dist/components/foundation/modules/command/command.mjs.map +1 -1
- package/dist/components/foundation/modules/command/lifecycle.d.mts +0 -2
- package/dist/components/foundation/modules/command/lifecycle.mjs.map +1 -1
- package/dist/components/foundation/modules/observability/observability.d.mts +0 -1
- package/dist/components/foundation/modules/observability/observability.mjs.map +1 -1
- package/dist/components/foundation/modules/query/query.d.mts +0 -1
- package/dist/components/foundation/modules/query/query.mjs.map +1 -1
- package/dist/components/foundation/operation.d.mts +2 -3
- package/dist/components/foundation/operation.mjs.map +1 -1
- package/dist/components/foundation/result.d.mts +0 -1
- package/dist/components/foundation/result.mjs.map +1 -1
- package/dist/components/foundation/schema.d.ts +0 -2
- package/dist/components/foundation/telemetry.d.mts +0 -1
- package/dist/components/foundation/telemetry.mjs +1 -1
- package/dist/components/foundation/telemetry.mjs.map +1 -1
- package/dist/contracts.d.mts +2 -2
- package/dist/contracts.mjs +1 -1
- package/dist/crud.d.mts +93 -97
- package/dist/crud.mjs +1 -1
- package/dist/crud.mjs.map +1 -1
- package/dist/effect.d.mts +2 -3
- package/dist/effect.mjs +1 -1
- package/dist/errors.d.mts +2 -4
- package/dist/errors.mjs +1 -1
- package/dist/errors.mjs.map +1 -1
- package/dist/filters.d.mts +1 -1
- package/dist/filters.mjs +1 -1
- package/dist/idempotency.mjs +1 -1
- package/dist/index.d.mts +10 -7
- package/dist/index.mjs +1 -1
- package/dist/json-schema.d.mts +40 -0
- package/dist/json-schema.mjs +2 -0
- package/dist/json-schema.mjs.map +1 -0
- package/dist/k/compile.d.mts +17 -0
- package/dist/k/compile.mjs +2 -0
- package/dist/k/compile.mjs.map +1 -0
- package/dist/k/dates.d.mts +23 -0
- package/dist/k/dates.mjs +2 -0
- package/dist/k/dates.mjs.map +1 -0
- package/dist/k/formats.d.mts +24 -0
- package/dist/k/formats.mjs +2 -0
- package/dist/k/formats.mjs.map +1 -0
- package/dist/k/index.d.mts +32 -0
- package/dist/k/index.mjs +2 -0
- package/dist/k/index.mjs.map +1 -0
- package/dist/k/issues.d.mts +31 -0
- package/dist/k/issues.mjs +2 -0
- package/dist/k/issues.mjs.map +1 -0
- package/dist/k/kinds.d.mts +81 -0
- package/dist/k/kinds.mjs +2 -0
- package/dist/k/kinds.mjs.map +1 -0
- package/dist/k/object.d.mts +43 -0
- package/dist/k/object.mjs +2 -0
- package/dist/k/object.mjs.map +1 -0
- package/dist/k/parse.d.mts +29 -0
- package/dist/k/parse.mjs +2 -0
- package/dist/k/parse.mjs.map +1 -0
- package/dist/k/schema.d.mts +100 -0
- package/dist/k/schema.mjs +2 -0
- package/dist/k/schema.mjs.map +1 -0
- package/dist/k/standard.d.mts +8 -0
- package/dist/k/standard.mjs +2 -0
- package/dist/k/standard.mjs.map +1 -0
- package/dist/k/types.d.mts +64 -0
- package/dist/k/types.mjs +1 -0
- package/dist/k.d.mts +8 -0
- package/dist/k.mjs +1 -0
- package/dist/middleware.d.mts +0 -2
- package/dist/middleware.mjs +1 -1
- package/dist/middleware.mjs.map +1 -1
- package/dist/modules/contracts/binding.d.mts +1 -2
- package/dist/modules/contracts/binding.mjs.map +1 -1
- package/dist/modules/contracts/contract.d.mts +0 -2
- package/dist/modules/contracts/contract.mjs.map +1 -1
- package/dist/modules/contracts/convex.d.mts +1 -3
- package/dist/modules/contracts/convex.mjs.map +1 -1
- package/dist/modules/contracts/domain.d.mts +1 -2
- package/dist/modules/contracts/domain.mjs.map +1 -1
- package/dist/modules/contracts/errors.d.mts +161 -2
- package/dist/modules/contracts/errors.mjs +1 -1
- package/dist/modules/contracts/errors.mjs.map +1 -1
- package/dist/modules/contracts/exposure.d.mts +1 -2
- package/dist/modules/contracts/exposure.mjs.map +1 -1
- package/dist/modules/contracts/idempotency.d.mts +1 -2
- package/dist/modules/contracts/idempotency.mjs +1 -1
- package/dist/modules/contracts/idempotency.mjs.map +1 -1
- package/dist/modules/contracts/lazy.d.mts +0 -2
- package/dist/modules/contracts/lazy.mjs.map +1 -1
- package/dist/modules/contracts/standard.d.mts +7 -5
- package/dist/modules/contracts/standard.mjs +1 -1
- package/dist/modules/contracts/standard.mjs.map +1 -1
- package/dist/modules/contracts/workflow.d.mts +1 -2
- package/dist/modules/contracts/workflow.mjs.map +1 -1
- package/dist/modules/effect/action.d.mts +6 -7
- package/dist/modules/effect/action.mjs +1 -1
- package/dist/modules/effect/action.mjs.map +1 -1
- package/dist/modules/effect/agent-tools.mjs +1 -1
- package/dist/modules/effect/api-runtime.d.mts +1 -2
- package/dist/modules/effect/api-runtime.mjs +1 -1
- package/dist/modules/effect/api-runtime.mjs.map +1 -1
- package/dist/modules/effect/api.d.mts +41 -15
- package/dist/modules/effect/api.mjs +1 -1
- package/dist/modules/effect/api.mjs.map +1 -1
- package/dist/modules/effect/auth.d.mts +5 -6
- package/dist/modules/effect/auth.mjs +1 -1
- package/dist/modules/effect/auth.mjs.map +1 -1
- package/dist/modules/effect/client.d.mts +7 -8
- package/dist/modules/effect/client.mjs +1 -1
- package/dist/modules/effect/command.d.mts +7 -5
- package/dist/modules/effect/command.mjs +1 -1
- package/dist/modules/effect/command.mjs.map +1 -1
- package/dist/modules/effect/crud.d.mts +272 -206
- package/dist/modules/effect/crud.mjs +1 -1
- package/dist/modules/effect/crud.mjs.map +1 -1
- package/dist/modules/effect/domain.d.mts +5 -6
- package/dist/modules/effect/domain.mjs.map +1 -1
- package/dist/modules/effect/errors.d.mts +4 -2
- package/dist/modules/effect/errors.mjs +1 -1
- package/dist/modules/effect/errors.mjs.map +1 -1
- package/dist/modules/effect/failure-audit.d.mts +2 -2
- package/dist/modules/effect/failure-audit.mjs +1 -1
- package/dist/modules/effect/failure-audit.mjs.map +1 -1
- package/dist/modules/effect/failures.d.mts +1 -2
- package/dist/modules/effect/failures.mjs.map +1 -1
- package/dist/modules/effect/foundation.d.mts +0 -2
- package/dist/modules/effect/foundation.mjs.map +1 -1
- package/dist/modules/effect/idempotency.d.mts +2 -3
- package/dist/modules/effect/idempotency.mjs +1 -1
- package/dist/modules/effect/idempotency.mjs.map +1 -1
- package/dist/modules/effect/input.d.mts +10 -0
- package/dist/modules/effect/input.mjs +2 -0
- package/dist/modules/effect/input.mjs.map +1 -0
- package/dist/modules/effect/normalize.d.mts +0 -2
- package/dist/modules/effect/normalize.mjs.map +1 -1
- package/dist/modules/effect/operation.d.mts +2 -3
- package/dist/modules/effect/operation.mjs.map +1 -1
- package/dist/modules/effect/query.d.mts +6 -4
- package/dist/modules/effect/query.mjs +1 -1
- package/dist/modules/effect/query.mjs.map +1 -1
- package/dist/modules/effect/schema.d.mts +0 -2
- package/dist/modules/effect/schema.mjs.map +1 -1
- package/dist/modules/effect/scope.d.mts +0 -2
- package/dist/modules/effect/scope.mjs.map +1 -1
- package/dist/modules/effect/workflow.d.mts +4 -5
- package/dist/modules/effect/workflow.mjs +1 -1
- package/dist/modules/effect/workflow.mjs.map +1 -1
- package/dist/modules/foundation/foundation.d.mts +4 -5
- package/dist/modules/foundation/foundation.mjs +1 -1
- package/dist/modules/foundation/foundation.mjs.map +1 -1
- package/dist/modules/foundation/operation.d.mts +2 -3
- package/dist/modules/foundation/operation.mjs.map +1 -1
- package/dist/namespace.d.mts +104 -0
- package/dist/namespace.mjs +2 -0
- package/dist/namespace.mjs.map +1 -0
- package/dist/oxlint/architecture.d.mts +0 -2
- package/dist/oxlint/architecture.mjs +1 -1
- package/dist/oxlint/architecture.mjs.map +1 -1
- package/dist/oxlint/ast.d.mts +16 -8
- package/dist/oxlint/ast.mjs +1 -1
- package/dist/oxlint/ast.mjs.map +1 -1
- package/dist/oxlint/components.d.mts +0 -2
- package/dist/oxlint/components.mjs.map +1 -1
- package/dist/oxlint/ownership.d.mts +0 -2
- package/dist/oxlint/ownership.mjs +1 -1
- package/dist/oxlint/ownership.mjs.map +1 -1
- package/dist/oxlint/reserved-files.d.mts +0 -2
- package/dist/oxlint/reserved-files.mjs +1 -1
- package/dist/oxlint/reserved-files.mjs.map +1 -1
- package/dist/oxlint.d.mts +0 -2
- package/dist/oxlint.mjs +1 -1
- package/dist/oxlint.mjs.map +1 -1
- package/dist/querying/cursors.d.mts +27 -9
- package/dist/querying/cursors.mjs +1 -1
- package/dist/querying/cursors.mjs.map +1 -1
- package/dist/querying/execution.d.mts +6 -7
- package/dist/querying/execution.mjs +1 -1
- package/dist/querying/execution.mjs.map +1 -1
- package/dist/querying/failures.d.mts +0 -2
- package/dist/querying/failures.mjs +1 -1
- package/dist/querying/failures.mjs.map +1 -1
- package/dist/querying/filter-boundary.d.mts +18 -9
- package/dist/querying/filter-boundary.mjs +1 -1
- package/dist/querying/filter-boundary.mjs.map +1 -1
- package/dist/querying/filters.d.mts +71 -35
- package/dist/querying/filters.mjs +1 -1
- package/dist/querying/filters.mjs.map +1 -1
- package/dist/querying/planner.d.mts +16 -20
- package/dist/querying/planner.mjs +1 -1
- package/dist/querying/planner.mjs.map +1 -1
- package/dist/querying/relationships.d.mts +6 -6
- package/dist/querying/relationships.mjs +1 -1
- package/dist/querying/relationships.mjs.map +1 -1
- package/dist/querying/search.d.mts +12 -12
- package/dist/querying/search.mjs +1 -1
- package/dist/querying/search.mjs.map +1 -1
- package/dist/querying/security.d.mts +2 -3
- package/dist/querying/security.mjs.map +1 -1
- package/dist/querying/shared/ast.d.mts +0 -2
- package/dist/querying/shared/ast.mjs.map +1 -1
- package/dist/querying/shared/contract.d.mts +17 -23
- package/dist/querying/shared/contract.mjs +1 -1
- package/dist/querying/shared/contract.mjs.map +1 -1
- package/dist/querying/shared/evaluate.d.mts +0 -2
- package/dist/querying/shared/evaluate.mjs.map +1 -1
- package/dist/querying/shared/filters.d.mts +47 -29
- package/dist/querying/shared/filters.mjs +1 -1
- package/dist/querying/shared/filters.mjs.map +1 -1
- package/dist/querying/shared/native-json.d.mts +7 -0
- package/dist/querying/shared/native-json.mjs +2 -0
- package/dist/querying/shared/native-json.mjs.map +1 -0
- package/dist/querying/shared/page.d.mts +19 -22
- package/dist/querying/shared/page.mjs +1 -1
- package/dist/querying/shared/page.mjs.map +1 -1
- package/dist/querying.d.mts +6 -9
- package/dist/querying.mjs +1 -1
- package/dist/querying.mjs.map +1 -1
- package/dist/react/failures.d.mts +0 -2
- package/dist/react/failures.mjs.map +1 -1
- package/dist/react/optimistic.d.mts +2 -3
- package/dist/react/optimistic.mjs.map +1 -1
- package/dist/react/pagination-state.d.mts +1 -2
- package/dist/react/pagination-state.mjs.map +1 -1
- package/dist/react/use-command.d.mts +0 -2
- package/dist/react/use-command.mjs.map +1 -1
- package/dist/react/use-paginated-list.d.mts +1 -3
- package/dist/react/use-paginated-list.mjs +1 -1
- package/dist/react/use-paginated-list.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.mjs +1 -1
- package/dist/registration.d.mts +65 -0
- package/dist/registration.mjs +2 -0
- package/dist/registration.mjs.map +1 -0
- package/dist/relations-public.d.mts +2 -2
- package/dist/relations-public.mjs +1 -1
- package/dist/relations.d.mts +55 -46
- package/dist/relations.mjs +1 -1
- package/dist/relations.mjs.map +1 -1
- package/dist/state-machine.d.mts +0 -2
- package/dist/state-machine.mjs.map +1 -1
- package/dist/table.d.mts +222 -0
- package/dist/table.mjs +2 -0
- package/dist/table.mjs.map +1 -0
- package/dist/tenancy.d.mts +0 -2
- package/dist/tenancy.mjs.map +1 -1
- package/dist/triggers.d.mts +2 -4
- package/dist/triggers.mjs +1 -1
- package/dist/triggers.mjs.map +1 -1
- package/dist/webhooks.d.mts +9 -9
- package/dist/webhooks.mjs +1 -1
- package/dist/webhooks.mjs.map +1 -1
- package/dist/workflow.mjs +1 -1
- package/dist/zod.d.mts +30 -0
- package/dist/zod.mjs +2 -0
- package/dist/zod.mjs.map +1 -0
- package/package.json +51 -29
- package/dist/modules/effect/api-zod.d.mts +0 -34
- package/dist/modules/effect/api-zod.mjs +0 -2
- package/dist/modules/effect/api-zod.mjs.map +0 -1
- package/dist/querying/schema-snapshot.d.mts +0 -49
- package/dist/querying/schema-snapshot.mjs +0 -2
- package/dist/querying/schema-snapshot.mjs.map +0 -1
- package/dist/zod-convex.d.mts +0 -10
- package/dist/zod-convex.mjs +0 -2
- package/dist/zod-convex.mjs.map +0 -1
- package/dist/zod-registration.d.mts +0 -15
- package/dist/zod-registration.mjs +0 -2
- package/dist/zod-registration.mjs.map +0 -1
- package/dist/zod-table.d.mts +0 -351
- package/dist/zod-table.mjs +0 -2
- package/dist/zod-table.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ownership.mjs","names":["ownershipRules","metadata","settings","consumerOptions","context","root","resolve","existsSync","realpathSync","architectureAnchor","issue","inspectArchitecture","file","appFile","reason","componentFacade","standard","flag","node","statement","imported","containsComponentReference","argument","isDbWrite","isExternalCall","delegatingBody","owners","resolver","createResolver","sources","sourceVisitors","typeOnlySource","target","resolveImport","source","path","match","componentRoot","publicNames","exportedNames","declaration","item","isDbAccess","ref","memberPath","rootMember","isFunctionsImport","assembly","role","basename","pure","read","declarative","actionSide","method","propertyName","constructor","binding"],"sources":["../../src/oxlint/ownership.ts"],"sourcesContent":["import { existsSync, realpathSync } from 'node:fs'\nimport { basename, resolve } from 'node:path'\nimport type { CreateRule, ESTree } from '@oxlint/plugins'\nimport {\n\tarchitectureAnchor,\n\tinspectArchitecture,\n\tcreateResolver,\n\tresolveImport,\n} from './architecture'\nimport {\n\tconsumerOptions,\n\tappFile,\n\timported,\n\tsourceVisitors,\n\tisFunctionsImport,\n\ttypeOnlySource,\n\tisDbAccess,\n\tisExternalCall,\n\tcontainsComponentReference,\n\trootMember,\n\tmemberPath,\n\tisDbWrite,\n\tmetadata,\n\tcomponentRoot,\n\tpropertyName,\n\tbinding,\n\texportedNames,\n\tdelegatingBody,\n} from './ast'\n\nexport const ownershipRules = {\n\t'project-structure': {\n\t\tmeta: metadata('Validate the application tree, colocated tests, and module cycles.', {\n\t\t\tstructure: '{{file}}: {{message}}',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst settings = consumerOptions.parse(context.options[0] ?? {})\n\t\t\tconst root = resolve(context.cwd, settings.convexDir)\n\t\t\tif (\n\t\t\t\t(existsSync(context.filename)\n\t\t\t\t\t? realpathSync(context.filename)\n\t\t\t\t\t: resolve(context.filename)) !== architectureAnchor(root)\n\t\t\t)\n\t\t\t\treturn {}\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tfor (const issue of inspectArchitecture({\n\t\t\t\t\t\tcwd: context.cwd,\n\t\t\t\t\t\tconvexDir: settings.convexDir,\n\t\t\t\t\t\tcomponentDirs: settings.componentDirs,\n\t\t\t\t\t}))\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'structure',\n\t\t\t\t\t\t\tdata: { file: issue.file, message: issue.message },\n\t\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'root-wiring-only': {\n\t\tmeta: metadata('Keep root files limited to configuration, assembly, and component facades.', {\n\t\t\townership:\n\t\t\t\t'Root files only wire configuration and components. Move behavior into domain/<module>/: {{reason}}.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context)\n\t\t\tif (!file || file.includes('/')) return {}\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tlet reason = 'business implementation'\n\t\t\tlet componentFacade = false\n\t\t\tconst standard =\n\t\t\t\t/^(?:convex\\.config|auth\\.config|vite\\.config|vitest\\.config|auth|schema|functions|triggers|foundation|http|crons)\\.[cm]?[jt]s$/.test(\n\t\t\t\t\tfile,\n\t\t\t\t)\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.body.some(\n\t\t\t\t\t\t\t(statement) =>\n\t\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' ||\n\t\t\t\t\t\t\t\t(statement.type === 'ExportNamedDeclaration' &&\n\t\t\t\t\t\t\t\t\tstatement.declaration?.type === 'FunctionDeclaration'),\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tNewExpression(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\timported(context, node.callee) &&\n\t\t\t\t\t\tnode.arguments.some((argument) => containsComponentReference(context, argument))\n\t\t\t\t\t)\n\t\t\t\t\t\tcomponentFacade = true\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\timported(context, node.callee) &&\n\t\t\t\t\t\tnode.arguments.some((argument) => containsComponentReference(context, argument))\n\t\t\t\t\t)\n\t\t\t\t\t\tcomponentFacade = true\n\t\t\t\t\tif (\n\t\t\t\t\t\tisDbWrite(node) ||\n\t\t\t\t\t\tisExternalCall(context, node) ||\n\t\t\t\t\t\t(file === 'schema.ts' && !(imported(context, node.callee)?.name === 'defineSchema'))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tArrowFunctionExpression(node) {\n\t\t\t\t\tif (!node.body || !delegatingBody(node.body)) flag(node)\n\t\t\t\t},\n\t\t\t\tFunctionExpression(node) {\n\t\t\t\t\tif (!node.body || !delegatingBody(node.body)) flag(node)\n\t\t\t\t},\n\t\t\t\tIfStatement: flag,\n\t\t\t\tSwitchStatement: flag,\n\t\t\t\tConditionalExpression: flag,\n\t\t\t\tForStatement: flag,\n\t\t\t\tForOfStatement: flag,\n\t\t\t\tWhileStatement: flag,\n\t\t\t\t'Program:exit'(node) {\n\t\t\t\t\tif (!standard && !componentFacade) {\n\t\t\t\t\t\tissue = node\n\t\t\t\t\t\treason = 'unknown root file; only declared component facades may add root source files'\n\t\t\t\t\t}\n\t\t\t\t\tif (issue) context.report({ node: issue, messageId: 'ownership', data: { reason } })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'application-orchestration': {\n\t\tmeta: metadata('Reserve application/ for thin cross-domain coordination.', {\n\t\t\townership:\n\t\t\t\t'application/ only coordinates two or more domains. Move schemas, providers, storage access, helpers, and business decisions into their owning domain.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tif (!appFile(context)?.startsWith('application/')) return {}\n\t\t\tconst owners = new Set<string>()\n\t\t\tconst resolver = createResolver()\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\tconst sources = sourceVisitors(context, (node, source) => {\n\t\t\t\tif (typeOnlySource(node)) return\n\t\t\t\tconst target = resolveImport(resolver, context.filename, source)\n\t\t\t\tconst path = target && appFile(context, target)\n\t\t\t\tconst match = path?.match(/^domain\\/([^/]+)\\/(?:commands|queries|rules)(?:\\.[cm]?[jt]s)?$/)\n\t\t\t\tif (match && match[1] !== 'shared') owners.add(match[1])\n\t\t\t\tif (path?.startsWith('domain/') && !match && !path.startsWith('domain/shared/')) flag(node)\n\t\t\t\tif (\n\t\t\t\t\t!path &&\n\t\t\t\t\t!componentRoot(context, context.filename) &&\n\t\t\t\t\t![\n\t\t\t\t\t\t'cvx-kit',\n\t\t\t\t\t\t'cvx-kit/components/foundation',\n\t\t\t\t\t\t'@convex-dev/workflow',\n\t\t\t\t\t\t'convex/values',\n\t\t\t\t\t].includes(source)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...sources,\n\t\t\t\tProgram(node) {\n\t\t\t\t\tconst publicNames = exportedNames(node)\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' &&\n\t\t\t\t\t\t\tstatement.id &&\n\t\t\t\t\t\t\t!publicNames.has(statement.id.name)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t\tconst declaration =\n\t\t\t\t\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tdeclaration?.type === 'TSTypeAliasDeclaration' ||\n\t\t\t\t\t\t\tdeclaration?.type === 'TSInterfaceDeclaration'\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t\tif (declaration?.type === 'VariableDeclaration')\n\t\t\t\t\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\titem.init &&\n\t\t\t\t\t\t\t\t\t['ObjectExpression', 'ArrayExpression', 'Literal'].includes(item.init.type)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tflag(item)\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tstatement.type === 'VariableDeclaration' &&\n\t\t\t\t\t\t\t\t\titem.id.type === 'Identifier' &&\n\t\t\t\t\t\t\t\t\t!publicNames.has(item.id.name) &&\n\t\t\t\t\t\t\t\t\t['ArrowFunctionExpression', 'FunctionExpression'].includes(item.init?.type ?? '')\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tflag(item)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tsources.CallExpression?.(node)\n\t\t\t\t\tif (isDbAccess(node) || isExternalCall(context, node)) flag(node)\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (ref && ['zod', 'zod/v4'].includes(ref.source)) flag(node)\n\t\t\t\t},\n\t\t\t\tMemberExpression(node) {\n\t\t\t\t\tconst path = memberPath(node)\n\t\t\t\t\tif (path.length >= 4 && path[1] === 'domain') {\n\t\t\t\t\t\tconst ref = imported(context, rootMember(node))\n\t\t\t\t\t\tif (ref?.name === 'internal' && /_generated\\/api/.test(ref.source)) owners.add(path[2])\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tNewExpression: flag,\n\t\t\t\tIfStatement: flag,\n\t\t\t\tSwitchStatement: flag,\n\t\t\t\tConditionalExpression: flag,\n\t\t\t\t'Program:exit'(node) {\n\t\t\t\t\tif (owners.size < 2 || issue)\n\t\t\t\t\t\tcontext.report({ node: issue ?? node, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'internal-function-ownership': {\n\t\tmeta: metadata('Place internal handlers with their owner, never in root, api/, or shared/.', {\n\t\t\townership:\n\t\t\t\t'Declare system/internal handlers in domain/<module>/, cross-domain application/, migrations/, or an isolated component.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context) ?? ''\n\t\t\tif (\n\t\t\t\tcomponentRoot(context, context.filename) ||\n\t\t\t\t/^(?:domain\\/(?!shared\\/)[^/]+\\/|application\\/|migrations\\/)/.test(file)\n\t\t\t)\n\t\t\t\treturn {}\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (node.callee.type === 'CallExpression') return\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tref &&\n\t\t\t\t\t\t((isFunctionsImport(context, ref.source) &&\n\t\t\t\t\t\t\t/^system(Query|Mutation|Action)$/.test(ref.name)) ||\n\t\t\t\t\t\t\t(/(?:_generated\\/server|convex\\/server)/.test(ref.source) &&\n\t\t\t\t\t\t\t\t/^internal(Query|Mutation|Action)(Generic)?$/.test(ref.name)))\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'domain-file-responsibilities': {\n\t\tmeta: metadata(\n\t\t\t'Keep invariants pure, reads read-only, shapes declarative, and I/O action-side.',\n\t\t\t{\n\t\t\t\townership:\n\t\t\t\t\t'Respect this domain file responsibility: pure rules, read-only queries, declarative schemas/tables/constants, and external I/O only in actions or integrations.',\n\t\t\t},\n\t\t),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context) ?? ''\n\t\t\tconst assembly = file === 'domain/table.ts'\n\t\t\tif (!assembly && !/^domain\\/[^/]+\\//.test(file) && !componentRoot(context, context.filename))\n\t\t\t\treturn {}\n\t\t\tconst role = basename(file).replace(/\\.[cm]?[jt]s$/, '')\n\t\t\tconst pure = role === 'rules'\n\t\t\tconst read = role === 'queries'\n\t\t\tconst declarative = ['schema', 'table', 'contracts', 'constants'].includes(role)\n\t\t\tconst actionSide =\n\t\t\t\t/(?:^|\\/)(?:actions|integrations|providers)(?:\\/|\\.)/.test(file) ||\n\t\t\t\t/(?:^|_)actions\\./.test(file)\n\t\t\tconst resolver = createResolver()\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\tconst sources = sourceVisitors(context, (node, source) => {\n\t\t\t\tif (typeOnlySource(node)) return\n\t\t\t\tconst target = resolveImport(resolver, context.filename, source)\n\t\t\t\tconst path = target && appFile(context, target)\n\t\t\t\tif (\n\t\t\t\t\tassembly &&\n\t\t\t\t\tsource !== 'cvx-kit/zod-table' &&\n\t\t\t\t\t!/^domain\\/[^/]+\\/table(?:\\.[cm]?[jt]s)?$/.test(path ?? '')\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t\tif (pure && path && !/(?:^|\\/)(?:rules|constants)(?:\\.[cm]?[jt]s)?$/.test(path)) flag(node)\n\t\t\t\tif (\n\t\t\t\t\t(pure || read || declarative) &&\n\t\t\t\t\t!path &&\n\t\t\t\t\t!componentRoot(context, context.filename) &&\n\t\t\t\t\t![\n\t\t\t\t\t\t'zod',\n\t\t\t\t\t\t'zod/v4',\n\t\t\t\t\t\t'convex/values',\n\t\t\t\t\t\t'cvx-kit',\n\t\t\t\t\t\t'cvx-kit/zod-table',\n\t\t\t\t\t\t'cvx-kit/errors',\n\t\t\t\t\t\t'cvx-kit/contracts',\n\t\t\t\t\t].includes(source)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t\tif (\n\t\t\t\t\tread &&\n\t\t\t\t\tpath &&\n\t\t\t\t\t/(?:^|\\/)(?:commands|actions|integrations|providers)(?:[./]|$)/.test(path)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...sources,\n\t\t\t\tProgram(node) {\n\t\t\t\t\tif (!assembly) return\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (statement.type === 'ImportDeclaration' || statement.type === 'EmptyStatement')\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\tconst declaration =\n\t\t\t\t\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tdeclaration?.type !== 'VariableDeclaration' ||\n\t\t\t\t\t\t\tdeclaration.declarations.some((item) => item.init?.type !== 'CallExpression')\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tsources.CallExpression?.(node)\n\t\t\t\t\tif (assembly) {\n\t\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\t\tconst assemblyCall =\n\t\t\t\t\t\t\t(ref?.source === 'cvx-kit/zod-table' && ref.name === 'createModule') ||\n\t\t\t\t\t\t\t(ref?.source === 'cvx-kit/zod-table' && ref.name === 'namespaceIndex')\n\t\t\t\t\t\tif (!assemblyCall) flag(node)\n\t\t\t\t\t}\n\t\t\t\t\tconst method = node.callee.type === 'MemberExpression' ? propertyName(node.callee) : null\n\t\t\t\t\tif (\n\t\t\t\t\t\t(pure || declarative) &&\n\t\t\t\t\t\t(isDbAccess(node) ||\n\t\t\t\t\t\t\t['runQuery', 'runMutation', 'runAction', 'runAfter', 'runAt'].includes(method ?? ''))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tread &&\n\t\t\t\t\t\t(isDbWrite(node) ||\n\t\t\t\t\t\t\t['runMutation', 'runAction', 'runAfter', 'runAt'].includes(method ?? ''))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tconst constructor = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tconstructor &&\n\t\t\t\t\t\tisFunctionsImport(context, constructor.source) &&\n\t\t\t\t\t\t(pure || declarative || (read && /(?:Mutation|Action)$/.test(constructor.name)))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tread &&\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression' &&\n\t\t\t\t\t\tpropertyName(node.callee.object) === 'storage' &&\n\t\t\t\t\t\t['store', 'delete', 'generateUploadUrl'].includes(method ?? '')\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (!actionSide && isExternalCall(context, node)) flag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tpure &&\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression' &&\n\t\t\t\t\t\tnode.callee.object.type === 'Identifier' &&\n\t\t\t\t\t\t!binding(context, node.callee.object)?.defs.length &&\n\t\t\t\t\t\t((node.callee.object.name === 'Date' && method === 'now') ||\n\t\t\t\t\t\t\t(node.callee.object.name === 'Math' && method === 'random'))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tProperty(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\trole === 'contracts' &&\n\t\t\t\t\t\t['handler', 'context', 'audit', 'prepare', 'middleware', 'guard'].includes(\n\t\t\t\t\t\t\tnode.key.type === 'Identifier'\n\t\t\t\t\t\t\t\t? node.key.name\n\t\t\t\t\t\t\t\t: String(node.key.type === 'Literal' ? node.key.value : ''),\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tMemberExpression(node) {\n\t\t\t\t\tif (pure && ['db', 'storage', 'scheduler', 'env'].includes(propertyName(node) ?? ''))\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tNewExpression(node) {\n\t\t\t\t\tif (!(pure || read || declarative)) return\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.callee.type === 'Identifier' &&\n\t\t\t\t\t\t!binding(context, node.callee)?.defs.length &&\n\t\t\t\t\t\t['Error', 'TypeError', 'RangeError', 'Set', 'Map', 'RegExp'].includes(node.callee.name)\n\t\t\t\t\t)\n\t\t\t\t\t\treturn\n\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\t'Program:exit'() {\n\t\t\t\t\tif (issue) context.report({ node: issue, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n} satisfies Record<string, CreateRule>\n\nexport type OwnershipRuleName = keyof typeof ownershipRules\n"],"mappings":"ikBA8BA,MAAaA,EAAiB,CAC7B,oBAAqB,CACpB,KAAMC,EAAS,qEAAsE,CACpF,UAAW,uBACZ,CAAC,EACD,OAAO,EAAS,CACf,IAAMC,EAAWC,EAAgB,MAAMC,EAA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AAKC,CAAI,CACX,EACA,iBAAiB,EAAM,CAClBgC,GAAQ,CAAC,KAAM,UAAW,YAAa,KAAK,CAAC,CAAC,SAASK,EAAarC,CAAI,GAAK,EAAE,GAClFD,EAAKC,CAAI,CACX,EACA,cAAc,EAAM,EACbgC,GAAQC,GAAQC,KAErBlC,EAAK,OAAO,OAAS,cACpBuC,EAAQrD,EAASc,EAAK,MAAM,CAAC,EAAE,KAAK,QACrC,EAAC,QAAS,YAAa,aAAc,MAAO,MAAO,QAAQ,CAAC,CAAC,SAASA,EAAK,OAAO,IAAI,IAGvFD,EAAKC,CAAI,CACV,EACA,gBAAiB,CACZR,GAAON,EAAQ,OAAO,CAAE,KAAMM,EAAO,UAAW,WAAY,CAAC,CAClE,CACD,CACD,CACD,CACD"}
|
|
1
|
+
{"version":3,"file":"ownership.mjs","names":["ownershipRules","metadata","settings","consumerOptions","context","root","resolve","existsSync","realpathSync","architectureAnchor","issue","inspectArchitecture","file","appFile","reason","componentFacade","standard","flag","node","statement","imported","containsComponentReference","argument","isDbWrite","isExternalCall","delegatingBody","owners","resolver","createResolver","sources","sourceVisitors","typeOnlySource","target","resolveImport","source","path","match","componentRoot","publicNames","exportedNames","declaration","item","isDbAccess","kFactory","memberPath","ref","rootMember","isFunctionsImport","assembly","role","basename","pure","read","declarative","actionSide","method","propertyName","constructor","binding"],"sources":["../../src/oxlint/ownership.ts"],"sourcesContent":["import { existsSync, realpathSync } from 'node:fs'\nimport { basename, resolve } from 'node:path'\nimport type { CreateRule, ESTree } from '@oxlint/plugins'\nimport {\n\tarchitectureAnchor,\n\tinspectArchitecture,\n\tcreateResolver,\n\tresolveImport,\n} from './architecture'\nimport {\n\tconsumerOptions,\n\tappFile,\n\timported,\n\tkFactory,\n\tsourceVisitors,\n\tisFunctionsImport,\n\ttypeOnlySource,\n\tisDbAccess,\n\tisExternalCall,\n\tcontainsComponentReference,\n\trootMember,\n\tmemberPath,\n\tisDbWrite,\n\tmetadata,\n\tcomponentRoot,\n\tpropertyName,\n\tbinding,\n\texportedNames,\n\tdelegatingBody,\n} from './ast'\n\nexport const ownershipRules = {\n\t'project-structure': {\n\t\tmeta: metadata('Validate the application tree, colocated tests, and module cycles.', {\n\t\t\tstructure: '{{file}}: {{message}}',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst settings = consumerOptions.parse(context.options[0] ?? {})\n\t\t\tconst root = resolve(context.cwd, settings.convexDir)\n\t\t\tif (\n\t\t\t\t(existsSync(context.filename)\n\t\t\t\t\t? realpathSync(context.filename)\n\t\t\t\t\t: resolve(context.filename)) !== architectureAnchor(root)\n\t\t\t)\n\t\t\t\treturn {}\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tfor (const issue of inspectArchitecture({\n\t\t\t\t\t\tcwd: context.cwd,\n\t\t\t\t\t\tconvexDir: settings.convexDir,\n\t\t\t\t\t\tcomponentDirs: settings.componentDirs,\n\t\t\t\t\t}))\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'structure',\n\t\t\t\t\t\t\tdata: { file: issue.file, message: issue.message },\n\t\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'root-wiring-only': {\n\t\tmeta: metadata('Keep root files limited to configuration, assembly, and component facades.', {\n\t\t\townership:\n\t\t\t\t'Root files only wire configuration and components. Move behavior into domain/<module>/: {{reason}}.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context)\n\t\t\tif (!file || file.includes('/')) return {}\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tlet reason = 'business implementation'\n\t\t\tlet componentFacade = false\n\t\t\tconst standard =\n\t\t\t\t/^(?:convex\\.config|auth\\.config|vite\\.config|vitest\\.config|auth|schema|functions|triggers|foundation|http|crons)\\.[cm]?[jt]s$/.test(\n\t\t\t\t\tfile,\n\t\t\t\t)\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.body.some(\n\t\t\t\t\t\t\t(statement) =>\n\t\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' ||\n\t\t\t\t\t\t\t\t(statement.type === 'ExportNamedDeclaration' &&\n\t\t\t\t\t\t\t\t\tstatement.declaration?.type === 'FunctionDeclaration'),\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tNewExpression(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\timported(context, node.callee) &&\n\t\t\t\t\t\tnode.arguments.some((argument) => containsComponentReference(context, argument))\n\t\t\t\t\t)\n\t\t\t\t\t\tcomponentFacade = true\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\timported(context, node.callee) &&\n\t\t\t\t\t\tnode.arguments.some((argument) => containsComponentReference(context, argument))\n\t\t\t\t\t)\n\t\t\t\t\t\tcomponentFacade = true\n\t\t\t\t\tif (\n\t\t\t\t\t\tisDbWrite(node) ||\n\t\t\t\t\t\tisExternalCall(context, node) ||\n\t\t\t\t\t\t(file === 'schema.ts' && !(imported(context, node.callee)?.name === 'defineSchema'))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tArrowFunctionExpression(node) {\n\t\t\t\t\tif (!node.body || !delegatingBody(node.body)) flag(node)\n\t\t\t\t},\n\t\t\t\tFunctionExpression(node) {\n\t\t\t\t\tif (!node.body || !delegatingBody(node.body)) flag(node)\n\t\t\t\t},\n\t\t\t\tIfStatement: flag,\n\t\t\t\tSwitchStatement: flag,\n\t\t\t\tConditionalExpression: flag,\n\t\t\t\tForStatement: flag,\n\t\t\t\tForOfStatement: flag,\n\t\t\t\tWhileStatement: flag,\n\t\t\t\t'Program:exit'(node) {\n\t\t\t\t\tif (!standard && !componentFacade) {\n\t\t\t\t\t\tissue = node\n\t\t\t\t\t\treason = 'unknown root file; only declared component facades may add root source files'\n\t\t\t\t\t}\n\t\t\t\t\tif (issue) context.report({ node: issue, messageId: 'ownership', data: { reason } })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'application-orchestration': {\n\t\tmeta: metadata('Reserve application/ for thin cross-domain coordination.', {\n\t\t\townership:\n\t\t\t\t'application/ only coordinates two or more domains. Move schemas, providers, storage access, helpers, and business decisions into their owning domain.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tif (!appFile(context)?.startsWith('application/')) return {}\n\t\t\tconst owners = new Set<string>()\n\t\t\tconst resolver = createResolver()\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\tconst sources = sourceVisitors(context, (node, source) => {\n\t\t\t\tif (typeOnlySource(node)) return\n\t\t\t\tconst target = resolveImport(resolver, context.filename, source)\n\t\t\t\tconst path = target && appFile(context, target)\n\t\t\t\tconst match = path?.match(/^domain\\/([^/]+)\\/(?:commands|queries|rules)(?:\\.[cm]?[jt]s)?$/)\n\t\t\t\tif (match && match[1] !== 'shared') owners.add(match[1])\n\t\t\t\tif (path?.startsWith('domain/') && !match && !path.startsWith('domain/shared/')) flag(node)\n\t\t\t\tif (\n\t\t\t\t\t!path &&\n\t\t\t\t\t!componentRoot(context, context.filename) &&\n\t\t\t\t\t![\n\t\t\t\t\t\t'cvx-kit',\n\t\t\t\t\t\t'cvx-kit/components/foundation',\n\t\t\t\t\t\t'@convex-dev/workflow',\n\t\t\t\t\t\t'convex/values',\n\t\t\t\t\t].includes(source)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...sources,\n\t\t\t\tProgram(node) {\n\t\t\t\t\tconst publicNames = exportedNames(node)\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' &&\n\t\t\t\t\t\t\tstatement.id &&\n\t\t\t\t\t\t\t!publicNames.has(statement.id.name)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t\tconst declaration =\n\t\t\t\t\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tdeclaration?.type === 'TSTypeAliasDeclaration' ||\n\t\t\t\t\t\t\tdeclaration?.type === 'TSInterfaceDeclaration'\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t\tif (declaration?.type === 'VariableDeclaration')\n\t\t\t\t\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\titem.init &&\n\t\t\t\t\t\t\t\t\t['ObjectExpression', 'ArrayExpression', 'Literal'].includes(item.init.type)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tflag(item)\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tstatement.type === 'VariableDeclaration' &&\n\t\t\t\t\t\t\t\t\titem.id.type === 'Identifier' &&\n\t\t\t\t\t\t\t\t\t!publicNames.has(item.id.name) &&\n\t\t\t\t\t\t\t\t\t['ArrowFunctionExpression', 'FunctionExpression'].includes(item.init?.type ?? '')\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tflag(item)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tsources.CallExpression?.(node)\n\t\t\t\t\tif (isDbAccess(node) || isExternalCall(context, node)) flag(node)\n\t\t\t\t\tif (kFactory(context, node)) flag(node)\n\t\t\t\t},\n\t\t\t\tMemberExpression(node) {\n\t\t\t\t\tconst path = memberPath(node)\n\t\t\t\t\tif (path.length >= 4 && path[1] === 'domain') {\n\t\t\t\t\t\tconst ref = imported(context, rootMember(node))\n\t\t\t\t\t\tif (ref?.name === 'internal' && /_generated\\/api/.test(ref.source)) owners.add(path[2])\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tNewExpression: flag,\n\t\t\t\tIfStatement: flag,\n\t\t\t\tSwitchStatement: flag,\n\t\t\t\tConditionalExpression: flag,\n\t\t\t\t'Program:exit'(node) {\n\t\t\t\t\tif (owners.size < 2 || issue)\n\t\t\t\t\t\tcontext.report({ node: issue ?? node, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'internal-function-ownership': {\n\t\tmeta: metadata('Place internal handlers with their owner, never in root, api/, or shared/.', {\n\t\t\townership:\n\t\t\t\t'Declare system/internal handlers in domain/<module>/, cross-domain application/, migrations/, or an isolated component.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context) ?? ''\n\t\t\tif (\n\t\t\t\tcomponentRoot(context, context.filename) ||\n\t\t\t\t/^(?:domain\\/(?!shared\\/)[^/]+\\/|application\\/|migrations\\/)/.test(file)\n\t\t\t)\n\t\t\t\treturn {}\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (node.callee.type === 'CallExpression') return\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tref &&\n\t\t\t\t\t\t((isFunctionsImport(context, ref.source) &&\n\t\t\t\t\t\t\t/^system(Query|Mutation|Action)$/.test(ref.name)) ||\n\t\t\t\t\t\t\t(/(?:_generated\\/server|convex\\/server)/.test(ref.source) &&\n\t\t\t\t\t\t\t\t/^internal(Query|Mutation|Action)(Generic)?$/.test(ref.name)))\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'domain-file-responsibilities': {\n\t\tmeta: metadata(\n\t\t\t'Keep invariants pure, reads read-only, shapes declarative, and I/O action-side.',\n\t\t\t{\n\t\t\t\townership:\n\t\t\t\t\t'Respect this domain file responsibility: pure rules, read-only queries, declarative schemas/tables/constants, and external I/O only in actions or integrations.',\n\t\t\t},\n\t\t),\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context) ?? ''\n\t\t\tconst assembly = file === 'domain/table.ts'\n\t\t\tif (!assembly && !/^domain\\/[^/]+\\//.test(file) && !componentRoot(context, context.filename))\n\t\t\t\treturn {}\n\t\t\tconst role = basename(file).replace(/\\.[cm]?[jt]s$/, '')\n\t\t\tconst pure = role === 'rules'\n\t\t\tconst read = role === 'queries'\n\t\t\tconst declarative = ['schema', 'table', 'contracts', 'constants'].includes(role)\n\t\t\tconst actionSide =\n\t\t\t\t/(?:^|\\/)(?:actions|integrations|providers)(?:\\/|\\.)/.test(file) ||\n\t\t\t\t/(?:^|_)actions\\./.test(file)\n\t\t\tconst resolver = createResolver()\n\t\t\tlet issue: ESTree.Node | null = null\n\t\t\tfunction flag(node: ESTree.Node) {\n\t\t\t\tissue ??= node\n\t\t\t}\n\t\t\tconst sources = sourceVisitors(context, (node, source) => {\n\t\t\t\tif (typeOnlySource(node)) return\n\t\t\t\tconst target = resolveImport(resolver, context.filename, source)\n\t\t\t\tconst path = target && appFile(context, target)\n\t\t\t\tif (\n\t\t\t\t\tassembly &&\n\t\t\t\t\tsource !== 'cvx-kit/table' &&\n\t\t\t\t\t!/^domain\\/[^/]+\\/table(?:\\.[cm]?[jt]s)?$/.test(path ?? '')\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t\tif (pure && path && !/(?:^|\\/)(?:rules|constants)(?:\\.[cm]?[jt]s)?$/.test(path)) flag(node)\n\t\t\t\tif (\n\t\t\t\t\t(pure || read || declarative) &&\n\t\t\t\t\t!path &&\n\t\t\t\t\t!componentRoot(context, context.filename) &&\n\t\t\t\t\t![\n\t\t\t\t\t\t'zod',\n\t\t\t\t\t\t'zod/v4',\n\t\t\t\t\t\t'convex/values',\n\t\t\t\t\t\t'cvx-kit',\n\t\t\t\t\t\t'cvx-kit/k',\n\t\t\t\t\t\t'cvx-kit/table',\n\t\t\t\t\t\t'cvx-kit/errors',\n\t\t\t\t\t\t'cvx-kit/contracts',\n\t\t\t\t\t].includes(source)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t\tif (\n\t\t\t\t\tread &&\n\t\t\t\t\tpath &&\n\t\t\t\t\t/(?:^|\\/)(?:commands|actions|integrations|providers)(?:[./]|$)/.test(path)\n\t\t\t\t)\n\t\t\t\t\tflag(node)\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...sources,\n\t\t\t\tProgram(node) {\n\t\t\t\t\tif (!assembly) return\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (statement.type === 'ImportDeclaration' || statement.type === 'EmptyStatement')\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\tconst declaration =\n\t\t\t\t\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tdeclaration?.type !== 'VariableDeclaration' ||\n\t\t\t\t\t\t\tdeclaration.declarations.some((item) => item.init?.type !== 'CallExpression')\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tflag(statement)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tsources.CallExpression?.(node)\n\t\t\t\t\tif (assembly) {\n\t\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\t\tconst assemblyCall =\n\t\t\t\t\t\t\t(ref?.source === 'cvx-kit/table' && ref.name === 'createModule') ||\n\t\t\t\t\t\t\t(ref?.source === 'cvx-kit/table' && ref.name === 'namespaceIndex')\n\t\t\t\t\t\tif (!assemblyCall) flag(node)\n\t\t\t\t\t}\n\t\t\t\t\tconst method = node.callee.type === 'MemberExpression' ? propertyName(node.callee) : null\n\t\t\t\t\tif (\n\t\t\t\t\t\t(pure || declarative) &&\n\t\t\t\t\t\t(isDbAccess(node) ||\n\t\t\t\t\t\t\t['runQuery', 'runMutation', 'runAction', 'runAfter', 'runAt'].includes(method ?? ''))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tread &&\n\t\t\t\t\t\t(isDbWrite(node) ||\n\t\t\t\t\t\t\t['runMutation', 'runAction', 'runAfter', 'runAt'].includes(method ?? ''))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tconst constructor = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tconstructor &&\n\t\t\t\t\t\tisFunctionsImport(context, constructor.source) &&\n\t\t\t\t\t\t(pure || declarative || (read && /(?:Mutation|Action)$/.test(constructor.name)))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tread &&\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression' &&\n\t\t\t\t\t\tpropertyName(node.callee.object) === 'storage' &&\n\t\t\t\t\t\t['store', 'delete', 'generateUploadUrl'].includes(method ?? '')\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t\tif (!actionSide && isExternalCall(context, node)) flag(node)\n\t\t\t\t\tif (\n\t\t\t\t\t\tpure &&\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression' &&\n\t\t\t\t\t\tnode.callee.object.type === 'Identifier' &&\n\t\t\t\t\t\t!binding(context, node.callee.object)?.defs.length &&\n\t\t\t\t\t\t((node.callee.object.name === 'Date' && method === 'now') ||\n\t\t\t\t\t\t\t(node.callee.object.name === 'Math' && method === 'random'))\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tProperty(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\trole === 'contracts' &&\n\t\t\t\t\t\t['handler', 'context', 'audit', 'prepare', 'middleware', 'guard'].includes(\n\t\t\t\t\t\t\tnode.key.type === 'Identifier'\n\t\t\t\t\t\t\t\t? node.key.name\n\t\t\t\t\t\t\t\t: String(node.key.type === 'Literal' ? node.key.value : ''),\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tMemberExpression(node) {\n\t\t\t\t\tif (pure && ['db', 'storage', 'scheduler', 'env'].includes(propertyName(node) ?? ''))\n\t\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\tNewExpression(node) {\n\t\t\t\t\tif (!(pure || read || declarative)) return\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.callee.type === 'Identifier' &&\n\t\t\t\t\t\t!binding(context, node.callee)?.defs.length &&\n\t\t\t\t\t\t['Error', 'TypeError', 'RangeError', 'Set', 'Map', 'RegExp'].includes(node.callee.name)\n\t\t\t\t\t)\n\t\t\t\t\t\treturn\n\t\t\t\t\tflag(node)\n\t\t\t\t},\n\t\t\t\t'Program:exit'() {\n\t\t\t\t\tif (issue) context.report({ node: issue, messageId: 'ownership' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n} satisfies Record<string, CreateRule>\n\nexport type OwnershipRuleName = keyof typeof ownershipRules\n"],"mappings":"A,+kBA+BA,MAAaA,EAAiB,CAC7B,oBAAqB,CACpB,KAAMC,EAAS,qEAAsE,CACpF,UAAW,uBACZ,CAAC,EACD,OAAO,EAAS,CACf,IAAMC,EAAWC,EAAgB,MAAMC,EAAQ,QAAQ,IAAM,CAAC,CAAC,EACzDC,EAAOC,EAAQF,EAAQ,IAAKF,EAAS,SAAS,EAOpD,OALEK,EAAWH,EAAQ,QAAQ,EACzBI,EAAaJ,EAAQ,QAAQ,EAC7BE,EAAQF,EAAQ,QAAQ,KAAOK,EAAmBJ,CAAI,EAGnD,CACN,QAAQ,EAAM,CACb,IAAK,IAAMK,KAASC,EAAoB,CACvC,IAAKP,EAAQ,IACb,UAAWF,EAAS,UACpB,cAAeA,EAAS,aACzB,CAAC,EACAE,EAAQ,OAAO,CACd,OACA,UAAW,YACX,KAAM,CAAE,KAAMM,EAAM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4 @@
|
|
|
1
1
|
import { CreateRule } from "@oxlint/plugins";
|
|
2
|
-
//#region src/oxlint/reserved-files.d.ts
|
|
3
2
|
/** Reserved files prove their exported declaration's provenance, not an unused import. */
|
|
4
3
|
export declare const reservedDomainFiles: CreateRule;
|
|
5
|
-
//#endregion
|
|
6
4
|
//# sourceMappingURL=reserved-files.d.mts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{appFile as e,exportName as t,metadata as n,propertyName as r}from"./ast.mjs";import{createResolver as i,resolveImport as a}from"./architecture.mjs";import{readFileSync as o}from"node:fs";import{parseSync as s}from"oxc-parser";const c={meta:n(`Require kit-backed declarations in reserved domain files.`,{anatomy:`{{file}} must export {{expected}} built with cvx-kit; imports or local lookalikes do not count.`}),create(t){let n=e(t)??``,r=n.match(/^domain\/(?:.+\/)?(commands|queries|contracts|schema|table)\.ts$/);if(!r)return{};let i=r[1];return{Program(e){let r=u(t,e,t.filename),a=l(e).map(e=>r(e)),o=i===`commands`?`one Command registry`:i===`queries`?`one Query registry`:i===`schema`?`kTable shapes`:i===`contracts`?`declarative contracts`:n===`domain/table.ts`?`createModule assembly`:`a table topology map`,s=i===`commands`?`registry:Command`:i===`queries`?`registry:Query`:i===`schema`?`shape`:i===`contracts`?`contract`:n===`domain/table.ts`?`assembly`:`topology`,c=a.filter(e=>e===s).length;(i===`commands`||i===`queries`?c===1:c>0)||t.report({node:e,messageId:`anatomy`,data:{file:n,expected:o}})}}}};function l(e){let n=[],r=/* @__PURE__ */ new Map;for(let t of e.body){let e=t.type===`ExportNamedDeclaration`?t.declaration:t;if(e?.type===`VariableDeclaration`&&e.kind===`const`)for(let i of e.declarations)i.id.type===`Identifier`&&i.init&&(r.set(i.id.name,i.init),t.type===`ExportNamedDeclaration`&&n.push(i.init))}for(let i of e.body){if(i.type===`ExportNamedDeclaration`&&i.exportKind!==`type`&&!i.source)for(let e of i.specifiers){if(e.exportKind===`type`)continue;let i=r.get(t(e.local)??``);i&&n.push(i)}i.type===`ExportDefaultDeclaration`&&i.declaration.type!==`FunctionDeclaration`&&i.declaration.type!==`ClassDeclaration`&&i.declaration.type!==`TSInterfaceDeclaration`&&n.push(i.declaration)}return n}function u(n,c,l,d=/* @__PURE__ */ new Set){let f=/* @__PURE__ */ new Map,p=/* @__PURE__ */ new Map,m=i();for(let e of c.body){if(e.type===`ImportDeclaration`&&e.importKind!==`type`)for(let n of e.specifiers)(n.type!==`ImportSpecifier`||n.importKind!==`type`)&&f.set(n.local.name,{source:e.source.value,name:n.type===`ImportSpecifier`?t(n.imported)??``:n.type===`ImportNamespaceSpecifier`?`*`:`default`});let n=e.type===`ExportNamedDeclaration`?e.declaration:e;if(n?.type===`VariableDeclaration`&&n.kind===`const`){for(let e of n.declarations)if(e.init&&(e.id.type===`Identifier`&&p.set(e.id.name,{expression:e.init}),e.id.type===`ObjectPattern`))for(let n of e.id.properties)n.type===`Property`&&n.value.type===`Identifier`&&p.set(n.value.name,{expression:e.init,member:t(n.key)??``})}}function h(r,i){if([`cvx-kit`,`cvx-kit/effect`,`cvx-kit/components/foundation`,`cvx-kit/contracts`,`cvx-kit/table`,`cvx-kit/errors`].includes(r))return i===`*`?`namespace:${r}`:r===`cvx-kit`&&i===`k`?`validator`:r===`cvx-kit/effect`&&i===`createEffectFoundation`||r===`cvx-kit`&&i===`createFoundation`||[`cvx-kit`,`cvx-kit/components/foundation`].includes(r)&&i===`Foundation`?`foundationFactory`:[`cvx-kit`,`cvx-kit/table`].includes(r)&&[`kTable`,`kVariantTable`].includes(i)?`shapeFactory`:[`cvx-kit`,`cvx-kit/table`].includes(r)&&i===`createModule`?`assemblyFactory`:r===`cvx-kit/table`&&i===`namespace`?`namespaceFactory`:r===`cvx-kit/contracts`&&[`defineDomainContract`,`operationContract`].includes(i)||r===`cvx-kit/errors`&&i===`defineErrorContract`?`contractFactory`:null;if([`zod`,`zod/v4`,`convex/values`].includes(r)||r===`cvx-kit/k`&&i===`k`)return`validator`;let c=a(m,l,r),f=c&&e(n,c);if(!c||!f||!/^(?:foundation\.ts|domain\/.+\/(?:schema|contracts)\.ts)$/.test(f)||d.has(c)||d.size>=6)return null;if(i===`*`)return`namespace:${r}`;let p=s(c,o(c,`utf8`));if(p.errors.length)return null;let h=p.program,g=u(n,h,c,new Set(d).add(c));for(let e of h.body)if(e.type===`ExportNamedDeclaration`&&e.exportKind!==`type`){if(e.declaration?.type===`VariableDeclaration`)for(let t of e.declaration.declarations){if(t.id.type===`Identifier`&&t.id.name===i)return g(t.id);if(t.id.type===`ObjectPattern`){for(let e of t.id.properties)if(e.type===`Property`&&e.value.type===`Identifier`&&e.value.name===i)return g(e.value)}}for(let n of e.specifiers)if(n.exportKind!==`type`&&t(n.exported)===i&&!e.source)return g(n.local)}return null}function g(e,t){return e===`foundation`&&[`Command`,`Query`].includes(t)?t:e?.startsWith(`namespace:`)?h(e.slice(10),t):e===`validator`||e===`contract`?`validator`:e===`shape`&&t===`table`?`table`:e===`table`&&[`index`,`searchIndex`,`vectorIndex`].includes(t)?`indexFactory`:null}function _(e,t=/* @__PURE__ */ new Set){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`||e.type===`TSNonNullExpression`)return _(e.expression,t);if(e.type===`Identifier`){if(t.has(e.name))return null;let n=f.get(e.name);if(n)return h(n.source,n.name);let r=p.get(e.name);if(!r)return null;let i=_(r.expression,new Set(t).add(e.name));return r.member?g(i,r.member):i}if(e.type===`MemberExpression`)return g(_(e.object,t),r(e)??``);if(e.type===`CallExpression`||e.type===`NewExpression`){let n=_(e.callee,t);if(n===`foundationFactory`)return`foundation`;if(n===`Command`||n===`Query`)return`registry:${n}`;if(n===`shapeFactory`)return`shape`;if(n===`assemblyFactory`)return`assembly`;if(n===`contractFactory`||n===`validator`)return`contract`;if(n===`indexFactory`)return`table`;if(n===`namespaceFactory`){let n=e.arguments[1];if(n?.type!==`ObjectExpression`)return null;let r=n.properties.map(e=>e.type===`Property`?_(e.value,t):null);return r.length&&r.every(e=>e===`table`||e===`topology`||e===`shape`)?`topology`:null}return null}if(e.type===`ObjectExpression`){let n=e.properties.map(e=>e.type===`Property`?_(e.value,t):null);if(n.length&&n.every(e=>e===`table`||e===`topology`))return`topology`;if(n.some(e=>e===`contract`||e===`validator`)&&n.every(e=>e===`contract`||e===`validator`||e===`data`))return`contract`;if(n.every(e=>e===`data`))return`data`}return e.type===`Literal`?`data`:null}return _}export{c as reservedDomainFiles};
|
|
2
2
|
//# sourceMappingURL=reserved-files.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reserved-files.mjs","names":["reservedDomainFiles","metadata","file","appFile","context","match","role","evaluate","provenance","program","values","publicExpressions","expression","expected","wanted","count","value","expressions","declarations","statement","declaration","item","specifier","exportName","imports","variables","resolver","createResolver","property","imported","source","name","target","resolveImport","filename","visited","parsed","parseSync","readFileSync","remote","evaluateRemote","member","owner","node","active","reference","variable","propertyName","callee","members"],"sources":["../../src/oxlint/reserved-files.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport type { Context, CreateRule, ESTree } from '@oxlint/plugins'\nimport { parseSync } from 'oxc-parser'\nimport { appFile, metadata, propertyName, exportName } from './ast'\nimport { createResolver, resolveImport } from './architecture'\n\n/** Reserved files prove their exported declaration's provenance, not an unused import. */\nexport const reservedDomainFiles: CreateRule = {\n\tmeta: metadata('Require kit-backed declarations in reserved domain files.', {\n\t\tanatomy:\n\t\t\t'{{file}} must export {{expected}} built with cvx-kit; imports or local lookalikes do not count.',\n\t}),\n\tcreate(context) {\n\t\tconst file = appFile(context) ?? ''\n\t\tconst match = file.match(/^domain\\/(?:.+\\/)?(commands|queries|contracts|schema|table)\\.ts$/)\n\t\tif (!match) return {}\n\t\tconst role = match[1]\n\t\treturn {\n\t\t\tProgram(program) {\n\t\t\t\tconst evaluate = provenance(context, program, context.filename)\n\t\t\t\tconst exports = publicExpressions(program)\n\t\t\t\tconst values = exports.map((expression) => evaluate(expression))\n\t\t\t\tconst expected =\n\t\t\t\t\trole === 'commands'\n\t\t\t\t\t\t? 'one Command registry'\n\t\t\t\t\t\t: role === 'queries'\n\t\t\t\t\t\t\t? 'one Query registry'\n\t\t\t\t\t\t\t: role === 'schema'\n\t\t\t\t\t\t\t\t? 'zodTable shapes'\n\t\t\t\t\t\t\t\t: role === 'contracts'\n\t\t\t\t\t\t\t\t\t? 'declarative contracts'\n\t\t\t\t\t\t\t\t\t: file === 'domain/table.ts'\n\t\t\t\t\t\t\t\t\t\t? 'createModule assembly'\n\t\t\t\t\t\t\t\t\t\t: 'a table topology map'\n\t\t\t\tconst wanted =\n\t\t\t\t\trole === 'commands'\n\t\t\t\t\t\t? 'registry:Command'\n\t\t\t\t\t\t: role === 'queries'\n\t\t\t\t\t\t\t? 'registry:Query'\n\t\t\t\t\t\t\t: role === 'schema'\n\t\t\t\t\t\t\t\t? 'shape'\n\t\t\t\t\t\t\t\t: role === 'contracts'\n\t\t\t\t\t\t\t\t\t? 'contract'\n\t\t\t\t\t\t\t\t\t: file === 'domain/table.ts'\n\t\t\t\t\t\t\t\t\t\t? 'assembly'\n\t\t\t\t\t\t\t\t\t\t: 'topology'\n\t\t\t\tconst count = values.filter((value) => value === wanted).length\n\t\t\t\tconst valid = role === 'commands' || role === 'queries' ? count === 1 : count > 0\n\t\t\t\tif (!valid)\n\t\t\t\t\tcontext.report({ node: program, messageId: 'anatomy', data: { file, expected } })\n\t\t\t},\n\t\t}\n\t},\n}\n\nfunction publicExpressions(program: ESTree.Program): ESTree.Expression[] {\n\tconst expressions: ESTree.Expression[] = []\n\tconst declarations = new Map<string, ESTree.Expression>()\n\tfor (const statement of program.body) {\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type === 'VariableDeclaration' && declaration.kind === 'const')\n\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\tif (item.id.type === 'Identifier' && item.init) {\n\t\t\t\t\tdeclarations.set(item.id.name, item.init)\n\t\t\t\t\tif (statement.type === 'ExportNamedDeclaration') expressions.push(item.init)\n\t\t\t\t}\n\t\t\t}\n\t}\n\tfor (const statement of program.body) {\n\t\tif (\n\t\t\tstatement.type === 'ExportNamedDeclaration' &&\n\t\t\tstatement.exportKind !== 'type' &&\n\t\t\t!statement.source\n\t\t)\n\t\t\tfor (const specifier of statement.specifiers) {\n\t\t\t\tif (specifier.exportKind === 'type') continue\n\t\t\t\tconst expression = declarations.get(exportName(specifier.local) ?? '')\n\t\t\t\tif (expression) expressions.push(expression)\n\t\t\t}\n\t\tif (\n\t\t\tstatement.type === 'ExportDefaultDeclaration' &&\n\t\t\tstatement.declaration.type !== 'FunctionDeclaration' &&\n\t\t\tstatement.declaration.type !== 'ClassDeclaration' &&\n\t\t\tstatement.declaration.type !== 'TSInterfaceDeclaration'\n\t\t) {\n\t\t\texpressions.push(statement.declaration)\n\t\t}\n\t}\n\treturn expressions\n}\n\nfunction provenance(\n\tcontext: Context,\n\tprogram: ESTree.Program,\n\tfilename: string,\n\tvisited = new Set<string>(),\n) {\n\tconst imports = new Map<string, { source: string; name: string }>()\n\tconst variables = new Map<string, { expression: ESTree.Expression; member?: string }>()\n\tconst resolver = createResolver()\n\tfor (const statement of program.body) {\n\t\tif (statement.type === 'ImportDeclaration' && statement.importKind !== 'type')\n\t\t\tfor (const specifier of statement.specifiers) {\n\t\t\t\tif (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') continue\n\t\t\t\timports.set(specifier.local.name, {\n\t\t\t\t\tsource: statement.source.value,\n\t\t\t\t\tname:\n\t\t\t\t\t\tspecifier.type === 'ImportSpecifier'\n\t\t\t\t\t\t\t? (exportName(specifier.imported) ?? '')\n\t\t\t\t\t\t\t: specifier.type === 'ImportNamespaceSpecifier'\n\t\t\t\t\t\t\t\t? '*'\n\t\t\t\t\t\t\t\t: 'default',\n\t\t\t\t})\n\t\t\t}\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type === 'VariableDeclaration' && declaration.kind === 'const')\n\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\tif (!item.init) continue\n\t\t\t\tif (item.id.type === 'Identifier') variables.set(item.id.name, { expression: item.init })\n\t\t\t\tif (item.id.type === 'ObjectPattern')\n\t\t\t\t\tfor (const property of item.id.properties) {\n\t\t\t\t\t\tif (property.type === 'Property' && property.value.type === 'Identifier')\n\t\t\t\t\t\t\tvariables.set(property.value.name, {\n\t\t\t\t\t\t\t\texpression: item.init,\n\t\t\t\t\t\t\t\tmember: exportName(property.key) ?? '',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t}\n\t}\n\tfunction imported(source: string, name: string): string | null {\n\t\tif (\n\t\t\t[\n\t\t\t\t'cvx-kit',\n\t\t\t\t'cvx-kit/effect',\n\t\t\t\t'cvx-kit/components/foundation',\n\t\t\t\t'cvx-kit/contracts',\n\t\t\t\t'cvx-kit/zod-table',\n\t\t\t\t'cvx-kit/errors',\n\t\t\t].includes(source)\n\t\t) {\n\t\t\tif (name === '*') return `namespace:${source}`\n\t\t\tif (\n\t\t\t\t(source === 'cvx-kit/effect' && name === 'createEffectFoundation') ||\n\t\t\t\t(source === 'cvx-kit' && name === 'createFoundation') ||\n\t\t\t\t(['cvx-kit', 'cvx-kit/components/foundation'].includes(source) && name === 'Foundation')\n\t\t\t)\n\t\t\t\treturn 'foundationFactory'\n\t\t\tif (\n\t\t\t\t['cvx-kit', 'cvx-kit/zod-table'].includes(source) &&\n\t\t\t\t['zodTable', 'zodVariantTable'].includes(name)\n\t\t\t)\n\t\t\t\treturn 'shapeFactory'\n\t\t\tif (['cvx-kit', 'cvx-kit/zod-table'].includes(source) && name === 'createModule')\n\t\t\t\treturn 'assemblyFactory'\n\t\t\tif (source === 'cvx-kit/zod-table' && name === 'namespace') return 'namespaceFactory'\n\t\t\tif (\n\t\t\t\tsource === 'cvx-kit/contracts' &&\n\t\t\t\t['defineDomainContract', 'operationContract'].includes(name)\n\t\t\t)\n\t\t\t\treturn 'contractFactory'\n\t\t\tif (source === 'cvx-kit/errors' && name === 'defineErrorContract') return 'contractFactory'\n\t\t\treturn null\n\t\t}\n\t\tif (['zod', 'zod/v4', 'convex/values'].includes(source)) return 'validator'\n\t\tconst target = resolveImport(resolver, filename, source)\n\t\tconst file = target && appFile(context, target)\n\t\tif (\n\t\t\t!target ||\n\t\t\t!file ||\n\t\t\t!/^(?:foundation\\.ts|domain\\/.+\\/(?:schema|contracts)\\.ts)$/.test(file) ||\n\t\t\tvisited.has(target) ||\n\t\t\tvisited.size >= 6\n\t\t)\n\t\t\treturn null\n\t\tif (name === '*') return `namespace:${source}`\n\t\tconst parsed = parseSync(target, readFileSync(target, 'utf8'))\n\t\tif (parsed.errors.length) return null\n\t\t// SAFETY: oxc-parser and the rule API share these declaration fields; provenance never reads rule-API loc/tokens.\n\t\t// oxlint-disable-next-line anti-slop/no-chained-type-assertions\n\t\tconst remote = parsed.program as unknown as ESTree.Program\n\t\tconst nextVisited = new Set(visited).add(target)\n\t\tconst evaluateRemote = provenance(context, remote, target, nextVisited)\n\t\tfor (const statement of remote.body) {\n\t\t\tif (statement.type !== 'ExportNamedDeclaration' || statement.exportKind === 'type') continue\n\t\t\tif (statement.declaration?.type === 'VariableDeclaration')\n\t\t\t\tfor (const item of statement.declaration.declarations) {\n\t\t\t\t\tif (item.id.type === 'Identifier' && item.id.name === name) return evaluateRemote(item.id)\n\t\t\t\t\tif (item.id.type === 'ObjectPattern')\n\t\t\t\t\t\tfor (const property of item.id.properties)\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t\t\t\tproperty.value.type === 'Identifier' &&\n\t\t\t\t\t\t\t\tproperty.value.name === name\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn evaluateRemote(property.value)\n\t\t\t\t}\n\t\t\tfor (const specifier of statement.specifiers)\n\t\t\t\tif (\n\t\t\t\t\tspecifier.exportKind !== 'type' &&\n\t\t\t\t\texportName(specifier.exported) === name &&\n\t\t\t\t\t!statement.source\n\t\t\t\t)\n\t\t\t\t\treturn evaluateRemote(specifier.local)\n\t\t}\n\t\treturn null\n\t}\n\tfunction member(owner: string | null, name: string): string | null {\n\t\tif (owner === 'foundation' && ['Command', 'Query'].includes(name)) return name\n\t\tif (owner?.startsWith('namespace:')) return imported(owner.slice(10), name)\n\t\tif (owner === 'validator' || owner === 'contract') return 'validator'\n\t\tif (owner === 'shape' && name === 'table') return 'table'\n\t\tif (owner === 'table' && ['index', 'searchIndex', 'vectorIndex'].includes(name))\n\t\t\treturn 'indexFactory'\n\t\treturn null\n\t}\n\tfunction evaluate(node: ESTree.Node, active = new Set<string>()): string | null {\n\t\tif (\n\t\t\tnode.type === 'TSAsExpression' ||\n\t\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\t\tnode.type === 'TSNonNullExpression'\n\t\t)\n\t\t\treturn evaluate(node.expression, active)\n\t\tif (node.type === 'Identifier') {\n\t\t\tif (active.has(node.name)) return null\n\t\t\tconst reference = imports.get(node.name)\n\t\t\tif (reference) return imported(reference.source, reference.name)\n\t\t\tconst variable = variables.get(node.name)\n\t\t\tif (!variable) return null\n\t\t\tconst value = evaluate(variable.expression, new Set(active).add(node.name))\n\t\t\treturn variable.member ? member(value, variable.member) : value\n\t\t}\n\t\tif (node.type === 'MemberExpression')\n\t\t\treturn member(evaluate(node.object, active), propertyName(node) ?? '')\n\t\tif (node.type === 'CallExpression' || node.type === 'NewExpression') {\n\t\t\tconst callee = evaluate(node.callee, active)\n\t\t\tif (callee === 'foundationFactory') return 'foundation'\n\t\t\tif (callee === 'Command' || callee === 'Query') return `registry:${callee}`\n\t\t\tif (callee === 'shapeFactory') return 'shape'\n\t\t\tif (callee === 'assemblyFactory') return 'assembly'\n\t\t\tif (callee === 'contractFactory' || callee === 'validator') return 'contract'\n\t\t\tif (callee === 'indexFactory') return 'table'\n\t\t\tif (callee === 'namespaceFactory') {\n\t\t\t\t// namespace(name, members) is a topology map when every member is a table\n\t\t\t\t// definition or a table boundary (namespace() unwraps boundaries itself).\n\t\t\t\tconst members = node.arguments[1]\n\t\t\t\tif (members?.type !== 'ObjectExpression') return null\n\t\t\t\tconst values = members.properties.map((property) =>\n\t\t\t\t\tproperty.type === 'Property' ? evaluate(property.value, active) : null,\n\t\t\t\t)\n\t\t\t\treturn values.length &&\n\t\t\t\t\tvalues.every((value) => value === 'table' || value === 'topology' || value === 'shape')\n\t\t\t\t\t? 'topology'\n\t\t\t\t\t: null\n\t\t\t}\n\t\t\treturn null\n\t\t}\n\t\tif (node.type === 'ObjectExpression') {\n\t\t\tconst values = node.properties.map((property) =>\n\t\t\t\tproperty.type === 'Property' ? evaluate(property.value, active) : null,\n\t\t\t)\n\t\t\tif (values.length && values.every((value) => value === 'table' || value === 'topology'))\n\t\t\t\treturn 'topology'\n\t\t\tif (\n\t\t\t\tvalues.some((value) => value === 'contract' || value === 'validator') &&\n\t\t\t\tvalues.every((value) => value === 'contract' || value === 'validator' || value === 'data')\n\t\t\t)\n\t\t\t\treturn 'contract'\n\t\t\tif (values.every((value) => value === 'data')) return 'data'\n\t\t}\n\t\tif (node.type === 'Literal') return 'data'\n\t\treturn null\n\t}\n\treturn evaluate\n}\n"],"mappings":"yOAOA,MAAaA,EAAkC,CAC9C,KAAMC,EAAS,4DAA6D,CAC3E,QACC,iGACF,CAAC,EACD,OAAO,EAAS,CACf,IAAMC,EAAOC,EAAQC,CAAO,GAAK,GAC3BC,EAAQH,EAAK,MAAM,kEAAkE,EAC3F,GAAI,CAACG,EAAO,MAAO,CAAC,EACpB,IAAMC,EAAOD,EAAM,GACnB,MAAO,CACN,QAAQ,EAAS,CAChB,IAAME,EAAWC,EAAWJ,EAASK,EAASL,EAAQ,QAAQ,EAExDM,EADUC,EAAkBF,CACb,CAAC,CAAC,IAAK,GAAeF,EAASK,CAAU,CAAC,EACzDC,EACLP,IAAS,WACN,uBACAA,IAAS,UACR,qBACAA,IAAS,SACR,kBACAA,I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,OAAS,kBAAoBA,EAAK,OAAS,gBAAiB,CACpE,IAAMK,EAASzC,EAASoC,EAAK,OAAQC,CAAM,EAC3C,GAAII,IAAW,oBAAqB,MAAO,aAC3C,GAAIA,IAAW,WAAaA,IAAW,QAAS,MAAO,YAAYA,IACnE,GAAIA,IAAW,eAAgB,MAAO,QACtC,GAAIA,IAAW,kBAAmB,MAAO,WACzC,GAAIA,IAAW,mBAAqBA,IAAW,YAAa,MAAO,WACnE,GAAIA,IAAW,eAAgB,MAAO,QACtC,GAAIA,IAAW,mBAAoB,CAGlC,IAAMC,EAAUN,EAAK,UAAU,GAC/B,GAAIM,GAAS,OAAS,mBAAoB,OAAO,KACjD,IAAMvC,EAASuC,EAAQ,WAAW,IAAK,GACtCrB,EAAS,OAAS,WAAarB,EAASqB,EAAS,MAAOgB,CAAM,EAAI,IACnE,EACA,OAAOlC,EAAO,QACbA,EAAO,MAAO,GAAUM,IAAU,SAAWA,IAAU,YAAcA,IAAU,OAAO,EACpF,WACA,IACJ,CACA,OAAO,IACR,CACA,GAAI2B,EAAK,OAAS,mBAAoB,CACrC,IAAMjC,EAASiC,EAAK,WAAW,IAAK,GACnCf,EAAS,OAAS,WAAarB,EAASqB,EAAS,MAAOgB,CAAM,EAAI,IACnE,EACA,GAAIlC,EAAO,QAAUA,EAAO,MAAO,GAAUM,IAAU,SAAWA,IAAU,UAAU,EACrF,MAAO,WACR,GACCN,EAAO,KAAM,GAAUM,IAAU,YAAcA,IAAU,WAAW,GACpEN,EAAO,MAAO,GAAUM,IAAU,YAAcA,IAAU,aAAeA,IAAU,MAAM,EAEzF,MAAO,WACR,GAAIN,EAAO,MAAO,GAAUM,IAAU,MAAM,EAAG,MAAO,MACvD,CAEA,OADI2B,EAAK,OAAS,UAAkB,OAC7B,IACR,CACA,OAAOpC,CACR"}
|
|
1
|
+
{"version":3,"file":"reserved-files.mjs","names":["reservedDomainFiles","metadata","file","appFile","context","match","role","evaluate","provenance","program","values","publicExpressions","expression","expected","wanted","count","value","expressions","declarations","statement","declaration","item","specifier","exportName","imports","variables","resolver","createResolver","property","imported","source","name","target","resolveImport","filename","visited","parsed","parseSync","readFileSync","remote","evaluateRemote","member","owner","node","active","reference","variable","propertyName","callee","members"],"sources":["../../src/oxlint/reserved-files.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport type { Context, CreateRule, ESTree } from '@oxlint/plugins'\nimport { parseSync } from 'oxc-parser'\nimport { appFile, metadata, propertyName, exportName } from './ast'\nimport { createResolver, resolveImport } from './architecture'\n\n/** Reserved files prove their exported declaration's provenance, not an unused import. */\nexport const reservedDomainFiles: CreateRule = {\n\tmeta: metadata('Require kit-backed declarations in reserved domain files.', {\n\t\tanatomy:\n\t\t\t'{{file}} must export {{expected}} built with cvx-kit; imports or local lookalikes do not count.',\n\t}),\n\tcreate(context) {\n\t\tconst file = appFile(context) ?? ''\n\t\tconst match = file.match(/^domain\\/(?:.+\\/)?(commands|queries|contracts|schema|table)\\.ts$/)\n\t\tif (!match) return {}\n\t\tconst role = match[1]\n\t\treturn {\n\t\t\tProgram(program) {\n\t\t\t\tconst evaluate = provenance(context, program, context.filename)\n\t\t\t\tconst exports = publicExpressions(program)\n\t\t\t\tconst values = exports.map((expression) => evaluate(expression))\n\t\t\t\tconst expected =\n\t\t\t\t\trole === 'commands'\n\t\t\t\t\t\t? 'one Command registry'\n\t\t\t\t\t\t: role === 'queries'\n\t\t\t\t\t\t\t? 'one Query registry'\n\t\t\t\t\t\t\t: role === 'schema'\n\t\t\t\t\t\t\t\t? 'kTable shapes'\n\t\t\t\t\t\t\t\t: role === 'contracts'\n\t\t\t\t\t\t\t\t\t? 'declarative contracts'\n\t\t\t\t\t\t\t\t\t: file === 'domain/table.ts'\n\t\t\t\t\t\t\t\t\t\t? 'createModule assembly'\n\t\t\t\t\t\t\t\t\t\t: 'a table topology map'\n\t\t\t\tconst wanted =\n\t\t\t\t\trole === 'commands'\n\t\t\t\t\t\t? 'registry:Command'\n\t\t\t\t\t\t: role === 'queries'\n\t\t\t\t\t\t\t? 'registry:Query'\n\t\t\t\t\t\t\t: role === 'schema'\n\t\t\t\t\t\t\t\t? 'shape'\n\t\t\t\t\t\t\t\t: role === 'contracts'\n\t\t\t\t\t\t\t\t\t? 'contract'\n\t\t\t\t\t\t\t\t\t: file === 'domain/table.ts'\n\t\t\t\t\t\t\t\t\t\t? 'assembly'\n\t\t\t\t\t\t\t\t\t\t: 'topology'\n\t\t\t\tconst count = values.filter((value) => value === wanted).length\n\t\t\t\tconst valid = role === 'commands' || role === 'queries' ? count === 1 : count > 0\n\t\t\t\tif (!valid)\n\t\t\t\t\tcontext.report({ node: program, messageId: 'anatomy', data: { file, expected } })\n\t\t\t},\n\t\t}\n\t},\n}\n\nfunction publicExpressions(program: ESTree.Program): ESTree.Expression[] {\n\tconst expressions: ESTree.Expression[] = []\n\tconst declarations = new Map<string, ESTree.Expression>()\n\tfor (const statement of program.body) {\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type === 'VariableDeclaration' && declaration.kind === 'const')\n\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\tif (item.id.type === 'Identifier' && item.init) {\n\t\t\t\t\tdeclarations.set(item.id.name, item.init)\n\t\t\t\t\tif (statement.type === 'ExportNamedDeclaration') expressions.push(item.init)\n\t\t\t\t}\n\t\t\t}\n\t}\n\tfor (const statement of program.body) {\n\t\tif (\n\t\t\tstatement.type === 'ExportNamedDeclaration' &&\n\t\t\tstatement.exportKind !== 'type' &&\n\t\t\t!statement.source\n\t\t)\n\t\t\tfor (const specifier of statement.specifiers) {\n\t\t\t\tif (specifier.exportKind === 'type') continue\n\t\t\t\tconst expression = declarations.get(exportName(specifier.local) ?? '')\n\t\t\t\tif (expression) expressions.push(expression)\n\t\t\t}\n\t\tif (\n\t\t\tstatement.type === 'ExportDefaultDeclaration' &&\n\t\t\tstatement.declaration.type !== 'FunctionDeclaration' &&\n\t\t\tstatement.declaration.type !== 'ClassDeclaration' &&\n\t\t\tstatement.declaration.type !== 'TSInterfaceDeclaration'\n\t\t) {\n\t\t\texpressions.push(statement.declaration)\n\t\t}\n\t}\n\treturn expressions\n}\n\nfunction provenance(\n\tcontext: Context,\n\tprogram: ESTree.Program,\n\tfilename: string,\n\tvisited = new Set<string>(),\n) {\n\tconst imports = new Map<string, { source: string; name: string }>()\n\tconst variables = new Map<string, { expression: ESTree.Expression; member?: string }>()\n\tconst resolver = createResolver()\n\tfor (const statement of program.body) {\n\t\tif (statement.type === 'ImportDeclaration' && statement.importKind !== 'type')\n\t\t\tfor (const specifier of statement.specifiers) {\n\t\t\t\tif (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') continue\n\t\t\t\timports.set(specifier.local.name, {\n\t\t\t\t\tsource: statement.source.value,\n\t\t\t\t\tname:\n\t\t\t\t\t\tspecifier.type === 'ImportSpecifier'\n\t\t\t\t\t\t\t? (exportName(specifier.imported) ?? '')\n\t\t\t\t\t\t\t: specifier.type === 'ImportNamespaceSpecifier'\n\t\t\t\t\t\t\t\t? '*'\n\t\t\t\t\t\t\t\t: 'default',\n\t\t\t\t})\n\t\t\t}\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tif (declaration?.type === 'VariableDeclaration' && declaration.kind === 'const')\n\t\t\tfor (const item of declaration.declarations) {\n\t\t\t\tif (!item.init) continue\n\t\t\t\tif (item.id.type === 'Identifier') variables.set(item.id.name, { expression: item.init })\n\t\t\t\tif (item.id.type === 'ObjectPattern')\n\t\t\t\t\tfor (const property of item.id.properties) {\n\t\t\t\t\t\tif (property.type === 'Property' && property.value.type === 'Identifier')\n\t\t\t\t\t\t\tvariables.set(property.value.name, {\n\t\t\t\t\t\t\t\texpression: item.init,\n\t\t\t\t\t\t\t\tmember: exportName(property.key) ?? '',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t}\n\t}\n\tfunction imported(source: string, name: string): string | null {\n\t\tif (\n\t\t\t[\n\t\t\t\t'cvx-kit',\n\t\t\t\t'cvx-kit/effect',\n\t\t\t\t'cvx-kit/components/foundation',\n\t\t\t\t'cvx-kit/contracts',\n\t\t\t\t'cvx-kit/table',\n\t\t\t\t'cvx-kit/errors',\n\t\t\t].includes(source)\n\t\t) {\n\t\t\tif (name === '*') return `namespace:${source}`\n\t\t\tif (source === 'cvx-kit' && name === 'k') return 'validator'\n\t\t\tif (\n\t\t\t\t(source === 'cvx-kit/effect' && name === 'createEffectFoundation') ||\n\t\t\t\t(source === 'cvx-kit' && name === 'createFoundation') ||\n\t\t\t\t(['cvx-kit', 'cvx-kit/components/foundation'].includes(source) && name === 'Foundation')\n\t\t\t)\n\t\t\t\treturn 'foundationFactory'\n\t\t\tif (\n\t\t\t\t['cvx-kit', 'cvx-kit/table'].includes(source) &&\n\t\t\t\t['kTable', 'kVariantTable'].includes(name)\n\t\t\t)\n\t\t\t\treturn 'shapeFactory'\n\t\t\tif (['cvx-kit', 'cvx-kit/table'].includes(source) && name === 'createModule')\n\t\t\t\treturn 'assemblyFactory'\n\t\t\tif (source === 'cvx-kit/table' && name === 'namespace') return 'namespaceFactory'\n\t\t\tif (\n\t\t\t\tsource === 'cvx-kit/contracts' &&\n\t\t\t\t['defineDomainContract', 'operationContract'].includes(name)\n\t\t\t)\n\t\t\t\treturn 'contractFactory'\n\t\t\tif (source === 'cvx-kit/errors' && name === 'defineErrorContract') return 'contractFactory'\n\t\t\treturn null\n\t\t}\n\t\t// A raw Zod import stays a validator so app-level Zod schemas in a contracts file are not flagged.\n\t\tif (['zod', 'zod/v4', 'convex/values'].includes(source)) return 'validator'\n\t\tif (source === 'cvx-kit/k' && name === 'k') return 'validator'\n\t\tconst target = resolveImport(resolver, filename, source)\n\t\tconst file = target && appFile(context, target)\n\t\tif (\n\t\t\t!target ||\n\t\t\t!file ||\n\t\t\t!/^(?:foundation\\.ts|domain\\/.+\\/(?:schema|contracts)\\.ts)$/.test(file) ||\n\t\t\tvisited.has(target) ||\n\t\t\tvisited.size >= 6\n\t\t)\n\t\t\treturn null\n\t\tif (name === '*') return `namespace:${source}`\n\t\tconst parsed = parseSync(target, readFileSync(target, 'utf8'))\n\t\tif (parsed.errors.length) return null\n\t\t// SAFETY: oxc-parser and the rule API share these declaration fields; provenance never reads rule-API loc/tokens.\n\t\t// oxlint-disable-next-line anti-slop/no-chained-type-assertions\n\t\tconst remote = parsed.program as unknown as ESTree.Program\n\t\tconst nextVisited = new Set(visited).add(target)\n\t\tconst evaluateRemote = provenance(context, remote, target, nextVisited)\n\t\tfor (const statement of remote.body) {\n\t\t\tif (statement.type !== 'ExportNamedDeclaration' || statement.exportKind === 'type') continue\n\t\t\tif (statement.declaration?.type === 'VariableDeclaration')\n\t\t\t\tfor (const item of statement.declaration.declarations) {\n\t\t\t\t\tif (item.id.type === 'Identifier' && item.id.name === name) return evaluateRemote(item.id)\n\t\t\t\t\tif (item.id.type === 'ObjectPattern')\n\t\t\t\t\t\tfor (const property of item.id.properties)\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t\t\t\tproperty.value.type === 'Identifier' &&\n\t\t\t\t\t\t\t\tproperty.value.name === name\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn evaluateRemote(property.value)\n\t\t\t\t}\n\t\t\tfor (const specifier of statement.specifiers)\n\t\t\t\tif (\n\t\t\t\t\tspecifier.exportKind !== 'type' &&\n\t\t\t\t\texportName(specifier.exported) === name &&\n\t\t\t\t\t!statement.source\n\t\t\t\t)\n\t\t\t\t\treturn evaluateRemote(specifier.local)\n\t\t}\n\t\treturn null\n\t}\n\tfunction member(owner: string | null, name: string): string | null {\n\t\tif (owner === 'foundation' && ['Command', 'Query'].includes(name)) return name\n\t\tif (owner?.startsWith('namespace:')) return imported(owner.slice(10), name)\n\t\tif (owner === 'validator' || owner === 'contract') return 'validator'\n\t\tif (owner === 'shape' && name === 'table') return 'table'\n\t\tif (owner === 'table' && ['index', 'searchIndex', 'vectorIndex'].includes(name))\n\t\t\treturn 'indexFactory'\n\t\treturn null\n\t}\n\tfunction evaluate(node: ESTree.Node, active = new Set<string>()): string | null {\n\t\tif (\n\t\t\tnode.type === 'TSAsExpression' ||\n\t\t\tnode.type === 'TSSatisfiesExpression' ||\n\t\t\tnode.type === 'TSNonNullExpression'\n\t\t)\n\t\t\treturn evaluate(node.expression, active)\n\t\tif (node.type === 'Identifier') {\n\t\t\tif (active.has(node.name)) return null\n\t\t\tconst reference = imports.get(node.name)\n\t\t\tif (reference) return imported(reference.source, reference.name)\n\t\t\tconst variable = variables.get(node.name)\n\t\t\tif (!variable) return null\n\t\t\tconst value = evaluate(variable.expression, new Set(active).add(node.name))\n\t\t\treturn variable.member ? member(value, variable.member) : value\n\t\t}\n\t\tif (node.type === 'MemberExpression')\n\t\t\treturn member(evaluate(node.object, active), propertyName(node) ?? '')\n\t\tif (node.type === 'CallExpression' || node.type === 'NewExpression') {\n\t\t\tconst callee = evaluate(node.callee, active)\n\t\t\tif (callee === 'foundationFactory') return 'foundation'\n\t\t\tif (callee === 'Command' || callee === 'Query') return `registry:${callee}`\n\t\t\tif (callee === 'shapeFactory') return 'shape'\n\t\t\tif (callee === 'assemblyFactory') return 'assembly'\n\t\t\tif (callee === 'contractFactory' || callee === 'validator') return 'contract'\n\t\t\tif (callee === 'indexFactory') return 'table'\n\t\t\tif (callee === 'namespaceFactory') {\n\t\t\t\t// namespace(name, members) is a topology map when every member is a table\n\t\t\t\t// definition or a table boundary (namespace() unwraps boundaries itself).\n\t\t\t\tconst members = node.arguments[1]\n\t\t\t\tif (members?.type !== 'ObjectExpression') return null\n\t\t\t\tconst values = members.properties.map((property) =>\n\t\t\t\t\tproperty.type === 'Property' ? evaluate(property.value, active) : null,\n\t\t\t\t)\n\t\t\t\treturn values.length &&\n\t\t\t\t\tvalues.every((value) => value === 'table' || value === 'topology' || value === 'shape')\n\t\t\t\t\t? 'topology'\n\t\t\t\t\t: null\n\t\t\t}\n\t\t\treturn null\n\t\t}\n\t\tif (node.type === 'ObjectExpression') {\n\t\t\tconst values = node.properties.map((property) =>\n\t\t\t\tproperty.type === 'Property' ? evaluate(property.value, active) : null,\n\t\t\t)\n\t\t\tif (values.length && values.every((value) => value === 'table' || value === 'topology'))\n\t\t\t\treturn 'topology'\n\t\t\tif (\n\t\t\t\tvalues.some((value) => value === 'contract' || value === 'validator') &&\n\t\t\t\tvalues.every((value) => value === 'contract' || value === 'validator' || value === 'data')\n\t\t\t)\n\t\t\t\treturn 'contract'\n\t\t\tif (values.every((value) => value === 'data')) return 'data'\n\t\t}\n\t\tif (node.type === 'Literal') return 'data'\n\t\treturn null\n\t}\n\treturn evaluate\n}\n"],"mappings":"A,yOAOA,MAAaA,EAAkC,CAC9C,KAAMC,EAAS,4DAA6D,CAC3E,QACC,iGACF,CAAC,EACD,OAAO,EAAS,CACf,IAAMC,EAAOC,EAAQC,CAAO,GAAK,GAC3BC,EAAQH,EAAK,MAAM,kEAAkE,EAC3F,GAAI,CAACG,EAAO,MAAO,CAAC,EACpB,IAAMC,EAAOD,EAAM,GACnB,MAAO,CACN,QAAQ,EAAS,CAChB,IAAME,EAAWC,EAAWJ,EAASK,EAASL,EAAQ,QAAQ,EAExDM,EADUC,EAAkBF,CACb,CAAC,CAAC,IAAK,GAAeF,EAASK,CAAU,CAAC,EACzDC,EACLP,IAAS,WACN,uBACAA,IAAS,UACR,qBACAA,IAAS,SACR,gBACAA,IAAS,YACR,wBACAJ,IAAS,kBACR,wBACA,uBACFY,EACLR,IAAS,WACN,mBACAA,IAAS,UACR,iBACAA,IAAS,SACR,QACAA,IAAS,YACR,WACAJ,IAAS,kBACR,WACA,WACFa,EAAQL,EAAO,OAAQ,GAAUM,IAAUF,CAAM,CAAC,CAAC,QAC3CR,IAAS,YAAcA,IAAS,UAAYS,IAAU,EAAIA,EAAQ,IAE/EX,EAAQ,OAAO,CAAE,KAAMK,EAAS,UAAW,UAAW,KAAM,CAAE,OAAM,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AAW,YAAa,MAAO,WACnE,GAAIA,IAAW,eAAgB,MAAO,QACtC,GAAIA,IAAW,mBAAoB,CAGlC,IAAMC,EAAUN,EAAK,UAAU,GAC/B,GAAIM,GAAS,OAAS,mBAAoB,OAAO,KACjD,IAAMvC,EAASuC,EAAQ,WAAW,IAAK,GACtCrB,EAAS,OAAS,WAAarB,EAASqB,EAAS,MAAOgB,CAAM,EAAI,IACnE,EACA,OAAOlC,EAAO,QACbA,EAAO,MAAO,GAAUM,IAAU,SAAWA,IAAU,YAAcA,IAAU,OAAO,EACpF,WACA,IACJ,CACA,OAAO,IACR,CACA,GAAI2B,EAAK,OAAS,mBAAoB,CACrC,IAAMjC,EAASiC,EAAK,WAAW,IAAK,GACnCf,EAAS,OAAS,WAAarB,EAASqB,EAAS,MAAOgB,CAAM,EAAI,IACnE,EACA,GAAIlC,EAAO,QAAUA,EAAO,MAAO,GAAUM,IAAU,SAAWA,IAAU,UAAU,EACrF,MAAO,WACR,GACCN,EAAO,KAAM,GAAUM,IAAU,YAAcA,IAAU,WAAW,GACpEN,EAAO,MAAO,GAAUM,IAAU,YAAcA,IAAU,aAAeA,IAAU,MAAM,EAEzF,MAAO,WACR,GAAIN,EAAO,MAAO,GAAUM,IAAU,MAAM,EAAG,MAAO,MACvD,CAEA,OADI2B,EAAK,OAAS,UAAkB,OAC7B,IACR,CACA,OAAOpC,CACR,C"}
|
package/dist/oxlint.d.mts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ArchitectureDiagnostic, ArchitectureOptions } from "./oxlint/architecture.mjs";
|
|
2
2
|
import { OwnershipRuleName } from "./oxlint/ownership.mjs";
|
|
3
3
|
import { Plugin, Rule } from "@oxlint/plugins";
|
|
4
|
-
//#region src/oxlint.d.ts
|
|
5
4
|
export declare function checkArchitecture(options?: ArchitectureOptions): ArchitectureDiagnostic[];
|
|
6
5
|
export type RuleName = OwnershipRuleName | 'component-boundaries' | 'no-component-env' | 'schema-file-boundaries' | 'no-internal-reexports' | 'public-api-first' | 'named-private-helpers' | 'no-raw-builders' | 'no-handwritten-references' | 'domain-import-boundaries' | 'public-functions-in-api' | 'thin-api-adapters' | 'no-inline-enums' | 'no-unbounded-reads' | 'no-manual-timestamps' | 'reserved-domain-file-anatomy' | 'root-facade-ownership' | 'no-manual-id-projection' | 'no-copied-pagination';
|
|
7
6
|
export declare const rules: Record<RuleName, Rule>;
|
|
8
7
|
declare const plugin: Plugin;
|
|
9
|
-
//#endregion
|
|
10
8
|
export { type ArchitectureDiagnostic, type ArchitectureOptions, plugin as default };
|
|
11
9
|
//# sourceMappingURL=oxlint.d.mts.map
|
package/dist/oxlint.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{forceRegistry as e}from"./modules/contracts/lazy.mjs";import{createResolver as t,inspectArchitecture as n,narrowRootDeclaration as r,resolveImport as i}from"./oxlint/architecture.mjs";import{appFile as a,binding as o,componentRoot as s,consumerOptions as c,exportName as l,exportedNames as u,imported as d,isDbWrite as f,isFunctionsImport as p,isTableChain as m,localInitializer as h,metadata as g,propertyName as _,readProvenance as v,sourceVisitors as y,staticString as b}from"./oxlint/ast.mjs";import{reservedDomainFiles as x}from"./oxlint/reserved-files.mjs";import{ownershipRules as S}from"./oxlint/ownership.mjs";import{basename as C,dirname as w,relative as T,sep as E}from"node:path";function D(t={}){for(let n of t.registries??[])e(n);return n(t)}const O=A({...S,"root-wiring-only":{...S[`root-wiring-only`],create(e){let t=a(e)??``;return[`relations.ts`,`querying.ts`].includes(t)?r(t,e.sourceCode.text)?{}:{Program(n){e.report({node:n,messageId:`ownership`,data:{reason:`${t} must export one kit factory declaration and contain only declarative configuration`}})}}:S[`root-wiring-only`].create(e)}},"reserved-domain-file-anatomy":x,"root-facade-ownership":{meta:g(`Configure shared kit infrastructure once in its root facade.`,{facade:`Configure {{name}} once in convex/{{file}}; import that facade elsewhere.`}),create(e){let t=s(e,e.filename),n=/* @__PURE__ */ new Set;function r(r){let i=d(e,r.callee);if(!i)return;let o=null;[`cvx-kit`,`cvx-kit/querying`].includes(i.source)&&i.name===`createQueryEngine`&&(o=`querying.ts`),[`cvx-kit`,`cvx-kit/relations`].includes(i.source)&&i.name===`defineRelations`&&(o=`relations.ts`),[`cvx-kit`,`cvx-kit/auth`].includes(i.source)&&i.name===`createAuthFunctions`&&(o=`functions.ts`),[`cvx-kit`,`cvx-kit/triggers`].includes(i.source)&&i.name===`createTriggers`&&(o=`triggers.ts`),[`cvx-kit`,`cvx-kit/components/foundation`].includes(i.source)&&i.name===`Foundation`&&(o=`foundation.ts`),(i.source===`cvx-kit/effect`&&i.name===`createEffectFoundation`||i.source===`cvx-kit`&&i.name===`createFoundation`)&&(o=`foundation.ts`),o&&(((t?T(t,e.filename).split(E).join(`/`):a(e))!==o||n.has(i.name))&&e.report({node:r,messageId:`facade`,data:{name:i.name,file:o}}),n.add(i.name))}return{CallExpression:r,NewExpression:r}}},"no-raw-builders":{meta:g(`Build host functions through the auth-aware root constructors.`,{builder:`Import raw builders only in convex/functions.ts; use auth*/role*/admin* or system* elsewhere.`}),create(e){let n=s(e,e.filename);if((n?T(n,e.filename).split(E).join(`/`):a(e))===`functions.ts`)return{};let r=t();return{ImportDeclaration(t){if(t.importKind===`type`)return;let o=t.source.value,s=i(r,e.filename,o),c=s?n?T(n,s).split(E).join(`/`):a(e,s):null,u=c?.startsWith(`_generated/`)?c:o;if(/(?:^|\/)_generated\/server(?:\.[cm]?[jt]s)?$/.test(u)||u===`convex/server`)for(let n of t.specifiers){if(n.type===`ImportSpecifier`&&n.importKind===`type`)continue;let t=n.type===`ImportSpecifier`?l(n.imported):null;(t===null&&u!==`convex/server`||t&&/^(?:internal)?(?:Query|Mutation|Action)(?:Generic)?$|^(?:query|mutation|action)(?:Generic)?$/.test(t))&&e.report({node:n,messageId:`builder`})}},CallExpression(t){let n=d(e,t.callee);n?.source===`convex/server`&&/^(?:internal)?(?:Query|Mutation|Action)Generic$|^(?:query|mutation|action)Generic$/.test(n.name)&&t.callee.type===`MemberExpression`&&e.report({node:t,messageId:`builder`})}}}},"no-handwritten-references":{meta:g(`Use generated api/internal references.`,{reference:`Use generated api/internal references instead of makeFunctionReference.`}),create(e){return{CallExpression(t){let n=d(e,t.callee);n?.source===`convex/server`&&n.name===`makeFunctionReference`&&e.report({node:t,messageId:`reference`})}}}},"domain-import-boundaries":{meta:g(`Keep api, application, domain, and shared dependencies directed.`,{boundary:`Follow api → application/domain → shared; sibling modules expose only rules.ts and queries.ts.`}),create(e){let{domainPublicFiles:n}=c.parse(e.options[0]??{}),r=a(e);if(s(e,e.filename))return{};let o=t();return y(e,(t,s)=>{if(!r)return;let c=i(o,e.filename,s);if(!c)return;let l=a(e,c)?.replace(/\.[cm]?[jt]s$/,``);if(!l){c.split(E).includes(`node_modules`)||e.report({node:t,messageId:`boundary`});return}let u=r.split(`/`),d=l.split(`/`),f=!1;u[0]===`domain`?(f=[`api`,`application`,`migrations`].includes(d[0]),d[0]===`domain`&&u[1]!==d[1]&&d[1]!==`shared`&&u[1]!==`table.ts`&&(f=u[1]===`shared`||![`rules`,`queries`,`contracts`].includes(d.slice(2).join(`/`))&&!n[d[1]]?.includes(d.slice(2).join(`/`)))):u[0]===`api`?f=[`api`,`migrations`].includes(d[0])||d[0]===`domain`&&d[1]!==`shared`&&d[1]!==(u.length>2?u[1]:C(r).replace(/\.[cm]?[jt]s$/,``)):u[0]===`application`?f=[`api`,`migrations`].includes(d[0]):[`relations.ts`,`querying.ts`].includes(r)&&d[0]===`domain`&&(f=!(r===`relations.ts`?[`schema`,`table`]:[`queries`,`contracts`]).includes(d.slice(2).join(`/`))&&(r!==`relations.ts`||l!==`domain/table`)),d[0]===`migrations`&&u[0]!==`migrations`&&(f=!0),[`api`,`domain`,`application`].includes(u[0])&&d.length>1&&![`api`,`domain`,`application`,`_generated`,`components`,`migrations`].includes(d[0])&&(f=!0),f&&e.report({node:t,messageId:`boundary`})})}},"public-functions-in-api":{meta:g(`Expose authenticated public functions only through api/.`,{public:`Declare public auth*/role*/admin* functions in convex/api/<module>.ts.`}),create(e){return a(e)?.startsWith(`api/`)?{}:{CallExpression(t){let n=d(e,t.callee);t.callee.type!==`CallExpression`&&n&&p(e,n.source)&&/^(auth|role|admin)(Query|Mutation|Action)$/.test(n.name)&&e.report({node:t,messageId:`public`})}}}},"thin-api-adapters":{meta:g(`Keep business decisions and writes in domain executors.`,{adapter:`Move business branches, private helpers, and database writes into the owning domain executor.`}),create(e){return a(e)?.startsWith(`api/`)?{IfStatement(t){e.report({node:t,messageId:`adapter`})},SwitchStatement(t){e.report({node:t,messageId:`adapter`})},ConditionalExpression(t){e.report({node:t,messageId:`adapter`})},Program(t){let n=u(t);for(let r of t.body)if(r.type===`FunctionDeclaration`&&r.id&&!n.has(r.id.name)&&e.report({node:r,messageId:`adapter`}),r.type===`VariableDeclaration`)for(let t of r.declarations)t.id.type===`Identifier`&&!n.has(t.id.name)&&[`ArrowFunctionExpression`,`FunctionExpression`].includes(t.init?.type??``)&&e.report({node:t,messageId:`adapter`})},CallExpression(t){f(t)&&e.report({node:t,messageId:`adapter`})}}:{}}},"no-inline-enums":{meta:g(`Keep vocabularies in named constants.ts tuples.`,{vocabulary:`Define a named readonly tuple in constants.ts and pass it to z.enum().`}),create(e){return{CallExpression(t){let n=d(e,t.callee),r=t.arguments[0];for(;r?.type===`TSAsExpression`||r?.type===`TSSatisfiesExpression`;)r=r.expression;n&&/^zod(?:\/v4)?$/.test(n.source)&&n.name===`enum`&&r?.type===`ArrayExpression`&&e.report({node:t,messageId:`vocabulary`})}}}},"no-unbounded-reads":{meta:g(`Bound collection reads through include or pagination.`,{bounded:`Use include(...).execute(limit) or bounded pagination; do not collect() or resolve() an unbounded query.`,order:`Apply eligibility filters in the indexed query before take(), execute(), or paginate(); filtering a bounded result can omit eligible rows. Do not move the predicate automatically.`}),create(e){return{CallExpression(t){if(t.callee.type!==`MemberExpression`)return;let n=_(t.callee),r=v(e,t.callee.object);n===`filter`&&r===`bounded`&&e.report({node:t,messageId:`order`}),(n===`collect`&&(r===`stream`||r===`relationship`)||n===`resolve`&&r===`stream`)&&e.report({node:t,messageId:`bounded`})}}}},"no-manual-id-projection":{meta:g(`Use the table DTO boundary to project public IDs.`,{projection:`Use toPublicDto(row, true) to include _id; do not add IDs manually after a table DTO parse or projection.`}),create(e){return{ObjectExpression(t){if(t.properties.some(t=>t.type===`SpreadElement`&&v(e,t.argument)===`dto`))for(let n of t.properties)n.type===`Property`&&[`id`,`_id`].includes((n.computed?b(n.key):l(n.key))??``)&&e.report({node:n,messageId:`projection`})},AssignmentExpression(t){t.left.type===`MemberExpression`&&[`id`,`_id`].includes(_(t.left)??``)&&v(e,t.left.object)===`dto`&&e.report({node:t,messageId:`projection`})}}}},"no-copied-pagination":{meta:g(`Use native or table pagination schemas instead of copying their shape.`,{pagination:`Use the native paginationOptsValidator (or paginated(table.dto())) for native pagination, or table.paginationOpts(selection) for table queries; do not copy pagination fields.`}),create(e){return{CallExpression(t){let n=d(e,t.callee);if(!(n?.name===`object`&&[`zod`,`zod/v4`,`convex/values`].includes(n.source)))return;let r=t.arguments[0],i=r&&(h(e,r)??r);if(i?.type!==`ObjectExpression`)return;let a=new Set(i.properties.flatMap(e=>e.type===`Property`?[e.computed?b(e.key):l(e.key)]:[]));(a.has(`numItems`)&&a.has(`cursor`)||[`page`,`isDone`,`continueCursor`].every(e=>a.has(e)))&&e.report({node:t,messageId:`pagination`})}}}},"no-manual-timestamps":{meta:g(`Let timestamps triggers own createdAt and updatedAt.`,{timestamp:`Remove {{field}} from this write; register the timestamps trigger instead.`}),create(e){return{CallExpression(t){if(!f(t))return;let n=t.arguments.at(-1);if(n?.type===`ObjectExpression`)for(let t of n.properties){if(t.type!==`Property`)continue;let n=t.computed?b(t.key):l(t.key);(n===`createdAt`||n===`updatedAt`)&&e.report({node:t,messageId:`timestamp`,data:{field:n}})}}}}},"component-boundaries":{meta:g(`Keep portable components isolated and consume their client facades.`,{boundary:`Components may import only their own files and npm dependencies; inject host policy through the client API.`,facade:`Import a component through its client.ts facade, not its private implementation.`}),create(e){let n=s(e,e.filename),r=t(!1);return y(e,(t,o)=>{o.startsWith(`.`)||/^cvx-kit\/components\/[^/]+\//.test(o)&&!/^cvx-kit\/components\/[^/]+\/convex\.config(?:\.js)?$/.test(o)&&e.report({node:t,messageId:`facade`});let c=i(r,e.filename,o);c&&!c.split(E).includes(`node_modules`)&&(n&&(T(n,c).startsWith(`..${E}`)||c===w(n))?e.report({node:t,messageId:`boundary`}):!n&&s(e,c)&&!/^client(?:\.[cm]?[jt]s)?$/.test(C(c))&&!(a(e)===`convex.config.ts`&&/^convex\.config(?:\.[cm]?[jt]s)?$/.test(C(c)))&&e.report({node:t,messageId:`facade`}))})}},"no-component-env":{meta:g(`Pass environment configuration into portable components.`,{env:`Portable components must receive configuration through arguments; do not read process.env.`}),create(e){if(!s(e,e.filename))return{};function t(t){if(t.type!==`Identifier`)return!1;let n=o(e,t);return t.name===`process`&&!n?.defs.length||n?.defs.some(e=>e.type===`ImportBinding`&&e.parent?.type===`ImportDeclaration`&&[`node:process`,`process`].includes(e.parent.source.value)&&[`ImportDefaultSpecifier`,`ImportNamespaceSpecifier`].includes(e.node.type))}return{ImportDeclaration(t){if([`node:process`,`process`].includes(t.source.value))for(let n of t.specifiers)n.type===`ImportSpecifier`&&l(n.imported)===`env`&&e.report({node:n,messageId:`env`})},MemberExpression(n){if(_(n)!==`env`)return;let r=n.object,i=r.type===`MemberExpression`&&_(r)===`process`&&r.object.type===`Identifier`&&r.object.name===`globalThis`&&!o(e,r.object)?.defs.length;(t(r)||i)&&e.report({node:n,messageId:`env`})},VariableDeclarator(n){if(n.init&&t(n.init)&&n.id.type===`ObjectPattern`)for(let t of n.id.properties)t.type===`Property`&&(t.computed?b(t.key):l(t.key))===`env`&&e.report({node:t,messageId:`env`})}}}},"schema-file-boundaries":{meta:g(`Keep storage shapes and indexes in their documented owners.`,{schema:`{{builder}} belongs in {{file}}.`}),create(e){return{CallExpression(t){let n=d(e,t.callee),r=a(e);if(!r)return;let i=null;n?.source===`convex/server`&&(n.name===`defineSchema`&&r!==`schema.ts`&&!(s(e,e.filename)&&C(r)===`schema.ts`)&&(i=`the root schema.ts (or a component schema.ts)`),n.name===`defineTable`&&!(s(e,e.filename)&&[`schema.ts`,`table.ts`].includes(C(r)))&&(i=`a component schema.ts/table.ts; host tables use zodTable in domain/<module>/schema.ts`)),n&&[`cvx-kit`,`cvx-kit/zod-table`].includes(n.source)&&[`zodTable`,`tenantTable`,`zodVariantTable`].includes(n.name)&&!/^domain\/[^/]+\/schema\.ts$/.test(r)&&!(s(e,e.filename)&&[`schema.ts`,`table.ts`].includes(C(r)))&&(i=`domain/<module>/schema.ts or a component schema.ts/table.ts`),i&&e.report({node:t,messageId:`schema`,data:{builder:n?.name??`table`,file:i}}),t.callee.type===`MemberExpression`&&[`index`,`searchIndex`,`vectorIndex`].includes(_(t.callee)??``)&&m(t.callee.object)&&!(s(e,e.filename)?C(r)===`table.ts`:/^domain\/[^/]+\/table\.ts$/.test(r))&&e.report({node:t,messageId:`schema`,data:{builder:`Table indexes`,file:s(e,e.filename)?`a component table.ts`:`domain/<module>/table.ts`}})}}}},"no-internal-reexports":{meta:g(`Import from owning modules directly; consumer apps have no barrels.`,{reexport:`Import from the owning file directly; do not re-export imports inside convex/.`}),create(e){function t(t){if(t.source){e.report({node:t,messageId:`reexport`});return}for(let n of t.type===`ExportNamedDeclaration`?t.specifiers:[])o(e,n.local)?.defs.some(e=>e.type===`ImportBinding`)&&e.report({node:n,messageId:`reexport`})}return{ExportNamedDeclaration:t,ExportAllDeclaration:t,ExportDefaultDeclaration(t){t.declaration.type===`Identifier`&&o(e,t.declaration)?.defs.some(e=>e.type===`ImportBinding`)&&e.report({node:t,messageId:`reexport`})}}}},"public-api-first":{meta:g(`Place private helper implementations after the exported API.`,{order:`Move this private helper below the exported API so the file reads from public purpose to implementation.`}),create(e){return{Program(t){let n=u(t),r=t.body.findLastIndex(e=>e.type.startsWith(`Export`));for(let i of t.body.slice(0,r<0?0:r))i.type===`FunctionDeclaration`&&i.id&&!n.has(i.id.name)&&e.report({node:i,messageId:`order`})}}}},"named-private-helpers":{meta:g(`Use named declarations for top-level private helper functions.`,{helper:`Declare this private helper with function name(...) at the bottom of the file.`}),create(e){return{Program(t){let n=u(t);for(let r of t.body)if(r.type===`VariableDeclaration`)for(let t of r.declarations)t.id.type===`Identifier`&&!n.has(t.id.name)&&(t.init?.type===`ArrowFunctionExpression`||t.init?.type===`FunctionExpression`)&&e.report({node:t,messageId:`helper`})}}}}}),k={meta:{name:`cvx`},rules:O};function A(e){let t={...e},n=Object.keys(e);for(let r of n){let n={convexDir:{type:`string`,minLength:1},componentDirs:{type:`array`,items:{type:`string`,minLength:1}}},i=e[r];t[r]={meta:{...i.meta,schema:[{type:`object`,properties:r===`domain-import-boundaries`?{...n,domainPublicFiles:{type:`object`,additionalProperties:{type:`array`,items:{type:`string`,minLength:1}}}}:n,additionalProperties:!1}]},create(e){let t=a(e);return!t||/(?:^|\/)(?:_generated|__tests__)(?:\/|$)/.test(t)||/\.(?:test|spec)\.[cm]?[jt]s$/.test(t)?{}:i.create(e)}}}return t}export{D as checkArchitecture,k as default,O as rules};
|
|
1
|
+
import{forceRegistry as e}from"./modules/contracts/lazy.mjs";import{createResolver as t,inspectArchitecture as n,narrowRootDeclaration as r,resolveImport as i}from"./oxlint/architecture.mjs";import{reservedDomainFiles as a}from"./oxlint/reserved-files.mjs";import{ownershipRules as o}from"./oxlint/ownership.mjs";import{TABLE_SOURCES as s,appFile as c,binding as l,componentRoot as u,consumerOptions as d,exportName as f,exportedNames as p,imported as m,isDbWrite as h,isFunctionsImport as g,isTableChain as _,kFactory as v,localInitializer as y,metadata as b,propertyName as x,readProvenance as S,sourceVisitors as C,staticString as w}from"./oxlint/ast.mjs";import{basename as T,dirname as E,relative as D,sep as O}from"node:path";function k(t={}){for(let n of t.registries??[])e(n);return n(t)}const A=M({...o,"root-wiring-only":{...o[`root-wiring-only`],create(e){let t=c(e)??``;return[`relations.ts`,`querying.ts`].includes(t)?r(t,e.sourceCode.text)?{}:{Program(n){e.report({node:n,messageId:`ownership`,data:{reason:`${t} must export one kit factory declaration and contain only declarative configuration`}})}}:o[`root-wiring-only`].create(e)}},"reserved-domain-file-anatomy":a,"root-facade-ownership":{meta:b(`Configure shared kit infrastructure once in its root facade.`,{facade:`Configure {{name}} once in convex/{{file}}; import that facade elsewhere.`}),create(e){let t=u(e,e.filename),n=/* @__PURE__ */ new Set;function r(r){let i=m(e,r.callee);if(!i)return;let a=null;[`cvx-kit`,`cvx-kit/querying`].includes(i.source)&&i.name===`createQueryEngine`&&(a=`querying.ts`),[`cvx-kit`,`cvx-kit/relations`].includes(i.source)&&i.name===`defineRelations`&&(a=`relations.ts`),[`cvx-kit`,`cvx-kit/auth`].includes(i.source)&&i.name===`createAuthFunctions`&&(a=`functions.ts`),[`cvx-kit`,`cvx-kit/triggers`].includes(i.source)&&i.name===`createTriggers`&&(a=`triggers.ts`),[`cvx-kit`,`cvx-kit/components/foundation`].includes(i.source)&&i.name===`Foundation`&&(a=`foundation.ts`),(i.source===`cvx-kit/effect`&&i.name===`createEffectFoundation`||i.source===`cvx-kit`&&i.name===`createFoundation`)&&(a=`foundation.ts`),a&&(((t?D(t,e.filename).split(O).join(`/`):c(e))!==a||n.has(i.name))&&e.report({node:r,messageId:`facade`,data:{name:i.name,file:a}}),n.add(i.name))}return{CallExpression:r,NewExpression:r}}},"no-raw-builders":{meta:b(`Build host functions through the auth-aware root constructors.`,{builder:`Import raw builders only in convex/functions.ts; use auth*/role*/admin* or system* elsewhere.`}),create(e){let n=u(e,e.filename);if((n?D(n,e.filename).split(O).join(`/`):c(e))===`functions.ts`)return{};let r=t();return{ImportDeclaration(t){if(t.importKind===`type`)return;let a=t.source.value,o=i(r,e.filename,a),s=o?n?D(n,o).split(O).join(`/`):c(e,o):null,l=s?.startsWith(`_generated/`)?s:a;if(/(?:^|\/)_generated\/server(?:\.[cm]?[jt]s)?$/.test(l)||l===`convex/server`)for(let n of t.specifiers){if(n.type===`ImportSpecifier`&&n.importKind===`type`)continue;let t=n.type===`ImportSpecifier`?f(n.imported):null;(t===null&&l!==`convex/server`||t&&/^(?:internal)?(?:Query|Mutation|Action)(?:Generic)?$|^(?:query|mutation|action)(?:Generic)?$/.test(t))&&e.report({node:n,messageId:`builder`})}},CallExpression(t){let n=m(e,t.callee);n?.source===`convex/server`&&/^(?:internal)?(?:Query|Mutation|Action)Generic$|^(?:query|mutation|action)Generic$/.test(n.name)&&t.callee.type===`MemberExpression`&&e.report({node:t,messageId:`builder`})}}}},"no-handwritten-references":{meta:b(`Use generated api/internal references.`,{reference:`Use generated api/internal references instead of makeFunctionReference.`}),create(e){return{CallExpression(t){let n=m(e,t.callee);n?.source===`convex/server`&&n.name===`makeFunctionReference`&&e.report({node:t,messageId:`reference`})}}}},"domain-import-boundaries":{meta:b(`Keep api, application, domain, and shared dependencies directed.`,{boundary:`Follow api → application/domain → shared; sibling modules expose only rules.ts and queries.ts.`}),create(e){let{domainPublicFiles:n}=d.parse(e.options[0]??{}),r=c(e);if(u(e,e.filename))return{};let a=t();return C(e,(t,o)=>{if(!r)return;let s=i(a,e.filename,o);if(!s)return;let l=c(e,s)?.replace(/\.[cm]?[jt]s$/,``);if(!l){s.split(O).includes(`node_modules`)||e.report({node:t,messageId:`boundary`});return}let u=r.split(`/`),d=l.split(`/`),f=!1;u[0]===`domain`?(f=[`api`,`application`,`migrations`].includes(d[0]),d[0]===`domain`&&u[1]!==d[1]&&d[1]!==`shared`&&u[1]!==`table.ts`&&(f=u[1]===`shared`||![`rules`,`queries`,`contracts`].includes(d.slice(2).join(`/`))&&!n[d[1]]?.includes(d.slice(2).join(`/`)))):u[0]===`api`?f=[`api`,`migrations`].includes(d[0])||d[0]===`domain`&&d[1]!==`shared`&&d[1]!==(u.length>2?u[1]:T(r).replace(/\.[cm]?[jt]s$/,``)):u[0]===`application`?f=[`api`,`migrations`].includes(d[0]):[`relations.ts`,`querying.ts`].includes(r)&&d[0]===`domain`&&(f=!(r===`relations.ts`?[`schema`,`table`]:[`queries`,`contracts`]).includes(d.slice(2).join(`/`))&&(r!==`relations.ts`||l!==`domain/table`)),d[0]===`migrations`&&u[0]!==`migrations`&&(f=!0),[`api`,`domain`,`application`].includes(u[0])&&d.length>1&&![`api`,`domain`,`application`,`_generated`,`components`,`migrations`].includes(d[0])&&(f=!0),f&&e.report({node:t,messageId:`boundary`})})}},"public-functions-in-api":{meta:b(`Expose authenticated public functions only through api/.`,{public:`Declare public auth*/role*/admin* functions in convex/api/<module>.ts.`}),create(e){return c(e)?.startsWith(`api/`)?{}:{CallExpression(t){let n=m(e,t.callee);t.callee.type!==`CallExpression`&&n&&g(e,n.source)&&/^(auth|role|admin)(Query|Mutation|Action)$/.test(n.name)&&e.report({node:t,messageId:`public`})}}}},"thin-api-adapters":{meta:b(`Keep business decisions and writes in domain executors.`,{adapter:`Move business branches, private helpers, and database writes into the owning domain executor.`}),create(e){return c(e)?.startsWith(`api/`)?{IfStatement(t){e.report({node:t,messageId:`adapter`})},SwitchStatement(t){e.report({node:t,messageId:`adapter`})},ConditionalExpression(t){e.report({node:t,messageId:`adapter`})},Program(t){let n=p(t);for(let r of t.body)if(r.type===`FunctionDeclaration`&&r.id&&!n.has(r.id.name)&&e.report({node:r,messageId:`adapter`}),r.type===`VariableDeclaration`)for(let t of r.declarations)t.id.type===`Identifier`&&!n.has(t.id.name)&&[`ArrowFunctionExpression`,`FunctionExpression`].includes(t.init?.type??``)&&e.report({node:t,messageId:`adapter`})},CallExpression(t){h(t)&&e.report({node:t,messageId:`adapter`})}}:{}}},"no-inline-enums":{meta:b(`Keep vocabularies in named constants.ts tuples.`,{vocabulary:`Define a named readonly tuple in constants.ts and pass it to k.enum().`}),create(e){return{CallExpression(t){let n=t.arguments[0];for(;n?.type===`TSAsExpression`||n?.type===`TSSatisfiesExpression`;)n=n.expression;v(e,t)===`enum`&&n?.type===`ArrayExpression`&&e.report({node:t,messageId:`vocabulary`})}}}},"no-unbounded-reads":{meta:b(`Bound collection reads through include or pagination.`,{bounded:`Use include(...).execute(limit) or bounded pagination; do not collect() or resolve() an unbounded query.`,order:`Apply eligibility filters in the indexed query before take(), execute(), or paginate(); filtering a bounded result can omit eligible rows. Do not move the predicate automatically.`}),create(e){return{CallExpression(t){if(t.callee.type!==`MemberExpression`)return;let n=x(t.callee),r=S(e,t.callee.object);n===`filter`&&r===`bounded`&&e.report({node:t,messageId:`order`}),(n===`collect`&&(r===`stream`||r===`relationship`)||n===`resolve`&&r===`stream`)&&e.report({node:t,messageId:`bounded`})}}}},"no-manual-id-projection":{meta:b(`Use the table DTO boundary to project public IDs.`,{projection:`Use toPublicDto(row, true) to include _id; do not add IDs manually after a table DTO parse or projection.`}),create(e){return{ObjectExpression(t){if(t.properties.some(t=>t.type===`SpreadElement`&&S(e,t.argument)===`dto`))for(let n of t.properties)n.type===`Property`&&[`id`,`_id`].includes((n.computed?w(n.key):f(n.key))??``)&&e.report({node:n,messageId:`projection`})},AssignmentExpression(t){t.left.type===`MemberExpression`&&[`id`,`_id`].includes(x(t.left)??``)&&S(e,t.left.object)===`dto`&&e.report({node:t,messageId:`projection`})}}}},"no-copied-pagination":{meta:b(`Use native or table pagination schemas instead of copying their shape.`,{pagination:`Use the native paginationOptsValidator (or paginated(table.dto())) for native pagination, or table.paginationOpts(selection) for table queries; do not copy pagination fields.`}),create(e){return{CallExpression(t){let n=m(e,t.callee);if(!(v(e,t)===`object`||n?.name===`object`&&n.source===`convex/values`))return;let r=t.arguments[0],i=r&&(y(e,r)??r);if(i?.type!==`ObjectExpression`)return;let a=new Set(i.properties.flatMap(e=>e.type===`Property`?[e.computed?w(e.key):f(e.key)]:[]));(a.has(`numItems`)&&a.has(`cursor`)||[`page`,`isDone`,`continueCursor`].every(e=>a.has(e)))&&e.report({node:t,messageId:`pagination`})}}}},"no-manual-timestamps":{meta:b(`Let timestamps triggers own createdAt and updatedAt.`,{timestamp:`Remove {{field}} from this write; register the timestamps trigger instead.`}),create(e){return{CallExpression(t){if(!h(t))return;let n=t.arguments.at(-1);if(n?.type===`ObjectExpression`)for(let t of n.properties){if(t.type!==`Property`)continue;let n=t.computed?w(t.key):f(t.key);(n===`createdAt`||n===`updatedAt`)&&e.report({node:t,messageId:`timestamp`,data:{field:n}})}}}}},"component-boundaries":{meta:b(`Keep portable components isolated and consume their client facades.`,{boundary:`Components may import only their own files and npm dependencies; inject host policy through the client API.`,facade:`Import a component through its client.ts facade, not its private implementation.`}),create(e){let n=u(e,e.filename),r=t(!1);return C(e,(t,a)=>{a.startsWith(`.`)||/^cvx-kit\/components\/[^/]+\//.test(a)&&!/^cvx-kit\/components\/[^/]+\/convex\.config(?:\.js)?$/.test(a)&&e.report({node:t,messageId:`facade`});let o=i(r,e.filename,a);o&&!o.split(O).includes(`node_modules`)&&(n&&(D(n,o).startsWith(`..${O}`)||o===E(n))?e.report({node:t,messageId:`boundary`}):!n&&u(e,o)&&!/^client(?:\.[cm]?[jt]s)?$/.test(T(o))&&!(c(e)===`convex.config.ts`&&/^convex\.config(?:\.[cm]?[jt]s)?$/.test(T(o)))&&e.report({node:t,messageId:`facade`}))})}},"no-component-env":{meta:b(`Pass environment configuration into portable components.`,{env:`Portable components must receive configuration through arguments; do not read process.env.`}),create(e){if(!u(e,e.filename))return{};function t(t){if(t.type!==`Identifier`)return!1;let n=l(e,t);return t.name===`process`&&!n?.defs.length||n?.defs.some(e=>e.type===`ImportBinding`&&e.parent?.type===`ImportDeclaration`&&[`node:process`,`process`].includes(e.parent.source.value)&&[`ImportDefaultSpecifier`,`ImportNamespaceSpecifier`].includes(e.node.type))}return{ImportDeclaration(t){if([`node:process`,`process`].includes(t.source.value))for(let n of t.specifiers)n.type===`ImportSpecifier`&&f(n.imported)===`env`&&e.report({node:n,messageId:`env`})},MemberExpression(n){if(x(n)!==`env`)return;let r=n.object,i=r.type===`MemberExpression`&&x(r)===`process`&&r.object.type===`Identifier`&&r.object.name===`globalThis`&&!l(e,r.object)?.defs.length;(t(r)||i)&&e.report({node:n,messageId:`env`})},VariableDeclarator(n){if(n.init&&t(n.init)&&n.id.type===`ObjectPattern`)for(let t of n.id.properties)t.type===`Property`&&(t.computed?w(t.key):f(t.key))===`env`&&e.report({node:t,messageId:`env`})}}}},"schema-file-boundaries":{meta:b(`Keep storage shapes and indexes in their documented owners.`,{schema:`{{builder}} belongs in {{file}}.`}),create(e){return{CallExpression(t){let n=m(e,t.callee),r=c(e);if(!r)return;let i=null;n?.source===`convex/server`&&(n.name===`defineSchema`&&r!==`schema.ts`&&!(u(e,e.filename)&&T(r)===`schema.ts`)&&(i=`the root schema.ts (or a component schema.ts)`),n.name===`defineTable`&&!(u(e,e.filename)&&[`schema.ts`,`table.ts`].includes(T(r)))&&(i=`a component schema.ts/table.ts; host tables use kTable in domain/<module>/schema.ts`)),n&&s.includes(n.source)&&[`kTable`,`tenantTable`,`kVariantTable`].includes(n.name)&&!/^domain\/[^/]+\/schema\.ts$/.test(r)&&!(u(e,e.filename)&&[`schema.ts`,`table.ts`].includes(T(r)))&&(i=`domain/<module>/schema.ts or a component schema.ts/table.ts`),i&&e.report({node:t,messageId:`schema`,data:{builder:n?.name??`table`,file:i}}),t.callee.type===`MemberExpression`&&[`index`,`searchIndex`,`vectorIndex`].includes(x(t.callee)??``)&&_(t.callee.object)&&!(u(e,e.filename)?T(r)===`table.ts`:/^domain\/[^/]+\/table\.ts$/.test(r))&&e.report({node:t,messageId:`schema`,data:{builder:`Table indexes`,file:u(e,e.filename)?`a component table.ts`:`domain/<module>/table.ts`}})}}}},"no-internal-reexports":{meta:b(`Import from owning modules directly; consumer apps have no barrels.`,{reexport:`Import from the owning file directly; do not re-export imports inside convex/.`}),create(e){function t(t){if(t.source)e.report({node:t,messageId:`reexport`});else for(let n of t.type===`ExportNamedDeclaration`?t.specifiers:[])l(e,n.local)?.defs.some(e=>e.type===`ImportBinding`)&&e.report({node:n,messageId:`reexport`})}return{ExportNamedDeclaration:t,ExportAllDeclaration:t,ExportDefaultDeclaration(t){t.declaration.type===`Identifier`&&l(e,t.declaration)?.defs.some(e=>e.type===`ImportBinding`)&&e.report({node:t,messageId:`reexport`})}}}},"public-api-first":{meta:b(`Place private helper implementations after the exported API.`,{order:`Move this private helper below the exported API so the file reads from public purpose to implementation.`}),create(e){return{Program(t){let n=p(t),r=t.body.findLastIndex(e=>e.type.startsWith(`Export`));for(let i of t.body.slice(0,r<0?0:r))i.type===`FunctionDeclaration`&&i.id&&!n.has(i.id.name)&&e.report({node:i,messageId:`order`})}}}},"named-private-helpers":{meta:b(`Use named declarations for top-level private helper functions.`,{helper:`Declare this private helper with function name(...) at the bottom of the file.`}),create(e){return{Program(t){let n=p(t);for(let r of t.body)if(r.type===`VariableDeclaration`)for(let t of r.declarations)t.id.type!==`Identifier`||n.has(t.id.name)||t.init?.type!==`ArrowFunctionExpression`&&t.init?.type!==`FunctionExpression`||e.report({node:t,messageId:`helper`})}}}}}),j={meta:{name:`cvx`},rules:A};function M(e){let t={...e},n=Object.keys(e);for(let r of n){let n={convexDir:{type:`string`,minLength:1},componentDirs:{type:`array`,items:{type:`string`,minLength:1}}},i=e[r];t[r]={meta:{...i.meta,schema:[{type:`object`,properties:r===`domain-import-boundaries`?{...n,domainPublicFiles:{type:`object`,additionalProperties:{type:`array`,items:{type:`string`,minLength:1}}}}:n,additionalProperties:!1}]},create(e){let t=c(e);return!t||/(?:^|\/)(?:_generated|__tests__)(?:\/|$)/.test(t)||/\.(?:test|spec)\.[cm]?[jt]s$/.test(t)?{}:i.create(e)}}}return t}export{k as checkArchitecture,j as default,A as rules};
|
|
2
2
|
//# sourceMappingURL=oxlint.mjs.map
|
package/dist/oxlint.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxlint.mjs","names":["checkArchitecture","registry","options","forceRegistry","inspectArchitecture","rules","scopeRules","ownershipRules","file","appFile","context","narrowRootDeclaration","reservedDomainFiles","metadata","owner","componentRoot","seen","check","ref","imported","node","relative","sep","resolver","createResolver","importedSource","target","resolveImport","localTarget","source","specifier","name","exportName","consumerOptions","sourceVisitors","resolved","from","to","forbidden","domainPublicFiles","basename","isFunctionsImport","exported","exportedNames","statement","declaration","isDbWrite","values","propertyName","origin","readProvenance","property","staticString","argument","fieldsNode","localInitializer","fields","field","data","dirname","isProcess","variable","binding","def","object","globalProcess","expected","isTableChain","exports","lastExport","plugin","scoped","names","commonProperties","rule"],"sources":["../src/oxlint.ts"],"sourcesContent":["import { forceRegistry } from './modules/contracts/lazy'\nimport { basename, dirname, relative, sep } from 'node:path'\nimport type { CreateRule, ESTree, Plugin, Rule } from '@oxlint/plugins'\nimport {\n\tinspectArchitecture,\n\tcreateResolver,\n\tresolveImport,\n\tnarrowRootDeclaration,\n\ttype ArchitectureOptions,\n\ttype ArchitectureDiagnostic,\n} from './oxlint/architecture'\nimport { reservedDomainFiles } from './oxlint/reserved-files'\nimport { ownershipRules, type OwnershipRuleName } from './oxlint/ownership'\nimport {\n\tappFile,\n\tconsumerOptions,\n\timported,\n\tsourceVisitors,\n\tisFunctionsImport,\n\tisTableChain,\n\tisDbWrite,\n\tmetadata,\n\tcomponentRoot,\n\tstaticString,\n\tpropertyName,\n\tbinding,\n\treadProvenance,\n\tlocalInitializer,\n\texportedNames,\n\texportName,\n} from './oxlint/ast'\n\nexport type { ArchitectureOptions, ArchitectureDiagnostic } from './oxlint/architecture'\n\nexport function checkArchitecture(options: ArchitectureOptions = {}): ArchitectureDiagnostic[] {\n\tfor (const registry of options.registries ?? []) forceRegistry(registry)\n\treturn inspectArchitecture(options)\n}\n\nexport type RuleName =\n\t| OwnershipRuleName\n\t| 'component-boundaries'\n\t| 'no-component-env'\n\t| 'schema-file-boundaries'\n\t| 'no-internal-reexports'\n\t| 'public-api-first'\n\t| 'named-private-helpers'\n\t| 'no-raw-builders'\n\t| 'no-handwritten-references'\n\t| 'domain-import-boundaries'\n\t| 'public-functions-in-api'\n\t| 'thin-api-adapters'\n\t| 'no-inline-enums'\n\t| 'no-unbounded-reads'\n\t| 'no-manual-timestamps'\n\t| 'reserved-domain-file-anatomy'\n\t| 'root-facade-ownership'\n\t| 'no-manual-id-projection'\n\t| 'no-copied-pagination'\n\n/** Consumer application rules derived from docs/conventions.md. */\nconst applicationRules: Record<RuleName, CreateRule> = {\n\t...ownershipRules,\n\t'root-wiring-only': {\n\t\t...ownershipRules['root-wiring-only'],\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context) ?? ''\n\t\t\tif (['relations.ts', 'querying.ts'].includes(file)) {\n\t\t\t\tif (narrowRootDeclaration(file, context.sourceCode.text)) return {}\n\t\t\t\treturn {\n\t\t\t\t\tProgram(node) {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'ownership',\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\treason: `${file} must export one kit factory declaration and contain only declarative configuration`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ownershipRules['root-wiring-only'].create(context)\n\t\t},\n\t},\n\t'reserved-domain-file-anatomy': reservedDomainFiles,\n\t'root-facade-ownership': {\n\t\tmeta: metadata('Configure shared kit infrastructure once in its root facade.', {\n\t\t\tfacade: 'Configure {{name}} once in convex/{{file}}; import that facade elsewhere.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst owner = componentRoot(context, context.filename)\n\t\t\tconst seen = new Set<string>()\n\t\t\tfunction check(node: ESTree.CallExpression | ESTree.NewExpression) {\n\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\tif (!ref) return\n\t\t\t\tlet file: string | null = null\n\t\t\t\tif (\n\t\t\t\t\t['cvx-kit', 'cvx-kit/querying'].includes(ref.source) &&\n\t\t\t\t\tref.name === 'createQueryEngine'\n\t\t\t\t)\n\t\t\t\t\tfile = 'querying.ts'\n\t\t\t\tif (['cvx-kit', 'cvx-kit/relations'].includes(ref.source) && ref.name === 'defineRelations')\n\t\t\t\t\tfile = 'relations.ts'\n\t\t\t\tif (['cvx-kit', 'cvx-kit/auth'].includes(ref.source) && ref.name === 'createAuthFunctions')\n\t\t\t\t\tfile = 'functions.ts'\n\t\t\t\tif (['cvx-kit', 'cvx-kit/triggers'].includes(ref.source) && ref.name === 'createTriggers')\n\t\t\t\t\tfile = 'triggers.ts'\n\t\t\t\tif (\n\t\t\t\t\t['cvx-kit', 'cvx-kit/components/foundation'].includes(ref.source) &&\n\t\t\t\t\tref.name === 'Foundation'\n\t\t\t\t)\n\t\t\t\t\tfile = 'foundation.ts'\n\t\t\t\tif (\n\t\t\t\t\t(ref.source === 'cvx-kit/effect' && ref.name === 'createEffectFoundation') ||\n\t\t\t\t\t(ref.source === 'cvx-kit' && ref.name === 'createFoundation')\n\t\t\t\t)\n\t\t\t\t\tfile = 'foundation.ts'\n\t\t\t\tif (!file) return\n\t\t\t\tif (\n\t\t\t\t\t(owner ? relative(owner, context.filename).split(sep).join('/') : appFile(context)) !==\n\t\t\t\t\t\tfile ||\n\t\t\t\t\tseen.has(ref.name)\n\t\t\t\t)\n\t\t\t\t\tcontext.report({ node, messageId: 'facade', data: { name: ref.name, file } })\n\t\t\t\tseen.add(ref.name)\n\t\t\t}\n\t\t\treturn { CallExpression: check, NewExpression: check }\n\t\t},\n\t},\n\t'no-raw-builders': {\n\t\tmeta: metadata('Build host functions through the auth-aware root constructors.', {\n\t\t\tbuilder:\n\t\t\t\t'Import raw builders only in convex/functions.ts; use auth*/role*/admin* or system* elsewhere.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst owner = componentRoot(context, context.filename)\n\t\t\tif (\n\t\t\t\t(owner ? relative(owner, context.filename).split(sep).join('/') : appFile(context)) ===\n\t\t\t\t'functions.ts'\n\t\t\t)\n\t\t\t\treturn {}\n\t\t\tconst resolver = createResolver()\n\t\t\treturn {\n\t\t\t\tImportDeclaration(node) {\n\t\t\t\t\tif (node.importKind === 'type') return\n\t\t\t\t\tconst importedSource = node.source.value\n\t\t\t\t\tconst target = resolveImport(resolver, context.filename, importedSource)\n\t\t\t\t\tconst localTarget = target\n\t\t\t\t\t\t? owner\n\t\t\t\t\t\t\t? relative(owner, target).split(sep).join('/')\n\t\t\t\t\t\t\t: appFile(context, target)\n\t\t\t\t\t\t: null\n\t\t\t\t\tconst source = localTarget?.startsWith('_generated/') ? localTarget : importedSource\n\t\t\t\t\tif (\n\t\t\t\t\t\t!/(?:^|\\/)_generated\\/server(?:\\.[cm]?[jt]s)?$/.test(source) &&\n\t\t\t\t\t\tsource !== 'convex/server'\n\t\t\t\t\t)\n\t\t\t\t\t\treturn\n\t\t\t\t\tfor (const specifier of node.specifiers) {\n\t\t\t\t\t\tif (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') continue\n\t\t\t\t\t\tconst name =\n\t\t\t\t\t\t\tspecifier.type === 'ImportSpecifier' ? exportName(specifier.imported) : null\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t(name === null && source !== 'convex/server') ||\n\t\t\t\t\t\t\t(name &&\n\t\t\t\t\t\t\t\t/^(?:internal)?(?:Query|Mutation|Action)(?:Generic)?$|^(?:query|mutation|action)(?:Generic)?$/.test(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontext.report({ node: specifier, messageId: 'builder' })\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tref?.source === 'convex/server' &&\n\t\t\t\t\t\t/^(?:internal)?(?:Query|Mutation|Action)Generic$|^(?:query|mutation|action)Generic$/.test(\n\t\t\t\t\t\t\tref.name,\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression'\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontext.report({ node, messageId: 'builder' })\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-handwritten-references': {\n\t\tmeta: metadata('Use generated api/internal references.', {\n\t\t\treference: 'Use generated api/internal references instead of makeFunctionReference.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (ref?.source === 'convex/server' && ref.name === 'makeFunctionReference')\n\t\t\t\t\t\tcontext.report({ node, messageId: 'reference' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'domain-import-boundaries': {\n\t\tmeta: metadata('Keep api, application, domain, and shared dependencies directed.', {\n\t\t\tboundary:\n\t\t\t\t'Follow api → application/domain → shared; sibling modules expose only rules.ts and queries.ts.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst { domainPublicFiles } = consumerOptions.parse(context.options[0] ?? {})\n\t\t\tconst file = appFile(context)\n\t\t\tif (componentRoot(context, context.filename)) return {}\n\t\t\tconst resolver = createResolver()\n\t\t\treturn sourceVisitors(context, (node, source) => {\n\t\t\t\tif (!file) return\n\t\t\t\tconst resolved = resolveImport(resolver, context.filename, source)\n\t\t\t\tif (!resolved) return\n\t\t\t\tconst target = appFile(context, resolved)?.replace(/\\.[cm]?[jt]s$/, '')\n\t\t\t\tif (!target) {\n\t\t\t\t\tif (!resolved.split(sep).includes('node_modules'))\n\t\t\t\t\t\tcontext.report({ node, messageId: 'boundary' })\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst from = file.split('/')\n\t\t\t\tconst to = target.split('/')\n\t\t\t\tlet forbidden = false\n\t\t\t\tif (from[0] === 'domain') {\n\t\t\t\t\tforbidden = ['api', 'application', 'migrations'].includes(to[0])\n\t\t\t\t\tif (\n\t\t\t\t\t\tto[0] === 'domain' &&\n\t\t\t\t\t\tfrom[1] !== to[1] &&\n\t\t\t\t\t\tto[1] !== 'shared' &&\n\t\t\t\t\t\tfrom[1] !== 'table.ts'\n\t\t\t\t\t) {\n\t\t\t\t\t\tforbidden =\n\t\t\t\t\t\t\tfrom[1] === 'shared' ||\n\t\t\t\t\t\t\t(!['rules', 'queries', 'contracts'].includes(to.slice(2).join('/')) &&\n\t\t\t\t\t\t\t\t!domainPublicFiles[to[1]]?.includes(to.slice(2).join('/')))\n\t\t\t\t\t}\n\t\t\t\t} else if (from[0] === 'api') {\n\t\t\t\t\tforbidden =\n\t\t\t\t\t\t['api', 'migrations'].includes(to[0]) ||\n\t\t\t\t\t\t(to[0] === 'domain' &&\n\t\t\t\t\t\t\tto[1] !== 'shared' &&\n\t\t\t\t\t\t\tto[1] !== (from.length > 2 ? from[1] : basename(file).replace(/\\.[cm]?[jt]s$/, '')))\n\t\t\t\t} else if (from[0] === 'application') forbidden = ['api', 'migrations'].includes(to[0])\n\t\t\t\telse if (['relations.ts', 'querying.ts'].includes(file) && to[0] === 'domain') {\n\t\t\t\t\tconst allowed = file === 'relations.ts' ? ['schema', 'table'] : ['queries', 'contracts']\n\t\t\t\t\tforbidden =\n\t\t\t\t\t\t!allowed.includes(to.slice(2).join('/')) &&\n\t\t\t\t\t\t!(file === 'relations.ts' && target === 'domain/table')\n\t\t\t\t}\n\t\t\t\tif (to[0] === 'migrations' && from[0] !== 'migrations') forbidden = true\n\t\t\t\tif (\n\t\t\t\t\t['api', 'domain', 'application'].includes(from[0]) &&\n\t\t\t\t\tto.length > 1 &&\n\t\t\t\t\t!['api', 'domain', 'application', '_generated', 'components', 'migrations'].includes(\n\t\t\t\t\t\tto[0],\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tforbidden = true\n\t\t\t\tif (forbidden) context.report({ node, messageId: 'boundary' })\n\t\t\t})\n\t\t},\n\t},\n\t'public-functions-in-api': {\n\t\tmeta: metadata('Expose authenticated public functions only through api/.', {\n\t\t\tpublic: 'Declare public auth*/role*/admin* functions in convex/api/<module>.ts.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tif (appFile(context)?.startsWith('api/')) return {}\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.callee.type !== 'CallExpression' &&\n\t\t\t\t\t\tref &&\n\t\t\t\t\t\tisFunctionsImport(context, ref.source) &&\n\t\t\t\t\t\t/^(auth|role|admin)(Query|Mutation|Action)$/.test(ref.name)\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'public' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'thin-api-adapters': {\n\t\tmeta: metadata('Keep business decisions and writes in domain executors.', {\n\t\t\tadapter:\n\t\t\t\t'Move business branches, private helpers, and database writes into the owning domain executor.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tif (!appFile(context)?.startsWith('api/')) return {}\n\t\t\treturn {\n\t\t\t\tIfStatement(node) {\n\t\t\t\t\tcontext.report({ node, messageId: 'adapter' })\n\t\t\t\t},\n\t\t\t\tSwitchStatement(node) {\n\t\t\t\t\tcontext.report({ node, messageId: 'adapter' })\n\t\t\t\t},\n\t\t\t\tConditionalExpression(node) {\n\t\t\t\t\tcontext.report({ node, messageId: 'adapter' })\n\t\t\t\t},\n\t\t\t\tProgram(node) {\n\t\t\t\t\tconst exported = exportedNames(node)\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' &&\n\t\t\t\t\t\t\tstatement.id &&\n\t\t\t\t\t\t\t!exported.has(statement.id.name)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tcontext.report({ node: statement, messageId: 'adapter' })\n\t\t\t\t\t\tif (statement.type === 'VariableDeclaration')\n\t\t\t\t\t\t\tfor (const declaration of statement.declarations) {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tdeclaration.id.type === 'Identifier' &&\n\t\t\t\t\t\t\t\t\t!exported.has(declaration.id.name) &&\n\t\t\t\t\t\t\t\t\t['ArrowFunctionExpression', 'FunctionExpression'].includes(\n\t\t\t\t\t\t\t\t\t\tdeclaration.init?.type ?? '',\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tcontext.report({ node: declaration, messageId: 'adapter' })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (isDbWrite(node)) context.report({ node, messageId: 'adapter' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-inline-enums': {\n\t\tmeta: metadata('Keep vocabularies in named constants.ts tuples.', {\n\t\t\tvocabulary: 'Define a named readonly tuple in constants.ts and pass it to z.enum().',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tlet values = node.arguments[0]\n\t\t\t\t\twhile (values?.type === 'TSAsExpression' || values?.type === 'TSSatisfiesExpression')\n\t\t\t\t\t\tvalues = values.expression\n\t\t\t\t\tif (\n\t\t\t\t\t\tref &&\n\t\t\t\t\t\t/^zod(?:\\/v4)?$/.test(ref.source) &&\n\t\t\t\t\t\tref.name === 'enum' &&\n\t\t\t\t\t\tvalues?.type === 'ArrayExpression'\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'vocabulary' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-unbounded-reads': {\n\t\tmeta: metadata('Bound collection reads through include or pagination.', {\n\t\t\tbounded:\n\t\t\t\t'Use include(...).execute(limit) or bounded pagination; do not collect() or resolve() an unbounded query.',\n\t\t\torder:\n\t\t\t\t'Apply eligibility filters in the indexed query before take(), execute(), or paginate(); filtering a bounded result can omit eligible rows. Do not move the predicate automatically.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (node.callee.type !== 'MemberExpression') return\n\t\t\t\t\tconst name = propertyName(node.callee)\n\t\t\t\t\tconst origin = readProvenance(context, node.callee.object)\n\t\t\t\t\tif (name === 'filter' && origin === 'bounded')\n\t\t\t\t\t\tcontext.report({ node, messageId: 'order' })\n\t\t\t\t\tif (\n\t\t\t\t\t\t(name === 'collect' && (origin === 'stream' || origin === 'relationship')) ||\n\t\t\t\t\t\t(name === 'resolve' && origin === 'stream')\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'bounded' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-manual-id-projection': {\n\t\tmeta: metadata('Use the table DTO boundary to project public IDs.', {\n\t\t\tprojection:\n\t\t\t\t'Use toPublicDto(row, true) to include _id; do not add IDs manually after a table DTO parse or projection.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tObjectExpression(node) {\n\t\t\t\t\tconst dto = node.properties.some(\n\t\t\t\t\t\t(property) =>\n\t\t\t\t\t\t\tproperty.type === 'SpreadElement' &&\n\t\t\t\t\t\t\treadProvenance(context, property.argument) === 'dto',\n\t\t\t\t\t)\n\t\t\t\t\tif (!dto) return\n\t\t\t\t\tfor (const property of node.properties) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t\t\t['id', '_id'].includes(\n\t\t\t\t\t\t\t\t(property.computed ? staticString(property.key) : exportName(property.key)) ?? '',\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tcontext.report({ node: property, messageId: 'projection' })\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tAssignmentExpression(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.left.type === 'MemberExpression' &&\n\t\t\t\t\t\t['id', '_id'].includes(propertyName(node.left) ?? '') &&\n\t\t\t\t\t\treadProvenance(context, node.left.object) === 'dto'\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'projection' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-copied-pagination': {\n\t\tmeta: metadata('Use native or table pagination schemas instead of copying their shape.', {\n\t\t\tpagination:\n\t\t\t\t'Use the native paginationOptsValidator (or paginated(table.dto())) for native pagination, or table.paginationOpts(selection) for table queries; do not copy pagination fields.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (!(ref?.name === 'object' && ['zod', 'zod/v4', 'convex/values'].includes(ref.source)))\n\t\t\t\t\t\treturn\n\t\t\t\t\tconst argument = node.arguments[0]\n\t\t\t\t\tconst fieldsNode = argument && (localInitializer(context, argument) ?? argument)\n\t\t\t\t\tif (fieldsNode?.type !== 'ObjectExpression') return\n\t\t\t\t\tconst fields = new Set(\n\t\t\t\t\t\tfieldsNode.properties.flatMap((property) =>\n\t\t\t\t\t\t\tproperty.type === 'Property'\n\t\t\t\t\t\t\t\t? [property.computed ? staticString(property.key) : exportName(property.key)]\n\t\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t\tif (\n\t\t\t\t\t\t(fields.has('numItems') && fields.has('cursor')) ||\n\t\t\t\t\t\t['page', 'isDone', 'continueCursor'].every((field) => fields.has(field))\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'pagination' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-manual-timestamps': {\n\t\tmeta: metadata('Let timestamps triggers own createdAt and updatedAt.', {\n\t\t\ttimestamp: 'Remove {{field}} from this write; register the timestamps trigger instead.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (!isDbWrite(node)) return\n\t\t\t\t\tconst data = node.arguments.at(-1)\n\t\t\t\t\tif (data?.type !== 'ObjectExpression') return\n\t\t\t\t\tfor (const property of data.properties) {\n\t\t\t\t\t\tif (property.type !== 'Property') continue\n\t\t\t\t\t\tconst field = property.computed ? staticString(property.key) : exportName(property.key)\n\t\t\t\t\t\tif (field === 'createdAt' || field === 'updatedAt')\n\t\t\t\t\t\t\tcontext.report({ node: property, messageId: 'timestamp', data: { field } })\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'component-boundaries': {\n\t\tmeta: metadata('Keep portable components isolated and consume their client facades.', {\n\t\t\tboundary:\n\t\t\t\t'Components may import only their own files and npm dependencies; inject host policy through the client API.',\n\t\t\tfacade: 'Import a component through its client.ts facade, not its private implementation.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst owner = componentRoot(context, context.filename)\n\t\t\tconst resolver = createResolver(false)\n\n\t\t\treturn sourceVisitors(context, (node, specifier) => {\n\t\t\t\tif (!specifier.startsWith('.')) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t/^cvx-kit\\/components\\/[^/]+\\//.test(specifier) &&\n\t\t\t\t\t\t!/^cvx-kit\\/components\\/[^/]+\\/convex\\.config(?:\\.js)?$/.test(specifier)\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontext.report({ node, messageId: 'facade' })\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst target = resolveImport(resolver, context.filename, specifier)\n\t\t\t\tif (!target || target.split(sep).includes('node_modules')) return\n\t\t\t\tif (\n\t\t\t\t\towner &&\n\t\t\t\t\t(relative(owner, target).startsWith(`..${sep}`) || target === dirname(owner))\n\t\t\t\t) {\n\t\t\t\t\tcontext.report({ node, messageId: 'boundary' })\n\t\t\t\t} else if (\n\t\t\t\t\t!owner &&\n\t\t\t\t\tcomponentRoot(context, target) &&\n\t\t\t\t\t!/^client(?:\\.[cm]?[jt]s)?$/.test(basename(target)) &&\n\t\t\t\t\t!(\n\t\t\t\t\t\tappFile(context) === 'convex.config.ts' &&\n\t\t\t\t\t\t/^convex\\.config(?:\\.[cm]?[jt]s)?$/.test(basename(target))\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tcontext.report({ node, messageId: 'facade' })\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t},\n\t'no-component-env': {\n\t\tmeta: metadata('Pass environment configuration into portable components.', {\n\t\t\tenv: 'Portable components must receive configuration through arguments; do not read process.env.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tif (!componentRoot(context, context.filename)) return {}\n\t\t\tfunction isProcess(node: ESTree.Node) {\n\t\t\t\tif (node.type !== 'Identifier') return false\n\t\t\t\tconst variable = binding(context, node)\n\t\t\t\tif (node.name === 'process' && !variable?.defs.length) return true\n\t\t\t\treturn variable?.defs.some(\n\t\t\t\t\t(def) =>\n\t\t\t\t\t\tdef.type === 'ImportBinding' &&\n\t\t\t\t\t\tdef.parent?.type === 'ImportDeclaration' &&\n\t\t\t\t\t\t['node:process', 'process'].includes(def.parent.source.value) &&\n\t\t\t\t\t\t['ImportDefaultSpecifier', 'ImportNamespaceSpecifier'].includes(def.node.type),\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tImportDeclaration(node) {\n\t\t\t\t\tif (['node:process', 'process'].includes(node.source.value)) {\n\t\t\t\t\t\tfor (const specifier of node.specifiers) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tspecifier.type === 'ImportSpecifier' &&\n\t\t\t\t\t\t\t\texportName(specifier.imported) === 'env'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcontext.report({ node: specifier, messageId: 'env' })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tMemberExpression(node) {\n\t\t\t\t\tif (propertyName(node) !== 'env') return\n\t\t\t\t\tconst object = node.object\n\t\t\t\t\tconst globalProcess =\n\t\t\t\t\t\tobject.type === 'MemberExpression' &&\n\t\t\t\t\t\tpropertyName(object) === 'process' &&\n\t\t\t\t\t\tobject.object.type === 'Identifier' &&\n\t\t\t\t\t\tobject.object.name === 'globalThis' &&\n\t\t\t\t\t\t!binding(context, object.object)?.defs.length\n\t\t\t\t\tif (isProcess(object) || globalProcess) context.report({ node, messageId: 'env' })\n\t\t\t\t},\n\t\t\t\tVariableDeclarator(node) {\n\t\t\t\t\tif (node.init && isProcess(node.init) && node.id.type === 'ObjectPattern') {\n\t\t\t\t\t\tfor (const property of node.id.properties) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t\t\t\t(property.computed ? staticString(property.key) : exportName(property.key)) ===\n\t\t\t\t\t\t\t\t\t'env'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcontext.report({ node: property, messageId: 'env' })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'schema-file-boundaries': {\n\t\tmeta: metadata('Keep storage shapes and indexes in their documented owners.', {\n\t\t\tschema: '{{builder}} belongs in {{file}}.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tconst file = appFile(context)\n\t\t\t\t\tif (!file) return\n\t\t\t\t\tlet expected: string | null = null\n\t\t\t\t\tif (ref?.source === 'convex/server') {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tref.name === 'defineSchema' &&\n\t\t\t\t\t\t\tfile !== 'schema.ts' &&\n\t\t\t\t\t\t\t!(componentRoot(context, context.filename) && basename(file) === 'schema.ts')\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\texpected = 'the root schema.ts (or a component schema.ts)'\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tref.name === 'defineTable' &&\n\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\tcomponentRoot(context, context.filename) &&\n\t\t\t\t\t\t\t\t['schema.ts', 'table.ts'].includes(basename(file))\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\texpected =\n\t\t\t\t\t\t\t\t'a component schema.ts/table.ts; host tables use zodTable in domain/<module>/schema.ts'\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tref &&\n\t\t\t\t\t\t['cvx-kit', 'cvx-kit/zod-table'].includes(ref.source) &&\n\t\t\t\t\t\t['zodTable', 'tenantTable', 'zodVariantTable'].includes(ref.name) &&\n\t\t\t\t\t\t!/^domain\\/[^/]+\\/schema\\.ts$/.test(file) &&\n\t\t\t\t\t\t!(\n\t\t\t\t\t\t\tcomponentRoot(context, context.filename) &&\n\t\t\t\t\t\t\t['schema.ts', 'table.ts'].includes(basename(file))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\texpected = 'domain/<module>/schema.ts or a component schema.ts/table.ts'\n\t\t\t\t\tif (expected)\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'schema',\n\t\t\t\t\t\t\tdata: { builder: ref?.name ?? 'table', file: expected },\n\t\t\t\t\t\t})\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression' &&\n\t\t\t\t\t\t['index', 'searchIndex', 'vectorIndex'].includes(propertyName(node.callee) ?? '') &&\n\t\t\t\t\t\tisTableChain(node.callee.object) &&\n\t\t\t\t\t\t!(componentRoot(context, context.filename)\n\t\t\t\t\t\t\t? basename(file) === 'table.ts'\n\t\t\t\t\t\t\t: /^domain\\/[^/]+\\/table\\.ts$/.test(file))\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'schema',\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tbuilder: 'Table indexes',\n\t\t\t\t\t\t\t\tfile: componentRoot(context, context.filename)\n\t\t\t\t\t\t\t\t\t? 'a component table.ts'\n\t\t\t\t\t\t\t\t\t: 'domain/<module>/table.ts',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-internal-reexports': {\n\t\tmeta: metadata('Import from owning modules directly; consumer apps have no barrels.', {\n\t\t\treexport: 'Import from the owning file directly; do not re-export imports inside convex/.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tfunction check(node: ESTree.ExportNamedDeclaration | ESTree.ExportAllDeclaration) {\n\t\t\t\tif (node.source) {\n\t\t\t\t\tcontext.report({ node, messageId: 'reexport' })\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfor (const specifier of node.type === 'ExportNamedDeclaration' ? node.specifiers : []) {\n\t\t\t\t\tif (binding(context, specifier.local)?.defs.some((def) => def.type === 'ImportBinding')) {\n\t\t\t\t\t\tcontext.report({ node: specifier, messageId: 'reexport' })\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tExportNamedDeclaration: check,\n\t\t\t\tExportAllDeclaration: check,\n\t\t\t\tExportDefaultDeclaration(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.declaration.type === 'Identifier' &&\n\t\t\t\t\t\tbinding(context, node.declaration)?.defs.some((def) => def.type === 'ImportBinding')\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontext.report({ node, messageId: 'reexport' })\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'public-api-first': {\n\t\tmeta: metadata('Place private helper implementations after the exported API.', {\n\t\t\torder:\n\t\t\t\t'Move this private helper below the exported API so the file reads from public purpose to implementation.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tconst exports = exportedNames(node)\n\t\t\t\t\tconst lastExport = node.body.findLastIndex((statement) =>\n\t\t\t\t\t\tstatement.type.startsWith('Export'),\n\t\t\t\t\t)\n\t\t\t\t\tfor (const statement of node.body.slice(0, lastExport < 0 ? 0 : lastExport)) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' &&\n\t\t\t\t\t\t\tstatement.id &&\n\t\t\t\t\t\t\t!exports.has(statement.id.name)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontext.report({ node: statement, messageId: 'order' })\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'named-private-helpers': {\n\t\tmeta: metadata('Use named declarations for top-level private helper functions.', {\n\t\t\thelper: 'Declare this private helper with function name(...) at the bottom of the file.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tconst exports = exportedNames(node)\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (statement.type !== 'VariableDeclaration') continue\n\t\t\t\t\t\tfor (const declaration of statement.declarations) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdeclaration.id.type === 'Identifier' &&\n\t\t\t\t\t\t\t\t!exports.has(declaration.id.name) &&\n\t\t\t\t\t\t\t\t(declaration.init?.type === 'ArrowFunctionExpression' ||\n\t\t\t\t\t\t\t\t\tdeclaration.init?.type === 'FunctionExpression')\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcontext.report({ node: declaration, messageId: 'helper' })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n}\n\nexport const rules: Record<RuleName, Rule> = scopeRules(applicationRules)\nconst plugin: Plugin = { meta: { name: 'cvx' }, rules }\nexport default plugin\n\nfunction scopeRules(source: Record<RuleName, CreateRule>): Record<RuleName, Rule> {\n\tconst scoped = { ...source }\n\t// SAFETY: source is the closed applicationRules record; its own keys are exactly RuleName.\n\tconst names = Object.keys(source) as RuleName[]\n\tfor (const name of names) {\n\t\tconst commonProperties = {\n\t\t\tconvexDir: { type: 'string', minLength: 1 },\n\t\t\tcomponentDirs: { type: 'array', items: { type: 'string', minLength: 1 } },\n\t\t}\n\t\tconst rule = source[name]\n\t\tscoped[name] = {\n\t\t\tmeta: {\n\t\t\t\t...rule.meta,\n\t\t\t\tschema: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\tproperties:\n\t\t\t\t\t\t\tname === 'domain-import-boundaries'\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t...commonProperties,\n\t\t\t\t\t\t\t\t\t\tdomainPublicFiles: {\n\t\t\t\t\t\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\t\t\t\t\t\tadditionalProperties: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\t\t\t\t\t\titems: { type: 'string', minLength: 1 },\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: commonProperties,\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\tcreate(context) {\n\t\t\t\tconst file = appFile(context)\n\t\t\t\tif (\n\t\t\t\t\t!file ||\n\t\t\t\t\t/(?:^|\\/)(?:_generated|__tests__)(?:\\/|$)/.test(file) ||\n\t\t\t\t\t/\\.(?:test|spec)\\.[cm]?[jt]s$/.test(file)\n\t\t\t\t)\n\t\t\t\t\treturn {}\n\t\t\t\treturn rule.create(context)\n\t\t\t},\n\t\t}\n\t}\n\treturn scoped\n}\n"],"mappings":"2rBAkCA,SAAgBA,EAAkB,EAA+B,CAAC,EAA6B,CAC9F,IAAK,IAAMC,KAAYC,EAAQ,YAAc,CAAC,EAAGC,EAAcF,CAAQ,EACvE,OAAOG,EAAoBF,CAAO,CACnC,CA+pBA,MAAaG,EAAgCC,EAAW,CAtoBvD,G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,OAAQ,CACP,CACC,KAAM,SACN,WACC3C,IAAS,2BACN,CACA,GAAG0C,EACH,kBAAmB,CAClB,KAAM,SACN,qBAAsB,CACrB,KAAM,QACN,MAAO,CAAE,KAAM,SAAU,UAAW,CAAE,CACvC,CACD,CACD,EACCA,EACJ,qBAAsB,EACvB,CACD,CACD,EACA,OAAO,EAAS,CACf,IAAMjE,EAAOC,EAAQC,CAAO,EAO5B,MALC,CAACF,GACD,2CAA2C,KAAKA,CAAI,GACpD,+BAA+B,KAAKA,CAAI,EAEjC,CAAC,EACFkE,EAAK,OAAOhE,CAAO,CAC3B,CACD,CACD,CACA,OAAO6D,CACR"}
|
|
1
|
+
{"version":3,"file":"oxlint.mjs","names":["checkArchitecture","registry","options","forceRegistry","inspectArchitecture","rules","scopeRules","ownershipRules","file","appFile","context","narrowRootDeclaration","reservedDomainFiles","metadata","owner","componentRoot","seen","check","ref","imported","node","relative","sep","resolver","createResolver","importedSource","target","resolveImport","localTarget","source","specifier","name","exportName","consumerOptions","sourceVisitors","resolved","from","to","forbidden","domainPublicFiles","basename","isFunctionsImport","exported","exportedNames","statement","declaration","isDbWrite","values","kFactory","propertyName","origin","readProvenance","property","staticString","argument","fieldsNode","localInitializer","fields","field","data","dirname","isProcess","variable","binding","def","object","globalProcess","expected","TABLE_SOURCES","isTableChain","exports","lastExport","plugin","scoped","names","commonProperties","rule"],"sources":["../src/oxlint.ts"],"sourcesContent":["import { forceRegistry } from './modules/contracts/lazy'\nimport { basename, dirname, relative, sep } from 'node:path'\nimport type { CreateRule, ESTree, Plugin, Rule } from '@oxlint/plugins'\nimport {\n\tinspectArchitecture,\n\tcreateResolver,\n\tresolveImport,\n\tnarrowRootDeclaration,\n\ttype ArchitectureOptions,\n\ttype ArchitectureDiagnostic,\n} from './oxlint/architecture'\nimport { reservedDomainFiles } from './oxlint/reserved-files'\nimport { ownershipRules, type OwnershipRuleName } from './oxlint/ownership'\nimport {\n\tappFile,\n\tconsumerOptions,\n\timported,\n\tsourceVisitors,\n\tisFunctionsImport,\n\tisTableChain,\n\tisDbWrite,\n\tkFactory,\n\tTABLE_SOURCES,\n\tmetadata,\n\tcomponentRoot,\n\tstaticString,\n\tpropertyName,\n\tbinding,\n\treadProvenance,\n\tlocalInitializer,\n\texportedNames,\n\texportName,\n} from './oxlint/ast'\n\nexport type { ArchitectureOptions, ArchitectureDiagnostic } from './oxlint/architecture'\n\nexport function checkArchitecture(options: ArchitectureOptions = {}): ArchitectureDiagnostic[] {\n\tfor (const registry of options.registries ?? []) forceRegistry(registry)\n\treturn inspectArchitecture(options)\n}\n\nexport type RuleName =\n\t| OwnershipRuleName\n\t| 'component-boundaries'\n\t| 'no-component-env'\n\t| 'schema-file-boundaries'\n\t| 'no-internal-reexports'\n\t| 'public-api-first'\n\t| 'named-private-helpers'\n\t| 'no-raw-builders'\n\t| 'no-handwritten-references'\n\t| 'domain-import-boundaries'\n\t| 'public-functions-in-api'\n\t| 'thin-api-adapters'\n\t| 'no-inline-enums'\n\t| 'no-unbounded-reads'\n\t| 'no-manual-timestamps'\n\t| 'reserved-domain-file-anatomy'\n\t| 'root-facade-ownership'\n\t| 'no-manual-id-projection'\n\t| 'no-copied-pagination'\n\n/** Consumer application rules derived from docs/conventions.md. */\nconst applicationRules: Record<RuleName, CreateRule> = {\n\t...ownershipRules,\n\t'root-wiring-only': {\n\t\t...ownershipRules['root-wiring-only'],\n\t\tcreate(context) {\n\t\t\tconst file = appFile(context) ?? ''\n\t\t\tif (['relations.ts', 'querying.ts'].includes(file)) {\n\t\t\t\tif (narrowRootDeclaration(file, context.sourceCode.text)) return {}\n\t\t\t\treturn {\n\t\t\t\t\tProgram(node) {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'ownership',\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\treason: `${file} must export one kit factory declaration and contain only declarative configuration`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ownershipRules['root-wiring-only'].create(context)\n\t\t},\n\t},\n\t'reserved-domain-file-anatomy': reservedDomainFiles,\n\t'root-facade-ownership': {\n\t\tmeta: metadata('Configure shared kit infrastructure once in its root facade.', {\n\t\t\tfacade: 'Configure {{name}} once in convex/{{file}}; import that facade elsewhere.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst owner = componentRoot(context, context.filename)\n\t\t\tconst seen = new Set<string>()\n\t\t\tfunction check(node: ESTree.CallExpression | ESTree.NewExpression) {\n\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\tif (!ref) return\n\t\t\t\tlet file: string | null = null\n\t\t\t\tif (\n\t\t\t\t\t['cvx-kit', 'cvx-kit/querying'].includes(ref.source) &&\n\t\t\t\t\tref.name === 'createQueryEngine'\n\t\t\t\t)\n\t\t\t\t\tfile = 'querying.ts'\n\t\t\t\tif (['cvx-kit', 'cvx-kit/relations'].includes(ref.source) && ref.name === 'defineRelations')\n\t\t\t\t\tfile = 'relations.ts'\n\t\t\t\tif (['cvx-kit', 'cvx-kit/auth'].includes(ref.source) && ref.name === 'createAuthFunctions')\n\t\t\t\t\tfile = 'functions.ts'\n\t\t\t\tif (['cvx-kit', 'cvx-kit/triggers'].includes(ref.source) && ref.name === 'createTriggers')\n\t\t\t\t\tfile = 'triggers.ts'\n\t\t\t\tif (\n\t\t\t\t\t['cvx-kit', 'cvx-kit/components/foundation'].includes(ref.source) &&\n\t\t\t\t\tref.name === 'Foundation'\n\t\t\t\t)\n\t\t\t\t\tfile = 'foundation.ts'\n\t\t\t\tif (\n\t\t\t\t\t(ref.source === 'cvx-kit/effect' && ref.name === 'createEffectFoundation') ||\n\t\t\t\t\t(ref.source === 'cvx-kit' && ref.name === 'createFoundation')\n\t\t\t\t)\n\t\t\t\t\tfile = 'foundation.ts'\n\t\t\t\tif (!file) return\n\t\t\t\tif (\n\t\t\t\t\t(owner ? relative(owner, context.filename).split(sep).join('/') : appFile(context)) !==\n\t\t\t\t\t\tfile ||\n\t\t\t\t\tseen.has(ref.name)\n\t\t\t\t)\n\t\t\t\t\tcontext.report({ node, messageId: 'facade', data: { name: ref.name, file } })\n\t\t\t\tseen.add(ref.name)\n\t\t\t}\n\t\t\treturn { CallExpression: check, NewExpression: check }\n\t\t},\n\t},\n\t'no-raw-builders': {\n\t\tmeta: metadata('Build host functions through the auth-aware root constructors.', {\n\t\t\tbuilder:\n\t\t\t\t'Import raw builders only in convex/functions.ts; use auth*/role*/admin* or system* elsewhere.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst owner = componentRoot(context, context.filename)\n\t\t\tif (\n\t\t\t\t(owner ? relative(owner, context.filename).split(sep).join('/') : appFile(context)) ===\n\t\t\t\t'functions.ts'\n\t\t\t)\n\t\t\t\treturn {}\n\t\t\tconst resolver = createResolver()\n\t\t\treturn {\n\t\t\t\tImportDeclaration(node) {\n\t\t\t\t\tif (node.importKind === 'type') return\n\t\t\t\t\tconst importedSource = node.source.value\n\t\t\t\t\tconst target = resolveImport(resolver, context.filename, importedSource)\n\t\t\t\t\tconst localTarget = target\n\t\t\t\t\t\t? owner\n\t\t\t\t\t\t\t? relative(owner, target).split(sep).join('/')\n\t\t\t\t\t\t\t: appFile(context, target)\n\t\t\t\t\t\t: null\n\t\t\t\t\tconst source = localTarget?.startsWith('_generated/') ? localTarget : importedSource\n\t\t\t\t\tif (\n\t\t\t\t\t\t!/(?:^|\\/)_generated\\/server(?:\\.[cm]?[jt]s)?$/.test(source) &&\n\t\t\t\t\t\tsource !== 'convex/server'\n\t\t\t\t\t)\n\t\t\t\t\t\treturn\n\t\t\t\t\tfor (const specifier of node.specifiers) {\n\t\t\t\t\t\tif (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') continue\n\t\t\t\t\t\tconst name =\n\t\t\t\t\t\t\tspecifier.type === 'ImportSpecifier' ? exportName(specifier.imported) : null\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t(name === null && source !== 'convex/server') ||\n\t\t\t\t\t\t\t(name &&\n\t\t\t\t\t\t\t\t/^(?:internal)?(?:Query|Mutation|Action)(?:Generic)?$|^(?:query|mutation|action)(?:Generic)?$/.test(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontext.report({ node: specifier, messageId: 'builder' })\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tref?.source === 'convex/server' &&\n\t\t\t\t\t\t/^(?:internal)?(?:Query|Mutation|Action)Generic$|^(?:query|mutation|action)Generic$/.test(\n\t\t\t\t\t\t\tref.name,\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression'\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontext.report({ node, messageId: 'builder' })\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-handwritten-references': {\n\t\tmeta: metadata('Use generated api/internal references.', {\n\t\t\treference: 'Use generated api/internal references instead of makeFunctionReference.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (ref?.source === 'convex/server' && ref.name === 'makeFunctionReference')\n\t\t\t\t\t\tcontext.report({ node, messageId: 'reference' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'domain-import-boundaries': {\n\t\tmeta: metadata('Keep api, application, domain, and shared dependencies directed.', {\n\t\t\tboundary:\n\t\t\t\t'Follow api → application/domain → shared; sibling modules expose only rules.ts and queries.ts.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst { domainPublicFiles } = consumerOptions.parse(context.options[0] ?? {})\n\t\t\tconst file = appFile(context)\n\t\t\tif (componentRoot(context, context.filename)) return {}\n\t\t\tconst resolver = createResolver()\n\t\t\treturn sourceVisitors(context, (node, source) => {\n\t\t\t\tif (!file) return\n\t\t\t\tconst resolved = resolveImport(resolver, context.filename, source)\n\t\t\t\tif (!resolved) return\n\t\t\t\tconst target = appFile(context, resolved)?.replace(/\\.[cm]?[jt]s$/, '')\n\t\t\t\tif (!target) {\n\t\t\t\t\tif (!resolved.split(sep).includes('node_modules'))\n\t\t\t\t\t\tcontext.report({ node, messageId: 'boundary' })\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst from = file.split('/')\n\t\t\t\tconst to = target.split('/')\n\t\t\t\tlet forbidden = false\n\t\t\t\tif (from[0] === 'domain') {\n\t\t\t\t\tforbidden = ['api', 'application', 'migrations'].includes(to[0])\n\t\t\t\t\tif (\n\t\t\t\t\t\tto[0] === 'domain' &&\n\t\t\t\t\t\tfrom[1] !== to[1] &&\n\t\t\t\t\t\tto[1] !== 'shared' &&\n\t\t\t\t\t\tfrom[1] !== 'table.ts'\n\t\t\t\t\t) {\n\t\t\t\t\t\tforbidden =\n\t\t\t\t\t\t\tfrom[1] === 'shared' ||\n\t\t\t\t\t\t\t(!['rules', 'queries', 'contracts'].includes(to.slice(2).join('/')) &&\n\t\t\t\t\t\t\t\t!domainPublicFiles[to[1]]?.includes(to.slice(2).join('/')))\n\t\t\t\t\t}\n\t\t\t\t} else if (from[0] === 'api') {\n\t\t\t\t\tforbidden =\n\t\t\t\t\t\t['api', 'migrations'].includes(to[0]) ||\n\t\t\t\t\t\t(to[0] === 'domain' &&\n\t\t\t\t\t\t\tto[1] !== 'shared' &&\n\t\t\t\t\t\t\tto[1] !== (from.length > 2 ? from[1] : basename(file).replace(/\\.[cm]?[jt]s$/, '')))\n\t\t\t\t} else if (from[0] === 'application') forbidden = ['api', 'migrations'].includes(to[0])\n\t\t\t\telse if (['relations.ts', 'querying.ts'].includes(file) && to[0] === 'domain') {\n\t\t\t\t\tconst allowed = file === 'relations.ts' ? ['schema', 'table'] : ['queries', 'contracts']\n\t\t\t\t\tforbidden =\n\t\t\t\t\t\t!allowed.includes(to.slice(2).join('/')) &&\n\t\t\t\t\t\t!(file === 'relations.ts' && target === 'domain/table')\n\t\t\t\t}\n\t\t\t\tif (to[0] === 'migrations' && from[0] !== 'migrations') forbidden = true\n\t\t\t\tif (\n\t\t\t\t\t['api', 'domain', 'application'].includes(from[0]) &&\n\t\t\t\t\tto.length > 1 &&\n\t\t\t\t\t!['api', 'domain', 'application', '_generated', 'components', 'migrations'].includes(\n\t\t\t\t\t\tto[0],\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tforbidden = true\n\t\t\t\tif (forbidden) context.report({ node, messageId: 'boundary' })\n\t\t\t})\n\t\t},\n\t},\n\t'public-functions-in-api': {\n\t\tmeta: metadata('Expose authenticated public functions only through api/.', {\n\t\t\tpublic: 'Declare public auth*/role*/admin* functions in convex/api/<module>.ts.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tif (appFile(context)?.startsWith('api/')) return {}\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.callee.type !== 'CallExpression' &&\n\t\t\t\t\t\tref &&\n\t\t\t\t\t\tisFunctionsImport(context, ref.source) &&\n\t\t\t\t\t\t/^(auth|role|admin)(Query|Mutation|Action)$/.test(ref.name)\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'public' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'thin-api-adapters': {\n\t\tmeta: metadata('Keep business decisions and writes in domain executors.', {\n\t\t\tadapter:\n\t\t\t\t'Move business branches, private helpers, and database writes into the owning domain executor.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tif (!appFile(context)?.startsWith('api/')) return {}\n\t\t\treturn {\n\t\t\t\tIfStatement(node) {\n\t\t\t\t\tcontext.report({ node, messageId: 'adapter' })\n\t\t\t\t},\n\t\t\t\tSwitchStatement(node) {\n\t\t\t\t\tcontext.report({ node, messageId: 'adapter' })\n\t\t\t\t},\n\t\t\t\tConditionalExpression(node) {\n\t\t\t\t\tcontext.report({ node, messageId: 'adapter' })\n\t\t\t\t},\n\t\t\t\tProgram(node) {\n\t\t\t\t\tconst exported = exportedNames(node)\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' &&\n\t\t\t\t\t\t\tstatement.id &&\n\t\t\t\t\t\t\t!exported.has(statement.id.name)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tcontext.report({ node: statement, messageId: 'adapter' })\n\t\t\t\t\t\tif (statement.type === 'VariableDeclaration')\n\t\t\t\t\t\t\tfor (const declaration of statement.declarations) {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tdeclaration.id.type === 'Identifier' &&\n\t\t\t\t\t\t\t\t\t!exported.has(declaration.id.name) &&\n\t\t\t\t\t\t\t\t\t['ArrowFunctionExpression', 'FunctionExpression'].includes(\n\t\t\t\t\t\t\t\t\t\tdeclaration.init?.type ?? '',\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tcontext.report({ node: declaration, messageId: 'adapter' })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (isDbWrite(node)) context.report({ node, messageId: 'adapter' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-inline-enums': {\n\t\tmeta: metadata('Keep vocabularies in named constants.ts tuples.', {\n\t\t\tvocabulary: 'Define a named readonly tuple in constants.ts and pass it to k.enum().',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tlet values = node.arguments[0]\n\t\t\t\t\twhile (values?.type === 'TSAsExpression' || values?.type === 'TSSatisfiesExpression')\n\t\t\t\t\t\tvalues = values.expression\n\t\t\t\t\tif (kFactory(context, node) === 'enum' && values?.type === 'ArrayExpression')\n\t\t\t\t\t\tcontext.report({ node, messageId: 'vocabulary' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-unbounded-reads': {\n\t\tmeta: metadata('Bound collection reads through include or pagination.', {\n\t\t\tbounded:\n\t\t\t\t'Use include(...).execute(limit) or bounded pagination; do not collect() or resolve() an unbounded query.',\n\t\t\torder:\n\t\t\t\t'Apply eligibility filters in the indexed query before take(), execute(), or paginate(); filtering a bounded result can omit eligible rows. Do not move the predicate automatically.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (node.callee.type !== 'MemberExpression') return\n\t\t\t\t\tconst name = propertyName(node.callee)\n\t\t\t\t\tconst origin = readProvenance(context, node.callee.object)\n\t\t\t\t\tif (name === 'filter' && origin === 'bounded')\n\t\t\t\t\t\tcontext.report({ node, messageId: 'order' })\n\t\t\t\t\tif (\n\t\t\t\t\t\t(name === 'collect' && (origin === 'stream' || origin === 'relationship')) ||\n\t\t\t\t\t\t(name === 'resolve' && origin === 'stream')\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'bounded' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-manual-id-projection': {\n\t\tmeta: metadata('Use the table DTO boundary to project public IDs.', {\n\t\t\tprojection:\n\t\t\t\t'Use toPublicDto(row, true) to include _id; do not add IDs manually after a table DTO parse or projection.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tObjectExpression(node) {\n\t\t\t\t\tconst dto = node.properties.some(\n\t\t\t\t\t\t(property) =>\n\t\t\t\t\t\t\tproperty.type === 'SpreadElement' &&\n\t\t\t\t\t\t\treadProvenance(context, property.argument) === 'dto',\n\t\t\t\t\t)\n\t\t\t\t\tif (!dto) return\n\t\t\t\t\tfor (const property of node.properties) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t\t\t['id', '_id'].includes(\n\t\t\t\t\t\t\t\t(property.computed ? staticString(property.key) : exportName(property.key)) ?? '',\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tcontext.report({ node: property, messageId: 'projection' })\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tAssignmentExpression(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.left.type === 'MemberExpression' &&\n\t\t\t\t\t\t['id', '_id'].includes(propertyName(node.left) ?? '') &&\n\t\t\t\t\t\treadProvenance(context, node.left.object) === 'dto'\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'projection' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-copied-pagination': {\n\t\tmeta: metadata('Use native or table pagination schemas instead of copying their shape.', {\n\t\t\tpagination:\n\t\t\t\t'Use the native paginationOptsValidator (or paginated(table.dto())) for native pagination, or table.paginationOpts(selection) for table queries; do not copy pagination fields.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tconst isObject =\n\t\t\t\t\t\tkFactory(context, node) === 'object' ||\n\t\t\t\t\t\t(ref?.name === 'object' && ref.source === 'convex/values')\n\t\t\t\t\tif (!isObject) return\n\t\t\t\t\tconst argument = node.arguments[0]\n\t\t\t\t\tconst fieldsNode = argument && (localInitializer(context, argument) ?? argument)\n\t\t\t\t\tif (fieldsNode?.type !== 'ObjectExpression') return\n\t\t\t\t\tconst fields = new Set(\n\t\t\t\t\t\tfieldsNode.properties.flatMap((property) =>\n\t\t\t\t\t\t\tproperty.type === 'Property'\n\t\t\t\t\t\t\t\t? [property.computed ? staticString(property.key) : exportName(property.key)]\n\t\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t\tif (\n\t\t\t\t\t\t(fields.has('numItems') && fields.has('cursor')) ||\n\t\t\t\t\t\t['page', 'isDone', 'continueCursor'].every((field) => fields.has(field))\n\t\t\t\t\t)\n\t\t\t\t\t\tcontext.report({ node, messageId: 'pagination' })\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-manual-timestamps': {\n\t\tmeta: metadata('Let timestamps triggers own createdAt and updatedAt.', {\n\t\t\ttimestamp: 'Remove {{field}} from this write; register the timestamps trigger instead.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tif (!isDbWrite(node)) return\n\t\t\t\t\tconst data = node.arguments.at(-1)\n\t\t\t\t\tif (data?.type !== 'ObjectExpression') return\n\t\t\t\t\tfor (const property of data.properties) {\n\t\t\t\t\t\tif (property.type !== 'Property') continue\n\t\t\t\t\t\tconst field = property.computed ? staticString(property.key) : exportName(property.key)\n\t\t\t\t\t\tif (field === 'createdAt' || field === 'updatedAt')\n\t\t\t\t\t\t\tcontext.report({ node: property, messageId: 'timestamp', data: { field } })\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'component-boundaries': {\n\t\tmeta: metadata('Keep portable components isolated and consume their client facades.', {\n\t\t\tboundary:\n\t\t\t\t'Components may import only their own files and npm dependencies; inject host policy through the client API.',\n\t\t\tfacade: 'Import a component through its client.ts facade, not its private implementation.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tconst owner = componentRoot(context, context.filename)\n\t\t\tconst resolver = createResolver(false)\n\n\t\t\treturn sourceVisitors(context, (node, specifier) => {\n\t\t\t\tif (!specifier.startsWith('.')) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t/^cvx-kit\\/components\\/[^/]+\\//.test(specifier) &&\n\t\t\t\t\t\t!/^cvx-kit\\/components\\/[^/]+\\/convex\\.config(?:\\.js)?$/.test(specifier)\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontext.report({ node, messageId: 'facade' })\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst target = resolveImport(resolver, context.filename, specifier)\n\t\t\t\tif (!target || target.split(sep).includes('node_modules')) return\n\t\t\t\tif (\n\t\t\t\t\towner &&\n\t\t\t\t\t(relative(owner, target).startsWith(`..${sep}`) || target === dirname(owner))\n\t\t\t\t) {\n\t\t\t\t\tcontext.report({ node, messageId: 'boundary' })\n\t\t\t\t} else if (\n\t\t\t\t\t!owner &&\n\t\t\t\t\tcomponentRoot(context, target) &&\n\t\t\t\t\t!/^client(?:\\.[cm]?[jt]s)?$/.test(basename(target)) &&\n\t\t\t\t\t!(\n\t\t\t\t\t\tappFile(context) === 'convex.config.ts' &&\n\t\t\t\t\t\t/^convex\\.config(?:\\.[cm]?[jt]s)?$/.test(basename(target))\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tcontext.report({ node, messageId: 'facade' })\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t},\n\t'no-component-env': {\n\t\tmeta: metadata('Pass environment configuration into portable components.', {\n\t\t\tenv: 'Portable components must receive configuration through arguments; do not read process.env.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tif (!componentRoot(context, context.filename)) return {}\n\t\t\tfunction isProcess(node: ESTree.Node) {\n\t\t\t\tif (node.type !== 'Identifier') return false\n\t\t\t\tconst variable = binding(context, node)\n\t\t\t\tif (node.name === 'process' && !variable?.defs.length) return true\n\t\t\t\treturn variable?.defs.some(\n\t\t\t\t\t(def) =>\n\t\t\t\t\t\tdef.type === 'ImportBinding' &&\n\t\t\t\t\t\tdef.parent?.type === 'ImportDeclaration' &&\n\t\t\t\t\t\t['node:process', 'process'].includes(def.parent.source.value) &&\n\t\t\t\t\t\t['ImportDefaultSpecifier', 'ImportNamespaceSpecifier'].includes(def.node.type),\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tImportDeclaration(node) {\n\t\t\t\t\tif (['node:process', 'process'].includes(node.source.value)) {\n\t\t\t\t\t\tfor (const specifier of node.specifiers) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tspecifier.type === 'ImportSpecifier' &&\n\t\t\t\t\t\t\t\texportName(specifier.imported) === 'env'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcontext.report({ node: specifier, messageId: 'env' })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tMemberExpression(node) {\n\t\t\t\t\tif (propertyName(node) !== 'env') return\n\t\t\t\t\tconst object = node.object\n\t\t\t\t\tconst globalProcess =\n\t\t\t\t\t\tobject.type === 'MemberExpression' &&\n\t\t\t\t\t\tpropertyName(object) === 'process' &&\n\t\t\t\t\t\tobject.object.type === 'Identifier' &&\n\t\t\t\t\t\tobject.object.name === 'globalThis' &&\n\t\t\t\t\t\t!binding(context, object.object)?.defs.length\n\t\t\t\t\tif (isProcess(object) || globalProcess) context.report({ node, messageId: 'env' })\n\t\t\t\t},\n\t\t\t\tVariableDeclarator(node) {\n\t\t\t\t\tif (node.init && isProcess(node.init) && node.id.type === 'ObjectPattern') {\n\t\t\t\t\t\tfor (const property of node.id.properties) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tproperty.type === 'Property' &&\n\t\t\t\t\t\t\t\t(property.computed ? staticString(property.key) : exportName(property.key)) ===\n\t\t\t\t\t\t\t\t\t'env'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcontext.report({ node: property, messageId: 'env' })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'schema-file-boundaries': {\n\t\tmeta: metadata('Keep storage shapes and indexes in their documented owners.', {\n\t\t\tschema: '{{builder}} belongs in {{file}}.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tCallExpression(node) {\n\t\t\t\t\tconst ref = imported(context, node.callee)\n\t\t\t\t\tconst file = appFile(context)\n\t\t\t\t\tif (!file) return\n\t\t\t\t\tlet expected: string | null = null\n\t\t\t\t\tif (ref?.source === 'convex/server') {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tref.name === 'defineSchema' &&\n\t\t\t\t\t\t\tfile !== 'schema.ts' &&\n\t\t\t\t\t\t\t!(componentRoot(context, context.filename) && basename(file) === 'schema.ts')\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\texpected = 'the root schema.ts (or a component schema.ts)'\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tref.name === 'defineTable' &&\n\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\tcomponentRoot(context, context.filename) &&\n\t\t\t\t\t\t\t\t['schema.ts', 'table.ts'].includes(basename(file))\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\texpected =\n\t\t\t\t\t\t\t\t'a component schema.ts/table.ts; host tables use kTable in domain/<module>/schema.ts'\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tref &&\n\t\t\t\t\t\tTABLE_SOURCES.includes(ref.source) &&\n\t\t\t\t\t\t['kTable', 'tenantTable', 'kVariantTable'].includes(ref.name) &&\n\t\t\t\t\t\t!/^domain\\/[^/]+\\/schema\\.ts$/.test(file) &&\n\t\t\t\t\t\t!(\n\t\t\t\t\t\t\tcomponentRoot(context, context.filename) &&\n\t\t\t\t\t\t\t['schema.ts', 'table.ts'].includes(basename(file))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\texpected = 'domain/<module>/schema.ts or a component schema.ts/table.ts'\n\t\t\t\t\tif (expected)\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'schema',\n\t\t\t\t\t\t\tdata: { builder: ref?.name ?? 'table', file: expected },\n\t\t\t\t\t\t})\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.callee.type === 'MemberExpression' &&\n\t\t\t\t\t\t['index', 'searchIndex', 'vectorIndex'].includes(propertyName(node.callee) ?? '') &&\n\t\t\t\t\t\tisTableChain(node.callee.object) &&\n\t\t\t\t\t\t!(componentRoot(context, context.filename)\n\t\t\t\t\t\t\t? basename(file) === 'table.ts'\n\t\t\t\t\t\t\t: /^domain\\/[^/]+\\/table\\.ts$/.test(file))\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'schema',\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tbuilder: 'Table indexes',\n\t\t\t\t\t\t\t\tfile: componentRoot(context, context.filename)\n\t\t\t\t\t\t\t\t\t? 'a component table.ts'\n\t\t\t\t\t\t\t\t\t: 'domain/<module>/table.ts',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'no-internal-reexports': {\n\t\tmeta: metadata('Import from owning modules directly; consumer apps have no barrels.', {\n\t\t\treexport: 'Import from the owning file directly; do not re-export imports inside convex/.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\tfunction check(node: ESTree.ExportNamedDeclaration | ESTree.ExportAllDeclaration) {\n\t\t\t\tif (node.source) {\n\t\t\t\t\tcontext.report({ node, messageId: 'reexport' })\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfor (const specifier of node.type === 'ExportNamedDeclaration' ? node.specifiers : []) {\n\t\t\t\t\tif (binding(context, specifier.local)?.defs.some((def) => def.type === 'ImportBinding')) {\n\t\t\t\t\t\tcontext.report({ node: specifier, messageId: 'reexport' })\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tExportNamedDeclaration: check,\n\t\t\t\tExportAllDeclaration: check,\n\t\t\t\tExportDefaultDeclaration(node) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.declaration.type === 'Identifier' &&\n\t\t\t\t\t\tbinding(context, node.declaration)?.defs.some((def) => def.type === 'ImportBinding')\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontext.report({ node, messageId: 'reexport' })\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'public-api-first': {\n\t\tmeta: metadata('Place private helper implementations after the exported API.', {\n\t\t\torder:\n\t\t\t\t'Move this private helper below the exported API so the file reads from public purpose to implementation.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tconst exports = exportedNames(node)\n\t\t\t\t\tconst lastExport = node.body.findLastIndex((statement) =>\n\t\t\t\t\t\tstatement.type.startsWith('Export'),\n\t\t\t\t\t)\n\t\t\t\t\tfor (const statement of node.body.slice(0, lastExport < 0 ? 0 : lastExport)) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tstatement.type === 'FunctionDeclaration' &&\n\t\t\t\t\t\t\tstatement.id &&\n\t\t\t\t\t\t\t!exports.has(statement.id.name)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontext.report({ node: statement, messageId: 'order' })\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n\t'named-private-helpers': {\n\t\tmeta: metadata('Use named declarations for top-level private helper functions.', {\n\t\t\thelper: 'Declare this private helper with function name(...) at the bottom of the file.',\n\t\t}),\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\tProgram(node) {\n\t\t\t\t\tconst exports = exportedNames(node)\n\t\t\t\t\tfor (const statement of node.body) {\n\t\t\t\t\t\tif (statement.type !== 'VariableDeclaration') continue\n\t\t\t\t\t\tfor (const declaration of statement.declarations) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdeclaration.id.type === 'Identifier' &&\n\t\t\t\t\t\t\t\t!exports.has(declaration.id.name) &&\n\t\t\t\t\t\t\t\t(declaration.init?.type === 'ArrowFunctionExpression' ||\n\t\t\t\t\t\t\t\t\tdeclaration.init?.type === 'FunctionExpression')\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcontext.report({ node: declaration, messageId: 'helper' })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t},\n}\n\nexport const rules: Record<RuleName, Rule> = scopeRules(applicationRules)\nconst plugin: Plugin = { meta: { name: 'cvx' }, rules }\nexport default plugin\n\nfunction scopeRules(source: Record<RuleName, CreateRule>): Record<RuleName, Rule> {\n\tconst scoped = { ...source }\n\t// SAFETY: source is the closed applicationRules record; its own keys are exactly RuleName.\n\tconst names = Object.keys(source) as RuleName[]\n\tfor (const name of names) {\n\t\tconst commonProperties = {\n\t\t\tconvexDir: { type: 'string', minLength: 1 },\n\t\t\tcomponentDirs: { type: 'array', items: { type: 'string', minLength: 1 } },\n\t\t}\n\t\tconst rule = source[name]\n\t\tscoped[name] = {\n\t\t\tmeta: {\n\t\t\t\t...rule.meta,\n\t\t\t\tschema: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\tproperties:\n\t\t\t\t\t\t\tname === 'domain-import-boundaries'\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t...commonProperties,\n\t\t\t\t\t\t\t\t\t\tdomainPublicFiles: {\n\t\t\t\t\t\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\t\t\t\t\t\tadditionalProperties: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\t\t\t\t\t\titems: { type: 'string', minLength: 1 },\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: commonProperties,\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\tcreate(context) {\n\t\t\t\tconst file = appFile(context)\n\t\t\t\tif (\n\t\t\t\t\t!file ||\n\t\t\t\t\t/(?:^|\\/)(?:_generated|__tests__)(?:\\/|$)/.test(file) ||\n\t\t\t\t\t/\\.(?:test|spec)\\.[cm]?[jt]s$/.test(file)\n\t\t\t\t)\n\t\t\t\t\treturn {}\n\t\t\t\treturn rule.create(context)\n\t\t\t},\n\t\t}\n\t}\n\treturn scoped\n}\n"],"mappings":"A,4tBAoCA,SAAgBA,EAAkB,EAA+B,CAAC,EAA6B,CAC9F,IAAK,IAAMC,KAAYC,EAAQ,YAAc,CAAC,EAAGC,EAAcF,CAAQ,EACvE,OAAOG,EAAoBF,CAAO,CACnC,CA2pBA,MAAaG,EAAgCC,EAAW,CAloBvD,GAAGC,EACH,mBAAoB,CACnB,GAAGA,EAAe,oBAClB,OAAO,EAAS,CACf,IAAMC,EAAOC,EAAQC,CAAO,GAAK,GAejC,MAdI,CAAC,eAAgB,aAAa,CAAC,CAAC,SAASF,CAAI,EAC5CG,EAAsBH,EAAME,EAAQ,WAAW,IAAI,EAAU,CAAC,EAC3D,CACN,QAAQ,EAAM,CACbA,EAAQ,OAAO,CACd,OACA,UAAW,YACX,KAAM,CACL,OAAQ,GAAGF,EAAK,oFACjB,CACD,CAAC,CACF,CACD,EAEMD,EAAe,mBAAmB,CAAC,OAAOG,CAAO,CACzD,CACD,EACA,+BAAgCE,EAChC,wBAAyB,CACxB,KAAMC,EAAS,+DAAgE,CAC9E,OAAQ,2EACT,CAAC,EACD,OAAO,EAAS,CACf,IAAMC,EAAQC,EAAcL,EAASA,EAAQ,QAAQ,EAC/CM,kBAAO,IAAI,IACjB,SAASC,EAAM,EAAoD,CAClE,IAAMC,EAAMC,EAAST,EAASU,EAAK,MAAM,EACzC,GAAI,CAACF,EAAK,OACV,IAAIV,EAAsB,KAEzB,CAAC,UAAW,kBAAkB,CAAC,CAAC,SAASU,EAAI,MAAM,GACnDA,EAAI,O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