diff --git a/Gruntfile.js b/Gruntfile.js index 71162f0e0eb9..06a848439f54 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -64,6 +64,10 @@ module.exports = function (grunt) { cmd: 'node', args: ['node_modules/eslint/bin/eslint', 'src/**/*.ts', '--fix'], }, + 'autoformat-out-wpt': { + cmd: 'node', + args: ['node_modules/.bin/prettier', '--write', 'out-wpt/**/*.js'], + } }, watch: { @@ -160,6 +164,7 @@ module.exports = function (grunt) { ]); grunt.registerTask('build-wpt', 'Build out/ (no checks)', [ 'run:build-out-wpt', + 'run:autoformat-out-wpt', 'run:generate-version', 'run:generate-listings', 'copy:out-wpt-generated', diff --git a/babel.config.js b/babel.config.js index bc6bedb8ba17..501fa656a3c8 100644 --- a/babel.config.js +++ b/babel.config.js @@ -13,7 +13,10 @@ module.exports = function (api) { ], ], compact: false, - retainLines: true, // Keeps code *and comments* on ~the same line as in the source + // Keeps comments from getting hoisted to the end of the previous line of code. + // (Also keeps lines close to their original line numbers - but for WPT we + // reformat with prettier anyway.) + retainLines: true, shouldPrintComment: val => !/eslint|prettier-ignore/.test(val), }; };