From a41ca479d79e769d75fbd0ed9c07040759aefa97 Mon Sep 17 00:00:00 2001 From: Yannick Croissant Date: Thu, 15 Sep 2016 18:25:09 +0000 Subject: [PATCH] Fix style-prop-object false positive on computed properties (fixes #820) --- lib/rules/style-prop-object.js | 2 +- tests/lib/rules/style-prop-object.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/rules/style-prop-object.js b/lib/rules/style-prop-object.js index 2a67137360..1b861ca160 100644 --- a/lib/rules/style-prop-object.js +++ b/lib/rules/style-prop-object.js @@ -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') { diff --git a/tests/lib/rules/style-prop-object.js b/tests/lib/rules/style-prop-object.js index 90860e9206..19db43518a 100644 --- a/tests/lib/rules/style-prop-object.js +++ b/tests/lib/rules/style-prop-object.js @@ -106,6 +106,14 @@ ruleTester.run('style-prop-object', rule, { { code: '
', parserOptions: parserOptions + }, + { + code: [ + 'React.createElement(MyCustomElem, {', + ' [style]: true', + '}, \'My custom Elem\')' + ].join('\n'), + parserOptions: parserOptions } ], invalid: [