useReactAsyncServerFunction
Цей контент ще не доступний вашою мовою.
Summary
Section titled “Summary”- Rule available since:
v2.4.12 - Diagnostic Category:
lint/nursery/useReactAsyncServerFunction - This rule has an unsafe fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Same as
react/async-server-action - Same as
@eslint-react/rsc-function-definition - Same as
react-rsc/function-definition
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useReactAsyncServerFunction": "error" } } }}Description
Section titled “Description”Require functions with the “use server” directive to be async.
Require Server Functions (functions in a file with a top-level "use server" directive or functions with their own "use server" directive) to be async.
See the React documentation for more details.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<form action={() => { 'use server'; // ... }}> // ...</form>code-block.jsx:2:11 lint/nursery/useReactAsyncServerFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This server function is missing the async keyword.
1 │ <form
> 2 │ action={() => {
│ ^^^^^^^
> 3 │ ‘use server’;
> 4 │ // …
> 5 │ }}
│ ^
6 │ >
7 │ // …
ℹ Functions with the “use server” directive are React Server Functions and therefore must be async.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Unsafe fix: Add async keyword.
2 │ ··action={async·()·=>·{
│ ++++++
function serverFunction() { 'use server'; // ...}code-block.js:1:1 lint/nursery/useReactAsyncServerFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This server function is missing the async keyword.
> 1 │ function serverFunction() {
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 2 │ ‘use server’;
> 3 │ // …
> 4 │ }
│ ^
5 │
ℹ Functions with the “use server” directive are React Server Functions and therefore must be async.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Unsafe fix: Add async keyword.
1 │ async·function·serverFunction()·{
│ ++++++
'use server';export function serverFunction() { // ...}code-block.js:2:8 lint/nursery/useReactAsyncServerFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This server function is missing the async keyword.
1 │ ‘use server’;
> 2 │ export function serverFunction() {
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 3 │ // …
> 4 │ }
│ ^
5 │
ℹ Functions exported from files with the “use server” directive are React Server Functions and therefore must be async.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Unsafe fix: Add async keyword.
2 │ export·async·function·serverFunction()·{
│ ++++++
<form action={async () => { 'use server'; // ... }}> // ...</form>async function serverFunction() { 'use server'; // ...}'use server';export async function serverFunction() { // ...}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.