Skip to content

Commit

Permalink
Fix sorting inside CSS-in-JS css helper
Browse files Browse the repository at this point in the history
  • Loading branch information
hudochenkov committed Mar 7, 2023
1 parent 56d520f commit 7355fa5
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 25 deletions.
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"main": "index.js",
"dependencies": {
"postcss": "^8.4.21",
"postcss-sorting": "^8.0.1"
"postcss-sorting": "^8.0.2"
},
"peerDependencies": {
"stylelint": "^14.0.0 || ^15.0.0"
Expand All @@ -38,10 +38,10 @@
"lint-staged": "^13.1.1",
"postcss-html": "^1.5.0",
"postcss-less": "^6.0.0",
"postcss-styled-syntax": "^0.3.1",
"postcss-styled-syntax": "^0.4.0",
"prettier": "~2.8.4",
"prettier-config-hudochenkov": "^0.3.0",
"stylelint": "^15.0.0"
"stylelint": "^15.2.0"
},
"scripts": {
"lint": "eslint . --max-warnings=0 && prettier '**/*.js' --check",
Expand Down
20 changes: 20 additions & 0 deletions rules/properties-order/tests/flat.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,26 @@ testRule({
unfixable: true,
message: messages.expected('top', 'color'),
},
{
code: `
const Component = styled.div\`
\${() => css\`
color: tomato;
top: 0;
\`}
\`;
`,
fixed: `
const Component = styled.div\`
\${() => css\`
top: 0;
color: tomato;
\`}
\`;
`,
description: 'sort inside css helper',
message: messages.expected('top', 'color'),
},
],
});

Expand Down
2 changes: 1 addition & 1 deletion utils/getContainingNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function getContainingNode(node) {
}

// postcss-styled-syntax: declarations are children of Root node
if (node.parent?.type === 'root' && node.parent?.raws.styledSyntaxIsComponent) {
if (node.parent?.type === 'root' && node.parent?.raws.isRuleLike) {
return node.parent;
}

Expand Down

0 comments on commit 7355fa5

Please sign in to comment.