Skip to content

Commit 72f6167

Browse files
committed
Add CSS-in-JS caveats description
1 parent 6d6c8b6 commit 72f6167

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Lint and autofix style sheets order with [stylelint-order].
1212
* Sorts properties.
1313
* Sorts at-rules by different options.
1414
* Groups properties, custom properties, dollar variables, nested rules, nested at-rules.
15-
* Supports CSS, SCSS (if [postcss-scss] parser is used), [PreCSS] and most likely any other syntax added by other PostCSS plugins.
15+
* Supports CSS, SCSS (using [postcss-scss]), HTML (with [postcss-html]), CSS-in-JS (with [postcss-jsx]), [PreCSS] and most likely any other syntax added by other PostCSS plugins.
1616

1717
## Installation
1818

@@ -29,7 +29,9 @@ The plugin has no default options. Everything is disabled by default.
2929
- [`unspecified-properties-position`](./lib/properties-order/unspecified-properties-position.md): Specify position for properties not specified in `properties-order`.
3030
- `throw-validate-errors`: Throw config validation errors instead of just showing and ignoring them. Defaults to `false`.
3131

32-
## Handling comments
32+
## Caveats
33+
34+
### Handling comments
3335

3436
Comments that are before node and on a separate line linked to that node. Shared-line comments are also linked to that node. Shared-line comments are comments which are located after a node and on the same line as a node.
3537

@@ -42,10 +44,33 @@ a {
4244
}
4345
```
4446

45-
## Ignored at-rules
47+
### Ignored at-rules
4648

4749
Some at-rules, like [control](https://sass-lang.com/documentation/file.SASS_REFERENCE.html#control_directives__expressions) and [function](https://sass-lang.com/documentation/file.SASS_REFERENCE.html#function_directives) directives in Sass, are ignored. It means rules won't touch content inside these at-rules, as doing so could change or break functionality.
4850

51+
### CSS-in-JS
52+
53+
Plugin will ignore rules, which have template literal interpolation, to avoid breaking logic:
54+
55+
```js
56+
const Component = styled.div`
57+
/* The following properties WILL NOT be sorted, because interpolation is on properties level */
58+
z-index: 1;
59+
top: 1px;
60+
${props => props.great && 'color: red'};
61+
position: absolute;
62+
display: block;
63+
64+
div {
65+
/* The following properties WILL be sorted, because interpolation for property value only */
66+
z-index: 2;
67+
position: static;
68+
top: ${2 + 10}px;
69+
display: inline-block;
70+
}
71+
`;
72+
```
73+
4974
## Migration from `2.x`
5075

5176
Remove all `*-empty-line-before` and `clean-empty-lines` options. Use [stylelint] with `--fix` option instead.
@@ -207,6 +232,8 @@ I recommend [Prettier] for formatting style sheets.
207232
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
208233
[PreCSS]: https://github.com/jonathantneal/precss
209234
[postcss-scss]: https://github.com/postcss/postcss-scss
235+
[postcss-html]: https://github.com/gucong3000/postcss-html
236+
[postcss-jsx]: https://github.com/gucong3000/postcss-jsx
210237
[Prettier]: https://prettier.io/
211238
[stylelint]: https://stylelint.io/
212239
[stylelint-order]: https://github.com/hudochenkov/stylelint-order

0 commit comments

Comments
 (0)