diff --git a/.changeset/olive-tools-compete.md b/.changeset/olive-tools-compete.md new file mode 100644 index 00000000..c93e8b49 --- /dev/null +++ b/.changeset/olive-tools-compete.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-astro": patch +--- + +no-export-from-components - allow "partial" exception diff --git a/docs/rules/no-exports-from-components.md b/docs/rules/no-exports-from-components.md index d054f248..a95b15b6 100644 --- a/docs/rules/no-exports-from-components.md +++ b/docs/rules/no-exports-from-components.md @@ -16,6 +16,7 @@ The use of typed exports are still allowed. However, there are exceptions for specific named exports that are allowed: - `getStaticPaths`: This function can be exported for dynamic routing purposes. +- `partial`: This constant can be exported to dynamically update a section of a page. - `prerender`: This constant can be exported to opt-in to pre-rendering in server mode. diff --git a/src/rules/no-exports-from-components.ts b/src/rules/no-exports-from-components.ts index bdb16051..cf41c509 100644 --- a/src/rules/no-exports-from-components.ts +++ b/src/rules/no-exports-from-components.ts @@ -2,7 +2,7 @@ import type { TSESTree } from "@typescript-eslint/types" import { createRule } from "../utils" import { getSourceCode } from "../utils/compat" -const ALLOWED_EXPORTS = new Set(["getStaticPaths", "prerender"]) +const ALLOWED_EXPORTS = new Set(["getStaticPaths", "partial", "prerender"]) export default createRule("no-exports-from-components", { meta: { diff --git a/tests/fixtures/rules/no-exports-from-components/valid/exceptions-01-input.astro b/tests/fixtures/rules/no-exports-from-components/valid/exceptions-01-input.astro index 8479901e..52e76706 100644 --- a/tests/fixtures/rules/no-exports-from-components/valid/exceptions-01-input.astro +++ b/tests/fixtures/rules/no-exports-from-components/valid/exceptions-01-input.astro @@ -5,6 +5,7 @@ export const getStaticPaths = (): { param: unknown }[] => { // logic here return [{ param: "value" }] } +export const partial = true export const prerender = true ---