Add eslint and fix reported issues

This commit is contained in:
Juanjo Diaz
2018-05-24 00:25:44 +03:00
parent cfe1e44ed7
commit 8727f598c2
36 changed files with 134 additions and 108 deletions

8
utils/.eslintrc Normal file
View File

@@ -0,0 +1,8 @@
{
"env": {
"node": true
},
"rules": {
"no-console": 0
}
}

View File

@@ -13,7 +13,8 @@ var fs = require('fs');
var show_help = process.argv.length === 2;
var filename;
for (var i = 2; i < process.argv.length; ++i) {
var i;
for (i = 2; i < process.argv.length; ++i) {
switch (process.argv[i]) {
case "--help":
case "-h":
@@ -36,19 +37,19 @@ if (show_help) {
console.log("Usage: node parse.js [options] filename:");
console.log(" -h [ --help ] Produce this help message");
console.log(" filename The keysymdef.h file to parse");
return;
process.exit(0);
}
var buf = fs.readFileSync(filename);
var str = buf.toString('utf8');
var re = /^\#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-fA-F]+)\s*(\/\*\s*(.*)\s*\*\/)?\s*$/m;
var re = /^#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-fA-F]+)\s*(\/\*\s*(.*)\s*\*\/)?\s*$/m;
var arr = str.split('\n');
var codepoints = {};
for (var i = 0; i < arr.length; ++i) {
for (i = 0; i < arr.length; ++i) {
var result = re.exec(arr[i]);
if (result){
var keyname = result[1];
@@ -84,7 +85,7 @@ function toHex(num) {
s = ("0000" + s).slice(-4);
}
return "0x" + s;
};
}
for (var codepoint in codepoints) {
codepoint = parseInt(codepoint);

View File

@@ -100,7 +100,7 @@ var transform_html = function (legacy_scripts, only_legacy) {
var start_ind = contents.indexOf(start_marker) + start_marker.length;
var end_ind = contents.indexOf(end_marker, start_ind);
new_script = '';
var new_script = '';
if (only_legacy) {
// Only legacy version, so include things directly
@@ -161,11 +161,12 @@ var make_lib_files = function (import_format, source_maps, with_app_dir, only_le
}
var in_path;
var out_path_base;
if (with_app_dir) {
var out_path_base = paths.out_dir_base;
out_path_base = paths.out_dir_base;
in_path = paths.main;
} else {
var out_path_base = paths.lib_dir_base;
out_path_base = paths.lib_dir_base;
}
const legacy_path_base = only_legacy ? out_path_base : path.join(out_path_base, 'legacy');
@@ -223,7 +224,7 @@ var make_lib_files = function (import_format, source_maps, with_app_dir, only_le
return babelTransformFile(filename, opts)
.then(res => {
console.log(`Writing ${legacy_path}`);
var {code, map, ast} = res;
var {code, map} = res;
if (source_maps === true) {
// append URL for external source map
code += `\n//# sourceMappingURL=${path.basename(legacy_path)}.map\n`;

View File

@@ -1,6 +1,5 @@
// writes helpers require for vnc.html (they should output app.js)
var fs = require('fs');
var fse = require('fs-extra');
var path = require('path');
// util.promisify requires Node.js 8.x, so we have our own