Skip to content

noReactSpecificProps

诊断类别:lint/suspicious/noReactSpecificProps

¥Diagnostic Category: lint/suspicious/noReactSpecificProps

自从:v1.7.2

¥Since: v1.7.2

来源:

¥Sources:

防止使用 React 特定的 JSX 属性。

¥Prevents React-specific JSX properties from being used.

此规则旨在用于不使用 React 样式 prop 名称的基于 JSX 的框架(主要是 Solid.js)。

¥This rule is intended for use in JSX-based frameworks (mainly Solid.js) that do not use React-style prop names.

¥Examples

¥Invalid

<Hello className="John" />
code-block.jsx:1:8 lint/suspicious/noReactSpecificProps  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This JSX attribute is specific to React.

> 1 │ <Hello className=“John” />
^^^^^^^^^
2 │

This attribute may not be supported by non-React frameworks, as it is not native to HTML.

> 1 │ <Hello className=“John” />
^^^^^^^^^
2 │

Safe fix: Replace this attribute name with “class”

1 - <Hello·className=John·/>
1+ <Hello·class=John·/>
2 2

¥Valid

<Hello class="Doe" />

¥Related links