Replace sass-lint dependency with stylelint#6470
Merged
cee-chen merged 34 commits intoelastic:mainfrom Dec 12, 2022
Merged
Conversation
- see https://github.com/stylelint/stylelint/blob/main/docs/user-guide/get-started.md#using-a-community-shared-config - note that adding postcss@8 is necessary for the scss config to work - see stylelint-scss/stylelint-config-standard-scss#5
- JS file helps us do things like leave meaningful comments, which JSON doesn't allow
- previously ignored files were added due to vscode's overeager linting - it looks like said plugin no longer does so, so we can remove non `.scss` files - port over sass-lint excludes - add missed datepicker dir - add non-src files - remove no-longer-existant chart dir
+ fix issues caught by stylelint but not by sass-lint - unlike sass-lint, stylelint checks indentation of comments and also checks for tabs vs spaces + fix a few unnecessary `()`s, and add a disable because stylelint is confused by scss maps + remove unnecessary indentation disables
+ add skip for Sass scenarios where `"` has to be used for interpolation
- there isn't a handy `1tbs` option like eslint/sass-lint, so we need to combine a few different rules to get the effecrt we want + fix various instances where stylelint caught unnecessary double spaces before braces
+ include some rules that stylelint is more strict about than sass-lint was
- sass-lint was incorrectly marking pseudo *classes* as needing two `::`, whereas only pseudo *elements* need two `::`s. stylelint appears to correctly catch this OOTB @see https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Pseudo-classes_and_pseudo-elements
…espace - prettier does the same/similar for JS/CSS-in-JS in any case
- already appears to be something we do or was enforced by sass-lint, but stylelint needs the explicit rule
- specifically around empty comments & spacing around comments - I find them to be valid and inline with JS linting
- without these added rules, we get stylelint errors for how we currently write our CSS - although we may want to consider removing these in the future & using more modern syntax
- that were not previous enforced by sass-lint - we can consider turning them on at a later time if we want
+ remove unnecessary disables
- default with sass-lint but not with stylelint or existing configs + remove unnecessary disables + add newly necessary disables (some it's unclear why sass-lint didn't catch, and some are due to sass syntax, which stylelint unfortunately does not care about)
- by default, stylelint considers comments to not make the block empty
+ remove disables
- this is not perfect - stylelint does not appear to have a 1:1 with sass-lint on this, but it's somewhat close and will become less of an issue as we migrate to Emotion + remove disable lines that no longer apply
- no-mispelled-properties is simply wrong / out of date - no-warn was already disabled in -sass-lint.yml - empty-args isn't useful in a post-sass world
- there's no corresponding stylelint rule, and it feels pedantic / not terribly useful
- there's no corresponding stylelint rule, and it feels pedantic / not useful
- these don't appear to be enforced by stylelint, and as such nothing needs to be done
- It's not clear to me why that plugin was added or what it does, and it was last updated 5 years ago and uses a super old version of stylelint (8.x), so I'm removing it
5 tasks
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6470/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6470/ |
elizabetdev
approved these changes
Dec 12, 2022
Contributor
elizabetdev
left a comment
There was a problem hiding this comment.
Tested locally using VS Code and LGTM.
Are there any CSS lint rules that we currently linting that we do not want to be linting?
I just found one rule that I would remove it.
- thanks Elizabet!
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6470/ |
Contributor
Author
|
jenkins test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6470/ |
This was referenced Dec 13, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is part of a higher-level goal of removing our
node-sassdependency (see #6442).sass-linthas been deprecated for over 5 years now and its removal is long overdue.stylelintis generally held to be the updated replacement, and supports CSS-in-JS as well as Sass.📚 Helpful stylelint docs/reading:
What this PR does:
Dependencies:
sass-lintandsass-lint-auto-fix(stylelinthas a OOTB--fixflag)prettier-stylelint(it's not clear to me why this package was added or what it does, and it was last updated 5 years ago and uses a super old version of stylelint (8.x), so I opted to remove it)Rules:
sass-lintrules tostylelintequivalents (or as close as I could get it)sass-lintdefault rules (that I know of and saw) tostylelintrule equivalents, ifstylelintdid not have said rules enabled by defaultstylelintdefault rules, ifsass-lintwas not previously configured to enforce themWhat this PR does not do:
stylelintequivalent (that I also deemed not terribly useful) These rules are:What I'm looking for feedback on:
QA
yarn compile-scssand compare output diff of built EUI.cssfile tomainto ensure no changes::pseudo element fixes,+spacing, duplicate selector)General checklist
- [ ] A changelog entry exists and is marked appropriatelyDev-only changes