Skip to content

Commit f6167b2

Browse files
committed
Add Grunt task and clean up.
1 parent 4514b51 commit f6167b2

4 files changed

Lines changed: 37 additions & 12 deletions

File tree

‎.stylelintignore‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
# Ignore WordPress plugin files
1+
# Ignore WordPress plugin files.
22
src/wp-content/plugins/**/*
33

4-
# Ignore WordPress theme files
4+
# Ignore WordPress theme files.
5+
# Note that the dependencies of some themes would require the "stylelint-a11y"
6+
# package which is not used in Core and incompatible with latest Stylelint versions.
57
src/wp-content/themes/**/*
68

7-
# Ignore WordPress block files
9+
# Ignore WordPress block files.
810
src/wp-includes/blocks/**/*
911

10-
# Ignore WordPress included dist files
12+
# Ignore WordPress included dist files.
1113
src/wp-includes/css/dist/**/*
1214

13-
# Ignore WordPress TinyMCE files
15+
# Ignore WordPress TinyMCE files.
1416
src/wp-includes/js/tinymce/**/*
1517

16-
# Ignore WordPress JS vendor files
18+
# Ignore WordPress JS vendor files.
1719
src/js/_enqueues/vendor/**/*
1820

19-
# Ignore minified CSS files
21+
# Ignore minified CSS files.
2022
**/*.min.css
2123

22-
# Ignore RTL CSS files
24+
# Ignore RTL CSS files.
2325
**/*-rtl.css
2426
**/*-rtl.min.css

‎.stylelintrc.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ module.exports = {
5151
'no-invalid-position-at-import-rule': null,
5252
},
5353
reportDescriptionlessDisables: true,
54+
// Using ignorePath instead of ignoreFiles helps avoiding configuration
55+
// dependencies issues specifically helps ignoring some themes configurations
56+
// that require the "stylelint-a11y" package.
5457
ignorePath: '.stylelintignore',
5558
};
5659

‎Gruntfile.js‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1760,8 +1760,28 @@ module.exports = function(grunt) {
17601760
'qunit:compiled'
17611761
] );
17621762

1763+
grunt.registerTask( 'lint:css', 'Runs Stylelint on core CSS.', function() {
1764+
var done = this.async();
1765+
1766+
grunt.util.spawn( {
1767+
cmd: 'npx',
1768+
args: [
1769+
'wp-scripts',
1770+
'lint-style',
1771+
SOURCE_DIR + '**/*.{css,scss}',
1772+
// By default, the Stylelint CLI looks for files to ignore in
1773+
// .stylelintignore in process.cwd(). This way, the configuration
1774+
// is consistent with the one for the NPM script in .stylelintrc.js.
1775+
],
1776+
opts: { stdio: 'inherit' }
1777+
}, function( error ) {
1778+
done( ! error );
1779+
} );
1780+
} );
1781+
17631782
grunt.registerTask( 'precommit:css', [
1764-
'postcss:core'
1783+
'postcss:core',
1784+
'lint:css',
17651785
] );
17661786

17671787
grunt.registerTask( 'precommit:php', [

‎package.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
"grunt": "grunt",
128128
"lint:jsdoc": "wp-scripts lint-js",
129129
"lint:jsdoc:fix": "wp-scripts lint-js --fix",
130+
"lint:css": "wp-scripts lint-style \"src/**/*.{css,scss}\"",
131+
"lint:css:fix": "npm run lint:css -- --fix",
130132
"typecheck:js": "tsc --build",
131133
"env:start": "node ./tools/local-env/scripts/start.js && node ./tools/local-env/scripts/docker.js run -T --rm php composer update -W",
132134
"env:stop": "node ./tools/local-env/scripts/docker.js down",
@@ -147,8 +149,6 @@
147149
"typecheck:php:baselines": "node ./tools/local-env/scripts/docker.js run --rm php composer phpstan:baselines --",
148150
"gutenberg:copy": "node tools/gutenberg/copy.js",
149151
"gutenberg:verify": "node tools/gutenberg/utils.js",
150-
"gutenberg:download": "node tools/gutenberg/download.js && grunt build:gutenberg",
151-
"lint:css": "wp-scripts lint-style \"src/**/*.{css,pcss,scss}\"",
152-
"lint:css:fix": "npm run lint:css -- --fix"
152+
"gutenberg:download": "node tools/gutenberg/download.js && grunt build:gutenberg"
153153
}
154154
}

0 commit comments

Comments
 (0)