mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-74511 core: Add phpcs config generator
This commit is contained in:
parent
8b359ad7a6
commit
51c376cfca
4 changed files with 54 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -54,3 +54,4 @@ moodle-plugin-ci.phar
|
||||||
/admin/tool/componentlibrary/docs
|
/admin/tool/componentlibrary/docs
|
||||||
/admin/tool/componentlibrary/hugo/site/data/my-index.json
|
/admin/tool/componentlibrary/hugo/site/data/my-index.json
|
||||||
.hugo_build.lock
|
.hugo_build.lock
|
||||||
|
.phpcs.xml
|
||||||
|
|
|
@ -21,6 +21,43 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = grunt => {
|
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)
|
* Generate ignore files (utilising thirdpartylibs.xml data)
|
||||||
*/
|
*/
|
||||||
|
@ -53,6 +90,8 @@ module.exports = grunt => {
|
||||||
'admin/tool/componentlibrary/hugo/dist/css/docs.css',
|
'admin/tool/componentlibrary/hugo/dist/css/docs.css',
|
||||||
].concat(thirdPartyPaths);
|
].concat(thirdPartyPaths);
|
||||||
grunt.file.write('.stylelintignore', stylelintIgnores.join('\n') + '\n');
|
grunt.file.write('.stylelintignore', stylelintIgnores.join('\n') + '\n');
|
||||||
|
|
||||||
|
phpcsIgnore(thirdPartyPaths);
|
||||||
};
|
};
|
||||||
|
|
||||||
grunt.registerTask('ignorefiles', 'Generate ignore files for linters', handler);
|
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": "^3.6.10",
|
||||||
"jsdoc-to-markdown": "^7.1.1",
|
"jsdoc-to-markdown": "^7.1.1",
|
||||||
"jshint": "^2.13.4",
|
"jshint": "^2.13.4",
|
||||||
|
"jstoxml": "^3.2.3",
|
||||||
"node-sass": "^7.0.1",
|
"node-sass": "^7.0.1",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
|
@ -8566,6 +8567,12 @@
|
||||||
"node": ">=0.6.0"
|
"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": {
|
"node_modules/keyv": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/keyv/-/keyv-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/keyv/-/keyv-3.0.0.tgz",
|
||||||
|
@ -20632,6 +20639,12 @@
|
||||||
"verror": "1.10.0"
|
"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": {
|
"keyv": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/keyv/-/keyv-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/keyv/-/keyv-3.0.0.tgz",
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
"jsdoc": "^3.6.10",
|
"jsdoc": "^3.6.10",
|
||||||
"jsdoc-to-markdown": "^7.1.1",
|
"jsdoc-to-markdown": "^7.1.1",
|
||||||
"jshint": "^2.13.4",
|
"jshint": "^2.13.4",
|
||||||
|
"jstoxml": "^3.2.3",
|
||||||
"node-sass": "^7.0.1",
|
"node-sass": "^7.0.1",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue