qa-control 0.5.0 → 0.6.1

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.
Files changed (39) hide show
  1. package/README.md +2 -2
  2. package/bin/{0.3.0 → definition}/definition.js +688 -764
  3. package/bin/{0.3.0 → definition}/first-lines-both.txt +25 -25
  4. package/bin/definition/first-lines-client.txt +3 -0
  5. package/bin/{0.3.0 → definition}/first-lines-server-app.txt +2 -2
  6. package/bin/{0.3.0 → definition}/first-lines-server-cmd-tool.txt +2 -2
  7. package/bin/{0.3.0 → definition}/first-lines-server.txt +3 -3
  8. package/bin/definition/first-lines-web.txt +3 -0
  9. package/bin/qa-control.js +17 -42
  10. package/bin/qac-init.js +0 -18
  11. package/package.json +1 -1
  12. package/bin/0.0.1/definition.js +0 -556
  13. package/bin/0.0.1/first-lines-both.txt +0 -28
  14. package/bin/0.0.1/first-lines-client.txt +0 -6
  15. package/bin/0.0.1/first-lines-server-app.txt +0 -6
  16. package/bin/0.0.1/first-lines-server.txt +0 -6
  17. package/bin/0.0.2/definition.js +0 -577
  18. package/bin/0.0.2/first-lines-both.txt +0 -28
  19. package/bin/0.0.2/first-lines-client.txt +0 -6
  20. package/bin/0.0.2/first-lines-server-app.txt +0 -6
  21. package/bin/0.0.2/first-lines-server.txt +0 -6
  22. package/bin/0.1.3/definition.js +0 -653
  23. package/bin/0.1.3/first-lines-both.txt +0 -28
  24. package/bin/0.1.3/first-lines-client.txt +0 -6
  25. package/bin/0.1.3/first-lines-server-app.txt +0 -7
  26. package/bin/0.1.3/first-lines-server.txt +0 -7
  27. package/bin/0.1.4/definition.js +0 -706
  28. package/bin/0.1.4/first-lines-both.txt +0 -28
  29. package/bin/0.1.4/first-lines-client.txt +0 -6
  30. package/bin/0.1.4/first-lines-server-app.txt +0 -7
  31. package/bin/0.1.4/first-lines-server.txt +0 -7
  32. package/bin/0.2.0/definition.js +0 -771
  33. package/bin/0.2.0/first-lines-both.txt +0 -27
  34. package/bin/0.2.0/first-lines-client.txt +0 -5
  35. package/bin/0.2.0/first-lines-server-app.txt +0 -6
  36. package/bin/0.2.0/first-lines-server-cmd-tool.txt +0 -6
  37. package/bin/0.2.0/first-lines-server.txt +0 -6
  38. package/bin/0.3.0/first-lines-client.txt +0 -3
  39. package/bin/0.3.0/first-lines-web.txt +0 -3
@@ -1,653 +0,0 @@
1
- "use strict";
2
-
3
- var stripBom = require("strip-bom-string");
4
- var semver = require("semver");
5
- var jsh = require('jshint');
6
- var esl = require('eslint');
7
- var eslintLinter = new esl.Linter();
8
- function eslintrcToFlatConfig(rc) {
9
- var flat = {};
10
- if (rc.rules) { flat.rules = rc.rules; }
11
- var sourceType = (rc.env && rc.env.node) ? 'commonjs' : 'script';
12
- flat.languageOptions = { ecmaVersion: 'latest', sourceType: sourceType };
13
- flat.linterOptions = { reportUnusedDisableDirectives: 'off' };
14
- return flat;
15
- }
16
- var multilang = require('multilang');
17
- var fs = require('fs-promise');
18
- var Path = require('path');
19
-
20
- module.exports = function(qaControl){
21
- return {
22
- fileNameMainDoc: 'LEEME.md',
23
- sections: { // podria llamarse 'json-sections'...
24
- 'run-in': {
25
- mandatory: true,
26
- values: {
27
- server:{},
28
- both:{},
29
- client:{}
30
- }
31
- },
32
- type: {
33
- mandatory:true,
34
- values: {
35
- app: {},
36
- lib: {},
37
- "cmd-tool": {}
38
- }
39
- }
40
- },
41
- files:{
42
- 'README.md':{ mandatory:true },
43
- 'LEEME.md':{ mandatory:true },
44
- '.travis.yml':{ mandatory:true },
45
- '.gitignore':{
46
- mandatory:true,
47
- mandatoryLines:['local-*','*-local.*']
48
- },
49
- 'LICENSE':{ mandatory:true },
50
- 'appveyor.yml':{
51
- presentIf:function(packageJson){
52
- return !!packageJson['qa-control']["test-appveyor"];
53
- }
54
- }
55
- },
56
- cucardas:{
57
- 'proof-of-concept':{
58
- check: function(packageJson){
59
- return packageJson['qa-control'].purpose==='proof-of-concept';
60
- },
61
- md:'![proof-of-concept](https://img.shields.io/badge/stability-proof_of_concept-ff70c0.svg)',
62
- imgExample:'https://img.shields.io/badge/stability-designing-red.svg'
63
- },
64
- designing:{
65
- check: function(packageJson){
66
- return semver.satisfies(packageJson.version,'0.0.x') && !packageJson['qa-control'].purpose;
67
- },
68
- md:'![designing](https://img.shields.io/badge/stability-designing-red.svg)',
69
- imgExample:'https://img.shields.io/badge/stability-designing-red.svg',
70
- docDescription: 'opt. manual'
71
- },
72
- extending:{
73
- check: function(packageJson){
74
- return semver.satisfies(packageJson.version,'0.x.x') &&
75
- !semver.satisfies(packageJson.version,'0.0.x') &&
76
- !packageJson['qa-control'].purpose;
77
- },
78
- md:'![extending](https://img.shields.io/badge/stability-extending-orange.svg)',
79
- imgExample:'https://img.shields.io/badge/stability-extending-orange.svg',
80
- docDescription: 'opt. manual'
81
- },
82
- training:{
83
- check: function(packageJson){
84
- return packageJson['qa-control'].purpose==='training';
85
- },
86
- md:'![training](https://img.shields.io/badge/stability-training-ffa0c0.svg)',
87
- imgExample:'https://img.shields.io/badge/stability-training-ffa0c0.svg'
88
- },
89
- example:{
90
- check: function(packageJson){
91
- return packageJson['qa-control'].purpose==='example';
92
- },
93
- md:'![example](https://img.shields.io/badge/stability-example-a0a0f0.svg)',
94
- imgExample:'https://img.shields.io/badge/stability-example-a0a0f0.svg'
95
- },
96
- stable:{
97
- check: function(packageJson){
98
- return semver.satisfies(packageJson.version,'>=1.0.0') && !packageJson['qa-control'].purpose;
99
- },
100
- md:'![stable](https://img.shields.io/badge/stability-stable-brightgreen.svg)',
101
- imgExample:'https://img.shields.io/badge/stability-stable-brightgreen.svg'
102
- },
103
- 'npm-version':{
104
- mandatory:true,
105
- md:'[![npm-version](https://img.shields.io/npm/v/yyy.svg)](https://npmjs.org/package/yyy)',
106
- imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/npm-version.png',
107
- docDescription: ''
108
- },
109
- downloads:{
110
- mandatory:true,
111
- md:'[![downloads](https://img.shields.io/npm/dm/yyy.svg)](https://npmjs.org/package/yyy)',
112
- imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/downloads.png',
113
- docDescription: ''
114
- },
115
- build:{
116
- check: function(packageJson){
117
- return !packageJson['qa-control']['test-appveyor'];
118
- },
119
- md:'[![build](https://img.shields.io/travis/xxx/yyy/master.svg)](https://travis-ci.org/xxx/yyy)',
120
- imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/medalla-ejemplo-linux.png',
121
- docDescription: 'linux/build'
122
- },
123
- linux:{
124
- check: function(packageJson){
125
- return !!packageJson['qa-control']['test-appveyor'];
126
- },
127
- md:'[![linux](https://img.shields.io/travis/xxx/yyy/master.svg)](https://travis-ci.org/xxx/yyy)',
128
- imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/medalla-ejemplo-linux.png',
129
- hideInManual: true,
130
- },
131
- windows:{
132
- check: function(packageJson){
133
- return !!packageJson['qa-control']['test-appveyor'];
134
- },
135
- md:'[![windows](https://ci.appveyor.com/api/projects/status/github/xxx/yyy?svg=true)](https://ci.appveyor.com/project/xxx/yyy)',
136
- imgExample:'https://ci.appveyor.com/api/projects/status/github/codenautas/pg-promise-strict?svg=true',
137
- docDescription: 'casos especiales'
138
- },
139
- coverage:{
140
- check: function(packageJson){
141
- return packageJson['qa-control'].coverage;
142
- },
143
- md:'[![coverage](https://img.shields.io/coveralls/xxx/yyy/master.svg)](https://coveralls.io/r/xxx/yyy)',
144
- imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/coverage.png',
145
- docDescription: ''
146
- },
147
- climate:{
148
- check: function(packageJson){
149
- return packageJson['qa-control'].coverage || ! packageJson['qa-control'].purpose;
150
- },
151
- md:'[![climate](https://img.shields.io/codeclimate/github/xxx/yyy.svg)](https://codeclimate.com/github/xxx/yyy)',
152
- imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/climate.png',
153
- docDescription: ''
154
- },
155
- dependencies:{
156
- mandatory:true,
157
- md:'[![dependencies](https://img.shields.io/david/xxx/yyy.svg)](https://david-dm.org/xxx/yyy)',
158
- imgExample:'https://raw.githubusercontent.com/codenautas/codenautas/master/img/medalla-ejemplo-dependencies.png',
159
- docDescription: ''
160
- }
161
- },
162
- customs:{
163
- softRegExp:function(realRegex) {
164
- var re=realRegex.replace(/\\/g, '\\\\')
165
- .replace(/\s*(=+)\s*/g,'\\s*$1\\s*')
166
- .replace(/ /g, '\\s+')
167
- .replace(/\(/g, '\\(')
168
- .replace(/\)/g, '\\)');
169
- return new RegExp(re, 'im');
170
- },
171
- funtion_eid:{
172
- detect:'function eid',
173
- match:'function eid(id){ return document.getElementById(id); }'
174
- },
175
- var_winos:{
176
- // separo los siguientes dos strings en dos partes para que no salte un warning
177
- detect:'var '+'winos=',
178
- match:"var "+"winOS = Path.sep==='\\\\';"
179
- },
180
- var_path:{
181
- detect:'var path=',
182
- match:"var Path = require('path');"
183
- }
184
- },
185
- jshint_options: { "asi": false, "curly": true, "forin": true },
186
- eslint_options: {
187
- "env": {
188
- "node": false
189
- },
190
- "rules": {
191
- "strict": 0,
192
- "no-console": 1,
193
- "no-unused-vars": 1
194
- }
195
- },
196
- // Si info.scoring == true, cada regla debe agregar junto al warning, un objeto 'scoring'
197
- // con na o m�s de las siguientes propiedades:
198
- // qac: 1
199
- // mandatories: 1
200
- // cucardas:1
201
- // multilang:1
202
- // versions:1
203
- // parameters:1
204
- // format:1
205
- // customs:1
206
- // jshint:1
207
- // dependencies:1
208
- // Emilio redefinir� valores de cada score
209
- rules:{
210
- exist_package_json:{
211
- checks:[{
212
- warnings:function(info){
213
- if(!info.files['package.json']){
214
- return [{warning:'no_package_json', scoring:{mandatories:1}}];
215
- }
216
- return [];
217
- }
218
- }],
219
- shouldAbort:true
220
- },
221
- qa_control_section_in_package_json:{
222
- checks:[{
223
- warnings:function(info){
224
- if(!info.packageJson['qa-control']){
225
- return [{warning:info.files['package.json'].content.match(/codenautas/)?
226
- 'no_qa_control_section_in_codenautas_project':
227
- 'no_qa_control_section_in_package_json', scoring:{qac:1}}];
228
- }
229
- return [];
230
- }
231
- }],
232
- shouldAbort:true
233
- },
234
- package_version_in_qa_control_section:{
235
- checks:[{
236
- warnings:function(info){
237
- if(!info.packageJson['qa-control']['package-version']){
238
- return [{warning:'no_package_version_in_qa_control_section', scoring:{qac:1}}];
239
- } else {
240
- // defino la version para para siguientes checks
241
- info.packageVersion = info.packageJson['qa-control']['package-version'];
242
- }
243
- return [];
244
- }
245
- }],
246
- shouldAbort:true
247
- },
248
- invalid_qa_control_version: {
249
- checks:[{
250
- warnings:function(info){
251
- var ver=info.packageVersion;
252
- if(! semver.valid(ver)){
253
- return [{warning:'invalid_qa_control_version',params:[ver], scoring:{versions:1}}];
254
- }
255
- return [];
256
- }
257
- }],
258
- shouldAbort:true
259
- },
260
- deprecated_control_version: {
261
- checks:[{
262
- warnings:function(info) {
263
- var ver=info.packageVersion;
264
- if(semver.satisfies(ver, qaControl.deprecatedVersions)){
265
- return [{warning:'deprecated_qa_control_version',params:[ver], scoring:{versions:1}}];
266
- }
267
- return [];
268
- }
269
- }],
270
- shouldAbort:true
271
- },
272
- mandatory_files:{
273
- checks:[{
274
- warnings:function(info) {
275
- var warns =[];
276
- var files=qaControl.projectDefinition[info.packageVersion].files;
277
- for(var fileName in files) {
278
- if(files.hasOwnProperty(fileName)) {
279
- var file = files[fileName];
280
- if(file.mandatory && !info.files[fileName]) {
281
- warns.push({warning:'lack_of_mandatory_file_1', params:[fileName], scoring:{mandatories:1}});
282
- } else {
283
- if(file.presentIf && file.presentIf(info.packageJson) && !info.files[fileName]) {
284
- warns.push({warning:'lack_of_mandatory_file_1', params:[fileName], scoring:{mandatories:1}});
285
- }
286
- }
287
- }
288
- }
289
- return warns;
290
- }
291
- }],
292
- shouldAbort:true
293
- },
294
- repository_in_package_json:{
295
- checks:[{
296
- warnings:function(info) {
297
- var warns = [];
298
- if(!('repository' in info.packageJson)) {
299
- warns.push({warning:'lack_of_repository_section_in_package_json', scoring:{mandatories:1}});
300
- } else {
301
- if(! qaControl.getRepositoryUrl(info.packageJson).match(/^([-a-zA-Z0-9_.]+\/[-a-zA-Z0-9_.]+)$/)){
302
- return [{warning:'repository_name_not_found', scoring:{mandatories:1}}];
303
- }
304
- }
305
- return warns;
306
- }
307
- }],
308
- shouldAbort:true
309
- },
310
- valid_values_for_qa_control_keys:{
311
- checks:[{
312
- warnings:function(info){
313
- var warns=[];
314
- var qaControlSection=info.packageJson['qa-control'];
315
- var sections=qaControl.projectDefinition[info.packageVersion].sections;
316
- /*jshint forin: false */
317
- for(var sectionName in sections){
318
- var sectionDef=sections[sectionName];
319
- if(sectionDef.mandatory && !(sectionName in qaControlSection)){
320
- warns.push({warning:'lack_of_mandatory_section_1',params:[sectionName], scoring:{mandatories:1}});
321
- }else{
322
- var observedValue=qaControlSection[sectionName];
323
- if(sectionDef.values && !(observedValue in sectionDef.values)){
324
- warns.push({warning:'invalid_value_1_in_parameter_2',params:[observedValue,sectionName], scoring:{parameters:1}});
325
- }
326
- }
327
- }
328
- /*jshint forin: true */
329
- return warns;
330
- }
331
- }],
332
- shouldAbort:true
333
- },
334
- mandatory_lines:{
335
- checks:[{
336
- warnings:function(info) {
337
- var warns =[];
338
- var files=qaControl.projectDefinition[info.packageVersion].files;
339
- for(var fileName in files) {
340
- var file=files[fileName];
341
- if(file.mandatoryLines) {
342
- var fileContent = info.files[fileName].content;
343
- file.mandatoryLines.forEach(function(mandatoryLine) {
344
- // agrego '\n' antes para no utilizar expresiones regulares
345
- if(fileContent.indexOf('\n'+mandatoryLine)===-1) {
346
- warns.push({warning:'lack_of_mandatory_line_1_in_file_2',
347
- params:[mandatoryLine, fileName],
348
- scoring:{mandatories:1}});
349
- }
350
- });
351
- }
352
- };
353
- return warns;
354
- }
355
- }]
356
- }, // agregar desde ac�
357
- no_test_in_node_four:{
358
- checks:[{
359
- warnings:function(info){
360
- if(info.dotTravis && info.dotTravis.node_js.filter(function(x){ return x[0].match(/[45678]/); }).length<2){
361
- console.log('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
362
- console.log('length',info.dotTravis.node_js.filter(function(x){
363
- console.log('x',x,x[0],x[0].match(/[45678]/));
364
- return x[0].match(/[45678]/);
365
- }).length);
366
- return [{warning:'no_test_in_node_four', scoring:{versions:1}}];
367
- }
368
- return [];
369
- }
370
- }],
371
- },
372
- no_multilang_section_in_1:{
373
- checks:[{
374
- warnings:function(info){
375
- if(!info.files[qaControl.mainDoc()].content.match(/<!--multilang v[0-9]+\s+(.+)(-->)/)) {
376
- return [{
377
- warning:'no_multilang_section_in_1',
378
- params:[qaControl.mainDoc()],
379
- scoring:{multilang:1}
380
- }];
381
- }
382
- return [];
383
- }
384
- }]
385
- },
386
- invalid_repository_in_package_json:{
387
- checks:[{
388
- warnings:function(info) {
389
- var warns = [];
390
- var repoParts = qaControl.getRepositoryUrl(info.packageJson).split('/');
391
- var projName = repoParts[repoParts.length-1];
392
- if(projName !== info.packageJson.name) {
393
- return [{warning:'invalid_repository_section_in_package_json', scoring:{format:1}}];
394
- }
395
- return warns;
396
- }
397
- }]
398
- },
399
- cucardas:{
400
- eclipsers:['invalid_repository_section_in_package_json', 'lack_of_repository_section_in_package_json'],
401
- checks:[{
402
- warnings:function(info){
403
- var warns=[];
404
- var readme=info.files[qaControl.mainDoc()].content;
405
- if(readme.indexOf(qaControl.cucaMarker) === -1) {
406
- warns.push({warning:'lack_of_cucarda_marker_in_readme'});
407
- }
408
- var cucardas=qaControl.projectDefinition[info.packageVersion].cucardas;
409
- var modulo=info.packageJson.name;
410
- var repo=qaControl.getRepositoryUrl(info.packageJson).replace('/'+modulo,'');
411
- /*jshint forin: false */
412
- for(var nombreCucarda in cucardas) {
413
- var cucarda = cucardas[nombreCucarda];
414
- var cucaID = '!['+/!\[([-a-z]+)]/.exec(cucarda.md)[1]+']';
415
- var cucaStr = cucarda.md.replace(/\bxxx\b/g,repo).replace(/\byyy\b/g,modulo);
416
- if(readme.indexOf(cucaID) === -1) {
417
- if(cucarda.mandatory) {
418
- warns.push({warning:'lack_of_mandatory_cucarda_1', params:[nombreCucarda], scoring:{cucardas:1}});
419
- }
420
- } else {
421
- if('check' in cucarda && ! cucarda.check(info.packageJson)) {
422
- warns.push({warning:'wrong_format_in_cucarda_1', params:[nombreCucarda], scoring:{cucardas:1}});
423
- }
424
- if(readme.indexOf(cucaStr) === -1) {
425
- // si tengo cucarda mal formada, devuelvo warning aunque no sea obligatoria
426
- // porque existi� la intenci�n de definirla
427
- warns.push({warning:'wrong_format_in_cucarda_1', params:[nombreCucarda], scoring:{cucardas:1}});
428
- }
429
- }
430
- }
431
- /*jshint forin: true */
432
- if(warns.length || qaControl.cucardas_always) {
433
- fs.writeFile(Path.normalize(info.projectDir+'/cucardas.log'), qaControl.generateCucardas(cucardas, info.packageJson));
434
- }
435
- return warns;
436
- }
437
- }]
438
- },
439
- customs:{
440
- checks:[{
441
- warnings:function(info) {
442
- var warns=[];
443
- var customs = qaControl.projectDefinition[info.packageVersion].customs;
444
- function makeCheck(strOrRegexp, isMatchFunc) {
445
- var checker;
446
- if(!strOrRegexp){
447
- checker=function() { return false; };
448
- }else if(strOrRegexp instanceof RegExp) {
449
- checker=function(str) {
450
- return strOrRegexp.test(str);
451
- };
452
- } else {
453
- checker=function(str) {
454
- if(isMatchFunc) {
455
- return str.indexOf(strOrRegexp) !== -1;
456
- } else {
457
- return customs.softRegExp(strOrRegexp).test(str);
458
- }
459
- };
460
- }
461
- return checker;
462
- }
463
- for(var file in info.files) {
464
- if(file.match(/(.js)$/)) {
465
- for(var customeName in customs) {
466
- if(customs.hasOwnProperty(customeName)) {
467
- var content = info.files[file].content;
468
- var custom = customs[customeName];
469
- var detect = makeCheck(custom.detect);
470
- var match = makeCheck(custom.match, true);
471
- //console.log(file, " detect:", detect(content), " match: ", match(content))
472
- if(detect(content) && ! match(content)) {
473
- warns.push({warning:'file_1_does_not_match_custom_2', params:[file,customeName], scoring:{customs:1}});
474
- }
475
- }
476
- }
477
- }
478
- }
479
- return warns;
480
- }
481
- }]
482
- },
483
- first_lines:{
484
- checks:[{
485
- warnings:function(info) {
486
- var warns=[];
487
- var qaControlSection=info.packageJson['qa-control'];
488
- var whichRunIn=qaControlSection['run-in'];
489
- var whichType=qaControlSection.type;
490
- var firstLines=qaControl.projectDefinition[info.packageVersion].firstLines[whichRunIn][whichType];
491
- if(firstLines) {
492
- var ProjectName = qaControl.jsProjectName(info.packageJson.name);
493
- var projectName = qaControl.first("toLowerCase")(ProjectName);
494
- var mainName = ('main' in info.packageJson) ? info.packageJson.main : 'index.js';
495
- if(!(mainName in info.files)) {
496
- warns.push({warning:'packagejson_main_file_1_does_not_exists', params:[mainName], scoring:{customs:1}});
497
- } else {
498
- var fileContent = stripBom(info.files[mainName].content);
499
-
500
- if(!qaControl.startsWith(fileContent, firstLines.replace(/nombreDelModulo/g, ProjectName)) &&
501
- !qaControl.startsWith(fileContent, firstLines.replace(/nombreDelModulo/g, projectName))
502
- ) {
503
- if(qaControl.verbose){
504
- var code=qaControl.fixEOL(fileContent);
505
- var model1=qaControl.fixEOL(firstLines.replace(/nombreDelModulo/g, projectName));
506
- var model2=qaControl.fixEOL(firstLines.replace(/nombreDelModulo/g, ProjectName));
507
- for(var i=0; i<model1.length; i++){
508
- if(code[i]!== model1[i] && code[i] !== model2[i]){
509
- console.log('RUN-IN', whichRunIn);
510
- console.log('DIF STARTS IN:',JSON.stringify(code.substring(i, Math.min(model1.length, i+20))));
511
- console.log('MODEL 1 :',JSON.stringify(model1.substring(i, Math.min(model1.length, i+20))));
512
- console.log('MODEL 2 :',JSON.stringify(model2.substring(i, Math.min(model1.length, i+20))));
513
- break;
514
- }
515
- }
516
- }
517
- warns.push({warning:'first_lines_does_not_match_in_file_1', params:[mainName], scoring:{warning:1}});
518
- }
519
- }
520
- }
521
- return warns;
522
- }
523
- }]
524
- },
525
- normal_promises:{
526
- checks:[{
527
- warnings:function(info){
528
- var warns = [];
529
- for(var file in info.files) {
530
- if(file.match(/(.js)$/)) {
531
- var content = info.files[file].content;
532
- if(content.match(/require\(["'](promise|q|rsvp|es6promise)['"]\)/m)) {
533
- warns.push({warning:'using_normal_promise_in_file_1', params:[file], scoring:{customs:1}});
534
- }
535
- }
536
- }
537
- return warns;
538
- }
539
- }]
540
- },
541
- jshint_config:{
542
- checks:[{
543
- warnings:function(info){
544
- return qaControl.checkLintConfig(info,
545
- 'jshintConfig',
546
- 'lack_of_jshintconfig_section_in_package_json',
547
- qaControl.projectDefinition[info.packageVersion].jshint_options,
548
- 'incorrect_jshintconfig_option_1_in_package_json',
549
- {jshint:1});
550
- }
551
- }]
552
- },
553
- eslint_config:{
554
- checks:[{
555
- warnings:function(info){
556
- return qaControl.checkLintConfig(info,
557
- 'eslintConfig',
558
- 'lack_of_eslintconfig_section_in_package_json',
559
- qaControl.projectDefinition[info.packageVersion].eslint_options,
560
- 'incorrect_eslintconfig_option_1_in_package_json',
561
- {eslint:1});
562
- }
563
- }]
564
- },
565
- jshint:{
566
- eclipsers:['packagejson_main_file_1_does_not_exists', 'first_lines_does_not_match_in_file_1',
567
- 'lack_of_jshintconfig_section_in_package_json', 'incorrect_jshintconfig_option_1_in_package_json'],
568
- checks:[{
569
- warnings:function(info){
570
- var warns = [];
571
- var jshintOpts =
572
- info.packageJson.jshintConfig ||
573
- qaControl.projectDefinition[info.packageVersion].jshint_options;
574
- for(var file in info.files) {
575
- if(file.match(/(.js)$/)) {
576
- var content = info.files[file].content;
577
- jsh.JSHINT(content, jshintOpts , false);
578
- var data = jsh.JSHINT.data();
579
- if(data.errors) {
580
- if(qaControl.verbose){
581
- console.log('JSHINT output:');
582
- console.log('jshintOpts',jshintOpts);
583
- console.log(data.errors.length, " JSHINT errors");
584
- console.log(data.errors);
585
- //console.log(data);
586
- }
587
- warns.push({warning:'jshint_warnings_in_file_1', params:[file], scoring:{jshint:1}});
588
- }
589
- }
590
- }
591
- return warns;
592
- }
593
- }]
594
- },
595
- eslint:{
596
- eclipsers:['packagejson_main_file_1_does_not_exists', 'first_lines_does_not_match_in_file_1',
597
- 'lack_of_eslintconfig_section_in_package_json', 'incorrect_eslintconfig_option_1_in_package_json'],
598
- checks:[{
599
- warnings:function(info){
600
- var warns = [];
601
- var eslintOpts = eslintrcToFlatConfig(
602
- info.packageJson.eslintConfig ||
603
- qaControl.projectDefinition[info.packageVersion].eslint_options);
604
- for(var file in info.files) {
605
- if(file.match(/(.js)$/)) {
606
- var content = info.files[file].content;
607
- var data = eslintLinter.verify(content, eslintOpts);
608
- if(data.length) {
609
- if(qaControl.verbose){
610
- console.log('ESLINT output:');
611
- console.log('eslintOpts',eslintOpts);
612
- console.log(data.length, " ESLINT errors");
613
- console.log(data);
614
- //console.log(data);
615
- }
616
- warns.push({warning:'eslint_warnings_in_file_1', params:[file], scoring:{eslint:1}});
617
- }
618
- }
619
- }
620
- return warns;
621
- }
622
- }]
623
- },
624
- multilang:{
625
- checks:[{
626
- warnings:function(info) {
627
- var warns = [];
628
- var defReadme = qaControl.mainDoc();
629
- var content = info.files[defReadme].content;
630
- var obtainedLangs = multilang.obtainLangs(content);
631
- /*jshint forin: false */
632
- for(var lang in obtainedLangs.langs) {
633
- var file=obtainedLangs.langs[lang].fileName;
634
- if(file !== defReadme) {
635
- var mlContent = multilang.changeNamedDoc(file, content, lang);
636
- if(mlContent !== info.files[file].content) {
637
- warns.push({warning:'readme_multilang_not_sincronized_with_file_1', params:[file], scoring:{multilang:1}});
638
- }
639
- }
640
- }
641
- /*jshint forin: true */
642
- return warns;
643
- }
644
- }]
645
- },
646
- dependencies:{
647
- checks:[{
648
- warnings:qaControl.checkDepVerNumberFormat
649
- }]
650
- }
651
- }
652
- };
653
- };