Skip to content
This repository was archived by the owner on Dec 24, 2020. It is now read-only.

Commit

Permalink
More eslint adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpar committed Jun 7, 2018
1 parent 29f40e7 commit 0b6a199
Show file tree
Hide file tree
Showing 41 changed files with 375 additions and 305 deletions.
5 changes: 1 addition & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-comment-style": "off",
"multiline-ternary": [
"error",
"always-multiline"
],
"multiline-ternary": "off",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
Expand Down
13 changes: 13 additions & 0 deletions modules/devices/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"globals": {
"Chip": true,
"Device": true,
"LED": true,
"Input": true,
"Machine": true,
"MACHINE": true,
"ROM": true,
"Time": true,
"VERSION": true
}
}
18 changes: 9 additions & 9 deletions modules/devices/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Device {
*/
addBinding(binding, element)
{
let device = this;
let device = this, elementTextArea;

switch (binding) {

Expand All @@ -129,7 +129,7 @@ class Device {
break;

case Device.BINDING.PRINT:
let elementTextArea = /** @type {HTMLTextAreaElement} */ (element);
elementTextArea = /** @type {HTMLTextAreaElement} */ (element);
/*
* This was added for Firefox (Safari will clear the <textarea> on a page reload, but Firefox does not).
*/
Expand Down Expand Up @@ -391,15 +391,15 @@ class Device {
let afnHandlers = this.findHandlers(Device.HANDLER.COMMAND);
if (afnHandlers) {

let i = sText.lastIndexOf('\n', sText.length - 2);
let sCommand = sText.slice(i + 1, -1) || this.sCommandPrev;
let c, i = sText.lastIndexOf('\n', sText.length - 2);
let sCommand = sText.slice(i + 1, -1) || this.sCommandPrev, sResult;
this.sCommandPrev = "";
sCommand = sCommand.trim();
let aTokens = sCommand.split(' ');

switch(aTokens[0]) {
case 'c':
let c = aTokens[1];
c = aTokens[1];
if (c) {
this.println("set category '" + c + "'");
this.setCategory(c);
Expand All @@ -413,13 +413,13 @@ class Device {
}
break;
case '?':
let sResult = "";
Device.COMMANDS.forEach(cmd => {sResult += '\n' + cmd;});
sResult = "";
Device.COMMANDS.forEach((cmd) => {sResult += '\n' + cmd;});
if (sResult) this.println("default commands:" + sResult);
/* falls through */
default:
aTokens.unshift(sCommand);
for (let i = 0; i < afnHandlers.length; i++) {
for (i = 0; i < afnHandlers.length; i++) {
if (afnHandlers[i](aTokens, this)) break;
}
break;
Expand Down Expand Up @@ -713,7 +713,7 @@ class Device {
*
* NOTE: "http://archive.pcjs.org" is now "https://s3-us-west-2.amazonaws.com/archive.pcjs.org"
*/
sURL = sURL.replace(/^(http:\/\/archive\.pcjs\.org|https:\/\/s3-us-west-2\.amazonaws\.com\/archive\.pcjs\.org)(\/.*)\/([^\/]*)$/, "$2/archive/$3");
sURL = sURL.replace(/^(http:\/\/archive\.pcjs\.org|https:\/\/s3-us-west-2\.amazonaws\.com\/archive\.pcjs\.org)(\/.*)\/([^/]*)$/, "$2/archive/$3");
}

let device = this;
Expand Down
8 changes: 4 additions & 4 deletions modules/devices/ledctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class Chip extends Device {
*/
addBinding(binding, element)
{
let chip = this;
let chip = this, elementInput, patterns;

switch(binding) {
case Chip.BINDING.COLOR_PALETTE:
Expand Down Expand Up @@ -215,7 +215,7 @@ class Chip extends Device {
break;

case Chip.BINDING.SYMBOL_INPUT:
let elementInput = /** @type {HTMLInputElement} */ (element);
elementInput = /** @type {HTMLInputElement} */ (element);
elementInput.onkeypress = function onChangeSymbol(event) {
elementInput.value = String.fromCharCode(event.charCode);
let elementPreview = chip.bindings[Chip.BINDING.SYMBOL_PREVIEW];
Expand All @@ -235,7 +235,7 @@ class Chip extends Device {
* This code allows you to bind a specific control (ie, a button) to a specific pattern;
* however, it's preferable to use the PATTERN_SELECTION binding above, and use a single list.
*/
let patterns = this.config[Chip.BINDING.PATTERN_SELECTION];
patterns = this.config[Chip.BINDING.PATTERN_SELECTION];
if (patterns && patterns[binding]) {
element.onclick = function onClickPattern() {
chip.loadPattern(binding);
Expand Down Expand Up @@ -916,7 +916,7 @@ class Chip extends Device {

case '?':
sResult = "";
Chip.COMMANDS.forEach(cmd => {sResult += '\n' + cmd;});
Chip.COMMANDS.forEach((cmd) => {sResult += '\n' + cmd;});
if (sResult) sResult = "additional commands:" + sResult;
break;

Expand Down
16 changes: 8 additions & 8 deletions modules/devices/machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
class Machine extends Device {
/**
* Machine(idMachine, sConfig)
*
*
* If sConfig contains a JSON object definition, then we parse it immediately and save the result in this.config;
* otherwise, we assume it's the URL of an JSON object definition, so we request the resource, and once it's loaded,
* we parse it.
*
*
* Sample config:
*
* {
Expand Down Expand Up @@ -130,9 +130,9 @@ class Machine extends Device {
this.chip = null;
this.sConfigFile = "";
this.fConfigLoaded = this.fPageLoaded = false;

sConfig = sConfig.trim();

if (sConfig[0] == '{') {
this.loadConfig(sConfig);
} else {
Expand All @@ -149,7 +149,7 @@ class Machine extends Device {
}
});
}

/*
* Device initialization is now deferred until after the page is fully loaded, for the benefit
* of devices (eg, Input) that may be dependent on page resources.
Expand Down Expand Up @@ -230,17 +230,17 @@ class Machine extends Device {

/**
* killDevices()
*
*
* @this {Machine}
*/
killDevices()
{
let chip;
if (chip = this.chip) {
if ((chip = this.chip)) {
if (chip.onSave) chip.onSave();
if (chip.onPower) chip.onPower(false);
}

}

/**
Expand Down
4 changes: 2 additions & 2 deletions modules/devices/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class Time extends Device {
*/
addBinding(binding, element)
{
let time = this;
let time = this, elementInput;

switch(binding) {

Expand All @@ -221,7 +221,7 @@ class Time extends Device {
break;

case Time.BINDING.THROTTLE:
let elementInput = /** @type {HTMLInputElement} */ (element);
elementInput = /** @type {HTMLInputElement} */ (element);
elementInput.addEventListener("mousedown", function onThrottleStart() {
time.fThrottling = true;
});
Expand Down
54 changes: 29 additions & 25 deletions modules/devices/tms1500.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,9 @@ class Chip extends Device {
sOperands = this.sprintf("0x%04x", v);
}
else if (opCode >= 0) {
let d, j, k, l, n;
let mask = opCode & Chip.IW_MF.MASK;
let sMask, sOperator, sDst, sSrc, sStore;

switch(mask) {
case Chip.IW_MF.MMSD: // 0x0000: Mantissa Most Significant Digit (D12)
Expand All @@ -895,15 +897,15 @@ class Chip extends Device {
case Chip.IW_MF.DIGIT: // 0x0a00: (D14-D15)
case Chip.IW_MF.D13: // 0x0d00: (D13)
case Chip.IW_MF.D15: // 0x0f00: (D15)
let sMask = this.toStringMask(mask);
let j = (opCode & Chip.IW_MF.J_MASK) >> Chip.IW_MF.J_SHIFT;
let k = (opCode & Chip.IW_MF.K_MASK) >> Chip.IW_MF.K_SHIFT;
let l = (opCode & Chip.IW_MF.L_MASK) >> Chip.IW_MF.L_SHIFT;
let n = (opCode & Chip.IW_MF.N_MASK);
sMask = this.toStringMask(mask);
j = (opCode & Chip.IW_MF.J_MASK) >> Chip.IW_MF.J_SHIFT;
k = (opCode & Chip.IW_MF.K_MASK) >> Chip.IW_MF.K_SHIFT;
l = (opCode & Chip.IW_MF.L_MASK) >> Chip.IW_MF.L_SHIFT;
n = (opCode & Chip.IW_MF.N_MASK);

sOp = "LOAD";
let sOperator = "";
let sDst = "?", sSrc = "?";
sOperator = "";
sDst = "?"; sSrc = "?";

if (!n) {
sOperator = (k == 5? "<<" : "+");
Expand Down Expand Up @@ -972,12 +974,12 @@ class Chip extends Device {
break;
}
sOperands = this.regsO[(opCode & Chip.IW_FF.J_MASK) >> Chip.IW_FF.J_SHIFT].name;
let d = ((opCode & Chip.IW_FF.D_MASK) >> Chip.IW_FF.D_SHIFT);
d = ((opCode & Chip.IW_FF.D_MASK) >> Chip.IW_FF.D_SHIFT);
sOperands += '[' + (d? (d + 12) : '?') + ':' + ((opCode & Chip.IW_FF.B_MASK) >> Chip.IW_FF.B_SHIFT) + ']';
break;

case Chip.IW_MF.PF: // 0x0e00: (used for misc operations)
let sStore = "STORE";
sStore = "STORE";
switch(opCode & Chip.IW_PF.MASK) {
case Chip.IW_PF.STYA: // 0x0000: Contents of storage register Y defined by RAB loaded into operational register A (Yn -> A)
sOp = sStore;
Expand Down Expand Up @@ -1037,7 +1039,7 @@ class Chip extends Device {
* loadState(state)
*
* If any saved values don't match (possibly overridden), abandon the given state and return false.
*
*
* @this {Chip}
* @param {Object|Array|null} state
* @returns {boolean}
Expand All @@ -1056,9 +1058,9 @@ class Chip extends Device {
return false;
}
try {
this.regsO.forEach(reg => reg.set(stateChip.shift()));
this.regsX.forEach(reg => reg.set(stateChip.shift()));
this.regsY.forEach(reg => reg.set(stateChip.shift()));
this.regsO.forEach((reg) => reg.set(stateChip.shift()));
this.regsX.forEach((reg) => reg.set(stateChip.shift()));
this.regsY.forEach((reg) => reg.set(stateChip.shift()));
this.regSupp.set(stateChip.shift());
this.regTemp.set(stateChip.shift());
this.base = stateChip.shift();
Expand Down Expand Up @@ -1101,11 +1103,12 @@ class Chip extends Device {
let nWords = Number.parseInt(aTokens[3], 10) || 8;

this.nStringFormat = Chip.SFORMAT.DEFAULT;


let c, condition;

switch(s[0]) {
case 'b':
let c = s.substr(1);
let condition;
c = s.substr(1);
if (c == 'l') {
for (c in Chip.BREAK) {
condition = Chip.BREAK[c];
Expand Down Expand Up @@ -1161,7 +1164,7 @@ class Chip extends Device {

case '?':
sResult = "additional commands:";
Chip.COMMANDS.forEach(cmd => {sResult += '\n' + cmd;});
Chip.COMMANDS.forEach((cmd) => {sResult += '\n' + cmd;});
break;

default:
Expand Down Expand Up @@ -1412,9 +1415,9 @@ class Chip extends Device {
let stateChip = state[0];
let stateROM = state[1];
stateChip.push(Chip.VERSION);
this.regsO.forEach(reg => stateChip.push(reg.get()));
this.regsX.forEach(reg => stateChip.push(reg.get()));
this.regsY.forEach(reg => stateChip.push(reg.get()));
this.regsO.forEach((reg) => stateChip.push(reg.get()));
this.regsX.forEach((reg) => stateChip.push(reg.get()));
this.regsY.forEach((reg) => stateChip.push(reg.get()));
stateChip.push(this.regSupp.get());
stateChip.push(this.regTemp.get());
stateChip.push(this.base);
Expand Down Expand Up @@ -1448,6 +1451,7 @@ class Chip extends Device {
break;
}
}

/**
* status()
*
Expand Down Expand Up @@ -1562,15 +1566,15 @@ class Chip extends Device {
let element;
let f2nd = on && (this.type == Chip.TYPE.TMS1501? !!(this.regC.digits[14] & 0x8) : !!(this.regB.digits[15] & 0x4));
if (this.f2nd !== f2nd) {
if (element = this.bindings['2nd']) {
if ((element = this.bindings['2nd'])) {
element.style.opacity = f2nd? "1" : "0";
if (this.f2nd === undefined && this.led) element.style.color = this.led.color;
}
this.f2nd = f2nd;
}
let fINV = on && (this.type == Chip.TYPE.TMS1501? !!(this.regB.digits[15] & 0x4) : !!(this.regD.digits[15] & 0x8));
if (this.fINV !== fINV) {
if (element = this.bindings['INV']) {
if ((element = this.bindings['INV'])) {
element.style.opacity = fINV? "1" : "0";
if (this.fINV === undefined && this.led) element.style.color = this.led.color;
}
Expand All @@ -1579,15 +1583,15 @@ class Chip extends Device {
let angleBits = (this.type == Chip.TYPE.TMS1501? (this.regsX[4].digits[15] >> 2) : this.regC.digits[15]);
let angleMode = on? ((!angleBits)? Chip.ANGLEMODE.DEGREES : (angleBits == 1)? Chip.ANGLEMODE.RADIANS : Chip.ANGLEMODE.GRADIENTS) : Chip.ANGLEMODE.OFF;
if (this.angleMode !== angleMode) {
if (element = this.bindings['Deg']) {
if ((element = this.bindings['Deg'])) {
element.style.opacity = (angleMode == Chip.ANGLEMODE.DEGREES)? "1" : "0";
if (this.angleMode === undefined && this.led) element.style.color = this.led.color;
}
if (element = this.bindings['Rad']) {
if ((element = this.bindings['Rad'])) {
element.style.opacity = (angleMode == Chip.ANGLEMODE.RADIANS)? "1" : "0";
if (this.angleMode === undefined && this.led) element.style.color = this.led.color;
}
if (element = this.bindings['Grad']) {
if ((element = this.bindings['Grad'])) {
element.style.opacity = (angleMode == Chip.ANGLEMODE.GRADIENTS)? "1" : "0";
if (this.angleMode === undefined && this.led) element.style.color = this.led.color;
}
Expand Down
6 changes: 6 additions & 0 deletions modules/diskdump/lib/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"globals": {
"Buffer": true,
"process": true
}
}
6 changes: 6 additions & 0 deletions modules/filedump/lib/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"globals": {
"Buffer": true,
"process": true
}
}
2 changes: 1 addition & 1 deletion modules/filedump/lib/filedump.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ FileDump.prototype.parseListing = function(sListing)
var ab = [];
var matchLine;
var re = /^( [0-9 ]{8}|)([0-7]{6})[: ]+([0-7]+)[ ]*([0-7']+|)[ ]+([0-7']+|)[ ]+(.*)$/gm;
while (matchLine = re.exec(sListing)) {
while ((matchLine = re.exec(sListing))) {
/*
* matchLine[1]: line # (optional)
* matchLine[2]: address
Expand Down
5 changes: 5 additions & 0 deletions modules/htmlout/lib/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"globals": {
"Buffer": true
}
}
Loading

0 comments on commit 0b6a199

Please sign in to comment.