Skip to content

Commit

Permalink
Make eslint happy
Browse files Browse the repository at this point in the history
Since this code runs in a browser, we need to tell eslint that
it's going to run in a browser enviroment so things like `window`
and `document` are defined.

Signed-off-by: L. Pereira <[email protected]>
  • Loading branch information
lpereira committed May 30, 2024
1 parent d0f6635 commit 31cfc61
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
20 changes: 13 additions & 7 deletions crates/explorer/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import js from "@eslint/js";
import globals from "globals";
import pluginJs from "@eslint/js";

export default [
js.configs.recommended,

export default [
{
files: ["**/*.js"],
languageOptions: {
sourceType: "module"
}
},
{
rules: {
"no-unused-vars": "error",
"no-undef": "error",
},
languageOptions: {
globals: globals.browser
}
},
pluginJs.configs.recommended,
];
19 changes: 16 additions & 3 deletions crates/explorer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"devDependencies": {
"@eslint/js": "^9.3.0",
"eslint": "^9.3.0",
"globals": "^15.3.0",
"prettier": "3.2.5"
},
"type": "module"
Expand Down
4 changes: 2 additions & 2 deletions crates/explorer/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*** LRU Cache *****************************************************************/

class Cache {
class LruCache {
constructor(size, getFunc) {
// Maps preserve the insertion order, so we can use it to implement a naïve LRU
// cache.
Expand Down Expand Up @@ -139,7 +139,7 @@ const renderInst = (mnemonic, operands) => {

// Connects callbacks to mouse hovering events so elements are properly highlighted when
// hovered, and the bridging element is drawn between the instruction lists.
const linkedElementCache = new Cache(256, offset =>
const linkedElementCache = new LruCache(256, offset =>
document.querySelectorAll(`[data-wasm-offset="${offset}"]`),
);
const linkElements = element => {
Expand Down

0 comments on commit 31cfc61

Please sign in to comment.