Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/__tests__/lib/rules/prefer-to-have-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,15 @@ ruleTester.run("prefer-to-have-style", rule, {
code: `expect(element.style[0]).toBe(/RegExp/);`,
errors,
},
{
code: `expect(imageElement.style[computed]).toBe(\`inset 0px 0px 0px 400px \${c}\`)`,
errors,
output: null,
},
{
code: `expect(imageElement.style[computed]).not.toBe(\`inset 0px 0px 0px 400px \${c}\`)`,
errors,
output: null,
},
],
});
8 changes: 6 additions & 2 deletions src/rules/prefer-to-have-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ export const create = (context) => {

if (
typeof styleValue.value !== "number" &&
!(styleValue.value instanceof RegExp)
!(styleValue.value instanceof RegExp) &&
styleName.type !== "Identifier"
) {
fix = (fixer) => {
return [
Expand Down Expand Up @@ -208,7 +209,10 @@ export const create = (context) => {

let fix = null;

if (typeof styleName.value !== "number") {
if (
typeof styleName.value !== "number" &&
styleName.type !== "Identifier"
) {
fix = (fixer) => {
return [
fixer.removeRange([
Expand Down