-
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
41
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
41 commits
Select commit
Hold shift + click to select a range
8f469eb
First pass at adding a stylelint script.
afercia 94dce6d
Remove custom rule from gutenberg.
afercia 306b879
Clean up stylelintignore.
afercia 9f3fae0
Clean up config.
afercia 10d288f
Add Grunt task and clean up.
afercia 656a57a
Remove stylelint-config-wordpress package.
afercia 78aca49
Ignore admin color scheme auto generated files.
afercia 7507a14
Ignore files copied to wp-includes js.
afercia 5c3036a
Remove Stylelint configuration from Twenty Twenty theme.
afercia 55d3032
Remove Stylelint configuration from Twenty Twenty-One theme.
afercia 3895c8d
Remove comments.
afercia fdee94e
Add lint:css:themes script for bundled themes.
afercia d75b7e7
Build theme files.
afercia 63e533e
Use the root stylelintrc for twentytwentyone.
afercia 2386120
For twentytwentyone try adding a postcss script and run it twice.
afercia 8db42d0
Start refining rules.
afercia 139bc81
Add rules for empty lines before.
afercia 9e7acb1
Solve the indentation and leading space issues avoiding to run postcs…
afercia fa115d8
Improve comment-empty-line-before.
afercia 9632b7c
Improve comment.
afercia 390f15d
Improve selector-list-comma-space-after.
afercia 3bc303b
Refine empty libe before rule.
afercia b91eca3
Add selector-no-qualifying-type warning.
afercia a080723
Refine more rules.
afercia 95a0ce4
Improve order of rules related to indentation.
afercia 48f93d0
Reduce max-empty-lines to 1.
afercia 98377f2
Disable comment-empty-line-before.
afercia 968a159
Run stylelint directly so that it walks upwards until it finds the ro…
afercia 207efbd
Update test-and-zip-default-themes gh action.
afercia 45aac96
Add bacl @wordpress/scripts to twentytwentyone.
afercia b450b44
Add stylelint-plugin-logical-css to twentytwentyone.
afercia 3ced1b1
Update twentytwentyone styles.
afercia 011b671
Pass the glob as a quoted pattern.
afercia 3d16dc2
Add optimizeLegibility to value-keyword-case exceptions.
afercia d081421
Add @stylistic/selector-descendant-combinator-no-non-space true.
afercia d8d5cd8
Adjust a few rules.
afercia a568299
Ignore dashicons font-family.
afercia c1b5056
Apply a few minor JS coding standards to stylelintrc.js.
afercia de4c1a9
Try warnings threshold mechanism.
afercia 41140e9
Normalize the glob path for Windows on CI.
afercia 8add3f2
Increase warnings threshold.
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
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,9 @@ | ||
| # Ignore Node modules. | ||
| node_modules | ||
|
|
||
| # 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,114 @@ | ||
| /** @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 class segments separated with hyphens, double hyphens, or double underscores', | ||
| }, | ||
| ], | ||
| '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, | ||
| { | ||
| severity: 'warning', | ||
| }, | ||
| ], | ||
| '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, | ||
| ignorePath: '.stylelintignore', | ||
| }; | ||
|
|
||
|
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
This file was deleted.
Oops, something went wrong.
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.
This makes it much easier to see what the required criteria is. I'm on the fence here about whether we should actually move this to the
strategy.matrixinstead, though. It would become something like:Then the conditional check would simply be:
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.
Needs a decision on the two options for the themes first.