diff --git a/src/__tests__/lib/rules/prefer-to-have-style.js b/src/__tests__/lib/rules/prefer-to-have-style.js index 75e447c..4816a00 100644 --- a/src/__tests__/lib/rules/prefer-to-have-style.js +++ b/src/__tests__/lib/rules/prefer-to-have-style.js @@ -11,6 +11,11 @@ ruleTester.run("prefer-to-have-style", rule, { `expect(el.style).toMatchSnapshot()`, `expect(el.style).toEqual(foo)`, `expect(el).toHaveAttribute("style")`, + `React.useLayoutEffect(() => { + if (foo) { + document.body.setAttribute("style", "foo"); + } + }, [foo]);`, ], invalid: [ { diff --git a/src/rules/prefer-to-have-style.js b/src/rules/prefer-to-have-style.js index ef20a7e..96b6955 100644 --- a/src/rules/prefer-to-have-style.js +++ b/src/rules/prefer-to-have-style.js @@ -109,7 +109,7 @@ export const create = (context) => ({ }, //expect(el).toHaveAttribute("style", "foo: bar"); - [`CallExpression[callee.property.name][arguments.0.value=style][arguments.1]`]( + [`CallExpression[callee.property.name=toHaveAttribute][arguments.0.value=style][arguments.1][callee.object.callee.name=expect]`]( node ) { context.report({