Rules

no-string-style

Use JSX object styles instead of string styles.

Purpose and behavior

Use JSX object styles instead of string styles.

Reports string-valued JSX style attributes. Object expressions are allowed. This is a syntactic check, not validation of individual CSS properties.

Options

No configurable options. Enable with "rules/no-string-style": "error".

Invalid example

const el = <div style='color: red' />

Valid example

const el = <div style={{ color: 'red' }} />

Fixes and exceptions

This rule reports diagnostics without an automatic fix. Rewrite the code deliberately rather than guessing its intended semantics.

For a genuine boundary exception, use an oxlint-disable-next-line rules/no-string-style -- reason comment. Examples illustrate this rule alone and may omit imports and declarations.

Source and tests

Enabled by the TypeScript preset.

no-string-style.ts · Tests