Skip to content

Commit

Permalink
Fix style-prop-object false positive on computed properties (fixes #820)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Sep 15, 2016
1 parent a2a3de1 commit a41ca47
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/style-prop-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {
) {
if (node.arguments[1].type === 'ObjectExpression') {
var style = node.arguments[1].properties.find(function(property) {
return property.key.name === 'style';
return property.key.name === 'style' && !property.computed;
});
if (style) {
if (style.value.type === 'Identifier') {
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/style-prop-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ ruleTester.run('style-prop-object', rule, {
{
code: '<div style></div>',
parserOptions: parserOptions
},
{
code: [
'React.createElement(MyCustomElem, {',
' [style]: true',
'}, \'My custom Elem\')'
].join('\n'),
parserOptions: parserOptions
}
],
invalid: [
Expand Down

0 comments on commit a41ca47

Please sign in to comment.