Skip to content

Commit b66b467

Browse files
authored
Run eslint on .mjs files. NFC (#21563)
1 parent c2d6698 commit b66b467

File tree

6 files changed

+15
-45
lines changed

6 files changed

+15
-45
lines changed

.eslintrc.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
env:
22
browser: true
3-
es2020: true
3+
es2022: true
44
node: true
55
extends:
66
- prettier
77
parserOptions:
88
ecmaVersion: 13
9+
sourceType: "module"
910
ignorePatterns:
1011
- "out/"
1112
- "site/"
@@ -54,7 +55,10 @@ rules:
5455
max-len: "off"
5556
no-multi-spaces: "off"
5657
require-jsdoc: "off"
57-
no-unused-vars: "off"
5858
arrow-body-style: ["error", "as-needed"]
5959
space-infix-ops: "error"
6060
quotes: ["error", "single", {"avoidEscape": true}]
61+
overrides:
62+
- files: "**/*.mjs"
63+
rules:
64+
no-unused-vars: ["error", {"vars": "all", "args": "none", "ignoreRestSiblings": false, "destructuredArrayIgnorePattern": "^_" }]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"html-minifier-terser": "7.2.0"
2020
},
2121
"scripts": {
22-
"lint": "eslint .",
22+
"lint": "eslint --ext .js --ext .mjs .",
2323
"fmt": "prettier --write src/*.mjs tools/*.mjs",
2424
"check": "prettier --check src/*.mjs tools/*.mjs"
2525
}

test/test_browser.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3363,8 +3363,12 @@ def test_async_mainloop(self, args):
33633363
self.btest_exit('async_mainloop.cpp', args=args + ['-sASYNCIFY'])
33643364

33653365
@requires_sound_hardware
3366-
def test_sdl_audio_beep_sleep(self):
3367-
self.btest_exit('test_sdl_audio_beep_sleep.cpp', args=['-Os', '-sASSERTIONS', '-sDISABLE_EXCEPTION_CATCHING=0', '-profiling', '-sSAFE_HEAP', '-lSDL', '-sASYNCIFY'], timeout=90)
3366+
@parameterized({
3367+
'': ([],),
3368+
'safeheap': (['-sSAFE_HEAP'],),
3369+
})
3370+
def test_sdl_audio_beep_sleep(self, args):
3371+
self.btest_exit('test_sdl_audio_beep_sleep.cpp', args=['-Os', '-sASSERTIONS', '-sDISABLE_EXCEPTION_CATCHING=0', '-profiling', '-lSDL', '-sASYNCIFY'] + args, timeout=90)
33683372

33693373
def test_mainloop_reschedule(self):
33703374
self.btest('mainloop_reschedule.cpp', '1', args=['-Os', '-sASYNCIFY'])

tools/acorn-optimizer.mjs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ function print(x) {
1010
process.stdout.write(x + '\n');
1111
}
1212

13-
function printErr(x) {
14-
process.stderr.write(x + '\n');
15-
}
16-
1713
function read(x) {
1814
return fs.readFileSync(x).toString();
1915
}
@@ -33,13 +29,6 @@ function assertAt(condition, node, message = '') {
3329
}
3430
}
3531

36-
function warnOnce(msg) {
37-
if (!warnOnce.msgs) warnOnce.msgs = {};
38-
if (msg in warnOnce.msgs) return;
39-
warnOnce.msgs[msg] = true;
40-
printErr('warning: ' + msg);
41-
}
42-
4332
// Visits and walks
4433
// (We don't use acorn-walk because it ignores x in 'x = y'.)
4534

@@ -100,12 +89,6 @@ function emptyOut(node) {
10089
node.type = 'EmptyStatement';
10190
}
10291

103-
function nullify(node) {
104-
node.type = 'Literal';
105-
node.value = null;
106-
node.raw = 'null';
107-
}
108-
10992
// This converts the node into something that terser will ignore in a var
11093
// declaration, that is, it is a way to get rid of initial values.
11194
function convertToNothingInVarInit(node) {
@@ -114,11 +97,6 @@ function convertToNothingInVarInit(node) {
11497
node.raw = 'undefined';
11598
}
11699

117-
function convertToNull(node) {
118-
node.type = 'Identifier';
119-
node.name = 'null';
120-
}
121-
122100
function convertToNullStatement(node) {
123101
node.type = 'ExpressionStatement';
124102
node.expression = {
@@ -304,13 +282,6 @@ function runJSDCE(ast, aggressive) {
304282
function iteration() {
305283
let removed = 0;
306284
const scopes = [{}]; // begin with empty toplevel scope
307-
function DUMP() {
308-
printErr('vvvvvvvvvvvvvv');
309-
for (let i = 0; i < scopes.length; i++) {
310-
printErr(i + ' : ' + JSON.stringify(scopes[i]));
311-
}
312-
printErr('^^^^^^^^^^^^^^');
313-
}
314285
function ensureData(scope, name) {
315286
if (Object.prototype.hasOwnProperty.call(scope, name)) return scope[name];
316287
scope[name] = {
@@ -549,7 +520,6 @@ function applyImportAndExportNameChanges(ast) {
549520
}
550521
});
551522
} else if (node.type === 'AssignmentExpression') {
552-
const target = node.left;
553523
const value = node.right;
554524
if (isExportUse(value)) {
555525
const name = value.property.value;
@@ -737,7 +707,6 @@ function emitDCEGraph(ast) {
737707
emptyOut(node); // ignore this in the second pass; this does not root
738708
} else if (node.type === 'AssignmentExpression') {
739709
const target = node.left;
740-
const value = node.right;
741710
// Ignore assignment to the wasmExports object (as happens in
742711
// applySignatureConversions).
743712
if (isExportUse(target)) {
@@ -902,7 +871,7 @@ function emitDCEGraph(ast) {
902871
info.reaches[nameToGraphName[import_]] = 1;
903872
} // otherwise, it's a number, ignore
904873
}
905-
for (const [e, name] of Object.entries(exportNameToGraphName)) {
874+
for (const [e, _] of Object.entries(exportNameToGraphName)) {
906875
const name = exportNameToGraphName[e];
907876
infos[name] = {
908877
name: name,
@@ -1127,7 +1096,7 @@ function littleEndianHeap(ast) {
11271096
// replace the heap access with LE_HEAP_STORE
11281097
const name = target.object.name;
11291098
const idx = target.property;
1130-
switch (target.object.name) {
1099+
switch (name) {
11311100
case 'HEAP8':
11321101
case 'HEAPU8': {
11331102
// no action required - storing only 1 byte

tools/preprocessor.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import assert from 'assert';
1717
import {loadSettingsFile} from '../src/utility.mjs';
1818

1919
const args = process.argv.slice(2);
20-
const debug = false;
2120

2221
assert(args.length >= 2, 'Script requires 2 arguments');
2322
const settingsFile = args[0];

tools/unsafe_optimizations.mjs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ function visitNodes(root, types, func) {
3232
}
3333
}
3434

35-
function dump(nodeArray) {
36-
for (const node of nodeArray) {
37-
console.dir(node);
38-
}
39-
}
40-
4135
function optPassSimplifyModularizeFunction(ast) {
4236
visitNodes(ast, ['FunctionExpression'], (node) => {
4337
if (node.params.length == 1 && node.params[0].name == 'Module') {

0 commit comments

Comments
 (0)