mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-74511 core: Add phpcs config generator
This commit is contained in:
parent
4ca5665aa0
commit
38fff2d83f
1
.gitignore
vendored
1
.gitignore
vendored
@ -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
|
||||
|
@ -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)
|
||||
*/
|
||||
@ -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);
|
||||
|
13
npm-shrinkwrap.json
generated
13
npm-shrinkwrap.json
generated
@ -43,6 +43,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",
|
||||
@ -8566,6 +8567,12 @@
|
||||
"node": ">=0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jstoxml": {
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/jstoxml/-/jstoxml-3.2.3.tgz",
|
||||
"integrity": "sha512-IxoZkdFcKm1dO4g+JcZBB7z1p/vPXEZPV3APRDd3/zcVtthg2kfTmpzKNZMl37/MrE/Uoc2p6ZnLnv3P5HVMTw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/keyv": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/keyv/-/keyv-3.0.0.tgz",
|
||||
@ -20632,6 +20639,12 @@
|
||||
"verror": "1.10.0"
|
||||
}
|
||||
},
|
||||
"jstoxml": {
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/jstoxml/-/jstoxml-3.2.3.tgz",
|
||||
"integrity": "sha512-IxoZkdFcKm1dO4g+JcZBB7z1p/vPXEZPV3APRDd3/zcVtthg2kfTmpzKNZMl37/MrE/Uoc2p6ZnLnv3P5HVMTw==",
|
||||
"dev": true
|
||||
},
|
||||
"keyv": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/keyv/-/keyv-3.0.0.tgz",
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user