Skip to content

Commit 2879047

Browse files
committed
Fix error when style attribute is not an object
1 parent 962e05a commit 2879047

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

eslint-plugin/lib/rules/avoid-css-animations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = {
3838
(attribute) => attribute.name.name === "style",
3939
);
4040

41-
if (styleAttribute != null) {
41+
if (styleAttribute && styleAttribute.value.expression) {
4242
// To prevent (for example) <div style={{ animate: 'width 2s' }}>
4343
const property = styleAttribute.value.expression.properties.find(
4444
(prop) =>

eslint-plugin/tests/lib/rules/avoid-css-animations.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ ruleTester.run("avoid-css-animations", rule, {
5050
export default MyComponent;
5151
`,
5252
`<div style={{ width: '100px', height: '100px' }}>Hello world</div>`,
53+
`<div style="border: 2px solid red">My red element</div>`,
5354
],
5455

5556
invalid: [

0 commit comments

Comments
 (0)