Skip to content

Commit 5abf842

Browse files
authored
fix: allow string style prop on non-host elements in dom/no-string-style-prop, closes #1217 (#1222)
1 parent a17ccac commit 5abf842

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

packages/plugins/eslint-plugin-react-dom/src/rules/no-string-style-prop.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,10 @@ ruleTester.run(RULE_NAME, rule, {
5454
return <div style={someStyle} />;
5555
}
5656
`,
57+
tsx`
58+
function Component() {
59+
return <StatusBar style="auto" />;
60+
}
61+
`,
5762
],
5863
});

packages/plugins/eslint-plugin-react-dom/src/rules/no-string-style-prop.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default createRule<[], MessageID>({
3131
export function create(context: RuleContext<MessageID, []>): RuleListener {
3232
return {
3333
JSXElement(node) {
34+
if (!ER.isHostElement(context, node)) return;
3435
const getAttribute = ER.getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node));
3536
const attribute = getAttribute("style");
3637
if (attribute == null) return;

0 commit comments

Comments
 (0)