Skip to content

Commit

Permalink
Run JS linter on src/*.mjs files. NFC (emscripten-core#21510)
Browse files Browse the repository at this point in the history
As of today all `.mjs` files are part of the compiler itself and don't
contains preproccess macros, so that are safe to be run through linter
tools.
  • Loading branch information
sbc100 authored Mar 11, 2024
1 parent 25125ce commit 64feaf1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"scripts": {
"lint": "eslint .",
"fmt": "prettier --write tools/*.mjs",
"check": "prettier --check tools/*.mjs"
"fmt": "prettier --write src/*.mjs tools/*.mjs",
"check": "prettier --check src/*.mjs tools/*.mjs"
}
}
14 changes: 10 additions & 4 deletions src/compiler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ globalThis.read = (filename) => {
};

function load(f) {
vm.runInThisContext(read(f), { filename: find(f) });
vm.runInThisContext(read(f), {filename: find(f)});
}

// Basic utilities
Expand Down Expand Up @@ -73,7 +73,7 @@ globalThis.symbolsOnly = symbolsOnlyArg != -1;
// In case compiler.js is run directly (as in gen_sig_info)
// ALL_INCOMING_MODULE_JS_API might not be populated yet.
if (!ALL_INCOMING_MODULE_JS_API.length) {
ALL_INCOMING_MODULE_JS_API = INCOMING_MODULE_JS_API
ALL_INCOMING_MODULE_JS_API = INCOMING_MODULE_JS_API;
}

EXPORTED_FUNCTIONS = new Set(EXPORTED_FUNCTIONS);
Expand All @@ -87,7 +87,10 @@ if (symbolsOnly) {
}

// Side modules are pure wasm and have no JS
assert(!SIDE_MODULE || (ASYNCIFY && globalThis.symbolsOnly), 'JS compiler should only run on side modules if asyncify is used.');
assert(
!SIDE_MODULE || (ASYNCIFY && globalThis.symbolsOnly),
'JS compiler should only run on side modules if asyncify is used.',
);

// Load compiler code

Expand Down Expand Up @@ -116,7 +119,10 @@ try {
// Compiler failed on internal compiler error!
printErr('Internal compiler error in src/compiler.js!');
printErr('Please create a bug report at https://github.com/emscripten-core/emscripten/issues/');
printErr('with a log of the build and the input files used to run. Exception message: "' + (err.stack || err));
printErr(
'with a log of the build and the input files used to run. Exception message: "' +
(err.stack || err),
);
}

// Work around a node.js bug where stdout buffer is not flushed at process exit:
Expand Down

0 comments on commit 64feaf1

Please sign in to comment.