Skip to content

noDestructuredProps

Disallow destructuring props inside JSX components in Solid projects.

In Solid, props must be used with property accesses (props.foo) to preserve reactivity.

let Component = ({}) => <div />;
code-block.jsx:1:18 lint/nursery/noDestructuredProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

You cannot destructure props.

> 1 │ let Component = ({}) => <div />;
^^
2 │

In Solid, props must be used with property accesses (props.foo) to preserve reactivity.

Remove the destructuring and use props.foo instead.

let Component = ({ a: A }) => <div a={A} />;
code-block.jsx:1:39 lint/nursery/noDestructuredProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This variable shouldn’t be destructured.

> 1 │ let Component = ({ a: A }) => <div a={A} />;
^
2 │

This is where the props were destructured.

> 1 │ let Component = ({ a: A }) => <div a={A} />;
^^^^^^^^
2 │

In Solid, props must be used with property accesses (props.foo) to preserve reactivity.

Remove the destructuring and use props.foo instead.

let Component = ({ prop1 }: Props) => <div p1={prop1} />;
code-block.tsx:1:48 lint/nursery/noDestructuredProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This variable shouldn’t be destructured.

> 1 │ let Component = ({ prop1 }: Props) => <div p1={prop1} />;
^^^^^
2 │

This is where the props were destructured.

> 1 │ let Component = ({ prop1 }: Props) => <div p1={prop1} />;
^^^^^^^^^
2 │

In Solid, props must be used with property accesses (props.foo) to preserve reactivity.

Remove the destructuring and use props.foo instead.

let Component = (props) => <div />;
let Component = (props) => <div a={props.a} />;
biome.json
{
"linter": {
"rules": {
"nursery": {
"noDestructuredProps": "error"
}
}
}
}