Skip to content

noInlineStyles (JavaScript)

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

Disallow the use of inline styles.

Inline styles via the style attribute make code harder to maintain and override, prevent reusability of styling, and can be a security concern when implementing a strict Content Security Policy (CSP).

Instead of inline styles, use CSS classes, CSS modules, or a styling library.

<div style={{ color: "red" }}>Error</div>
code-block.jsx:1:6 lint/nursery/noInlineStyles  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Unexpected style attribute.

> 1 │ <div style={{ color: "red" }}>Error</div>
│ ^^^^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Inline styles make code harder to maintain, reduce reusability, and can prevent effective use of a strict Content Security Policy. Use external CSS classes or stylesheets instead.

ℹ 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 the style attribute.

1 │ <div·style={{·color:·"red"·}}>Error</div>
│ ------------------------
React.createElement("div", { style: { color: "red" } });
code-block.js:1:30 lint/nursery/noInlineStyles  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Unexpected style attribute.

> 1 │ React.createElement("div", { style: { color: "red" } });
│ ^^^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Inline styles make code harder to maintain, reduce reusability, and can prevent effective use of a strict Content Security Policy. Use external CSS classes or stylesheets instead.

ℹ 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 the style attribute.

1 │ React.createElement("div",·{·style:·{·color:·"red"·}·});
│ ------------------------
<div className="text-red">Error</div>
React.createElement("div", { className: "container" });