-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 stylelint for SCSS linting #8647
Conversation
core-blocks/button/editor.scss
Outdated
@@ -1,9 +1,11 @@ | |||
.editor-block-list__block[data-type="core/button"] { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird... why does it want empty lines here, @ntwb?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few reasons:
• Due to the number of permutations and combinations of where and where not new empty lines should occur, I've an issue to audit all of these at WordPress-Coding-Standards/stylelint-config-wordpress#65
• The lack off SCSS used currently in WordPress leading to not having an official "WordPress SCSS Coding Standards"
Solution/Workaround:
Update the config used here to override the appropriate rules here in this PR and then follow up by updating stylelint-config-wordpress
, either or both the CSS and SCSS configs and releasing a new version of stylelint-config-wordpress
.
6b19783
to
df96cf5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @noisysocks 💯
color(theme(primary) shade(30%)) 72%, | ||
theme(primary) 72% | ||
) !important; | ||
/* stylelint-enable */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: Investigate supporting this in stylelint core
#poststuff h2.hndle { /* WordPress selectors yolo */ | ||
#poststuff h2.hndle { | ||
|
||
/* WordPress selectors yolo */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not ideal, it's an idiosyncratic stylelint issue that requires fixing 😞
Reviewing the diff without whitespace changes is helpful 👌 |
Any idea why one of the unit tests failed on Travis? |
A snapshot failure: https://travis-ci.org/WordPress/gutenberg/jobs/412993016#L5006
A e2e test failure: https://travis-ci.org/WordPress/gutenberg/jobs/412993019#L1286
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of those weird new empty newlines aren't ideal, but I prefer automated, written rules I don't like over unwritten, unautomated ones I do like.
I'd be cool to fix all those newlines (eg https://github.com/WordPress/gutenberg/pull/8647/files#diff-44e5de5ab7a2465d8a970cbd777c427eR2). But hey, rules are cool!
352cf0a
to
d37b072
Compare
Thanks all! I disabled |
That ain't right... 😅 edit: Fixed thanks to #8660 |
4d71a48
to
061cc48
Compare
Adds stylelint and configures it to lint SCSS files with a very conservative rule set.
061cc48
to
8c72aab
Compare
package.json
Outdated
@@ -161,11 +163,13 @@ | |||
"fixtures:server-registered": "docker-compose run -w /var/www/html/wp-content/plugins/gutenberg --rm wordpress ./bin/get-server-blocks.php > core-blocks/test/server-registered.json", | |||
"fixtures:generate": "npm run fixtures:server-registered && cross-env GENERATE_MISSING_FIXTURES=y npm run test-unit", | |||
"fixtures:regenerate": "npm run fixtures:clean && npm run fixtures:generate", | |||
"lint": "npm run lint-js && npm run lint-pkg-json", | |||
"lint": "npm run lint-js && npm run lint-pkg-json && npm run lint-css", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we run it concurrently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 b977145
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome one 👏
I ❤️ npm run lint-css:fix
the most!
❤️ |
In case anyone is like me and was looking for editor integration for Sublime Text, here's the plugin for use with SublimeLinter: |
Who uses sublime nowadays ? |
It's way faster than Atom! And it never leads to |
@tofumatt I fully deserve this one :P |
Supersedes #1151. Closes #8618.
Adds the
npm run lint-css
andnpm run lint-css:fix
commands for SCSS linting, and configuresnpm run lint
to automatically runnpm run lint-css
.Linting is performed by stylelint. I've configured stylelint to extend stylelint-config-wordpress which enforces the WordPress CSS coding standards.
To save time and reduce merge conflicts, I've disabled every rule that isn't totally trivial to fix (e.g. with a find and replace). We can work towards re-enabling these rules one by one over the medium term.
To test:
npm run lint-css
stylelint --fix
or one of my regular expressions didn't completely backfire