Showing 2 out of 103 rules
fresh-handler-export
Fresh
Checks correct naming for named fresh middleware export
Checks correct naming for named fresh middleware export
Files inside the routes/
folder can export middlewares that run before any
rendering happens. They are expected to be available as a named export called
handler
. This rule checks for when the export was incorrectly named handlers
instead of handler
.
Invalid:
export const handlers = {
GET() {},
POST() {},
};
export function handlers() {}
export async function handlers() {}
Valid:
export const handler = {
GET() {},
POST() {},
};
export function handler() {}
export async function handler() {}
Disallows event handlers in fresh server components
Disallows event handlers in fresh server components
Components inside the routes/
folder in a fresh app are exclusively rendered
on the server. They are not rendered in the client and setting an event handler
will have no effect.
Note that this rule only applies to server components inside the routes/
folder, not to fresh islands or any other components.
Invalid:
<button onClick={() => {}} />
<button onclick={() => {}} />
<my-custom-element foo={() => {}} />
Valid:
<button />
<my-custom-element />