qa-control 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/bin/definition/definition.js +27 -61
- package/bin/qa-control-run.js +2 -2
- package/bin/qa-control.js +4 -8
- package/bin/qac-init.js +4 -4
- package/package.json +27 -20
package/README.md
CHANGED
|
@@ -8,7 +8,6 @@ Quality assurance tool for node/npm projects
|
|
|
8
8
|
[](https://npmjs.org/package/qa-control)
|
|
9
9
|
[](https://github.com/codenautas/qa-control/actions/workflows/node.js.yml)
|
|
10
10
|
[](https://coveralls.io/r/codenautas/qa-control)
|
|
11
|
-
[](https://codeclimate.com/github/codenautas/qa-control)
|
|
12
11
|
[](https://snyk.io/test/github/codenautas/qa-control)
|
|
13
12
|
[](http://codenautas.com/github/codenautas/qa-control)
|
|
14
13
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var stripBom = require("strip-bom-string");
|
|
4
4
|
var semver = require("semver");
|
|
5
|
-
var jsh = require('jshint');
|
|
6
5
|
var esl = require('eslint');
|
|
7
6
|
var eslintLinter = new esl.Linter();
|
|
8
7
|
function eslintrcToFlatConfig(rc) {
|
|
@@ -10,7 +9,7 @@ function eslintrcToFlatConfig(rc) {
|
|
|
10
9
|
if (rc.rules) { flat.rules = rc.rules; }
|
|
11
10
|
var sourceType = (rc.env && rc.env.node) ? 'commonjs' : 'script';
|
|
12
11
|
flat.languageOptions = { ecmaVersion: 'latest', sourceType: sourceType };
|
|
13
|
-
flat.linterOptions = { reportUnusedDisableDirectives:
|
|
12
|
+
flat.linterOptions = { reportUnusedDisableDirectives: false };
|
|
14
13
|
return flat;
|
|
15
14
|
}
|
|
16
15
|
var multilang = require('multilang');
|
|
@@ -18,6 +17,20 @@ var fs = require('fs-promise');
|
|
|
18
17
|
var Path = require('path');
|
|
19
18
|
var yaml = require('js-yaml');
|
|
20
19
|
|
|
20
|
+
/** @param {string} realRegex */
|
|
21
|
+
function softRegExp(realRegex) {
|
|
22
|
+
var re=realRegex.replace(/\\/g, '\\\\')
|
|
23
|
+
.replace(/\s*(=+)\s*/g,'\\s*$1\\s*')
|
|
24
|
+
.replace(/ /g, '\\s+')
|
|
25
|
+
.replace(/\(/g, '\\(')
|
|
26
|
+
.replace(/\)/g, '\\)');
|
|
27
|
+
return new RegExp(re, 'im');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {object} qaControl
|
|
32
|
+
* @returns {QADefinition}
|
|
33
|
+
*/
|
|
21
34
|
module.exports = function(qaControl){
|
|
22
35
|
return {
|
|
23
36
|
fileNameMainDoc: 'LEEME.md',
|
|
@@ -53,7 +66,6 @@ module.exports = function(qaControl){
|
|
|
53
66
|
return !!packageJson['qa-control']["test-appveyor"];
|
|
54
67
|
}
|
|
55
68
|
},
|
|
56
|
-
'.jshintrc':{ presentIf: function(pj) { return pj['qa-control'] && pj['qa-control'].profile !== 'minimum'; } },
|
|
57
69
|
'.eslintrc.yml':{ presentIf: function(pj) { return pj['qa-control'] && pj['qa-control'].profile !== 'minimum'; } }
|
|
58
70
|
},
|
|
59
71
|
cucardas:{
|
|
@@ -147,14 +159,6 @@ module.exports = function(qaControl){
|
|
|
147
159
|
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/coverage.png',
|
|
148
160
|
docDescription: ''
|
|
149
161
|
},
|
|
150
|
-
climate:{
|
|
151
|
-
check: function(packageJson){
|
|
152
|
-
return packageJson['qa-control'].coverage || ! packageJson['qa-control'].purpose;
|
|
153
|
-
},
|
|
154
|
-
md:'[](https://codeclimate.com/github/xxx/yyy)',
|
|
155
|
-
imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/climate.png',
|
|
156
|
-
docDescription: ''
|
|
157
|
-
},
|
|
158
162
|
dependencies:{
|
|
159
163
|
mandatory:true,
|
|
160
164
|
md:'[](https://snyk.io/test/github/xxx/yyy)',
|
|
@@ -167,19 +171,13 @@ module.exports = function(qaControl){
|
|
|
167
171
|
docDescription: ''
|
|
168
172
|
},
|
|
169
173
|
'outdated-deps':{
|
|
170
|
-
forbidden:true
|
|
171
|
-
|
|
174
|
+
forbidden:true
|
|
175
|
+
},
|
|
176
|
+
'climate':{
|
|
177
|
+
forbidden:true
|
|
172
178
|
}
|
|
173
179
|
},
|
|
174
180
|
customs:{
|
|
175
|
-
softRegExp:function(realRegex) {
|
|
176
|
-
var re=realRegex.replace(/\\/g, '\\\\')
|
|
177
|
-
.replace(/\s*(=+)\s*/g,'\\s*$1\\s*')
|
|
178
|
-
.replace(/ /g, '\\s+')
|
|
179
|
-
.replace(/\(/g, '\\(')
|
|
180
|
-
.replace(/\)/g, '\\)');
|
|
181
|
-
return new RegExp(re, 'im');
|
|
182
|
-
},
|
|
183
181
|
funtion_eid:{
|
|
184
182
|
detect:'function eid',
|
|
185
183
|
match:'function eid(id){ return document.getElementById(id); }'
|
|
@@ -194,7 +192,6 @@ module.exports = function(qaControl){
|
|
|
194
192
|
match:"var Path = require('path');"
|
|
195
193
|
}
|
|
196
194
|
},
|
|
197
|
-
jshint_options: { "asi": false, "curly": true, "forin": true },
|
|
198
195
|
eslint_options: {
|
|
199
196
|
"env": {
|
|
200
197
|
"node": false
|
|
@@ -357,8 +354,8 @@ module.exports = function(qaControl){
|
|
|
357
354
|
/*jshint forin: false */
|
|
358
355
|
for(var nombreCucarda in cucardas) {
|
|
359
356
|
var cucarda = cucardas[nombreCucarda];
|
|
360
|
-
var cucaID = '!['+/!\[([-a-z]+)]/.exec(cucarda.md)[1]+']';
|
|
361
|
-
var cucaStr = cucarda.md.replace(/\bxxx\b/g,repo).replace(/\byyy\b/g,modulo);
|
|
357
|
+
var cucaID = cucarda.forbidden ? '!['+nombreCucarda+']' : '!['+/!\[([-a-z]+)]/.exec(cucarda.md)[1]+']';
|
|
358
|
+
var cucaStr = cucarda.md ? cucarda.md.replace(/\bxxx\b/g,repo).replace(/\byyy\b/g,modulo) : '';
|
|
362
359
|
if(cucarda.forbidden) {
|
|
363
360
|
if(readme.indexOf(cucaID) !== -1) {
|
|
364
361
|
warns.push({warning:'forbidden_cucarda_1', params:[nombreCucarda], scoring:{cucardas:1}});
|
|
@@ -404,7 +401,7 @@ module.exports = function(qaControl){
|
|
|
404
401
|
if(isMatchFunc) {
|
|
405
402
|
return str.indexOf(strOrRegexp) !== -1;
|
|
406
403
|
} else {
|
|
407
|
-
return
|
|
404
|
+
return softRegExp(strOrRegexp).test(str);
|
|
408
405
|
}
|
|
409
406
|
};
|
|
410
407
|
}
|
|
@@ -489,35 +486,6 @@ module.exports = function(qaControl){
|
|
|
489
486
|
}
|
|
490
487
|
}]
|
|
491
488
|
},
|
|
492
|
-
jshint:{
|
|
493
|
-
eclipsers:['packagejson_main_file_1_does_not_exists', 'first_lines_does_not_match_in_file_1'],
|
|
494
|
-
mandatory:false,
|
|
495
|
-
checks:[{
|
|
496
|
-
warnings:function(info){
|
|
497
|
-
if(info.packageJson['qa-control'] && info.packageJson['qa-control'].profile === 'minimum') { return []; }
|
|
498
|
-
var warns = [];
|
|
499
|
-
var jshintOpts = JSON.parse(info.files['.jshintrc'].content);
|
|
500
|
-
for(var file in info.files) {
|
|
501
|
-
if(file.match(/(.js)$/)) {
|
|
502
|
-
var content = info.files[file].content;
|
|
503
|
-
jsh.JSHINT(content, jshintOpts , false);
|
|
504
|
-
var data = jsh.JSHINT.data();
|
|
505
|
-
if(data.errors) {
|
|
506
|
-
if(qaControl.verbose){
|
|
507
|
-
console.log('JSHINT output:');
|
|
508
|
-
console.log('jshintOpts',jshintOpts);
|
|
509
|
-
console.log('There are '+data.length+ " JSHINT errors");
|
|
510
|
-
console.log(data.errors);
|
|
511
|
-
//console.log(data);
|
|
512
|
-
}
|
|
513
|
-
warns.push({warning:'jshint_warnings_in_file_1', params:[file], scoring:{jshint:1}});
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
return warns;
|
|
518
|
-
}
|
|
519
|
-
}]
|
|
520
|
-
},
|
|
521
489
|
eslint:{
|
|
522
490
|
eclipsers:['packagejson_main_file_1_does_not_exists', 'first_lines_does_not_match_in_file_1'],
|
|
523
491
|
checks:[{
|
|
@@ -528,7 +496,7 @@ module.exports = function(qaControl){
|
|
|
528
496
|
for(var file in info.files) {
|
|
529
497
|
if(file.match(/(.js)$/)) {
|
|
530
498
|
var content = info.files[file].content;
|
|
531
|
-
var data = eslintLinter.verify(content, eslintOpts);
|
|
499
|
+
var data = eslintLinter.verify(content || '', eslintOpts);
|
|
532
500
|
if(data.length) {
|
|
533
501
|
if(qaControl.verbose){
|
|
534
502
|
console.log('ESLINT output:');
|
|
@@ -582,7 +550,8 @@ module.exports = function(qaControl){
|
|
|
582
550
|
for(var file in info.files) {
|
|
583
551
|
if(file.match(/(.js)$/)) {
|
|
584
552
|
var content = info.files[file].content;
|
|
585
|
-
|
|
553
|
+
if(content === undefined) { continue; }
|
|
554
|
+
var lines = content.split(/\r?\n/);
|
|
586
555
|
var prevLine = null;
|
|
587
556
|
for(var l=0; l<lines.length; ++l) {
|
|
588
557
|
var line = lines[l];
|
|
@@ -655,9 +624,6 @@ module.exports = function(qaControl){
|
|
|
655
624
|
checks:[{
|
|
656
625
|
warnings:function(info) {
|
|
657
626
|
var warns = [];
|
|
658
|
-
if('jshintConfig' in info.packageJson) {
|
|
659
|
-
warns.push({warning:'unexpected_jshintconfig_section_in_package_json', scoring:{conventions:1}});
|
|
660
|
-
}
|
|
661
627
|
if('eslintConfig' in info.packageJson) {
|
|
662
628
|
warns.push({warning:'unexpected_eslintconfig_section_in_package_json', scoring:{conventions:1}});
|
|
663
629
|
}
|
|
@@ -669,12 +635,12 @@ module.exports = function(qaControl){
|
|
|
669
635
|
checks:[{
|
|
670
636
|
warnings:function(info) {
|
|
671
637
|
var warns = [];
|
|
672
|
-
var nonRecomended = ['best-promise', 'lodash', 'promise-plus'];
|
|
638
|
+
var nonRecomended = ['best-promise', 'eslint', 'lodash', 'promise-plus'];
|
|
673
639
|
var dependencies = info.packageJson.dependencies;
|
|
674
640
|
var devDependencies = info.packageJson.devDependencies;
|
|
675
641
|
if(dependencies) {
|
|
676
642
|
nonRecomended.forEach(function(badDep) {
|
|
677
|
-
if(badDep in dependencies || badDep in devDependencies) {
|
|
643
|
+
if(badDep in (dependencies||{}) || (devDependencies && badDep in devDependencies)) {
|
|
678
644
|
warns.push({warning:'non_recomended_dependency_1_in_package_json', params:[badDep], scoring:{dependencies:1}});
|
|
679
645
|
}
|
|
680
646
|
});
|
package/bin/qa-control-run.js
CHANGED
|
@@ -9,7 +9,7 @@ var fs = require('fs-promise');
|
|
|
9
9
|
var path = require('path');
|
|
10
10
|
|
|
11
11
|
program
|
|
12
|
-
.version(require('../package').version)
|
|
12
|
+
.version(require('../package.json').version)
|
|
13
13
|
.argument('[projectDirectory]', 'Project directory to check')
|
|
14
14
|
.usage('[[options] projectDirectory|--list-langs]')
|
|
15
15
|
.option('-l, --lang [lang]', 'Language to generate')
|
|
@@ -21,7 +21,7 @@ program
|
|
|
21
21
|
|
|
22
22
|
var opts = program.opts();
|
|
23
23
|
|
|
24
|
-
if( ( !opts.init && !opts.listLangs && (
|
|
24
|
+
if( ( !opts.init && !opts.listLangs && (program.args.length===0 && !opts.projectDir))
|
|
25
25
|
|| (opts.lang && false === opts.lang in qaControl.msgs) )
|
|
26
26
|
{
|
|
27
27
|
program.help();
|
package/bin/qa-control.js
CHANGED
|
@@ -48,10 +48,7 @@ qaControl.msgs={
|
|
|
48
48
|
repository_name_not_found: 'packageJson.repository no tiene el formato /{[-a-zA-Z0-9_.]+}\/[-a-zA-Z0-9_.]+/',
|
|
49
49
|
using_normal_promise_in_file_1: 'se han usado Promise(s) normales en "$1"',
|
|
50
50
|
packagejson_main_file_1_does_not_exists: 'no existe el archivo "main" ($1) declarado en package.json',
|
|
51
|
-
jshint_warnings_in_file_1: 'el archivo "$1" tiene warnings de JSHint',
|
|
52
51
|
eslint_warnings_in_file_1: 'el archivo "$1" tiene warnings de ESLint',
|
|
53
|
-
lack_of_jshintconfig_section_in_package_json: 'falta la sección "jshintConfig" en package.json',
|
|
54
|
-
incorrect_jshintconfig_option_1_in_package_json: 'la opcion "$1" en "jshintConfig" es incorrecta en package.json',
|
|
55
52
|
readme_multilang_not_sincronized_with_file_1: 'README.md no esta sincronizado con "$1" para multilang',
|
|
56
53
|
lack_of_repository_section_in_package_json: 'Falta la sección "repository" en package.json',
|
|
57
54
|
invalid_repository_section_in_package_json: 'La sección "repository" en package.json es inválida',
|
|
@@ -60,7 +57,6 @@ qaControl.msgs={
|
|
|
60
57
|
lack_of_files_section_in_package_json: 'Falta la sección "files" en package.json',
|
|
61
58
|
invalid_files_section_in_package_json: 'La sección "files" en package.json es inválida',
|
|
62
59
|
incorrect_ecmascript_versions_in_package_json: 'Las versiones de ECMAScript utilizadas en package.json son incorrectas',
|
|
63
|
-
unexpected_jshintconfig_section_in_package_json: 'No se esperaba la sección jshintConfig en package.json',
|
|
64
60
|
non_recomended_dependency_1_in_package_json: 'Dependencia no recomendada "$1" en package.json'
|
|
65
61
|
}
|
|
66
62
|
};
|
|
@@ -241,7 +237,7 @@ var configReading=(function(){
|
|
|
241
237
|
});
|
|
242
238
|
|
|
243
239
|
qaControl.loadProject = function loadProject(projectDir) {
|
|
244
|
-
var info = {projectDir:projectDir};
|
|
240
|
+
var info = /** @type {ProjectInfo} */ ({projectDir:projectDir});
|
|
245
241
|
var cmsgs = qaControl.cmdMsgs[qaControl.lang];
|
|
246
242
|
if(qaControl.verbose) { process.stdout.write(cmsgs.msg_starting+projectDir+"'...\n"); }
|
|
247
243
|
return Promise.resolve().then(function(){
|
|
@@ -268,7 +264,7 @@ qaControl.loadProject = function loadProject(projectDir) {
|
|
|
268
264
|
/*jshint forin: true */
|
|
269
265
|
/*eslint-enable guard-for-in */
|
|
270
266
|
if(files.indexOf('package.json') !== -1) {
|
|
271
|
-
info.packageJson = {};
|
|
267
|
+
info.packageJson = /** @type {PackageJson} */ ({});
|
|
272
268
|
}
|
|
273
269
|
return Promise.all(files.map(function(file){
|
|
274
270
|
var iFile = Path.normalize(projectDir+'/'+file);
|
|
@@ -320,7 +316,7 @@ qaControl.controlInfo=function controlInfo(info, opts){
|
|
|
320
316
|
var cmsgs = qaControl.cmdMsgs[qaControl.lang];
|
|
321
317
|
var rules = qaControl.definition.rules;
|
|
322
318
|
var silenced = ((info.packageJson || {})['qa-control'] || {}).silenced || [];
|
|
323
|
-
var cadenaDePromesas = Promise.resolve(
|
|
319
|
+
var cadenaDePromesas = Promise.resolve(/** @type {Warning[]} */ ([]));
|
|
324
320
|
info.scoring = opts && opts.scoring;
|
|
325
321
|
forEach(rules, function(rule, ruleName) {
|
|
326
322
|
rule.checks.forEach(function(checkInfo){
|
|
@@ -366,7 +362,7 @@ qaControl.stringizeWarnings = function stringizeWarnings(warns, lang) {
|
|
|
366
362
|
if(numParams) {
|
|
367
363
|
//console.log(warn.warning, msg, " tiene ", numParams.length, " parametros y params tiene ", warn.params)
|
|
368
364
|
for(var p=0; p<numParams.length; ++p) {
|
|
369
|
-
msg = msg.replace('$'+
|
|
365
|
+
msg = msg.replace('$'+(p+1), warn.params[p]);
|
|
370
366
|
}
|
|
371
367
|
}
|
|
372
368
|
if(qaControl.verbose) {
|
package/bin/qac-init.js
CHANGED
|
@@ -102,7 +102,7 @@ qacInit.ask = function ask(param, msgs, callback) {
|
|
|
102
102
|
stdin.resume();
|
|
103
103
|
var prompt = param.prompt || param.name.substring(0,1).toUpperCase()+param.name.substring(1);
|
|
104
104
|
stdout.write(prompt+def+ ": ");
|
|
105
|
-
stdin.once('data', function(data) {
|
|
105
|
+
stdin.once('data', function(/** @type {any} */ data) {
|
|
106
106
|
data = data.toString().trim();
|
|
107
107
|
if(data === '') { data = param.def; }
|
|
108
108
|
if((param.valid && param.valid(data)) || (! param.valid && data !== '')) {
|
|
@@ -254,7 +254,7 @@ qacInit.configParams = [
|
|
|
254
254
|
},
|
|
255
255
|
post: function(ctx) {
|
|
256
256
|
var contributors = ctx.input.existingJson.contributors || [];
|
|
257
|
-
var nae = this.parseNE(ctx.result[this.name]);
|
|
257
|
+
var nae = /** @type {{name: string, email: string}} */ (this.parseNE(ctx.result[this.name]));
|
|
258
258
|
contributors.push({'name':nae.name, 'email':nae.email});
|
|
259
259
|
return contributors.length ? contributors : null;
|
|
260
260
|
},
|
|
@@ -293,8 +293,8 @@ qacInit.init = function init(initParams) {
|
|
|
293
293
|
var inputParams;
|
|
294
294
|
var tplData = {
|
|
295
295
|
vars: {},
|
|
296
|
-
tpls: [],
|
|
297
|
-
other: []
|
|
296
|
+
tpls: /** @type {string[]} */ ([]),
|
|
297
|
+
other: /** @type {string[]} */ ([])
|
|
298
298
|
};
|
|
299
299
|
var packageJS;
|
|
300
300
|
return qacInit.initDefaults(initParams).then(function(initResult) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qa-control",
|
|
3
3
|
"description": "QA control of things that nobody controls",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.2",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "codenautas/qa-control",
|
|
@@ -19,25 +19,31 @@
|
|
|
19
19
|
"qa-control": "./bin/qa-control-run.js"
|
|
20
20
|
},
|
|
21
21
|
"main": "./bin/qa-control.js",
|
|
22
|
+
"overrides": {
|
|
23
|
+
"diff": ">=8.0.2",
|
|
24
|
+
"serialize-javascript": ">=7.0.0",
|
|
25
|
+
"uuid": ">=14.0.0"
|
|
26
|
+
},
|
|
22
27
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"fs-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"semver": "
|
|
31
|
-
"strip-bom-string": "
|
|
32
|
-
"best-globals": "~2.1.3",
|
|
33
|
-
"multilang": "~1.2.0"
|
|
28
|
+
"best-globals": "^2.1.4",
|
|
29
|
+
"commander": "^14.0.3",
|
|
30
|
+
"eslint": "^10.3.0",
|
|
31
|
+
"fs-extra": "^11.3.5",
|
|
32
|
+
"fs-promise": "^2.0.3",
|
|
33
|
+
"js-yaml": "^4.1.1",
|
|
34
|
+
"multilang": "^1.2.1",
|
|
35
|
+
"semver": "^7.8.0",
|
|
36
|
+
"strip-bom-string": "^1.0.0"
|
|
34
37
|
},
|
|
35
38
|
"devDependencies": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
39
|
+
"@types/mocha": "^10.0.10",
|
|
40
|
+
"@types/node": "^25.7.0",
|
|
41
|
+
"expect-called": "^0.4.0",
|
|
42
|
+
"expect.js": "^0.3.1",
|
|
43
|
+
"mocha": "^11.7.5",
|
|
44
|
+
"nyc": "^18.0.0",
|
|
45
|
+
"sinon": "^22.0.0",
|
|
46
|
+
"typescript": "^6.0.3"
|
|
41
47
|
},
|
|
42
48
|
"engines": {
|
|
43
49
|
"node": ">= 10"
|
|
@@ -45,11 +51,12 @@
|
|
|
45
51
|
"scripts": {
|
|
46
52
|
"test": "mocha --reporter spec --bail --check-leaks test/",
|
|
47
53
|
"test-nc": "mocha --reporter spec --bail --check-leaks --no-colors test/",
|
|
48
|
-
"test-ci": "
|
|
49
|
-
"test-cov": "
|
|
54
|
+
"test-ci": "nyc --reporter=lcov mocha --reporter spec --check-leaks test/",
|
|
55
|
+
"test-cov": "nyc mocha --reporter dot --check-leaks test/",
|
|
50
56
|
"start": "node example/server.js",
|
|
51
|
-
"report": "
|
|
57
|
+
"report": "nyc report",
|
|
52
58
|
"qac": "node bin/qa-control-run.js . -v",
|
|
59
|
+
"typecheck": "tsc",
|
|
53
60
|
"all": "npm test && npm run test-cov && npm run report && npm run qac"
|
|
54
61
|
},
|
|
55
62
|
"files": [
|