On a project we have custom templates string to abstract styled-components functions. For example, we have templates string for the media-queries that look like this one:
// Definition
const for1080p = (...args) => css`
@media (min-height: 1080px) {
${css(...args)}
}
`;
// Usage
const Logo = styled.div`
width: 200px;
${for1080p`
width: 300px;
`}
`;
We made this choice because it keeps the original styled syntax. It is also nicely formated by prettier.
Our main problem today is that we don't know how to analyse with stylelint our CSS that are inside a custom template string.
For example:
const Logo = styled.div`
widht: 200px; /* <--- Unexpected unknown property "widht" */
${for1080p`
widht: 300px; /* <--- No error detected :( */
`}
`;
Do you know how to do this?
width
and wrotewidht
– Vaunt