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 18, 2022
1 parent 4ca5665 commit 38fff2d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ moodle-plugin-ci.phar
/admin/tool/componentlibrary/docs
/admin/tool/componentlibrary/hugo/site/data/my-index.json
.hugo_build.lock
.phpcs.xml
39 changes: 39 additions & 0 deletions .grunt/tasks/ignorefiles.js
Original file line number Diff line number Diff line change
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 @@ -53,6 +90,8 @@ module.exports = grunt => {
'admin/tool/componentlibrary/hugo/dist/css/docs.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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"jsdoc": "^3.6.10",
"jsdoc-to-markdown": "^7.1.1",
"jshint": "^2.13.4",
"jstoxml": "^3.2.3",
"node-sass": "^7.0.1",
"npm-run-all": "^4.1.5",
"rollup-plugin-terser": "^7.0.2",
Expand Down

0 comments on commit 38fff2d

Please sign in to comment.