-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add stylelint CSS linting #12934
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
Open
afercia
wants to merge
54
commits into
WordPress:trunk
Choose a base branch
from
afercia:add-stylelint-linting
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add stylelint CSS linting #12934
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
998b454
First pass at adding a stylelint script.
afercia 422a3b7
Remove custom rule from gutenberg.
afercia 927c036
Clean up stylelintignore.
afercia 89d8b53
Clean up config.
afercia dde3bbc
Add Grunt task and clean up.
afercia 3ccc502
Remove stylelint-config-wordpress package.
afercia ac8915c
Ignore admin color scheme auto generated files.
afercia 6ab9a4c
Ignore files copied to wp-includes js.
afercia ba06aa2
Remove Stylelint configuration from Twenty Twenty theme.
afercia 4f8d76d
Remove Stylelint configuration from Twenty Twenty-One theme.
afercia afa60f9
Remove comments.
afercia b14bd86
Add lint:css:themes script for bundled themes.
afercia 9fb042c
Build theme files.
afercia 764c162
Use the root stylelintrc for twentytwentyone.
afercia 249264b
For twentytwentyone try adding a postcss script and run it twice.
afercia 750ce8a
Start refining rules.
afercia 585ca96
Add rules for empty lines before.
afercia 712b258
Solve the indentation and leading space issues avoiding to run postcs…
afercia 7a4aae3
Improve comment-empty-line-before.
afercia d0dad73
Improve comment.
afercia 918fa17
Improve selector-list-comma-space-after.
afercia bd7f005
Refine empty libe before rule.
afercia 6997879
Add selector-no-qualifying-type warning.
afercia d75b235
Refine more rules.
afercia 3325172
Improve order of rules related to indentation.
afercia 55dea77
Reduce max-empty-lines to 1.
afercia 59e1619
Disable comment-empty-line-before.
afercia 41189d5
Run stylelint directly so that it walks upwards until it finds the ro…
afercia 34f68ca
Update test-and-zip-default-themes gh action.
afercia 76dcbef
Add bacl @wordpress/scripts to twentytwentyone.
afercia 72b4f38
Add stylelint-plugin-logical-css to twentytwentyone.
afercia 95feafb
Update twentytwentyone styles.
afercia 3512b19
Pass the glob as a quoted pattern.
afercia 0c910c3
Add optimizeLegibility to value-keyword-case exceptions.
afercia fbc64f2
Add @stylistic/selector-descendant-combinator-no-non-space true.
afercia aa10d74
Adjust a few rules.
afercia 4b9ca51
Ignore dashicons font-family.
afercia 8eb1a68
Apply a few minor JS coding standards to stylelintrc.js.
afercia aef6d21
Try warnings threshold mechanism.
afercia a41a407
Normalize the glob path for Windows on CI.
afercia fe2d5ac
Increase warnings threshold.
afercia fda28cb
Remove all changes related to themes.
afercia db00d3a
Align threshold with current trunk.
afercia 6e8a976
Build/Test Tools: Use Stylelint bulk suppressions as the CSS baseline.
lancewillett 1cf8b05
Build/Test Tools: Treat the Stylelint config files as configuration i…
lancewillett 8d60e1f
Make the class selector pattern match the current coding standards.
afercia e9c8492
Revert changes to css files.
afercia 5af9956
Upgrade sylelint and stylelint-plugin-logical-css versions.
afercia 0adeb1b
Checkout latest css changes from trunk.
afercia 016147c
Update Stylelint suppressions list.
afercia 54be2b0
Rebase and update suppressions list.
afercia 2d36ecd
Address part of CR.
afercia cf0bce5
Add lint:css:update-suppressions script.
afercia bd9c00e
Improve error message and add instructions.
afercia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Ignore WordPress plugin files. | ||
| src/wp-content/plugins/**/* | ||
|
|
||
| # Ignore WordPress theme files. | ||
| src/wp-content/themes/**/* | ||
|
|
||
| # Ignore WordPress block files. | ||
| src/wp-includes/blocks/**/* | ||
|
|
||
| # Ignore admin color schemes auto generated files. | ||
| src/wp-admin/css/colors/*/*.css | ||
|
|
||
| # Ignore WordPress included dist files. | ||
| src/wp-includes/css/dist/**/* | ||
|
|
||
| # Ignore files copied to wp-includes js. | ||
| src/wp-includes/js/**/* | ||
|
|
||
| # Ignore WordPress JS vendor files. | ||
| src/js/_enqueues/vendor/**/* | ||
|
|
||
| # Ignore minified CSS files. | ||
| **/*.min.css | ||
|
|
||
| # Ignore RTL CSS files. | ||
| **/*-rtl.css | ||
| **/*-rtl.min.css |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| /** @type {import('stylelint').Config} */ | ||
| module.exports = { | ||
| extends: '@wordpress/stylelint-config/scss-stylistic', | ||
| plugins: [ | ||
| 'stylelint-plugin-logical-css', | ||
| '@wordpress/theme/stylelint-plugins/no-token-fallback-values', | ||
| ], | ||
| reportNeedlessDisables: true, | ||
| rules: { | ||
| 'at-rule-empty-line-before': [ | ||
| 'always', | ||
| { | ||
| except: [ 'blockless-after-blockless' ], | ||
| ignore: [ 'first-nested', 'after-comment' ], | ||
| }, | ||
| ], | ||
| 'at-rule-no-unknown': null, | ||
| 'comment-empty-line-before': null, | ||
| 'declaration-property-unit-allowed-list': [ | ||
| { | ||
| 'line-height': [], | ||
| }, | ||
| ], | ||
| 'declaration-property-value-allowed-list': [ | ||
| { | ||
| 'flex-direction': '/^(?!(row|column)-reverse).*$/', | ||
| }, | ||
| { | ||
| message: ( property, value ) => | ||
| `Avoid "${ value }" value for the "${ property }" property. For accessibility reasons, visual, reading, and DOM order must match. Only use the reverse values when they do not affect reading order, meaning, and interaction.`, | ||
| }, | ||
| ], | ||
| 'font-family-no-missing-generic-family-keyword': [ | ||
| true, | ||
| { | ||
| ignoreFontFamilies: [ 'dashicons' ], | ||
| }, | ||
| ], | ||
| 'font-weight-notation': 'numeric', | ||
| 'function-disallowed-list': [ 'rgb' ], | ||
| 'no-descending-specificity': null, | ||
| 'no-invalid-position-at-import-rule': null, | ||
| 'property-disallowed-list': [ | ||
| [ 'order' ], | ||
| { | ||
| message: | ||
| 'Avoid the order property. For accessibility reasons, visual, reading, and DOM order must match. Only use the order property when it does not affect reading order, meaning, and interaction.', | ||
| }, | ||
| ], | ||
| 'rule-empty-line-before': [ | ||
| 'always', | ||
| { | ||
| except: [ 'first-nested' ], | ||
| ignore: [ 'after-comment' ], | ||
| }, | ||
| ], | ||
| 'selector-class-pattern': [ | ||
| '^([a-z][a-z0-9]*)(-[a-z0-9]+)*$', | ||
| { | ||
| message: | ||
| 'Class selector should use lowercase and separate words with hyphens', | ||
| }, | ||
| ], | ||
| 'selector-id-pattern': [ | ||
| '^([a-z][a-z0-9]*)(-[a-z0-9]+)*$', | ||
| { | ||
| message: | ||
| 'ID selector should use lowercase and separate words with hyphens', | ||
| }, | ||
| ], | ||
| 'selector-no-qualifying-type': true, | ||
| 'value-keyword-case': [ | ||
| 'lower', | ||
| { | ||
| ignoreKeywords: [ | ||
| 'currentColor', | ||
| 'optimizeLegibility', | ||
| ], | ||
| }, | ||
| ], | ||
| 'scss/at-else-empty-line-before': null, | ||
| 'scss/at-extend-no-missing-placeholder': null, | ||
| 'scss/at-if-closing-brace-newline-after': null, | ||
| 'scss/at-if-closing-brace-space-after': null, | ||
| 'scss/comment-no-empty': null, | ||
| 'scss/load-partial-extension': null, | ||
| 'scss/no-global-function-names': null, | ||
| 'scss/operator-no-newline-after': null, | ||
| 'scss/operator-no-unspaced': null, | ||
| 'scss/selector-no-redundant-nesting-selector': null, | ||
| '@stylistic/max-empty-lines': 1, | ||
| '@stylistic/max-line-length': null, | ||
| '@stylistic/selector-descendant-combinator-no-non-space': true, | ||
| // Keep these lines. Don't change their order otherwise indentation will break. | ||
| // It's not about a literal 'execution order', but rather a compatibility issue. | ||
| '@stylistic/block-closing-brace-newline-before': 'always', | ||
| '@stylistic/block-opening-brace-newline-after': 'always', | ||
| '@stylistic/declaration-block-semicolon-newline-after': 'always', | ||
| '@stylistic/selector-list-comma-space-after': 'always-single-line', | ||
| '@stylistic/selector-list-comma-newline-after': 'always', | ||
| '@stylistic/declaration-colon-newline-after': 'always-multi-line', | ||
| '@stylistic/indentation': 'tab', | ||
| // End keep these lines. | ||
| }, | ||
| reportDescriptionlessDisables: true, | ||
| }; |
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Changing the Stylelint config triggers the full
prereleasehere (PHP formatting, JS, CSS, images) whenprecommit:csswould be enough.stylelint-suppressions.jsonisn't in the list either, so editing only the suppressions file runs no lint locally.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.
Added by @lancewillett in 71bcf1a yes, worth considering adding
stylelint-suppressions.json.