-
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
40
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
40 commits
Select commit
Hold shift + click to select a range
35146be
First pass at adding a stylelint script.
afercia d2fa17d
Remove custom rule from gutenberg.
afercia 704305a
Clean up stylelintignore.
afercia 251dd0a
Clean up config.
afercia 11bd404
Add Grunt task and clean up.
afercia 24f2669
Remove stylelint-config-wordpress package.
afercia fb44727
Ignore admin color scheme auto generated files.
afercia dfe5b0e
Ignore files copied to wp-includes js.
afercia e39de71
Remove Stylelint configuration from Twenty Twenty theme.
afercia 437b0b9
Remove Stylelint configuration from Twenty Twenty-One theme.
afercia 40ab971
Remove comments.
afercia db6dfaa
Add lint:css:themes script for bundled themes.
afercia 09c0547
Build theme files.
afercia 6c712cd
Use the root stylelintrc for twentytwentyone.
afercia ffc503e
For twentytwentyone try adding a postcss script and run it twice.
afercia d148742
Start refining rules.
afercia 8a88427
Add rules for empty lines before.
afercia 5906c5c
Solve the indentation and leading space issues avoiding to run postcs…
afercia 0eebbe2
Improve comment-empty-line-before.
afercia 12e1e8e
Improve comment.
afercia e315b8a
Improve selector-list-comma-space-after.
afercia c4809ac
Refine empty libe before rule.
afercia 0daf3e1
Add selector-no-qualifying-type warning.
afercia 917b159
Refine more rules.
afercia dd9d1e1
Improve order of rules related to indentation.
afercia a01ad9e
Reduce max-empty-lines to 1.
afercia ca18681
Disable comment-empty-line-before.
afercia 6497ef9
Run stylelint directly so that it walks upwards until it finds the ro…
afercia a552ad5
Update test-and-zip-default-themes gh action.
afercia df7be8b
Add bacl @wordpress/scripts to twentytwentyone.
afercia a1337a2
Add stylelint-plugin-logical-css to twentytwentyone.
afercia 9db72a4
Update twentytwentyone styles.
afercia b99aee8
Pass the glob as a quoted pattern.
afercia 6154cf0
Add optimizeLegibility to value-keyword-case exceptions.
afercia e98eb18
Add @stylistic/selector-descendant-combinator-no-non-space true.
afercia 4e93f5a
Adjust a few rules.
afercia 16ca9f9
Ignore dashicons font-family.
afercia e1acdf9
Apply a few minor JS coding standards to stylelintrc.js.
afercia 894ade1
Try warnings threshold mechanism.
afercia 7ca37e0
Normalize the glob path for Windows on CI.
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.