Skip to content

Defer to phpcs.xml file if present. #312

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
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions tasks/quality.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down Expand Up @@ -190,11 +194,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');
Expand Down