43081j / postcss-lit

PostCSS syntax for extracting CSS from template literals inside JS/TS files
84 stars 6 forks source link

Indentation should account for template position #14

Closed 43081j closed 2 years ago

43081j commented 2 years ago

For example:

const style = css`
  .foo { color: hotpink; }
`;

stylelint will complain about this, because it thinks it should be indented one less:

const style = css`
.foo { color: hotpink; }
`;

i'd argue the former is perfectly fine and more readable. so we should probably de-indent when parsing, relative to the template's indentation level

we can use the template's end position as a base and de-indent everything by that amount.

@abdonrd FYI, this might affect you too. when i publish whats in master, it'll now work for you but i think you'll get a bunch of indentation warnings like i do, until this issue is fixed