Skip to content

Commit

Permalink
fix for no-css-tagged-template linting rule (#1537)
Browse files Browse the repository at this point in the history
* fix for no-css-tagged-template linting rule

* Add changeset
  • Loading branch information
liamqma authored Oct 24, 2023
1 parent 4a11c5f commit 941a723
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/cold-chairs-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@compiled/eslint-plugin': patch
'@compiled/webpack-loader': patch
---

Bugfix: no-css-tagged-template-expression ESLint rule truncates strings which include colons during autofixing.
Original file line number Diff line number Diff line change
Expand Up @@ -612,5 +612,22 @@ tester.run('no-css-tagged-template-expression', noCssTaggedTemplateExpressionRul
\`;
`,
},
{
filename: 'colon-in-value.ts',
code: `
import { css } from '@compiled/react';
css\`
background-image: url('https://some-url-b');
\`;
`,
output: `
import { css } from '@compiled/react';
css({
backgroundImage: "url('https://some-url-b')"
});
`,
},
]),
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ const getArguments = (
return args;
}

const [property, value] = chars.split(':');
// Split the property and value
// e.g. `color: red` becomes ['color', 'red']
// also consider `background: url("https://some-url-b")`, which has a colon in the value.
const [property, ...v] = chars.split(':');
const value = v.join(':');

// Extract any expressions listed before the property that were not delimited by a ;
if (expressions.length) {
Expand Down

0 comments on commit 941a723

Please sign in to comment.