Fix auto-fixable lint errors in modern (#840)

This commit is contained in:
Jordan Eldredge 2019-08-05 23:41:10 -07:00
parent 44066d32db
commit d9a911f46b
10 changed files with 34 additions and 8 deletions

View file

@ -130,7 +130,7 @@ function Debugger({ maki }) {
React.useEffect(() => {
run({ runtime, data: maki, system, debugHandler: setGen });
}, []);
}, [maki, system]);
const nextValue = React.useCallback(
value => {
@ -160,12 +160,12 @@ function Debugger({ maki }) {
// When we unpause, we should resume
React.useEffect(() => {
if (!paused) next();
}, [paused]);
}, [next, paused]);
// When we get a new generator, immediatly take the first step.
React.useEffect(() => {
next();
}, [gen]);
}, [gen, next]);
React.useEffect(() => {
function handler(e) {

View file

@ -20,7 +20,7 @@ import Status from "./runtime/Status";
async function loadImage(imgUrl) {
return await new Promise(resolve => {
const img = new Image();
img.addEventListener("load", function() {
img.addEventListener("load", () => {
resolve(img);
});
img.src = imgUrl;

View file

@ -80,7 +80,7 @@ class MakiFile {
let ret = "";
const end = Math.min(this._arr.length, this._i + length);
for (var i = this._i; i < end; ++i) {
for (let i = this._i; i < end; ++i) {
ret += String.fromCharCode(this._arr[i]);
}
this._i += length;

View file

@ -11,6 +11,7 @@ class Container extends GuiObject {
getclassname() {
return "Container";
}
getlayout(id) {
return findDescendantByTypeAndId(this, "layout", id);
}

View file

@ -10,6 +10,7 @@ class Group extends GuiObject {
getclassname() {
return "Group";
}
getobject(id) {
// Not sure this is correct, but it is my understanding this is just an alias
return this.findobject(id);

View file

@ -7,6 +7,7 @@ class GuiObject extends MakiObject {
this.visible = true;
}
/**
* getclassname()
*
@ -16,22 +17,27 @@ class GuiObject extends MakiObject {
getclassname() {
return "GuiObject";
}
findobject(id) {
return findDescendantByTypeAndId(this, null, id);
}
getobject(id) {
// Not sure this is correct, but it is my understanding this is just an alias
return this.findobject(id);
}
init(newRoot) {
this.parent = newRoot;
newRoot.js_addChild(this);
return this;
}
setxmlparam(param, value) {
this.xmlNode.attributes[param] = value;
return value;
}
getxmlparam(param) {
const attributes = this.xmlNode.attributes;
if (attributes !== undefined && attributes.hasOwnProperty(param)) {
@ -39,6 +45,7 @@ class GuiObject extends MakiObject {
}
return null;
}
getparent() {
return this.parent;
}

View file

@ -11,6 +11,7 @@ class Layout extends GuiObject {
getclassname() {
return "Layout";
}
getcontainer() {
return findParentNodeOfType(this, ["container"]);
}

View file

@ -11,15 +11,19 @@ class PopupMenu extends GuiObject {
getclassname() {
return "PopupMenu";
}
addcommand(txt, id, checked, disabled) {
unimplementedWarning("addcommand");
}
addseparator() {
unimplementedWarning("addseparator");
}
checkcommand(id, check) {
unimplementedWarning("checkcommand");
}
popatmouse() {
unimplementedWarning("popatmouse");
}

View file

@ -30,49 +30,62 @@ class System extends MakiObject {
getscriptgroup() {
return this.scriptGroup;
}
getcontainer(id) {
return findDescendantByTypeAndId(this.root, "container", id);
}
getruntimeversion() {
return "5.666";
}
gettoken(str, separator, tokennum) {
unimplementedWarning("gettoken");
return "Some Token String";
}
getparam() {
unimplementedWarning("getparam");
return "Some String";
}
messagebox(message, msgtitle, flag, notanymoreId) {
console.log({ message, msgtitle, flag, notanymoreId });
}
integertostring(value) {
return value.toString();
}
getprivateint(section, item, defvalue) {
unimplementedWarning("getprivateint");
return defvalue;
}
setprivateint(section, item, defvalue) {
unimplementedWarning("setprivateint");
}
getleftvumeter() {
unimplementedWarning("getleftvumeter");
return 0.5;
}
getrightvumeter() {
unimplementedWarning("getrightvumeter");
return 0.5;
}
getvolume() {
unimplementedWarning("getvolume");
return 1;
}
getplayitemlength() {
unimplementedWarning("getplayitemlength");
return 100000;
}
seekto(pos) {
unimplementedWarning("seekto");
}

View file

@ -45,9 +45,8 @@ export async function asyncFlatMap(arr, mapper) {
const childPromises = mapped.map(async item => {
if (Array.isArray(item)) {
return await asyncFlatMap(item, mapper);
} else {
return item;
}
return item;
});
return flatten(await Promise.all(childPromises));
}
@ -152,7 +151,7 @@ function findDirectDescendantById(node, id) {
function findInLexicalScope(node, pred) {
let currentNode = node;
while (currentNode.parent) {
let parent = currentNode.parent;
const parent = currentNode.parent;
const children = parent.children;
for (let i = 0; i < children.length; i++) {
const child = children[i];