noJsxLeakedDollar
此内容尚不支持你的语言。
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noJsxLeakedDollar - This rule has an unsafe fix.
- The default severity of this rule is warning.
- This rule belongs to the following domains:
- Sources:
- Same as
react-jsx/no-leaked-dollar - Same as
@eslint-react/jsx-no-leaked-dollar
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noJsxLeakedDollar": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”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>;}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.