Skip to content

Commit

Permalink
Fix error when style attribute is not an object
Browse files Browse the repository at this point in the history
  • Loading branch information
utarwyn committed Aug 17, 2023
1 parent 962e05a commit 2879047
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion eslint-plugin/lib/rules/avoid-css-animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
(attribute) => attribute.name.name === "style",
);

if (styleAttribute != null) {
if (styleAttribute && styleAttribute.value.expression) {
// To prevent (for example) <div style={{ animate: 'width 2s' }}>
const property = styleAttribute.value.expression.properties.find(
(prop) =>
Expand Down
1 change: 1 addition & 0 deletions eslint-plugin/tests/lib/rules/avoid-css-animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ ruleTester.run("avoid-css-animations", rule, {
export default MyComponent;
`,
`<div style={{ width: '100px', height: '100px' }}>Hello world</div>`,
`<div style="border: 2px solid red">My red element</div>`,
],

invalid: [
Expand Down

0 comments on commit 2879047

Please sign in to comment.