Some of the CSS in the Umami theme is not formatted following our CSS coding standards. Let's resave them using CSScomb to bring them up to speed.

This will mean if anyone is reviewing patches with an auto CSScomb (like me!), then code won't move around when a file is saved, making it harder to review.

Comments

markconroy created an issue. See original summary.

markconroy’s picture

Status: Active » Needs review
StatusFileSize
new33.8 KB

Adding patch.

markconroy’s picture

The changes in this patch don't all follow our CSS Coding formatting settings from here:
https://www.drupal.org/docs/develop/standards/css/css-formatting-guideli...

For example, that says "Add the pixel value in a comment directly after the the opening brace."
like so:
@media screen and (min-width: 28.125rem) { /* 450px */

But the .csscomb will render it like this:

@media screen and (min-width: 28.125rem) {
/* 450px */

I used the .csscomb settings from here: https://www.drupal.org/docs/develop/standards/css/csscomb-settings-for-d...

I'm not sure the issue is fixable, because single line comments are supposed to be on a line of their own, so we have a conflict here
https://www.drupal.org/docs/develop/standards/css/css-formatting-guideli...

Either we can't run the .csscomb or we update our coding standards.

I think this patch should be committed, as it fixes almost all coding standards issues, and the small few items it brings up (such as those in this comment) are much smaller issues than what it fixes.

eli-t’s picture

Status: Needs review » Postponed

Moving to postponed in anticipation of #2983568: Audit and improve focus styles across the Umami theme for logged out users landing. We don't want to cause a reroll for that patch, but this issue should immediately follow.

eli-t’s picture

markconroy’s picture

Status: Postponed » Needs review
StatusFileSize
new55.89 KB

Now that we have #2983568: Audit and improve focus styles across the Umami theme for logged out users patch committed, I've run every CSS file in the demo_umami profile through the csscomb using the settings from the Drupal Coding Standards csscomb settings.

There are no new code changes in this patch. It _only_ formats the CSS according to the coding standards from CSS comb. (One code block is added at the top of one file, from which it was missing.)

Once this is commited to Umami, we can then enforce it for all new CSS patches that are created.

markconroy’s picture

StatusFileSize
new54.18 KB
new21.43 KB

The above patch has failures according to `yarn run lint:css` so this patch fixes these. I think we (as in, Drupal) might have some discrepancies between our CSS coding standards vs csscomb file vs css lint rules that we might need to figure out.

eli-t’s picture

I have applied the patch in #7 and manually reviewed the changes using PHPStorms VCS functionality.
I can confirm no new rules are added, and none are removed.
Non-significant whitespace has been removed.
I have spot-checked a limited number of the rules that have been moved and all that were checked were in compliance with the order defined in https://www.drupal.org/docs/develop/standards/css/csscomb-settings-for-d....

A small number of rules were changed in the patch rather than simply moved. For example, the [dir='rtl'] selector was sometimes used as [dir=rtl] or [dir="rtl"] before application of the patch (see contact.css, menu-account.css, messages.css and others).

Similarly font-family: "Scope One", Georgia, serif; was changed to font-family: 'Scope One', Georgia, serif;, and content: "•"; to content: '•';

markconroy’s picture

StatusFileSize
new57.65 KB
new20.37 KB

Thanks @Eli-T for that review. The csscomb says to use double quotes, so I have no idea why it rewrote them to single quotes.

It's also a bit strange that yarn run lint:css didn't catch them as issues.

I'm attaching another patch with all those set to double quotes.

alexpott’s picture

Sooooo.... here's the thing I'm not sure we should be following the CSScomb file. We use stylelint in core and all CSS formatting issues should be done by fixing up core/.stylelintrc.json and making all of core be consistent to that rule. Otherwise we're bound to regress here. We need to take the same step by step slow but consistent approach we are trying to take with PHP and JS coding standards.

markconroy’s picture

HI Alex,

When I run yarn run lint:css I get no failures with the patch above.

However it does not give any errors for the ordering of CSS properties. The linter seems to accept this:

.view-mode-card {
   color: #000;
   display: flex;
   flex-direction: column;
   width: 100%;
   padding: 1rem;
}

and this:

.view-mode-card {
   display: flex;
   flex-direction: column;
   width: 100%;
   padding: 1rem;
   color: #000;
}

Though the bottom one is the one that should be correct.

So, I _think_ our CSS as per this patch is correct and following the guidelines (certainly better than it had been). If not, should we continue to stop working on other issues while we fix this, or should we abandon this and continue to work on other issues and fix up the CSS files as we touch them within other issues?

eli-t’s picture

I've reviewed the interdiff and confirmed that the only changes are ' being replaced with " where appropriate. Sometimes these are comments rather than functional CSS but I don't think that's an issue. The only remaining instances of ' are in comments where an apostrophe is actually intended. IE let's & doesn't.

Happy to move this to RTBC subject to @alexpott's reponse to @markconroy's comment #11

alexpott’s picture

Otherwise we're bound to regress here

This is the problem - we need to convert the CSScomb rules into stylelint rules and apply them to all of core. I'd be a fan of closing this issue and addressing CSS standards in the way outlined in #10.

markconroy’s picture

Maybe I'm missing something here, but I'm rather confused.

It seems to me that we have a patch for the demo_umami section of Drupal core that makes our code much cleaner and - as far as I can tell - follows Drupal's coding standards, but we are not going to commit it? Further, the patch was reviewed by another core maintainer (@Eli-T) who seems happy to mark it as RTBC, but we are not going to commit it?

I can appreciate that maybe the stylelintrc needs more work and that other sections of Drupal core may need their CSS fixed, but surely it's a positive thing for us to at least start with this one section - demo_umami - in good shape, and we can further amend it if we need to as the stylelintrc gets amended. It could also be the benchmark by which other sections/themes are gauged against when we get around to them.

I also think we need to look at marking the coding standards page - or at least the csscomb section of it - as obsolete if it is not to be followed any longer.

alexpott’s picture

@markconroy there have been many efforts to clean up different parts of core that all ultimately fail if they are not backed by some form of automated testing. In my opinion the CSScomb standards should not be part of the official documentation because so little of Drupal's CSS actually complies - because nothing is enforcing it. Which is my point.

markconroy’s picture

Should we abandon csscomb because so little of Drupal's CSS complies with its rules or should we commit the code that does comply with its rules, so we have one part of Drupal up-to-scratch?

I'm genuinely confused at why we are refusing to commit a patch that aims to follow Drupal's coding standards. We realised that demo_umami doesn't follow all the CSS coding standards, so we fixed that.

Is there a larger issue somewhere that I can help out with to fix all of Drupal's CSS in one go? Or to fix the stylelintrc file? Or will we fix all the other parts, like you say "step by step"? If step-by-step, is what we have here not a "step"? I'd expect that we should be able to fix all other files one file at a time and commit each as they are fixed. Here we're just attempting to do that with one full section, rather than one file at a time.

alexpott’s picture

The child issues of #2865971: Use stylelint as opposed to csslint in core are a great place to start.

alexpott’s picture

+++ b/core/profiles/demo_umami/themes/umami/css/base.css
@@ -101,136 +96,137 @@ button[disabled],
-@media screen and (min-width: 60rem) { /* 960px */
+@media screen and (min-width: 60rem) {
+  /* 960px */

This is an unfortunate affect of the CSSComb rules. Our standards say that the way it is done in HEAD is correct. See https://www.drupal.org/docs/develop/standards/css/css-formatting-guideli...

alexpott’s picture

So @markconroy for example - there was no issue for the string quotes - here's a start #3024505: Add quote standards to Stylelint config

markconroy’s picture

Status: Needs review » Postponed

I'm postponing this issue in favour of @alexpott's idea that all coding standards fixes should be automatable so they don't re-occur.

We can mark this as fixed/closed when we get to that stage.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Postponed » Closed (outdated)

Stylelint is now used to check CSS files and is automated. I am closing this as outdated.