MDL-74511 core: Add phpcs config generator
This commit is contained in:
@@ -51,3 +51,4 @@ moodle-plugin-ci.phar
|
||||
.eslintignore
|
||||
.stylelintignore
|
||||
/jsdoc
|
||||
.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)
|
||||
*/
|
||||
@@ -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);
|
||||
|
||||
Generated
+13
@@ -41,6 +41,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",
|
||||
@@ -7210,6 +7211,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/kind-of": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
|
||||
@@ -17323,6 +17330,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
|
||||
},
|
||||
"kind-of": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user