noSolidDestructuredProps
¥Summary
-
规则生效日期:
v2.0.0¥Rule available since:
v2.0.0 -
诊断类别:
lint/correctness/noSolidDestructuredProps¥Diagnostic Category:
lint/correctness/noSolidDestructuredProps -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
此规则属于以下域:
¥This rule belongs to the following domains:
-
来源:
¥Sources:
-
灵感来自
solid/no-destructure¥Inspired from
solid/no-destructure
-
¥How to configure
{ "linter": { "rules": { "correctness": { "noSolidDestructuredProps": "error" } } }}¥Description
禁止在 Solid 项目中解构 JSX 组件内的 props。
¥Disallow destructuring props inside JSX components in Solid projects.
在 Solid 中,必须使用 props 并结合属性访问(props.foo)来保持响应式。
¥In Solid, props must be used with property accesses (props.foo) to preserve reactivity.
¥Examples
¥Invalid
let Component = ({}) => <div />;code-block.jsx:1:18 lint/correctness/noSolidDestructuredProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ 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/correctness/noSolidDestructuredProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ 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/correctness/noSolidDestructuredProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ 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.
¥Valid
let Component = (props) => <div />;let Component = (props) => <div a={props.a} />;¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号