Skip to content

Commit

Permalink
no-export-from-components - allow "partial" exception (#405)
Browse files Browse the repository at this point in the history
* no-export-from-components - allow "partial" exception

* Create olive-tools-compete.md

---------

Co-authored-by: Stefan <stefan.milosevic@wm.rs>
Co-authored-by: Yosuke Ota <otameshiyo23@gmail.com>
  • Loading branch information
3 people committed Jul 7, 2024
1 parent 5ea40f1 commit a77445e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/olive-tools-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-astro": patch
---

no-export-from-components - allow "partial" exception
1 change: 1 addition & 0 deletions docs/rules/no-exports-from-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<ESLintCodeBlock>
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-exports-from-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const getStaticPaths = (): { param: unknown }[] => {
// logic here
return [{ param: "value" }]
}
export const partial = true
export const prerender = true
---

Expand Down

0 comments on commit a77445e

Please sign in to comment.