comparison env/lib/python3.7/site-packages/cwltool/jshint/jshint_wrapper.js @ 0:26e78fe6e8c4 draft

"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author shellac
date Sat, 02 May 2020 07:14:21 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:26e78fe6e8c4
1 "use strict";
2 // set a global object, in order for jshint to work
3 var global = this;
4
5 function validateJS(input) {
6 var jshintGlobalsObj = {};
7 input.globals.forEach(function (global) {
8 jshintGlobalsObj[global] = true;
9 })
10 var includewarnings;
11
12 if (input.options.includewarnings !== undefined) {
13 includewarnings = input.options.includewarnings;
14 delete input.options.includewarnings;
15 }
16
17 JSHINT(
18 input.code,
19 input.options,
20 jshintGlobalsObj
21 )
22
23 var jshintData = JSHINT.data();
24 if (jshintData.errors !== undefined) {
25 if (includewarnings !== undefined) {
26 jshintData.errors = jshintData.errors.filter(function (error) {
27 return includewarnings.indexOf(error.code) !== -1 || error.code[0] == "E";
28 })
29 }
30
31 jshintData.errors.forEach(function (error) {
32 if (error.code == "W104" || error.code == "W119") {
33 if (error.code == "W104"){
34 var jslint_suffix = " (use 'esversion: 6') or Mozilla JS extensions (use moz)."
35 }
36 else{
37 var jslint_suffix = " (use 'esversion: 6')"
38 }
39
40 error.reason = error.reason.slice(0, -jslint_suffix.length - 1) +
41 ". CWL only supports ES5.1";
42 }
43 })
44 }
45
46 return jshintData;
47 }