Problem/Motivation

Follow-up to #2865971: Use stylelint as opposed to csslint in core. This adds stylinelint config - let's use it in DrupalCI. It much better for our purposes since core patches can update it and add plugins.

All the commands below take place in DRUPAL_ROOT/core
To install stylelint

yarn install

This will install Drupal 8's node JS 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

yarn run lint:css

Proposed resolution

Make DrupalCI use yarn to install dependencies and run linting - hopefully it is already doing that for eslint.

Remaining tasks

User interface changes

None

API changes

tdb

Comments

alexpott created an issue. See original summary.

mile23’s picture

How does this map out to contrib?

alexpott’s picture

In my mind contrib should ship with a package.json too and declare their dependencies - which means we should really publish our eslint and stylelint rules too. At some point a module author ought to be able too use modern frontend techniques to compile es6 to js and what css processor they like - they shouldn't need to commit the output - DrupalCI etc should build it out for people.

However - at the moment this situation is no different from csslint or eslint - there's a .stylelintrc.json in root and if a module doesn't have it's own stylelint config we should use that. If it does we should use theirs.

mile23’s picture

Substitute yarn instead of npm in the IS, right?

alexpott’s picture

Issue summary: View changes

Yep!

alexpott’s picture

This is good to go now! So we need to get yarn on the build boxes and then we can run the lint:css-checkstyle command to lint our files.

mile23’s picture

Status: Active » Postponed
Mixologic’s picture

Status: Postponed » Needs work

#2874028: Create a Yarn Build step is done, so, unpostponing.

Mixologic’s picture

Had several talks with folks.

A. There's no global "Drupal" standard anywhere yet. Just the rules that core currently complies with in /core
B. We should only run this for a contrib project if they put a stylelintrc.json file in their project. Otherwise we should skip linting. Im +1 on this. We can change that later.
C. There will, eventually, be a stylelint global standard, and we'll keep it somewhere like drupal/css-coding-standards on github, add it to packagist, and point maintainers at that as a starting place.

theres a --fix option which I think I'll treat under the same policy we have for phpcs rules. seee (https://www.drupal.org/project/drupalci_testbot/issues/2912074)

  • 54fe20f committed on 2866840-use-stylelint
    Issue #2866840: preliminary commit of what I have so far
    
Mixologic’s picture

Turns out there is not a --fix option yet. not until https://www.drupal.org/project/drupal/issues/2910706 goes in.

Which means, we might want to do some sort of capabilities checking. If we can --fix, then we do it.
some scenarios to handle:
with and without the existance of --fix
test_autofixed_patch/generate the resultant patch +interdiff of what was autofixed

Core vs contrib
with/without stylelint.rc
with/without changes to stylelint.rc in patch
with/without changes to css files.

patch can add, remove, modify, or leave untouched .stylelintrc
project can either have, or not have .stylelintrc after codebase building.
Patch can either change css files or not.

the testrun itself can either have issues or not
if it has issues it can run --fix to fix those issues - maybe twice depending.

Mixologic’s picture

Component: Coding Standards » Jobs and Job Handling
Mixologic’s picture

Status: Needs work » Postponed
Related issues: +#2910706: Update Stylelint related Packages
joelpittet’s picture

Status: Postponed » Active

Unblocked

Mixologic’s picture

+++ awesome

jonathan1055’s picture

Any update on this? My contrib projects have CSSLINT coding standards faults, but if that is not being used in core, in favour of STYLELINT then I'd like to be able to run stylelint in drupal ci testbot runs instead.

joelpittet’s picture

Status: Active » Closed (outdated)

gitlab-ci is the successor, I don't believe this is relevant (cleaning up issues I was following)

jonathan1055’s picture

Thanks, yes csslint is not run in GitLab CI, we have Stylelint instead. Thanks for the tidy-up.