Skip to content

Commit

Permalink
eslint v9 fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengarrett committed May 30, 2024
1 parent cf3a48a commit 328e6d8
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 180 deletions.
133 changes: 0 additions & 133 deletions .eslintrc.js

This file was deleted.

29 changes: 17 additions & 12 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ export default [
},
globals: {
...globals.browser,
DOSee: "readonly", // browser is for firefox only
chrome: "readonly",
BrowserFS: "readonly",
DOSee: "readonly",
DoseeLoader: "readonly",
Emulator: "readonly",
FileSaver: "readonly",
FS: "writable",
Module: "writable",
},
},
linterOptions: {
Expand Down Expand Up @@ -63,16 +68,16 @@ export default [
"no-nested-ternary": "warn",
"no-negated-condition": "warn",
"no-multi-assign": "warn",
// "no-magic-numbers": [
// "warn",
// {
// ignore: [-1, 0, 1, 2],
// ignoreArrayIndexes: true,
// ignoreDefaultValues: true,
// ignoreClassFieldInitialValues: true,
// enforceConst: true,
// },
// ],
"no-magic-numbers": [
"warn",
{
ignore: [-1, 0, 1, 2],
ignoreArrayIndexes: true,
ignoreDefaultValues: true,
ignoreClassFieldInitialValues: true,
enforceConst: true,
},
],
"no-loop-func": "warn",
"no-lonely-if": "warn",
"no-implied-eval": "warn",
Expand Down
20 changes: 11 additions & 9 deletions src/js/dosee-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
// Resize the DOSee canvas
DOSee.canvasResize = (
width = DOSee.gfx.mode13h.width,
height = DOSee.gfx.mode13h.height
height = DOSee.gfx.mode13h.height,
) => {
console.log(`Resizing DOSee canvas to ${width}*${height}px`);
return window._emscripten_set_element_css_size(
document.getElementById(`doseeCanvas`),
parseInt(width),
parseInt(height)
parseInt(height),
);
};

Expand All @@ -51,7 +51,7 @@
keyCode: 17,
location: 1,
witch: 17,
})
}),
);
body.dispatchEvent(
new KeyboardEvent(`keydown`, {
Expand All @@ -63,7 +63,7 @@
keyCode: 120,
location: 0,
witch: 120,
})
}),
);
const e = document.getElementById(`doseeExit`);
if (e !== null) e.classList.add(`hide-true`);
Expand Down Expand Up @@ -131,8 +131,9 @@
DOSee.screenCapture = function () {
const blobSupport = () => {
try {
if (typeof Boolean(new Blob()) === `undefined`) return false;
} catch (err) {
const exists = typeof Boolean(new Blob()) === `undefined`;
if (exists) return false;
} catch {
return false;
}
return true;
Expand Down Expand Up @@ -168,7 +169,7 @@
storage.setItem(x, `test data`);
storage.removeItem(x);
return true;
} catch (err) {
} catch {
return false;
}
};
Expand Down Expand Up @@ -224,7 +225,7 @@
(element) => {
localStorage.setItem(`doseeScaler`, element.target.value);
},
0
0,
);
});
};
Expand All @@ -248,7 +249,8 @@

// Screen capture button
try {
if (typeof Boolean(new Blob()) !== `undefined`) {
const exists = typeof Boolean(new Blob()) !== `undefined`;
if (exists) {
const button = document.getElementById(`doseeCaptureScreen`);
if (button !== null)
button.addEventListener(`click`, DOSee.screenCapture);
Expand Down
34 changes: 17 additions & 17 deletions src/js/dosee-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
const urlParams = DOSee.newQueryString();
// Gravis UltraSound Audio drivers (dosaudio=gus)
const audio = urlParams.get(`dosaudio`);
if (
audio === `gus` ||
(audio == null && DOSee.getMetaContent(`dosee:audio`) === `gus`)
) {
const gusFallback =
(typeof audio === `undefined` || audio === null) &&
DOSee.getMetaContent(`dosee:audio`) === `gus`;
if (audio === `gus` || gusFallback) {
config.set(`gus`, `true`);
DOSee.setMetaContent(`dosee:audio:gus`, `true`);
}
Expand All @@ -67,8 +67,8 @@
`g`,
DoseeLoader.fetchFile(
`Gravis UltraSound (GUS) drivers`,
`${paths.get(`driveGUS`)}`
)
`${paths.get(`driveGUS`)}`,
),
);
};

Expand Down Expand Up @@ -101,7 +101,7 @@
const driveLetter = `u`;
return DoseeLoader.mountZip(
driveLetter,
DoseeLoader.fetchFile(`DOSee utilities`, `${paths.get(`driveUtils`)}`)
DoseeLoader.fetchFile(`DOSee utilities`, `${paths.get(`driveUtils`)}`),
);
};

Expand All @@ -127,7 +127,7 @@
// invalid protocols
try {
throw new Error(
`DOSee has aborted as it cannot be hosted over the "${url.protocol}" protocol.`
`DOSee has aborted as it cannot be hosted over the "${url.protocol}" protocol.`,
);
} catch (err) {
console.error(err);
Expand Down Expand Up @@ -176,25 +176,25 @@
DoseeLoader.locateAdditionalEmulatorJS(locateFiles),
DoseeLoader.nativeResolution(
nativeResolution()[0],
nativeResolution()[1]
nativeResolution()[1],
),
DoseeLoader.mountZip(
driveC,
DoseeLoader.fetchFile(
`'${config.get(`filename`)}'`,
`${config.get(`path`)}`
)
`${config.get(`path`)}`,
),
),
DoseeLoader.mountZip(
driveConfigs,
DoseeLoader.fetchFile(
`DOSee configurations`,
`${paths.get(`driveConfigs`)}`
)
`${paths.get(`driveConfigs`)}`,
),
),
gravisDriver(config.get(`gus`)),
utilities(config.get(`utils`)),
DoseeLoader.startExe(config.get(`exe`))
DoseeLoader.startExe(config.get(`exe`)),
);

// Start DOSee!
Expand All @@ -220,21 +220,21 @@
console.log(
`%cDOSee`,
`color:dimgray;font-weight:bold`,
`checking ${objName}, ${typeof window[objName]}`
`checking ${objName}, ${typeof window[objName]}`,
);
});
if (!pass) {
// console output
try {
throw new Error(
`DOSee has aborted as it is missing the above dependencies.`
`DOSee has aborted as it is missing the above dependencies.`,
);
} catch (err) {
console.error(err);
}
// error link
return errorBox(
`DOSee cannot load the required dependencies listed the Browser Console.`
`DOSee cannot load the required dependencies listed the Browser Console.`,
);
}
});
Expand Down
11 changes: 6 additions & 5 deletions src/js/dosee-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ window.Module = null;
function _loadHardDrive(data) {
if (typeof data === `undefined`)
throw Error(`_loadHardDrive requires the data argument`);
return new Promise(function (resolve, reject) {
return new Promise((resolve, reject) => {
const deltaFS = new BrowserFS.FileSystem.InMemory();
gameData = data;
// Any file system writes to MountableFileSystem will be written to the
Expand All @@ -532,7 +532,6 @@ window.Module = null;
new BrowserFS.FileSystem.MountableFileSystem(),
);
gameData.fileSystem.initialize(() => {
/* eslint-disable new-cap */
const Buffer = BrowserFS.BFSRequire(`buffer`).Buffer;
const fetch = (file) => {
if (
Expand Down Expand Up @@ -604,7 +603,8 @@ window.Module = null;
iphone = `iph`,
ipod = `ipo`;
const title = () => {
switch (navigator.platform.slice(0, 3).toLowerCase()) {
const prefixChrs = 3;
switch (navigator.platform.slice(0, prefixChrs).toLowerCase()) {
case android:
case ipad:
case iphone:
Expand Down Expand Up @@ -904,7 +904,7 @@ window.Module = null;
}
if (Array.isArray(one)) return one.concat(two);
if (oneType === `object`) {
Object.keys(two).forEach(function (key) {
Object.keys(two).forEach((key) => {
one[key] = mergeObjects(one[key], two[key]);

Check warning

Code scanning / CodeQL

Prototype-polluting function Medium

Properties are copied from
two
to
one
without guarding against prototype pollution.
});
return one;
Expand Down Expand Up @@ -1186,7 +1186,8 @@ window.Module = null;
return 0;
},
pathNotExistsAction: () => {
return 3;
const flag = 3;
return flag;
},
};

Expand Down
Loading

0 comments on commit 328e6d8

Please sign in to comment.