@kayjs/kay 1.108.0 → 1.110.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint.js +2093 -3774
- package/editors/zed/extension.toml +2 -2
- package/llms/action-protection.md +1 -1
- package/llms/actions-from-islands.md +5 -5
- package/llms/actions-refused-fields.md +4 -4
- package/llms/api-from-islands.md +6 -6
- package/llms/browser-only.md +2 -2
- package/llms/cdn-caching.md +1 -1
- package/llms/checks.md +1 -1
- package/llms/code-lints.md +1 -2
- package/llms/component-library-conventions.md +1 -1
- package/llms/components.md +5 -5
- package/llms/deprecated-lints.md +2 -7
- package/llms/effects.md +1 -1
- package/llms/errors.md +2 -2
- package/llms/events.md +1 -1
- package/llms/guards.md +1 -1
- package/llms/head.md +1 -1
- package/llms/hooks.md +2 -2
- package/llms/images.md +1 -1
- package/llms/island-and-form-lints.md +4 -2
- package/llms/island-sources.md +1 -1
- package/llms/islands-state-to-ids.md +2 -2
- package/llms/islands.md +8 -4
- package/llms/lints.md +1 -1
- package/llms/live-values.md +4 -4
- package/llms/local-collections.md +1 -1
- package/llms/locales.md +1 -1
- package/llms/mcp.md +2 -2
- package/llms/metrics.md +1 -1
- package/llms/navigation-from-code.md +7 -7
- package/llms/navigation.md +4 -2
- package/llms/prerendering.md +1 -0
- package/llms/production.md +2 -2
- package/llms/project-new-and-add.md +1 -1
- package/llms/project.md +4 -4
- package/llms/proxy-and-security.md +1 -1
- package/llms/queues.md +1 -1
- package/llms/rate-limits.md +4 -4
- package/llms/rendering.md +1 -1
- package/llms/server-islands.md +2 -2
- package/llms/server.md +1 -1
- package/llms/stores.md +1 -1
- package/llms/styles-and-assets.md +1 -1
- package/llms/templates-elements-slots-snippets.md +2 -2
- package/llms/testing-mount.md +49 -0
- package/llms/testing.md +4 -45
- package/llms/upgrading-1-105-config.md +13 -13
- package/llms/upgrading-archive.md +64 -74
- package/llms/upgrading.md +92 -70
- package/llms/whats-new.md +24 -0
- package/llms.txt +5 -6
- package/package.json +6 -10
- package/src/build/route-sizes.ts +2 -3
- package/src/build/variants.ts +132 -18
- package/src/check/browser-global-reads.ts +2 -2
- package/src/check/config-objects.ts +1 -1
- package/src/check/diagnose.ts +0 -22
- package/src/check/env-types.ts +1 -1
- package/src/check/export-homes.ts +1 -1
- package/src/check/guards.ts +3 -3
- package/src/check/index.ts +2 -7
- package/src/check/moved-keys.ts +1 -1
- package/src/check/project.ts +6 -7
- package/src/check/schema-builders.ts +125 -26
- package/src/check/shadow-types.ts +0 -86
- package/src/commands/check.ts +2 -2
- package/src/commands/env.ts +25 -3
- package/src/commands/upgrade.ts +2 -1
- package/src/compiler/allow-comments.ts +38 -2
- package/src/compiler/ast.ts +21 -19
- package/src/compiler/browser.ts +2 -14
- package/src/compiler/class-items.ts +16 -0
- package/src/compiler/codegen.ts +10 -10
- package/src/compiler/deprecated-library.ts +0 -12
- package/src/compiler/deprecated-lints-1-106.ts +2 -2
- package/src/compiler/deprecated-lints.ts +3 -495
- package/src/compiler/deprecated-ui-props.ts +5 -5
- package/src/compiler/errors.ts +2 -2
- package/src/compiler/fence-checks.ts +2 -121
- package/src/compiler/hand-parts.ts +83 -0
- package/src/compiler/helper-imports.ts +2 -2
- package/src/compiler/image-attributes.ts +1 -3
- package/src/compiler/index.ts +23 -23
- package/src/compiler/island-arguments.ts +17 -95
- package/src/compiler/island-cause.ts +7 -7
- package/src/compiler/island-declaration.ts +2 -8
- package/src/compiler/island-lints.ts +19 -0
- package/src/compiler/island-marker.ts +3 -3
- package/src/compiler/island-problems.ts +25 -0
- package/src/compiler/items.ts +12 -0
- package/src/compiler/jsx-class.ts +1 -25
- package/src/compiler/jsx.ts +7 -6
- package/src/compiler/kay-exports.ts +0 -2
- package/src/compiler/link-flags.ts +9 -38
- package/src/compiler/lints.ts +10 -18
- package/src/compiler/markup.ts +33 -41
- package/src/compiler/module-signals.ts +2 -2
- package/src/compiler/names.ts +1 -1
- package/src/compiler/page-settings.ts +11 -0
- package/src/compiler/parser.ts +6 -8
- package/src/compiler/plan.ts +1 -3
- package/src/compiler/removed-lints.ts +90 -0
- package/src/compiler/rewrite.ts +3 -18
- package/src/compiler/script-server.ts +8 -3
- package/src/compiler/signal-from-prop.ts +141 -0
- package/src/compiler/template-reads.ts +16 -0
- package/src/compiler/validate.ts +3 -8
- package/src/config-loader.ts +14 -4
- package/src/config-resolve.ts +18 -142
- package/src/config-shape.ts +44 -34
- package/src/config.ts +10 -114
- package/src/dev/preload.ts +4 -1
- package/src/lsp/server.ts +4 -0
- package/src/migrate/markup.ts +4 -1
- package/src/runtime/action-call.ts +0 -8
- package/src/runtime/action-encode.ts +26 -0
- package/src/runtime/action-error.ts +3 -11
- package/src/runtime/action-protection.ts +2 -2
- package/src/runtime/action-run.ts +2 -27
- package/src/runtime/action-shared.ts +14 -37
- package/src/runtime/action-stream.ts +0 -1
- package/src/runtime/action.ts +1 -1
- package/src/runtime/call-result.ts +2 -10
- package/src/runtime/checks.ts +25 -13
- package/src/runtime/client.ts +7 -11
- package/src/runtime/core.ts +5 -23
- package/src/runtime/dom.ts +1 -1
- package/src/runtime/html.ts +1 -1
- package/src/runtime/i18n.client.ts +1 -4
- package/src/runtime/i18n.server.ts +1 -4
- package/src/runtime/i18n.ts +3 -3
- package/src/runtime/image.ts +2 -19
- package/src/runtime/index.ts +3 -3
- package/src/runtime/island.server.ts +56 -13
- package/src/runtime/live-resource.server.ts +0 -1
- package/src/runtime/live-value.server.ts +2 -2
- package/src/runtime/live-value.shared.ts +7 -20
- package/src/runtime/live.ts +1 -12
- package/src/runtime/local-types.ts +1 -11
- package/src/runtime/local.ts +4 -14
- package/src/runtime/navigate-api.ts +2 -5
- package/src/runtime/navigate.ts +9 -0
- package/src/runtime/navigation-state.ts +0 -12
- package/src/runtime/navigation.ts +5 -1
- package/src/runtime/page-swap.ts +8 -8
- package/src/runtime/persist.ts +11 -3
- package/src/runtime/persisted.ts +4 -30
- package/src/runtime/presence.ts +6 -7
- package/src/runtime/query-param.ts +20 -12
- package/src/runtime/reactive.ts +3 -1
- package/src/runtime/refuse.ts +3 -17
- package/src/runtime/store-base.ts +4 -6
- package/src/runtime/swap-fetch.ts +1 -1
- package/src/runtime/swap-flight.ts +10 -10
- package/src/runtime/swap-kept.ts +69 -29
- package/src/runtime/swap-morph.ts +49 -9
- package/src/runtime/text-hash.ts +17 -0
- package/src/runtime/uid.server.ts +6 -4
- package/src/runtime/values.ts +52 -23
- package/src/runtime/with-query.ts +9 -0
- package/src/server/action-hooks.ts +8 -8
- package/src/server/actions.ts +13 -14
- package/src/server/api-modules.ts +2 -3
- package/src/server/app-stages.ts +15 -33
- package/src/server/app.ts +10 -5
- package/src/server/auth-mails.ts +0 -2
- package/src/server/env-state.ts +40 -10
- package/src/server/flash.ts +1 -1
- package/src/server/guard-requirement.ts +4 -4
- package/src/server/image.ts +2 -2
- package/src/server/index.ts +0 -2
- package/src/server/job-context.ts +3 -3
- package/src/server/jobs-page.ts +1 -1
- package/src/server/jobs.ts +5 -9
- package/src/server/kept-exports.ts +0 -2
- package/src/server/kv.ts +11 -14
- package/src/server/library.ts +1 -3
- package/src/server/live.ts +2 -2
- package/src/server/mcp.ts +3 -9
- package/src/server/metrics.ts +2 -4
- package/src/server/page-settings.ts +10 -19
- package/src/server/prerender.ts +19 -2
- package/src/server/protection.ts +15 -18
- package/src/server/queue.ts +3 -6
- package/src/server/rate-limit.ts +0 -3
- package/src/server/render-document.ts +9 -7
- package/src/server/render.ts +1 -1
- package/src/server/routes.ts +7 -3
- package/src/server/scope.ts +3 -2
- package/src/server/session.ts +5 -6
- package/src/server/setup.ts +1 -1
- package/src/server/signals.ts +17 -7
- package/src/server/signed.ts +1 -3
- package/src/server/source.ts +20 -4
- package/src/server/speculation.ts +1 -1
- package/src/server/storage.ts +3 -8
- package/src/server/validate.ts +1 -1
- package/src/server/vitals.ts +1 -3
- package/src/server/work-scope.ts +2 -4
- package/src/server/work.ts +1 -1
- package/src/server/workflow.ts +1 -1
- package/src/test/index.ts +2 -1
- package/src/test/site-actions.ts +16 -6
- package/src/test/site-keys.ts +10 -15
- package/src/test/site-socket.ts +1 -2
- package/src/test/site-types.ts +0 -8
- package/types/build/route-sizes.d.ts.map +1 -1
- package/types/build/variants.d.ts +9 -1
- package/types/build/variants.d.ts.map +1 -1
- package/types/check/diagnose.d.ts.map +1 -1
- package/types/check/index.d.ts +1 -2
- package/types/check/index.d.ts.map +1 -1
- package/types/check/project.d.ts.map +1 -1
- package/types/check/schema-builders.d.ts.map +1 -1
- package/types/check/shadow-types.d.ts.map +1 -1
- package/types/commands/env.d.ts.map +1 -1
- package/types/commands/upgrade.d.ts.map +1 -1
- package/types/compiler/allow-comments.d.ts +2 -0
- package/types/compiler/allow-comments.d.ts.map +1 -1
- package/types/compiler/ast.d.ts +1 -2
- package/types/compiler/ast.d.ts.map +1 -1
- package/types/compiler/browser.d.ts.map +1 -1
- package/types/compiler/class-items.d.ts +7 -0
- package/types/compiler/class-items.d.ts.map +1 -0
- package/types/compiler/deprecated-library.d.ts.map +1 -1
- package/types/compiler/deprecated-lints-1-106.d.ts +2 -2
- package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -1
- package/types/compiler/deprecated-lints.d.ts +2 -553
- package/types/compiler/deprecated-lints.d.ts.map +1 -1
- package/types/compiler/deprecated-ui-props.d.ts +1 -8
- package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
- package/types/compiler/errors.d.ts +2 -2
- package/types/compiler/errors.d.ts.map +1 -1
- package/types/compiler/fence-checks.d.ts +0 -1
- package/types/compiler/fence-checks.d.ts.map +1 -1
- package/types/compiler/hand-parts.d.ts +10 -0
- package/types/compiler/hand-parts.d.ts.map +1 -0
- package/types/compiler/image-attributes.d.ts +0 -1
- package/types/compiler/image-attributes.d.ts.map +1 -1
- package/types/compiler/index.d.ts.map +1 -1
- package/types/compiler/island-arguments.d.ts +7 -11
- package/types/compiler/island-arguments.d.ts.map +1 -1
- package/types/compiler/island-cause.d.ts +1 -1
- package/types/compiler/island-cause.d.ts.map +1 -1
- package/types/compiler/island-declaration.d.ts +1 -3
- package/types/compiler/island-declaration.d.ts.map +1 -1
- package/types/compiler/island-lints.d.ts +17 -0
- package/types/compiler/island-lints.d.ts.map +1 -0
- package/types/compiler/island-problems.d.ts +7 -0
- package/types/compiler/island-problems.d.ts.map +1 -0
- package/types/compiler/items.d.ts +1 -0
- package/types/compiler/items.d.ts.map +1 -1
- package/types/compiler/jsx-class.d.ts +1 -2
- package/types/compiler/jsx-class.d.ts.map +1 -1
- package/types/compiler/jsx.d.ts.map +1 -1
- package/types/compiler/kay-exports.d.ts.map +1 -1
- package/types/compiler/link-flags.d.ts +0 -6
- package/types/compiler/link-flags.d.ts.map +1 -1
- package/types/compiler/lints.d.ts +21 -566
- package/types/compiler/lints.d.ts.map +1 -1
- package/types/compiler/markup.d.ts +1 -1
- package/types/compiler/markup.d.ts.map +1 -1
- package/types/compiler/module-signals.d.ts.map +1 -1
- package/types/compiler/names.d.ts.map +1 -1
- package/types/compiler/page-settings.d.ts +4 -0
- package/types/compiler/page-settings.d.ts.map +1 -1
- package/types/compiler/parser.d.ts.map +1 -1
- package/types/compiler/plan.d.ts.map +1 -1
- package/types/compiler/removed-lints.d.ts +3 -0
- package/types/compiler/removed-lints.d.ts.map +1 -0
- package/types/compiler/script-server.d.ts.map +1 -1
- package/types/compiler/signal-from-prop.d.ts +4 -0
- package/types/compiler/signal-from-prop.d.ts.map +1 -0
- package/types/compiler/template-reads.d.ts +1 -0
- package/types/compiler/template-reads.d.ts.map +1 -1
- package/types/compiler/validate.d.ts.map +1 -1
- package/types/config-loader.d.ts.map +1 -1
- package/types/config-resolve.d.ts.map +1 -1
- package/types/config-shape.d.ts +1 -1
- package/types/config-shape.d.ts.map +1 -1
- package/types/config.d.ts +5 -105
- package/types/config.d.ts.map +1 -1
- package/types/dev/preload.d.ts.map +1 -1
- package/types/lsp/server.d.ts.map +1 -1
- package/types/migrate/markup.d.ts.map +1 -1
- package/types/runtime/action-call.d.ts.map +1 -1
- package/types/runtime/action-encode.d.ts +1 -0
- package/types/runtime/action-encode.d.ts.map +1 -1
- package/types/runtime/action-error.d.ts +1 -2
- package/types/runtime/action-error.d.ts.map +1 -1
- package/types/runtime/action-run.d.ts.map +1 -1
- package/types/runtime/action-shared.d.ts +1 -27
- package/types/runtime/action-shared.d.ts.map +1 -1
- package/types/runtime/action-stream.d.ts.map +1 -1
- package/types/runtime/action.d.ts +1 -1
- package/types/runtime/action.d.ts.map +1 -1
- package/types/runtime/call-result.d.ts +0 -10
- package/types/runtime/call-result.d.ts.map +1 -1
- package/types/runtime/checks.d.ts +14 -11
- package/types/runtime/checks.d.ts.map +1 -1
- package/types/runtime/client.d.ts.map +1 -1
- package/types/runtime/core.d.ts +2 -20
- package/types/runtime/core.d.ts.map +1 -1
- package/types/runtime/dom.d.ts +1 -1
- package/types/runtime/dom.d.ts.map +1 -1
- package/types/runtime/html.d.ts +1 -1
- package/types/runtime/html.d.ts.map +1 -1
- package/types/runtime/i18n.client.d.ts +0 -1
- package/types/runtime/i18n.client.d.ts.map +1 -1
- package/types/runtime/i18n.d.ts +1 -1
- package/types/runtime/i18n.d.ts.map +1 -1
- package/types/runtime/i18n.server.d.ts +0 -1
- package/types/runtime/i18n.server.d.ts.map +1 -1
- package/types/runtime/image.d.ts.map +1 -1
- package/types/runtime/index.d.ts +3 -3
- package/types/runtime/index.d.ts.map +1 -1
- package/types/runtime/island.server.d.ts +2 -0
- package/types/runtime/island.server.d.ts.map +1 -1
- package/types/runtime/live-resource.server.d.ts.map +1 -1
- package/types/runtime/live-value.shared.d.ts +7 -15
- package/types/runtime/live-value.shared.d.ts.map +1 -1
- package/types/runtime/live.d.ts +0 -11
- package/types/runtime/live.d.ts.map +1 -1
- package/types/runtime/local-types.d.ts +0 -14
- package/types/runtime/local-types.d.ts.map +1 -1
- package/types/runtime/navigate-api.d.ts +0 -4
- package/types/runtime/navigate-api.d.ts.map +1 -1
- package/types/runtime/navigate.d.ts.map +1 -1
- package/types/runtime/navigation-state.d.ts +0 -4
- package/types/runtime/navigation-state.d.ts.map +1 -1
- package/types/runtime/navigation.d.ts +2 -0
- package/types/runtime/navigation.d.ts.map +1 -1
- package/types/runtime/page-swap.d.ts.map +1 -1
- package/types/runtime/persist.d.ts +1 -0
- package/types/runtime/persist.d.ts.map +1 -1
- package/types/runtime/persisted.d.ts +0 -15
- package/types/runtime/persisted.d.ts.map +1 -1
- package/types/runtime/presence.d.ts +0 -2
- package/types/runtime/presence.d.ts.map +1 -1
- package/types/runtime/query-param.d.ts.map +1 -1
- package/types/runtime/reactive.d.ts +2 -1
- package/types/runtime/reactive.d.ts.map +1 -1
- package/types/runtime/refuse.d.ts +0 -7
- package/types/runtime/refuse.d.ts.map +1 -1
- package/types/runtime/store-base.d.ts +1 -2
- package/types/runtime/store-base.d.ts.map +1 -1
- package/types/runtime/swap-flight.d.ts +1 -1
- package/types/runtime/swap-flight.d.ts.map +1 -1
- package/types/runtime/swap-kept.d.ts.map +1 -1
- package/types/runtime/swap-morph.d.ts.map +1 -1
- package/types/runtime/text-hash.d.ts +2 -0
- package/types/runtime/text-hash.d.ts.map +1 -0
- package/types/runtime/uid.server.d.ts.map +1 -1
- package/types/runtime/values.d.ts +6 -1
- package/types/runtime/values.d.ts.map +1 -1
- package/types/runtime/with-query.d.ts +2 -0
- package/types/runtime/with-query.d.ts.map +1 -1
- package/types/server/action-hooks.d.ts +4 -4
- package/types/server/action-hooks.d.ts.map +1 -1
- package/types/server/actions.d.ts.map +1 -1
- package/types/server/api-modules.d.ts +0 -1
- package/types/server/api-modules.d.ts.map +1 -1
- package/types/server/app-stages.d.ts +5 -13
- package/types/server/app-stages.d.ts.map +1 -1
- package/types/server/app.d.ts +3 -8
- package/types/server/app.d.ts.map +1 -1
- package/types/server/auth-mails.d.ts +0 -5
- package/types/server/auth-mails.d.ts.map +1 -1
- package/types/server/env-state.d.ts +1 -0
- package/types/server/env-state.d.ts.map +1 -1
- package/types/server/guard-requirement.d.ts +0 -1
- package/types/server/guard-requirement.d.ts.map +1 -1
- package/types/server/image.d.ts +0 -1
- package/types/server/image.d.ts.map +1 -1
- package/types/server/index.d.ts +0 -2
- package/types/server/index.d.ts.map +1 -1
- package/types/server/job-context.d.ts +1 -1
- package/types/server/job-context.d.ts.map +1 -1
- package/types/server/jobs.d.ts +0 -4
- package/types/server/jobs.d.ts.map +1 -1
- package/types/server/kept-exports.d.ts.map +1 -1
- package/types/server/kv.d.ts +4 -4
- package/types/server/kv.d.ts.map +1 -1
- package/types/server/library.d.ts +1 -3
- package/types/server/library.d.ts.map +1 -1
- package/types/server/mcp.d.ts +0 -1
- package/types/server/mcp.d.ts.map +1 -1
- package/types/server/metrics.d.ts +0 -5
- package/types/server/metrics.d.ts.map +1 -1
- package/types/server/page-settings.d.ts +3 -3
- package/types/server/page-settings.d.ts.map +1 -1
- package/types/server/prerender.d.ts.map +1 -1
- package/types/server/protection.d.ts +6 -6
- package/types/server/protection.d.ts.map +1 -1
- package/types/server/queue.d.ts +1 -3
- package/types/server/queue.d.ts.map +1 -1
- package/types/server/rate-limit.d.ts +0 -2
- package/types/server/rate-limit.d.ts.map +1 -1
- package/types/server/render-document.d.ts +1 -1
- package/types/server/render-document.d.ts.map +1 -1
- package/types/server/routes.d.ts +1 -1
- package/types/server/routes.d.ts.map +1 -1
- package/types/server/scope.d.ts.map +1 -1
- package/types/server/session.d.ts +1 -1
- package/types/server/session.d.ts.map +1 -1
- package/types/server/signals.d.ts.map +1 -1
- package/types/server/signed.d.ts +0 -2
- package/types/server/signed.d.ts.map +1 -1
- package/types/server/source.d.ts +1 -1
- package/types/server/source.d.ts.map +1 -1
- package/types/server/storage.d.ts +0 -4
- package/types/server/storage.d.ts.map +1 -1
- package/types/server/vitals.d.ts +0 -1
- package/types/server/vitals.d.ts.map +1 -1
- package/types/server/work-scope.d.ts +0 -2
- package/types/server/work-scope.d.ts.map +1 -1
- package/types/server/workflow.d.ts +1 -1
- package/types/server/workflow.d.ts.map +1 -1
- package/types/test/index.d.ts.map +1 -1
- package/types/test/site-actions.d.ts +1 -1
- package/types/test/site-actions.d.ts.map +1 -1
- package/types/test/site-keys.d.ts +1 -1
- package/types/test/site-keys.d.ts.map +1 -1
- package/types/test/site-socket.d.ts +1 -1
- package/types/test/site-socket.d.ts.map +1 -1
- package/types/test/site-types.d.ts +0 -8
- package/types/test/site-types.d.ts.map +1 -1
- package/llms/deprecated-lints-1-105-libraries.md +0 -32
- package/llms/deprecated-lints-1-105.md +0 -58
- package/src/check/action-readers.ts +0 -115
- package/src/check/action-type.ts +0 -44
- package/src/check/ai-language.ts +0 -56
- package/src/check/app-hooks.ts +0 -90
- package/src/check/auth-methods.ts +0 -85
- package/src/check/auth-rate-limits.ts +0 -99
- package/src/check/call-result.ts +0 -242
- package/src/check/client-keys.ts +0 -10
- package/src/check/cms-options.ts +0 -81
- package/src/check/config-groups.ts +0 -22
- package/src/check/config-switches.ts +0 -38
- package/src/check/context-import.ts +0 -51
- package/src/check/env-files.ts +0 -31
- package/src/check/format-duration.ts +0 -75
- package/src/check/guard-options.ts +0 -58
- package/src/check/handler-events.ts +0 -149
- package/src/check/hook-context.ts +0 -94
- package/src/check/hook-names.ts +0 -104
- package/src/check/i18n-keys.ts +0 -50
- package/src/check/images-keys.ts +0 -54
- package/src/check/job-shapes.ts +0 -273
- package/src/check/link-flag-tests.ts +0 -130
- package/src/check/live-api.ts +0 -137
- package/src/check/mail-api.ts +0 -67
- package/src/check/one-state-api.ts +0 -357
- package/src/check/pages-options.ts +0 -35
- package/src/check/rate-enforce.ts +0 -53
- package/src/check/refusal-calls.ts +0 -185
- package/src/check/retired-lints.ts +0 -49
- package/src/check/route-keys.ts +0 -166
- package/src/check/secret-keys.ts +0 -83
- package/src/check/socket-frames.ts +0 -102
- package/src/check/source-readers.ts +0 -257
- package/src/check/store-ms.ts +0 -72
- package/src/check/store-names.ts +0 -88
- package/src/check/test-helpers.ts +0 -98
- package/src/check/ttl-names.ts +0 -142
- package/src/compiler/deprecated-ai-labels.ts +0 -97
- package/src/compiler/deprecated-ai-links.ts +0 -63
- package/src/compiler/deprecated-allow.ts +0 -50
- package/src/compiler/deprecated-auth-lints.ts +0 -14
- package/src/compiler/deprecated-auth-signed.ts +0 -29
- package/src/compiler/deprecated-children.ts +0 -66
- package/src/compiler/deprecated-image.ts +0 -116
- package/src/compiler/deprecated-island.ts +0 -155
- package/src/compiler/deprecated-lints-1-105.ts +0 -41
- package/src/compiler/deprecated-page.ts +0 -125
- package/src/compiler/deprecated-parts.ts +0 -22
- package/src/compiler/deprecated-typed-lints.ts +0 -23
- package/src/compiler/deprecated-ui-callbacks.ts +0 -66
- package/src/compiler/deprecated-ui-input.ts +0 -97
- package/src/compiler/deprecated-ui-items.ts +0 -47
- package/src/compiler/old-parts.ts +0 -84
- package/src/runtime/mount.compat.ts +0 -8
- package/src/server/moved-exports.ts +0 -17
- package/types/check/action-readers.d.ts +0 -3
- package/types/check/action-readers.d.ts.map +0 -1
- package/types/check/action-type.d.ts +0 -3
- package/types/check/action-type.d.ts.map +0 -1
- package/types/check/ai-language.d.ts +0 -3
- package/types/check/ai-language.d.ts.map +0 -1
- package/types/check/app-hooks.d.ts +0 -3
- package/types/check/app-hooks.d.ts.map +0 -1
- package/types/check/auth-methods.d.ts +0 -3
- package/types/check/auth-methods.d.ts.map +0 -1
- package/types/check/auth-rate-limits.d.ts +0 -3
- package/types/check/auth-rate-limits.d.ts.map +0 -1
- package/types/check/call-result.d.ts +0 -7
- package/types/check/call-result.d.ts.map +0 -1
- package/types/check/client-keys.d.ts +0 -3
- package/types/check/client-keys.d.ts.map +0 -1
- package/types/check/cms-options.d.ts +0 -3
- package/types/check/cms-options.d.ts.map +0 -1
- package/types/check/config-groups.d.ts +0 -3
- package/types/check/config-groups.d.ts.map +0 -1
- package/types/check/config-switches.d.ts +0 -3
- package/types/check/config-switches.d.ts.map +0 -1
- package/types/check/context-import.d.ts +0 -3
- package/types/check/context-import.d.ts.map +0 -1
- package/types/check/env-files.d.ts +0 -3
- package/types/check/env-files.d.ts.map +0 -1
- package/types/check/format-duration.d.ts +0 -5
- package/types/check/format-duration.d.ts.map +0 -1
- package/types/check/guard-options.d.ts +0 -3
- package/types/check/guard-options.d.ts.map +0 -1
- package/types/check/handler-events.d.ts +0 -9
- package/types/check/handler-events.d.ts.map +0 -1
- package/types/check/hook-context.d.ts +0 -3
- package/types/check/hook-context.d.ts.map +0 -1
- package/types/check/hook-names.d.ts +0 -3
- package/types/check/hook-names.d.ts.map +0 -1
- package/types/check/i18n-keys.d.ts +0 -3
- package/types/check/i18n-keys.d.ts.map +0 -1
- package/types/check/images-keys.d.ts +0 -3
- package/types/check/images-keys.d.ts.map +0 -1
- package/types/check/job-shapes.d.ts +0 -6
- package/types/check/job-shapes.d.ts.map +0 -1
- package/types/check/link-flag-tests.d.ts +0 -4
- package/types/check/link-flag-tests.d.ts.map +0 -1
- package/types/check/live-api.d.ts +0 -3
- package/types/check/live-api.d.ts.map +0 -1
- package/types/check/mail-api.d.ts +0 -3
- package/types/check/mail-api.d.ts.map +0 -1
- package/types/check/one-state-api.d.ts +0 -9
- package/types/check/one-state-api.d.ts.map +0 -1
- package/types/check/pages-options.d.ts +0 -3
- package/types/check/pages-options.d.ts.map +0 -1
- package/types/check/rate-enforce.d.ts +0 -3
- package/types/check/rate-enforce.d.ts.map +0 -1
- package/types/check/refusal-calls.d.ts +0 -3
- package/types/check/refusal-calls.d.ts.map +0 -1
- package/types/check/retired-lints.d.ts +0 -3
- package/types/check/retired-lints.d.ts.map +0 -1
- package/types/check/route-keys.d.ts +0 -3
- package/types/check/route-keys.d.ts.map +0 -1
- package/types/check/secret-keys.d.ts +0 -3
- package/types/check/secret-keys.d.ts.map +0 -1
- package/types/check/socket-frames.d.ts +0 -3
- package/types/check/socket-frames.d.ts.map +0 -1
- package/types/check/source-readers.d.ts +0 -3
- package/types/check/source-readers.d.ts.map +0 -1
- package/types/check/store-ms.d.ts +0 -3
- package/types/check/store-ms.d.ts.map +0 -1
- package/types/check/store-names.d.ts +0 -3
- package/types/check/store-names.d.ts.map +0 -1
- package/types/check/test-helpers.d.ts +0 -3
- package/types/check/test-helpers.d.ts.map +0 -1
- package/types/check/ttl-names.d.ts +0 -3
- package/types/check/ttl-names.d.ts.map +0 -1
- package/types/compiler/deprecated-ai-labels.d.ts +0 -5
- package/types/compiler/deprecated-ai-labels.d.ts.map +0 -1
- package/types/compiler/deprecated-ai-links.d.ts +0 -5
- package/types/compiler/deprecated-ai-links.d.ts.map +0 -1
- package/types/compiler/deprecated-allow.d.ts +0 -5
- package/types/compiler/deprecated-allow.d.ts.map +0 -1
- package/types/compiler/deprecated-auth-lints.d.ts +0 -12
- package/types/compiler/deprecated-auth-lints.d.ts.map +0 -1
- package/types/compiler/deprecated-auth-signed.d.ts +0 -5
- package/types/compiler/deprecated-auth-signed.d.ts.map +0 -1
- package/types/compiler/deprecated-children.d.ts +0 -4
- package/types/compiler/deprecated-children.d.ts.map +0 -1
- package/types/compiler/deprecated-image.d.ts +0 -5
- package/types/compiler/deprecated-image.d.ts.map +0 -1
- package/types/compiler/deprecated-island.d.ts +0 -9
- package/types/compiler/deprecated-island.d.ts.map +0 -1
- package/types/compiler/deprecated-lints-1-105.d.ts +0 -39
- package/types/compiler/deprecated-lints-1-105.d.ts.map +0 -1
- package/types/compiler/deprecated-page.d.ts +0 -4
- package/types/compiler/deprecated-page.d.ts.map +0 -1
- package/types/compiler/deprecated-parts.d.ts +0 -3
- package/types/compiler/deprecated-parts.d.ts.map +0 -1
- package/types/compiler/deprecated-typed-lints.d.ts +0 -21
- package/types/compiler/deprecated-typed-lints.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-callbacks.d.ts +0 -5
- package/types/compiler/deprecated-ui-callbacks.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-input.d.ts +0 -5
- package/types/compiler/deprecated-ui-input.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-items.d.ts +0 -5
- package/types/compiler/deprecated-ui-items.d.ts.map +0 -1
- package/types/compiler/old-parts.d.ts +0 -9
- package/types/compiler/old-parts.d.ts.map +0 -1
- package/types/runtime/mount.compat.d.ts +0 -7
- package/types/runtime/mount.compat.d.ts.map +0 -1
- package/types/server/moved-exports.d.ts +0 -12
- package/types/server/moved-exports.d.ts.map +0 -1
package/src/check/cms-options.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { NodeOfType } from '../compiler/estree'
|
|
3
|
-
import type { Edit } from './renamed-exports'
|
|
4
|
-
import { lintLevel } from '../compiler/lints'
|
|
5
|
-
import { keyName } from '../compiler/object-literal'
|
|
6
|
-
import { importsOf, walk } from './ast'
|
|
7
|
-
import { scan } from './renamed-exports'
|
|
8
|
-
|
|
9
|
-
const CMS = /\bcms\b/
|
|
10
|
-
const FROM_CMS = (source: string) => source === '@kayjs/cms' || source === '@kaynooo/kayjs-cms'
|
|
11
|
-
const COMMENT = /\/[*/]/
|
|
12
|
-
const TRAILING_COMMA = /,$/
|
|
13
|
-
|
|
14
|
-
type ObjectNode = NodeOfType<'ObjectExpression'>
|
|
15
|
-
type Property = Extract<ObjectNode['properties'][number], { type: 'Property' }>
|
|
16
|
-
|
|
17
|
-
// `role`, `guard: passwordGuard(...)` and an `uploads` list of `cms()`, which `access` and `uploads: { types }` took over in 1.105: `cms({ role: 'editor' })` is `cms({ access: 'editor' })`, `cms({ guard: passwordGuard(password, options) })` is `cms({ access: { password, ...options } })` and `uploads: ['image/*']` is `uploads: { types: ['image/*'] }`; `member` beside a custom guard is one `access` function, reported with no fix.
|
|
18
|
-
// Found on a call of `cms` imported from `@kayjs/cms`, in the options object written in the call, in the project's TypeScript files and `.kay` files.
|
|
19
|
-
export async function cmsOptions(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
20
|
-
if (lintLevel('deprecated-cms-options', options.lints) === 'allow')
|
|
21
|
-
return []
|
|
22
|
-
|
|
23
|
-
return scan(root, options, 'deprecated-cms-options', CMS, ({ source, parsed, report }) => {
|
|
24
|
-
for (const { ast, base } of parsed) {
|
|
25
|
-
const { locals, namespaces } = importsOf(ast, FROM_CMS, 'cms')
|
|
26
|
-
const passwordGuards = importsOf(ast, FROM_CMS, 'passwordGuard').locals
|
|
27
|
-
|
|
28
|
-
if (locals.size === 0 && namespaces.size === 0)
|
|
29
|
-
continue
|
|
30
|
-
|
|
31
|
-
const isCms = (callee: NodeOfType<'CallExpression'>['callee']): boolean => callee.type === 'Identifier'
|
|
32
|
-
? locals.has(callee.name)
|
|
33
|
-
: callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === 'cms'
|
|
34
|
-
|
|
35
|
-
walk(ast, (node) => {
|
|
36
|
-
const argument = node.type === 'CallExpression' && isCms(node.callee) ? node.arguments[0] : undefined
|
|
37
|
-
|
|
38
|
-
if (argument?.type !== 'ObjectExpression')
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
const property = (name: string) => argument.properties.find((one): one is Property => one.type === 'Property' && keyName(one) === name)
|
|
42
|
-
const spread = argument.properties.some(one => one.type === 'SpreadElement')
|
|
43
|
-
const present = (name: string) => property(name) !== undefined
|
|
44
|
-
const found: { property: Property, message: string, help: string, edits: Edit[] | null }[] = []
|
|
45
|
-
|
|
46
|
-
const role = property('role')
|
|
47
|
-
|
|
48
|
-
if (role)
|
|
49
|
-
found.push({ property: role, message: '`role` of `cms()` is deprecated since 1.105: `access` says who is let in', help: 'write `access` for `role`', edits: role.shorthand || spread || present('access') || present('member') ? null : [{ start: base + role.key.start, end: base + role.key.end, text: 'access' }] })
|
|
50
|
-
|
|
51
|
-
const guard = property('guard')
|
|
52
|
-
|
|
53
|
-
if (guard?.value.type === 'CallExpression' && guard.value.callee.type === 'Identifier' && passwordGuards.has(guard.value.callee.name)) {
|
|
54
|
-
const [password, given] = guard.value.arguments
|
|
55
|
-
const inner = given?.type === 'ObjectExpression' && given.properties.length > 0 ? source.slice(base + given.start + 1, base + given.end - 1).trim().replace(TRAILING_COMMA, '') : ''
|
|
56
|
-
const simple = password !== undefined && password.type !== 'SpreadElement' && (given === undefined || (given.type === 'ObjectExpression' && !given.properties.some(one => one.type === 'SpreadElement')))
|
|
57
|
-
const edits = simple && !spread && !present('access') && !present('member') && !guard.shorthand ? [{ start: base + guard.start, end: base + guard.end, text: `access: { password: ${source.slice(base + password.start, base + password.end)}${inner === '' ? '' : `, ${inner}`} }` }] : null
|
|
58
|
-
|
|
59
|
-
found.push({ property: guard, message: '`guard: passwordGuard()` of `cms()` is deprecated since 1.105: `access: { password }` takes the passwords and their options', help: 'write `access: { password }` for the `passwordGuard()`; the import it leaves unused can go', edits })
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const uploads = property('uploads')
|
|
63
|
-
|
|
64
|
-
if (uploads?.value.type === 'ArrayExpression')
|
|
65
|
-
found.push({ property: uploads, message: '`uploads` of `cms()` as a list is deprecated since 1.105: `uploads: { types }` names the types beside `maxSize`', help: 'write `{ types: [...] }` for the list', edits: uploads.shorthand ? null : [{ start: base + uploads.value.start, end: base + uploads.value.start, text: '{ types: ' }, { start: base + uploads.value.end, end: base + uploads.value.end, text: ' }' }] })
|
|
66
|
-
|
|
67
|
-
const member = property('member')
|
|
68
|
-
|
|
69
|
-
if (member)
|
|
70
|
-
found.push({ property: member, message: '`member` of `cms()` is deprecated since 1.105: `access` as a function says who is let in and who they are in one', help: 'move `member` and the guard into one `access` function returning the person, or nothing for a visitor', edits: null })
|
|
71
|
-
|
|
72
|
-
for (const { property: where, message, help, edits } of found) {
|
|
73
|
-
// A comment in a range the fix replaces would be lost with it.
|
|
74
|
-
const lost = edits?.some(edit => COMMENT.test(source.slice(edit.start, edit.end)))
|
|
75
|
-
|
|
76
|
-
report(base + where.start, base + where.end, message, help, lost ? null : edits)
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import { movedKeys } from './moved-keys'
|
|
3
|
-
|
|
4
|
-
// Each key of the config that lives in a group since 1.105: the files a site serves in `assets`, what runs the server in `ops`.
|
|
5
|
-
const GROUPS: Record<string, string> = {
|
|
6
|
-
images: 'assets',
|
|
7
|
-
fonts: 'assets',
|
|
8
|
-
favicon: 'assets',
|
|
9
|
-
manifest: 'assets',
|
|
10
|
-
publicCache: 'assets',
|
|
11
|
-
observe: 'ops',
|
|
12
|
-
health: 'ops',
|
|
13
|
-
metrics: 'ops',
|
|
14
|
-
jobs: 'ops',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const NEEDLE = /\b(?:images|fonts|favicon|manifest|publicCache|observe|health|metrics|jobs)\b/
|
|
18
|
-
|
|
19
|
-
// The keys `images`, `fonts`, `favicon`, `manifest` and `publicCache` of the config, which belong to `assets` since 1.105, and `observe`, `health`, `metrics` and `jobs`, which belong to `ops`.
|
|
20
|
-
export async function configGroups(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
21
|
-
return movedKeys(root, options, { lint: 'deprecated-config-groups', needle: NEEDLE, group: name => Object.hasOwn(GROUPS, name) ? GROUPS[name] : undefined, help: 'write the key in its group, `assets: { images, fonts, favicon, manifest, publicCache }` or `ops: { observe, health, metrics, jobs }`' })
|
|
22
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Edit } from './renamed-exports'
|
|
3
|
-
import { basename } from 'node:path'
|
|
4
|
-
import { lintLevel } from '../compiler/lints'
|
|
5
|
-
import { constBindings, exportedObject, keyName } from '../compiler/object-literal'
|
|
6
|
-
import { scan } from './renamed-exports'
|
|
7
|
-
|
|
8
|
-
const PROXY = /\bproxy\b/
|
|
9
|
-
|
|
10
|
-
// `proxy: 2` in kay.config.ts, `proxy: { hops: 2 }` since 1.105 and `proxy: true` for one: every feature key takes `false`, `true` or its bag, and a number was a third form of the same switch.
|
|
11
|
-
export async function configSwitches(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
12
|
-
if (lintLevel('deprecated-config-switch', options.lints) === 'allow')
|
|
13
|
-
return []
|
|
14
|
-
|
|
15
|
-
return scan(root, options, 'deprecated-config-switch', PROXY, ({ file, parsed, report }) => {
|
|
16
|
-
if (basename(file) !== 'kay.config.ts')
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
for (const { ast, base } of parsed) {
|
|
20
|
-
const exported = exportedObject(ast, constBindings(ast))
|
|
21
|
-
|
|
22
|
-
for (const property of exported?.properties ?? []) {
|
|
23
|
-
if (property.type !== 'Property' || keyName(property) !== 'proxy' || property.computed || property.shorthand)
|
|
24
|
-
continue
|
|
25
|
-
|
|
26
|
-
const { value } = property
|
|
27
|
-
|
|
28
|
-
if (value.type !== 'Literal' || typeof value.value !== 'number')
|
|
29
|
-
continue
|
|
30
|
-
|
|
31
|
-
const text = value.value === 1 ? 'true' : `{ hops: ${value.raw} }`
|
|
32
|
-
const edits: Edit[] = Number.isInteger(value.value) && value.value >= 1 ? [{ start: base + value.start, end: base + value.end, text }] : []
|
|
33
|
-
|
|
34
|
-
report(base + value.start, base + value.end, `\`proxy: ${value.raw}\` is deprecated since 1.105: a feature key is \`false\`, \`true\` or its options, and the number of proxies is \`hops\``, 'write `true` for one proxy and `{ hops: n }` for more', edits)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import { lintLevel } from '../compiler/lints'
|
|
3
|
-
import { scan } from './renamed-exports'
|
|
4
|
-
|
|
5
|
-
const NEEDLE = /\bdefineContext\b/
|
|
6
|
-
const LIBRARY_END = /library$/
|
|
7
|
-
const FROM_LIBRARY = (source: string) => source === 'kay/library' || source === '@kayjs/kay/library'
|
|
8
|
-
|
|
9
|
-
// `defineContext` imported from `kay/library`, `kay/server` since 1.105, where `defineEnv` and the rest of what an app imports live.
|
|
10
|
-
// The fix moves the specifier: the import's source when it names `defineContext` alone, else a new import beside it.
|
|
11
|
-
export async function contextImport(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
12
|
-
if (lintLevel('deprecated-context-import', options.lints) === 'allow')
|
|
13
|
-
return []
|
|
14
|
-
|
|
15
|
-
return scan(root, options, 'deprecated-context-import', NEEDLE, ({ parsed, source, report }) => {
|
|
16
|
-
for (const { ast, base } of parsed) {
|
|
17
|
-
for (const statement of ast.body) {
|
|
18
|
-
if (statement.type !== 'ImportDeclaration' || !FROM_LIBRARY(statement.source.value) || statement.importKind === 'type')
|
|
19
|
-
continue
|
|
20
|
-
|
|
21
|
-
const index = statement.specifiers.findIndex(specifier => specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier' && specifier.imported.name === 'defineContext' && specifier.importKind !== 'type')
|
|
22
|
-
|
|
23
|
-
if (index < 0)
|
|
24
|
-
continue
|
|
25
|
-
|
|
26
|
-
const specifier = statement.specifiers[index]!
|
|
27
|
-
const text = source.slice(base + specifier.start, base + specifier.end)
|
|
28
|
-
const target = statement.source.value.replace(LIBRARY_END, 'server')
|
|
29
|
-
const alone = statement.specifiers.length === 1
|
|
30
|
-
const edits = alone
|
|
31
|
-
? [{ start: base + statement.source.start, end: base + statement.source.end, text: `${source[base + statement.source.start]}${target}${source[base + statement.source.start]}` }]
|
|
32
|
-
: [{ start: base + statement.end, end: base + statement.end, text: `\nimport { ${text} } from '${target}'` }, ...removal(base, statement.specifiers, index)]
|
|
33
|
-
|
|
34
|
-
report(base + specifier.start, base + specifier.end, '`defineContext` from `kay/library` is deprecated since 1.105: it is imported from `kay/server`, as `defineEnv` is', 'import it from `kay/server`', edits)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Takes one specifier out of a list with its comma.
|
|
41
|
-
function removal(base: number, specifiers: { start: number, end: number }[], index: number): { start: number, end: number, text: string }[] {
|
|
42
|
-
const specifier = specifiers[index]!
|
|
43
|
-
const next = specifiers[index + 1]
|
|
44
|
-
|
|
45
|
-
if (next !== undefined)
|
|
46
|
-
return [{ start: base + specifier.start, end: base + next.start, text: '' }]
|
|
47
|
-
|
|
48
|
-
const before = specifiers[index - 1]!
|
|
49
|
-
|
|
50
|
-
return [{ start: base + before.end, end: base + specifier.end, text: '' }]
|
|
51
|
-
}
|
package/src/check/env-files.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import { basename } from 'node:path'
|
|
3
|
-
import { lintLevel } from '../compiler/lints'
|
|
4
|
-
import { constBindings, exportedObject, keyName } from '../compiler/object-literal'
|
|
5
|
-
import { scan } from './renamed-exports'
|
|
6
|
-
|
|
7
|
-
const ENV = /\benv\b/
|
|
8
|
-
|
|
9
|
-
// `env` in kay.config.ts, `envFiles` since 1.105: the key names the compose and example files the declared variables are compared with, where `env` read as the variables themselves. The fix renames the key; a config that already has an `envFiles`, or a computed key, is reported with no fix.
|
|
10
|
-
export async function envFiles(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
11
|
-
if (lintLevel('deprecated-env-files', options.lints) === 'allow')
|
|
12
|
-
return []
|
|
13
|
-
|
|
14
|
-
return scan(root, options, 'deprecated-env-files', ENV, ({ file, parsed, report }) => {
|
|
15
|
-
if (basename(file) !== 'kay.config.ts')
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
for (const { ast, base } of parsed) {
|
|
19
|
-
const properties = exportedObject(ast, constBindings(ast))?.properties.filter(property => property.type === 'Property') ?? []
|
|
20
|
-
const old = properties.find(property => keyName(property) === 'env')
|
|
21
|
-
|
|
22
|
-
if (old === undefined)
|
|
23
|
-
continue
|
|
24
|
-
|
|
25
|
-
const fixable = !old.computed && !properties.some(property => keyName(property) === 'envFiles')
|
|
26
|
-
const edits = fixable ? [old.shorthand ? { start: base + old.start, end: base + old.end, text: 'envFiles: env' } : { start: base + old.key.start, end: base + old.key.end, text: 'envFiles' }] : []
|
|
27
|
-
|
|
28
|
-
report(base + old.start, base + old.end, '`env` in kay.config.ts is deprecated since 1.105: it names the compose and example files the declared variables are compared with, `envFiles`', 'write `envFiles`', edits)
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import { lintLevel } from '../compiler/lints'
|
|
3
|
-
import { importsOf } from './ast'
|
|
4
|
-
import { scan } from './renamed-exports'
|
|
5
|
-
|
|
6
|
-
const FORMAT = /\bformatDuration\b/
|
|
7
|
-
const FROM_I18N = (source: string) => source === 'kay/i18n'
|
|
8
|
-
const HELP = 'write the length with its unit, `formatDuration(\'125m\')`'
|
|
9
|
-
|
|
10
|
-
export const EXPRESSION = /^\d[\d_]*(?:\.\d+)?(?:\s*[*+\-/]\s*\d[\d_]*(?:\.\d+)?)*$/
|
|
11
|
-
const TERMS = /\s*([*+\-/])\s*/
|
|
12
|
-
|
|
13
|
-
// The value of numbers written with `+`, `-`, `*` and `/` between them, as the language reads them; the caller checked there is nothing else.
|
|
14
|
-
export function evaluate(text: string): number {
|
|
15
|
-
const parts = text.replaceAll('_', '').split(TERMS)
|
|
16
|
-
const terms = [Number(parts[0])]
|
|
17
|
-
const signs: string[] = []
|
|
18
|
-
|
|
19
|
-
for (let at = 1; at < parts.length; at += 2) {
|
|
20
|
-
const sign = parts[at]!
|
|
21
|
-
const value = Number(parts[at + 1])
|
|
22
|
-
|
|
23
|
-
if (sign === '*') {
|
|
24
|
-
terms[terms.length - 1]! *= value
|
|
25
|
-
}
|
|
26
|
-
else if (sign === '/') {
|
|
27
|
-
terms[terms.length - 1]! /= value
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
signs.push(sign)
|
|
31
|
-
terms.push(value)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return terms.slice(1).reduce((sum, term, at) => signs[at] === '+' ? sum + term : sum - term, terms[0]!)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// A call of `formatDuration` from `kay/i18n` with a bare number, milliseconds until 1.105 and a `Duration` since: `formatDuration(7_500_000)` is `formatDuration('7500000ms')`.
|
|
39
|
-
// Found on a number written as a literal or as arithmetic of literals, in a fence, a module or a template; a number held in a variable is a type error the editor shows, as `kay check` reads no types here. The fix writes the value in milliseconds.
|
|
40
|
-
export async function formatDurationNumbers(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
41
|
-
if (lintLevel('deprecated-format-duration', options.lints) === 'allow')
|
|
42
|
-
return []
|
|
43
|
-
|
|
44
|
-
return scan(root, options, 'deprecated-format-duration', FORMAT, ({ source, parsed, report }) => {
|
|
45
|
-
const names = new Set<string>()
|
|
46
|
-
|
|
47
|
-
for (const { ast } of parsed) {
|
|
48
|
-
const { locals, namespaces } = importsOf(ast, FROM_I18N, 'formatDuration')
|
|
49
|
-
|
|
50
|
-
for (const name of locals)
|
|
51
|
-
names.add(name)
|
|
52
|
-
|
|
53
|
-
for (const name of namespaces)
|
|
54
|
-
names.add(`${name}\\.formatDuration`)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (names.size === 0)
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
// eslint-disable-next-line regexp/no-empty-group -- the names alternation is filled in at run time
|
|
61
|
-
const calls = new RegExp(String.raw`(?<![\w$.])(?:${[...names].join('|')})\(([^,()]*)(?=[,)])`, 'g')
|
|
62
|
-
|
|
63
|
-
for (const call of source.matchAll(calls)) {
|
|
64
|
-
const text = call[1]!.trim()
|
|
65
|
-
|
|
66
|
-
if (!EXPRESSION.test(text))
|
|
67
|
-
continue
|
|
68
|
-
|
|
69
|
-
const start = call.index + call[0].length - call[1]!.length + call[1]!.indexOf(text)
|
|
70
|
-
const milliseconds = evaluate(text)
|
|
71
|
-
|
|
72
|
-
report(start, start + text.length, '`formatDuration` takes a duration with its unit since 1.105, not milliseconds', HELP, Number.isFinite(milliseconds) ? [{ start, end: start + text.length, text: `'${milliseconds}ms'` }] : null)
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Edit } from './renamed-exports'
|
|
3
|
-
import { basename } from 'node:path'
|
|
4
|
-
import { lintLevel } from '../compiler/lints'
|
|
5
|
-
import { constBindings, exportedObject, keyName, objectOf } from '../compiler/object-literal'
|
|
6
|
-
import { featureProperties } from './config-objects'
|
|
7
|
-
import { renamedCallOptions } from './renamed-call-options'
|
|
8
|
-
import { scan } from './renamed-exports'
|
|
9
|
-
|
|
10
|
-
const GUARD = /\bguard\b|\brequireGuards\b/
|
|
11
|
-
const FROM_SERVER = (source: string) => source === 'kay/server' || source === '@kayjs/kay/server'
|
|
12
|
-
|
|
13
|
-
// `guard` in `vitals({ guard })`, in the `jobs` and `images` of kay.config.ts: `guards` since 1.105, the one name of a guard option; and `requireGuards`, `guards: { default }` since 1.105.
|
|
14
|
-
export async function guardOptions(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
15
|
-
if (lintLevel('deprecated-guard-option', options.lints) === 'allow')
|
|
16
|
-
return []
|
|
17
|
-
|
|
18
|
-
const calls = await renamedCallOptions(root, options, { lint: 'deprecated-guard-option', needle: GUARD, from: FROM_SERVER, calls: { vitals: 0 }, renames: [['guard', 'guards']], since: '1.105', of: '`vitals()`' })
|
|
19
|
-
|
|
20
|
-
const config = await scan(root, options, 'deprecated-guard-option', GUARD, ({ file, parsed, report }) => {
|
|
21
|
-
if (basename(file) !== 'kay.config.ts')
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
for (const { ast, base } of parsed) {
|
|
25
|
-
const bindings = constBindings(ast)
|
|
26
|
-
const exported = exportedObject(ast, bindings)
|
|
27
|
-
|
|
28
|
-
const own = (exported?.properties ?? []).filter((one): one is Extract<typeof one, { type: 'Property' }> => one.type === 'Property')
|
|
29
|
-
const required = own.find(one => keyName(one) === 'requireGuards')
|
|
30
|
-
|
|
31
|
-
if (required) {
|
|
32
|
-
const { value } = required
|
|
33
|
-
const taken = own.some(one => keyName(one) === 'guards')
|
|
34
|
-
const known = value.type === 'Literal' && typeof value.value === 'boolean'
|
|
35
|
-
const edits: Edit[] | null = taken || !known || required.shorthand || required.computed ? null : [{ start: base + required.start, end: base + required.end, text: `guards: { default: '${value.value ? 'closed' : 'open'}' }` }]
|
|
36
|
-
|
|
37
|
-
report(base + required.start, base + required.end, '`requireGuards` is deprecated since 1.105: `guards: { default }` says what a route no guard covers comes to', 'write `guards: { default: \'closed\' }` for `true` and `\'open\'` for `false`', edits)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const features = exported === undefined ? [] : [...featureProperties(exported, bindings, 'ops', 'jobs').map(feature => ({ name: 'jobs', feature })), ...featureProperties(exported, bindings, 'assets', 'images').map(feature => ({ name: 'images', feature }))]
|
|
41
|
-
|
|
42
|
-
for (const { name, feature } of features) {
|
|
43
|
-
const section = objectOf(feature.value, bindings)
|
|
44
|
-
const properties = (section?.properties ?? []).filter((one): one is Extract<typeof one, { type: 'Property' }> => one.type === 'Property')
|
|
45
|
-
const old = properties.find(one => keyName(one) === 'guard')
|
|
46
|
-
|
|
47
|
-
if (!old)
|
|
48
|
-
continue
|
|
49
|
-
|
|
50
|
-
const edits: Edit[] | null = properties.some(one => keyName(one) === 'guards') || old.computed ? null : [old.shorthand ? { start: base + old.start, end: base + old.end, text: 'guards: guard' } : { start: base + old.key.start, end: base + old.key.end, text: 'guards' }]
|
|
51
|
-
|
|
52
|
-
report(base + old.start, base + old.end, `\`guard\` of \`${name}\` is deprecated since 1.105: the option is \`guards\``, 'write `guards`', edits)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
return [...calls, ...config]
|
|
58
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import type { Fix, Span } from '../compiler/ast'
|
|
2
|
-
import { attributeNamed } from './template-hints'
|
|
3
|
-
|
|
4
|
-
// `Type '(next: boolean) => void' is not assignable to type '(event: { checked: boolean; }) => unknown'.` and the incompatible parameter that follows.
|
|
5
|
-
const EVENT_CALLBACK = /^Type '([\s\S]+?)' is not assignable to type '\(event: \{ ([\s\S]*?) \}\) => unknown'\.\n\s+Types of parameters '[^']*' and 'event' are incompatible\.\n([\s\S]*)$/
|
|
6
|
-
const PARAMETER_TYPE = /(?:to type|from type) '([\s\S]*?)'(?:\.|:)/
|
|
7
|
-
const FIELD = /^(\w+)\??:/
|
|
8
|
-
const CALLBACK_NAME = /^on[A-Z]\w*$/
|
|
9
|
-
const HANDLER_NAME = /^[A-Z_$][\w$]*(?:\??\.[A-Z_$][\w$]*)*$/i
|
|
10
|
-
// An object literal type or a named type, which no old argument was apart from a `File`: the handler may be written for the event already.
|
|
11
|
-
const OBJECT_TYPE = /^(?:\{|object\b|(?!File\b)[A-Z])/
|
|
12
|
-
const COMPONENT = /^([A-Z][\w$]*)(?:[.#][^\s(]*)?\(/
|
|
13
|
-
const NAME_AT = /^[\w$]+/
|
|
14
|
-
const EVENT_WORD = /\bevent\b/
|
|
15
|
-
const ELEMENT = /^[a-z.#][^\s(]*\(/
|
|
16
|
-
|
|
17
|
-
// What an old-form lint of the type check reports.
|
|
18
|
-
export interface OldFormLint {
|
|
19
|
-
message: string
|
|
20
|
-
help: string
|
|
21
|
-
span: Span
|
|
22
|
-
fixes?: Fix[]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// The segments of a type's text between its top-level `separator`s.
|
|
26
|
-
function splitTop(text: string, separator: string): string[] {
|
|
27
|
-
const parts: string[] = []
|
|
28
|
-
let depth = 0
|
|
29
|
-
let from = 0
|
|
30
|
-
|
|
31
|
-
for (const [index, char] of [...text].entries()) {
|
|
32
|
-
if ('{([<'.includes(char)) {
|
|
33
|
-
depth++
|
|
34
|
-
}
|
|
35
|
-
else if ('})]'.includes(char) || (char === '>' && text[index - 1] !== '=')) {
|
|
36
|
-
depth--
|
|
37
|
-
}
|
|
38
|
-
else if (char === separator && depth === 0) {
|
|
39
|
-
parts.push(text.slice(from, index))
|
|
40
|
-
from = index + 1
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
parts.push(text.slice(from))
|
|
45
|
-
|
|
46
|
-
return parts.map(part => part.trim()).filter(part => part !== '')
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// How many parameters a function type written as `(a: A, b: B) => R` takes, 1 for any other type, as a signal's `Setter<T>` takes one.
|
|
50
|
-
function parameterCount(type: string): number {
|
|
51
|
-
if (!type.startsWith('('))
|
|
52
|
-
return 1
|
|
53
|
-
|
|
54
|
-
let depth = 0
|
|
55
|
-
|
|
56
|
-
for (const [index, char] of [...type].entries()) {
|
|
57
|
-
if (char === '(')
|
|
58
|
-
depth++
|
|
59
|
-
else if (char === ')' && --depth === 0)
|
|
60
|
-
return splitTop(type.slice(1, index), ',').length
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return 1
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Whether the first parameter of a function type written as `(a: A, b: B) => R` is typed as an object, a literal or a named type.
|
|
67
|
-
function takesObject(type: string): boolean {
|
|
68
|
-
if (!type.startsWith('('))
|
|
69
|
-
return false
|
|
70
|
-
|
|
71
|
-
const first = splitTop(type.slice(1), ',')[0] ?? ''
|
|
72
|
-
|
|
73
|
-
// A destructured parameter takes an object whatever its type is called.
|
|
74
|
-
if (first.startsWith('{'))
|
|
75
|
-
return true
|
|
76
|
-
|
|
77
|
-
const colon = first.indexOf(':')
|
|
78
|
-
|
|
79
|
-
return colon !== -1 && OBJECT_TYPE.test(first.slice(colon + 1).trim())
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// The component an attribute is written on, read off its line or, for an attribute on a line of its own, the line above it that opens the call.
|
|
83
|
-
function componentAt(source: string, at: number): string | undefined {
|
|
84
|
-
const lineEnd = source.indexOf('\n', at)
|
|
85
|
-
const [own, ...above] = source.slice(0, lineEnd === -1 ? source.length : lineEnd).split('\n').toReversed()
|
|
86
|
-
const opened = COMPONENT.exec(own!.trimStart())
|
|
87
|
-
|
|
88
|
-
if (opened !== null)
|
|
89
|
-
return opened[1]
|
|
90
|
-
|
|
91
|
-
if (ELEMENT.test(own!.trimStart()))
|
|
92
|
-
return undefined
|
|
93
|
-
|
|
94
|
-
const indent = own!.length - own!.trimStart().length
|
|
95
|
-
|
|
96
|
-
for (const line of above) {
|
|
97
|
-
const trimmed = line.trimStart()
|
|
98
|
-
|
|
99
|
-
if (trimmed !== '' && line.length - trimmed.length < indent)
|
|
100
|
-
return COMPONENT.exec(trimmed)?.[1]
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return undefined
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// A callback a component of a kayjs library takes as one event object since 1.105, given a function written for its positional arguments: the handler of `onValueChange={query.set}`, `onCheckedChange={toggle}` or `onFiles={upload}`.
|
|
107
|
-
// The fix wraps a handler written as a name, `event => query.set(event.value)`, passing the fields the handler took, first ones first. It is applied where the handler's parameter is no object, which the old arguments were; a handler taking an object may be written for the event already, so its fix is offered.
|
|
108
|
-
export function handlerEventLint(message: string, source: string, span: Span | undefined): OldFormLint | undefined {
|
|
109
|
-
const found = EVENT_CALLBACK.exec(message)
|
|
110
|
-
|
|
111
|
-
if (found === null || span === undefined)
|
|
112
|
-
return undefined
|
|
113
|
-
|
|
114
|
-
const name = NAME_AT.exec(source.slice(span.start))?.[0]
|
|
115
|
-
|
|
116
|
-
if (name === undefined || !CALLBACK_NAME.test(name))
|
|
117
|
-
return undefined
|
|
118
|
-
|
|
119
|
-
const component = componentAt(source, span.start)
|
|
120
|
-
|
|
121
|
-
if (component === undefined || !new RegExp(`^import\\b[^\\n]*\\b${component}\\b[^\\n]*from\\s+['"]@kayjs/`, 'm').test(source))
|
|
122
|
-
return undefined
|
|
123
|
-
|
|
124
|
-
const [, handlerType, eventFields, rest] = found
|
|
125
|
-
const fields = splitTop(eventFields!, ';').flatMap(segment => FIELD.exec(segment)?.[1] ?? [])
|
|
126
|
-
|
|
127
|
-
if (fields.length === 0)
|
|
128
|
-
return undefined
|
|
129
|
-
|
|
130
|
-
const object = takesObject(handlerType!) || PARAMETER_TYPE.exec(rest!)?.[1]?.startsWith('{') === true
|
|
131
|
-
const taken = fields.slice(0, Math.max(1, Math.min(parameterCount(handlerType!), fields.length)))
|
|
132
|
-
const attribute = attributeNamed(source, { start: span.start, end: source.length }, name)
|
|
133
|
-
const value = attribute === undefined ? undefined : source.slice(attribute.start + name.length + 1, attribute.end)
|
|
134
|
-
const inner = value?.startsWith('{') && value.endsWith('}') ? value.slice(1, -1).trim() : undefined
|
|
135
|
-
const handler = inner !== undefined && HANDLER_NAME.test(inner) && !EVENT_WORD.test(inner) ? inner : undefined
|
|
136
|
-
const written = `event => ${handler}(${taken.map(field => `event.${field}`).join(', ')})`
|
|
137
|
-
const report = {
|
|
138
|
-
message: `\`${name}\` on \`${component}\` takes one event object since 1.105, \`{ ${fields.join(', ')} }\`, where it took ${fields.map(field => `\`${field}\``).join(', ')} as ${fields.length === 1 ? 'its argument' : 'arguments'}`,
|
|
139
|
-
help: handler === undefined ? 'take the event object, `({ value }) => ...`, and read the fields from it' : `write \`${name}={${written}}\``,
|
|
140
|
-
span,
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (handler === undefined || attribute === undefined)
|
|
144
|
-
return report
|
|
145
|
-
|
|
146
|
-
const start = attribute.start + name.length + 1 + value!.indexOf(handler)
|
|
147
|
-
|
|
148
|
-
return { ...report, fixes: [{ title: `Write \`${name}={${written}}\``, safe: !object, edits: [{ start, end: start + handler.length, text: written }] }] }
|
|
149
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Node, NodeOfType } from '../compiler/estree'
|
|
3
|
-
import type { Edit } from './renamed-exports'
|
|
4
|
-
import { lintLevel } from '../compiler/lints'
|
|
5
|
-
import { keyName } from '../compiler/object-literal'
|
|
6
|
-
import { importsOf, walk } from './ast'
|
|
7
|
-
import { configObjects, isProperty, propertiesOf } from './config-objects'
|
|
8
|
-
import { scan } from './renamed-exports'
|
|
9
|
-
|
|
10
|
-
type ObjectExpression = NodeOfType<'ObjectExpression'>
|
|
11
|
-
|
|
12
|
-
const NEEDLE = /\bctx\b/
|
|
13
|
-
const HOOKS = ['beforeRun', 'onSuccess', 'onError']
|
|
14
|
-
const FROM_KAY = (source: string): boolean => source === 'kay' || source === 'kay/server'
|
|
15
|
-
|
|
16
|
-
type Hook = NodeOfType<'ArrowFunctionExpression'> | NodeOfType<'FunctionExpression'>
|
|
17
|
-
|
|
18
|
-
// The `ctx` an action hook reads off its event, `context` since 1.105: the one field every hook event carries, which holds the action's own context besides who asks.
|
|
19
|
-
// A hook is the function written under `beforeRun`, `onSuccess` or `onError` in the `actions` of the config or the options of an `action()` call; the fix renames what a destructured parameter or a member read of the event names, and offers none where the name is given a default or the event is used another way.
|
|
20
|
-
function hookEdits(hook: Hook, base: number): { start: number, end: number, edits: Edit[] | null }[] {
|
|
21
|
-
const [event] = hook.params
|
|
22
|
-
const found: { start: number, end: number, edits: Edit[] | null }[] = []
|
|
23
|
-
|
|
24
|
-
if (event?.type === 'ObjectPattern') {
|
|
25
|
-
for (const property of event.properties) {
|
|
26
|
-
if (property.type !== 'Property' || property.computed || keyName(property) !== 'ctx')
|
|
27
|
-
continue
|
|
28
|
-
|
|
29
|
-
const value = property.value
|
|
30
|
-
const renamed = property.shorthand ? { start: base + property.start, end: base + property.end, text: 'context: ctx' } : { start: base + property.key.start, end: base + property.key.end, text: 'context' }
|
|
31
|
-
const edits: Edit[] | null = property.shorthand && value.type !== 'Identifier' ? null : [renamed]
|
|
32
|
-
|
|
33
|
-
found.push({ start: base + property.start, end: base + property.end, edits })
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return found
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (event?.type !== 'Identifier' || hook.body === null || hook.body === undefined)
|
|
40
|
-
return found
|
|
41
|
-
|
|
42
|
-
walk(hook.body, (node) => {
|
|
43
|
-
if (node.type === 'MemberExpression' && !node.computed && node.object.type === 'Identifier' && node.object.name === event.name && node.property.type === 'Identifier' && node.property.name === 'ctx')
|
|
44
|
-
found.push({ start: base + node.property.start, end: base + node.property.end, edits: [{ start: base + node.property.start, end: base + node.property.end, text: 'context' }] })
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
return found
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const isHook = (node: Node): node is Hook => node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression'
|
|
51
|
-
|
|
52
|
-
// The hook functions an object of action hooks holds.
|
|
53
|
-
function hooksOf(object: ObjectExpression): Hook[] {
|
|
54
|
-
return HOOKS.flatMap(name => propertiesOf(object, name)).flatMap(property => isProperty(property) && isHook(property.value) ? [property.value] : [])
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export async function hookContext(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
58
|
-
if (lintLevel('deprecated-hook-context', options.lints) === 'allow')
|
|
59
|
-
return []
|
|
60
|
-
|
|
61
|
-
return scan(root, options, 'deprecated-hook-context', NEEDLE, ({ file, parsed, report }) => {
|
|
62
|
-
for (const { ast, base } of parsed) {
|
|
63
|
-
const objects: ObjectExpression[] = []
|
|
64
|
-
|
|
65
|
-
for (const { object } of configObjects(file, ast)) {
|
|
66
|
-
const [actions] = propertiesOf(object, 'actions')
|
|
67
|
-
|
|
68
|
-
if (actions?.value.type === 'ObjectExpression')
|
|
69
|
-
objects.push(actions.value)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const { locals, namespaces } = importsOf(ast, FROM_KAY, 'action')
|
|
73
|
-
|
|
74
|
-
if (locals.size > 0 || namespaces.size > 0) {
|
|
75
|
-
walk(ast, (node) => {
|
|
76
|
-
if (node.type !== 'CallExpression')
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
const callee = node.callee
|
|
80
|
-
const called = callee.type === 'Identifier' ? locals.has(callee.name) : callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === 'action'
|
|
81
|
-
const last = node.arguments.at(-1)
|
|
82
|
-
|
|
83
|
-
if (called && last?.type === 'ObjectExpression')
|
|
84
|
-
objects.push(last)
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
for (const hook of objects.flatMap(hooksOf)) {
|
|
89
|
-
for (const { start, end, edits } of hookEdits(hook, base))
|
|
90
|
-
report(start, end, '`ctx` of an action hook\'s event is deprecated since 1.105: every hook event carries one `context`, which holds the action\'s own context beside who asks', 'read `context`', edits)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
}
|