Skip to content

Commit

Permalink
[js] Fix syntatic style violations found by eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Oct 23, 2017
1 parent 9be4f9a commit 0d0ff48
Show file tree
Hide file tree
Showing 11 changed files with 5,028 additions and 5,032 deletions.
25 changes: 11 additions & 14 deletions src/vm/js/nqp-runtime/core.js
Expand Up @@ -142,11 +142,9 @@ const strToObj = exports.strToObj = function(currentHLL, s) {
const arg = exports.arg = function(currentHLL, arg) {
if (arg instanceof NativeIntArg) {
return intToObj(currentHLL, arg.value);
}
else if (arg instanceof NativeNumArg) {
} else if (arg instanceof NativeNumArg) {
return numToObj(currentHLL, arg.value);
}
else if (arg instanceof NativeStrArg) {
} else if (arg instanceof NativeStrArg) {
return strToObj(currentHLL, arg.value);
} else {
return arg;
Expand Down Expand Up @@ -573,13 +571,13 @@ function createSourceMap(js, p6, mapping, jsFile, p6File) {
generator.addMapping({
generated: {
line: jsProps.lineAt(mapping[i+1])+1,
column: jsProps.columnAt(mapping[i+1])+1
column: jsProps.columnAt(mapping[i+1])+1,
},
original: {
line: p6Props.lineAt(mapping[i])+1,
column: p6Props.columnAt(mapping[i])+1
column: p6Props.columnAt(mapping[i])+1,
},
source: p6File
source: p6File,
});
}

Expand All @@ -588,7 +586,6 @@ function createSourceMap(js, p6, mapping, jsFile, p6File) {

class JavaScriptCompiler extends NQPObject {
eval(ctx, _NAMED, self, code) {

if (!(_NAMED !== null && _NAMED.hasOwnProperty('mapping'))) {
return fromJS(eval(nqp.arg_s(ctx, code)));
}
Expand All @@ -606,8 +603,8 @@ class JavaScriptCompiler extends NQPObject {
sourceMaps[fakeFilename] = createSourceMap(codeStr, _NAMED['p6-source'], _NAMED.mapping.array, fakeFilename, nqp.toStr(_NAMED.file, ctx));
const node = SourceNode.fromStringWithSourceMap(codeStr, sourceMaps[fakeFilename]);

//HACK
sourceMaps[fakeFilename] = new SourceMapConsumer(node.toStringWithSourceMap({file: fakeFilename}).map.toString())
// HACK
sourceMaps[fakeFilename] = new SourceMapConsumer(node.toStringWithSourceMap({file: fakeFilename}).map.toString());

const jsProps = charProps(codeStr);
const p6Props = charProps(_NAMED['p6-source']);
Expand Down Expand Up @@ -915,7 +912,7 @@ op.lcm_i = function(a, b) {

op.div_i = function(a, b) {
if (b == 0) {
throw new NQPException("Division by zero");
throw new NQPException('Division by zero');
} else {
return Math.floor(a/b);
}
Expand Down Expand Up @@ -1362,7 +1359,7 @@ op.getstrfromname = function(name) {
};

op.codepointfromname = function(name) {
let codePoint
let codePoint;

if (codePoint = ucd.nameToCodePoint(name)) {
return codePoint;
Expand All @@ -1381,7 +1378,7 @@ function formatCodePoint(codePoint) {
op.getuniname = function(codePoint) {
if (codePoint <= 0x1F || (0x7F <= codePoint && codePoint <= 0x9F)) {
return '<control-' + formatCodePoint(codePoint) + '>';
} else if ( (0xFDD0 <= codePoint && codePoint <= 0xFDEF) || (0xFFFE & codePoint) == 0xFFFE) {
} else if ( (0xFDD0 <= codePoint && codePoint <= 0xFDEF) || (0xFFFE & codePoint) == 0xFFFE) {
return '<noncharacter-' + formatCodePoint(codePoint) + '>';
} else {
return ucd.codePointToName(codePoint) || 'missing';
Expand Down Expand Up @@ -1415,7 +1412,7 @@ op.strtocodes = function(str, form, codes) {

op.codes = function(str) {
return str.normalize('NFC').length;
}
};

op.islist = function(list) {
return (list._STable && list._STable.REPR instanceof reprs.VMArray) ? 1 : 0;
Expand Down
4 changes: 2 additions & 2 deletions src/vm/js/nqp-runtime/hll.js
Expand Up @@ -85,8 +85,8 @@ exports.hllConfigs = hllConfigs;
function getHLL(language) {
if (!hllConfigs[language]) {
hllConfigs[language] = new Map;
hllConfigs[language].set('slurpy_array', BOOT.Array)
hllConfigs[language].set('list', BOOT.Array)
hllConfigs[language].set('slurpy_array', BOOT.Array);
hllConfigs[language].set('list', BOOT.Array);

// For serialization purposes
hllConfigs[language].set('name', language);
Expand Down
2 changes: 1 addition & 1 deletion src/vm/js/nqp-runtime/io.js
Expand Up @@ -428,7 +428,7 @@ op.getstdin = function() {
let fd;
try {
fd = fs.openSync('/dev/stdin', 'rs');
} catch(e) {
} catch (e) {
/* this should work on Windows, we need to test it tho */
fd = 0;
};
Expand Down
8 changes: 4 additions & 4 deletions src/vm/js/nqp-runtime/native-args.js
Expand Up @@ -8,7 +8,7 @@ class NativeIntArg {
}

$$decont() {
throw new Error("deconting native int arg");
throw new Error('deconting native int arg');
}
};

Expand All @@ -24,7 +24,7 @@ class NativeNumArg {
}

$$decont() {
throw new Error("deconting native num arg");
throw new Error('deconting native num arg');
}
};

Expand All @@ -38,9 +38,9 @@ class NativeStrArg {
$$getStr() {
return this.value;
}

$$decont() {
throw new Error("deconting native str arg");
throw new Error('deconting native str arg');
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/vm/js/nqp-runtime/nativecall.js
Expand Up @@ -39,7 +39,7 @@ op.buildnativecall = function(ctx, target, libname, symbol, convention, args, re
target.$$ret = returns.content.get('type').$$getStr();
target.$$args = args.array.map(arg => arg.content.get('type').$$getStr());
} catch (e) {
throw new NQPException("native call exception:" + e);
throw new NQPException('native call exception:' + e);
}
};

Expand All @@ -64,7 +64,7 @@ op.nativecall = function(returns, callObject, args) {
} else if (type === 'cpointer') {
mangled[i] = args.array[i].$$decont(null).$$getPointer();
} else {
throw "can't mangle: " + callObject.$$args[i];
throw 'can\'t mangle: ' + callObject.$$args[i];
}
}
const ret = callObject.$$lib[callObject.$$symbol].apply(callObject.$$lib, mangled);
Expand Down Expand Up @@ -105,7 +105,7 @@ op.nativecallsizeof = function(obj) {
if (obj._STable.REPR.nativeCallSize) {
return obj._STable.REPR.nativeCallSize();
} else {
throw new NQPException("can't do nativecallsizeof");
throw new NQPException('can\'t do nativecallsizeof');
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/vm/js/nqp-runtime/nfa.js
Expand Up @@ -25,11 +25,11 @@ const EDGE_CHARRANGE_NEG = 13;
const EDGE_CODEPOINT_LL = 14;
const EDGE_CODEPOINT_I_LL = 15;
const EDGE_CODEPOINT_M = 16;
const EDGE_CODEPOINT_M_NEG = 17;
const EDGE_CODEPOINT_M_LL = 18;
const EDGE_CODEPOINT_IM = 19;
const EDGE_CODEPOINT_M_NEG = 17;
const EDGE_CODEPOINT_M_LL = 18;
const EDGE_CODEPOINT_IM = 19;
const EDGE_CODEPOINT_IM_NEG = 20;
const EDGE_CODEPOINT_IM_LL = 21;
const EDGE_CODEPOINT_IM_LL = 21;

function convertState(thing) {
if (thing.$$toArray) {
Expand Down
2 changes: 1 addition & 1 deletion src/vm/js/nqp-runtime/nqp-exception-with-ctx.js
Expand Up @@ -3,7 +3,7 @@ class NQPExceptionWithCtx extends NQPException {
constructor(message, ctx, stack) {
super(message);
this.$$ctx = ctx;
this.$$stack = stack
this.$$stack = stack;
}

};
Expand Down
9 changes: 4 additions & 5 deletions src/vm/js/nqp-runtime/reprs.js
Expand Up @@ -391,7 +391,7 @@ class P6opaque {
if (!this.unboxSlots) this.unboxSlots = [];
this.unboxSlots.push({slot: curAttr, reprId: REPR.ID});
if (!REPR.generateBoxingMethods) {
console.log("we do not have a generateBoxingMethods");
console.log('we do not have a generateBoxingMethods');
console.log(REPR.name);
}
REPR.generateBoxingMethods(STable, slotToAttr(curAttr), attrType._STable);
Expand Down Expand Up @@ -1472,7 +1472,7 @@ reprs.P6bigint = P6bigint;

class NativeCall extends REPR {
generateBoxingMethods(STable, name) {
//TODO - figure out what if anything needs to be here
// TODO - figure out what if anything needs to be here
}
};
reprs.NativeCall = NativeCall;
Expand Down Expand Up @@ -2007,8 +2007,8 @@ class CArray extends REPR {
setupSTable(STable) {
STable.addInternalMethods(class {
$$setStr(str) {
//TODO
//console.log('CArray setting with str: ', str);
// TODO
// console.log('CArray setting with str: ', str);
}
});
}
Expand All @@ -2020,7 +2020,6 @@ class CStr extends REPR {
reprs.CStr = CArray;



var ID = 0;
for (var name in reprs) {
module.exports[name] = reprs[name];
Expand Down
4 changes: 2 additions & 2 deletions src/vm/js/nqp-runtime/runtime.js
Expand Up @@ -564,7 +564,7 @@ for (let name of Object.keys(chunkNamesToTypes)) {
}

exports.coercion = function(got, expected) {
throw new Error("Can't convert, got: " + chunkTypesToNames[got] + ' expected:' + chunkTypesToNames[expected]);
throw new Error('Can\'t convert, got: ' + chunkTypesToNames[got] + ' expected:' + chunkTypesToNames[expected]);
};

exports.charrange_i = function(char, lower, upper) {
Expand Down Expand Up @@ -595,7 +595,7 @@ exports.literal_m = function(target, pos, literal) {
return result;
};

//TODO optimize and fold in a better manner
// TODO optimize and fold in a better manner
exports.literal_im = function(target, pos, literal) {
let count = 0;
let result = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/vm/js/nqp-runtime/sixmodel.js
Expand Up @@ -217,7 +217,7 @@ class STable {
};
obj.$$clone = function(ctx) {
return this;
}
};
return obj;
}

Expand Down

0 comments on commit 0d0ff48

Please sign in to comment.