From 78bb3b813e83121e79f4d4ee32826101ce955e47 Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Thu, 5 Jan 2017 11:44:55 -0800 Subject: [PATCH 1/2] Defer to phpcs.xml file if present. - Fixes #311 --- tasks/quality.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tasks/quality.js b/tasks/quality.js index ccfd2596..e0cc8034 100644 --- a/tasks/quality.js +++ b/tasks/quality.js @@ -190,11 +190,18 @@ module.exports = function(grunt) { grunt.registerTask('validate', 'Validate the quality of custom code.', function(mode) { phpcsConfig = grunt.config.get('phpcs'); var files; + if (phpcsConfig && phpcsConfig.validate) { - files = filesToProcess(phpcsConfig.validate.src); - if (files.length) { - grunt.config.set('phpcs.validate.src', files); + // Defer to phpcs.xml/phpcs.xml.dist if present. + if (grunt.file.exists('./phpcs.xml') || grunt.file.exists('./phpcs.xml.dist')) { + grunt.config.set('phpcs.validate.src', []); validate.push('phpcs:validate'); + } else { + files = filesToProcess(phpcsConfig.validate.src); + if (files.length) { + grunt.config.set('phpcs.validate.src', files); + validate.push('phpcs:validate'); + } } } eslintConfig = grunt.config.get('eslint'); From 816d3f095b4b1c04dae8be6c12d21aae8ac8df43 Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Thu, 31 Aug 2017 10:10:40 -0700 Subject: [PATCH 2/2] Warn if Gruntconfig phpcs settings are ignored. --- tasks/quality.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasks/quality.js b/tasks/quality.js index e0cc8034..2f7ff2d9 100644 --- a/tasks/quality.js +++ b/tasks/quality.js @@ -53,6 +53,10 @@ module.exports = function(grunt) { phpcsPatterns.push('!<%= config.srcPaths.drupal %>/{modules,profiles,libraries,static}/**/*.tpl.php'); var phpcsConfig = grunt.config.get('config.phpcs'); + // Warn if existing phpcs configs will be overridden. + if (phpcsConfig.path && (grunt.file.exists('./phpcs.xml') || grunt.file.exists('./phpcs.xml.dist'))) { + grunt.warn('The PHPCS configuration is being specified by phpcs.xml. Please remove the configuration settings from the Gruntconfig file as these are ignored.'); + } if (phpcsConfig) { var phpcs = phpcsConfig.dir || phpcsPatterns; var phpStandard = phpcsConfig.standard ||