Skip to content

Commit

Permalink
MDL-74511 core: Add phpcs config generator
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Apr 19, 2022
1 parent ed0dacb commit b9e3bcb
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -51,3 +51,4 @@ moodle-plugin-ci.phar
.eslintignore
.stylelintignore
/jsdoc
.phpcs.xml
39 changes: 39 additions & 0 deletions .grunt/tasks/ignorefiles.js
Expand Up @@ -21,6 +21,43 @@
*/

module.exports = grunt => {

/**
* Generate the PHPCS configuration.
*
* @param {Object} thirdPartyPaths
*/
const phpcsIgnore = (thirdPartyPaths) => {
const {toXML} = require('jstoxml');

const config = {
_name: 'ruleset',
_attrs: {
name: "MoodleCore",
},
_content: [
{
rule: {
_attrs: {
ref: 'moodle',
},
},
},
],
};

thirdPartyPaths.forEach(library => {
config._content.push({
'exclude-pattern': library,
});
});

grunt.file.write('.phpcs.xml', toXML(config, {
header: true,
indent: ' ',
}) + "\n");
};

/**
* Generate ignore files (utilising thirdpartylibs.xml data)
*/
Expand Down Expand Up @@ -52,6 +89,8 @@ module.exports = grunt => {
'jsdoc/styles/*.css',
].concat(thirdPartyPaths);
grunt.file.write('.stylelintignore', stylelintIgnores.join('\n') + '\n');

phpcsIgnore(thirdPartyPaths);
};

grunt.registerTask('ignorefiles', 'Generate ignore files for linters', handler);
Expand Down
13 changes: 13 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -35,6 +35,7 @@
"jsdoc": "^3.6.10",
"jsdoc-to-markdown": "^7.1.1",
"jshint": "^2.13.4",
"jstoxml": "^3.2.3",
"node-sass": "^7.0.1",
"rollup-plugin-terser": "^7.0.2",
"semver": "7.3.5",
Expand Down

0 comments on commit b9e3bcb

Please sign in to comment.