Aller au contenu

noJsxLeakedDollar

Ce contenu n’est pas encore disponible dans votre langue.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noJsxLeakedDollar": "error"
}
}
}
}

Flags text nodes with a trailing $ before a JSX expression.

This can happen when refactoring from a template literal to JSX and forgetting to remove the dollar sign. This results in an unintentional $ being rendered as text in the output.

function MyComponent({ user }) {
return `Hello ${user.name}`;
}

When refactored to JSX, it might look like this:

function MyComponent({ user }) {
return <>Hello ${user.name}</>;
}

However, the $ before {user.name} is unnecessary and will be rendered as text in the output.

function MyComponent({ user }) {
return <div>Hello ${user.name}</div>;
}
code-block.jsx:2:21 lint/nursery/noJsxLeakedDollar  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Possible unintentional ’$’ before a JSX expression.

1 │ function MyComponent({ user }) {
> 2 │ return <div>Hello ${user.name}</div>;
^
3 │ }
4 │

This ’$’ will be rendered as text. Remove the ’$’ from the text node or add a suppression if it is intentional.

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: Remove dollar sign.

2 │ ··return·<div>Hello·${user.name}</div>;
-
function MyComponent({ user }) {
return <div>${user.name} is your name</div>;
}
code-block.jsx:2:15 lint/nursery/noJsxLeakedDollar  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Possible unintentional ’$’ before a JSX expression.

1 │ function MyComponent({ user }) {
> 2 │ return <div>${user.name} is your name</div>;
^
3 │ }
4 │

This ’$’ will be rendered as text. Remove the ’$’ from the text node or add a suppression if it is intentional.

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: Remove dollar sign.

2 │ ··return·<div>${user.name}·is·your·name</div>;
-
function MyComponent({ user }) {
return <div>Hello {user.name}</div>;
}
// A lone `$` before a single expression is treated as intentional (e.g. a price).
function MyComponent({ price }) {
return <div>${price}</div>;
}