-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a CSS Validator #2189
Comments
We already have this npm script |
Agreed. When this ticket is picked up, it'd be good to explore usage of certain stylelint plugins , eg |
@jroebu14 does it catch css that is programatically set? The padding auto from before was inside a function in the css like
|
I just discovered this https://www.styled-components.com/docs/tooling#interpolation-tagging Looks like wherever we add mixins (or any sort of interpolation) we can tag it to let stylelint know what it is e.g. export const Grid = styled.div`
${/* sc-custom */ layoutGridWrapper}
`; That way it can pass stylelint validation.
That's a very good question and the answer is, no it doesn't seem to 😞 |
Here's an update on the use of the advantages
disadvantages
export const Grid = styled.div`
${/* sc-custom */ layoutGridWrapper}
`;
I don't think there are any alternatives out there that integrate well with styled-components. To summarise, I think there's some value in adding Keen to hear your thoughts. |
Interesting @jroebu14, I think i agree that it is worth adding, the string interpolation one is a bit of a pain though, as thats used soooooo much. Im assuming this would need to be used in psammead too? I still think we need a validator on the rendered output of our pages, but this could be a nice step forward |
@dr3 @sareh yeh we'd need to add this in Psammead too. OK cool so the plan to close this issue would be to open a PR each for psammead and simorgh with these changes:
|
As I was working on implementing this in Simorgh and Psammead I noticed that using the
Fig 3. the only way to fix this is to disable and re-enable linting around the mixin which creates a lot of clutter in the styles. If we want to continue using
"rules": {
"csstree/validator": {
"ignore": ["-styled-mixin0", "-styled-mixin1", "-styled-mixin2", "-styled-mixin3", "-styled-mixin4", "-styled-mixin5"]
}
} This would allow up to 5 mixins within a block of styles which should be sufficient as we generally don't go above 2 mixins per block.
"rules": {
"csstree/validator": {
"ignore": ["/styled-mixin/"]
}
} |
@jroebu14 Hmm thats a tricky one, for the time being can we raise an issue for 3, or maybe an issue for scoped ignore comments so export const Grid = styled.div`
// THIS IS CHECKED
${/* sc-custom-line */ layoutGridWrapper}
// THIS IS CHECKED
`; or even better export const Grid = styled.div`
// THIS IS CHECKED
${/* sc-custom-line styled-mixin */ layoutGridWrapper}
// THIS IS CHECKED
`; Perhaps? checking interest might make it easier to pick |
Raised an issue for regular expression support csstree/stylelint-validator#19 |
Based on this comment I quickly wrote a custom stylint processor to transform mixins into custom css properties. |
Is your feature request related to a problem? Please describe.
Highlighted by #2188, we should add a css validator to simorgh.
Having a look around, I noticed the package
css-validator
which we could run on the collated output of css from simorgh, however it currently has vulnerabilities (which we could fix twolfson/css-validator#15)Alternatively we could introduce some form of styled components validator, ideally validating to the w3c spec, so look around and see if you can find a good one.
Describe the solution you'd like
Testing notes
This issue will investigate css validators and then the check will be implemented on CI.Wouldn't require any testing from a tester.
Dev insight: This in itself would be a test, so limited if not no testing required, unless we write our own validator, which is likely inadvisable
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: