Problem/Motivation
Follow-up to #2865971: Use stylelint as opposed to csslint in core. Configure the length-zero-no-unit
to be consistent with https://www.drupal.org/docs/develop/standards/css/css-coding-standards
From the CSS Formatting Guidelines:
Where allowed, avoid specifying units for zero-values, e.g. use margin: 0; instead of margin: 0px;.
Proposed resolution
Brief instructions on running stylelint - you'll need npm...
All the commands below take place in DRUPAL_ROOT/core
To install stylelint
npm install
This will install Drupal 8's npm dependencies of which stylelint is one.
To run it on all core css files. Apply this issue's patch and do the following command from DRUPAL_ROOT/core
npm run lint:css
Remaining tasks
User interface changes
None
API changes
None
Comment | File | Size | Author |
---|---|---|---|
#23 | interdiff-2866816-21-22.txt | 654 bytes | harsha012 |
#23 | 2866816-22.patch | 6.72 KB | harsha012 |
#21 | interdiff-2866816-19-21.txt | 985 bytes | harsha012 |
#21 | 2866816-21.patch | 6.9 KB | harsha012 |
#19 | 2866816-19.patch | 6.25 KB | harsha012 |
Comments
Comment #2
alexpottComment #3
alexpottComment #4
BrightBoldComment #5
BrightBoldPatch with length-zero-no-unit rule and associated CSS fixes.
This patch is dependent on #2865971-41: Use stylelint as opposed to csslint in core so will fail testing until that one is committed.
Comment #6
BrightBoldPatch for testing purposes that combines the patch in #5 above with the patch in #2865971-41: Use stylelint as opposed to csslint in core.
Comment #7
BrightBoldComment #8
idebr CreditAttribution: idebr at ezCompany commentedHi BrightBold,
Thanks for working on this issue! The patch works as expected, however I would like to suggest one change:
Considering this line matches the "stylelint-config-standard" we are extending, I suggest we remove this line completely.
Source: https://github.com/stylelint/stylelint-config-standard/blob/master/index...
Comment #9
BrightBoldOh, good point idebr.
However, will this make nearly every other stylelint-related patch (I've made a bunch so far) have to be rerolled each time we apply one because the linenumbers in .stylelintrc.json will have changed? If so, is it more efficient to keep setting the values and then once all the patches are committed, go back and remove all the rules that duplicate stylelint-config-standards? Or is it better to go ahead with removing redundant lines so each issue is completely solved, and just know we will be rerolling tons of patches? (I'm assuming some will have to be rerolled anyway when errors for different rules appear in the same line of code.) Or is git smarter than I think and I need to stop worrying?
Comment #10
idebr CreditAttribution: idebr at ezCompany commentedConsidering we are not changing the same lines, subsequent patches would probably not have to be rerolled. However, I agree we should create a followup if it turns out rerolling the patches turns out to be a lot of work.
Comment #11
BrightBoldSounds like a plan @idebr. It will probably be a few days before I can get back to working on these, so in the meantime I will keep my eye on #2865971: Use stylelint as opposed to csslint in core. Once it's resolved & committed and one of the child issues is reviewed & committed I can see how much trouble rerolling will be and make a call on how to proceed.
Comment #12
chrisfromredfinComment #13
chrisfromredfinUpdated against 8.4.x
Comment #15
chrisfromredfinTest only ran against 8.3 by accident. 8.4 passes, so setting back to NR.
Comment #17
joelpittetOne more snuck in 🙃
Comment #18
joelpittetWhoops, that was from an upgrade test for stylelint.
The actual reroll is because this file doesn't exist
error: core/modules/outside_in/css/outside_in.theme.css: does not exist in index
Comment #19
harsha012 CreditAttribution: harsha012 as a volunteer and at Red Crackle commentedre-rolled the patch
Comment #20
joelpittetOne more change snuck in... 🙃
Comment #21
harsha012 CreditAttribution: harsha012 as a volunteer and at Red Crackle commentedfixed as per #20
Comment #22
alexpottUnrelated changes.
Comment #23
harsha012 CreditAttribution: harsha012 as a volunteer and at Red Crackle commentedremoved the unrelated changes
Comment #24
joelpittetUsed
git diff --color-words
to see if unrelated changes were there. Ran the linter with and without the CSS changes to ensure they are caught by the rule.Thanks @harsha012, @cswells, and @alexpott!
Comment #25
alexpottCommitted 7bf384b and pushed to 8.5.x. Thanks!