Skip to content

Commit a41ca47

Browse files
committed
Fix style-prop-object false positive on computed properties (fixes #820)
1 parent a2a3de1 commit a41ca47

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/rules/style-prop-object.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = {
4848
) {
4949
if (node.arguments[1].type === 'ObjectExpression') {
5050
var style = node.arguments[1].properties.find(function(property) {
51-
return property.key.name === 'style';
51+
return property.key.name === 'style' && !property.computed;
5252
});
5353
if (style) {
5454
if (style.value.type === 'Identifier') {

tests/lib/rules/style-prop-object.js

+8
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ ruleTester.run('style-prop-object', rule, {
106106
{
107107
code: '<div style></div>',
108108
parserOptions: parserOptions
109+
},
110+
{
111+
code: [
112+
'React.createElement(MyCustomElem, {',
113+
' [style]: true',
114+
'}, \'My custom Elem\')'
115+
].join('\n'),
116+
parserOptions: parserOptions
109117
}
110118
],
111119
invalid: [

0 commit comments

Comments
 (0)