Add `prettier` as an npm dev dependency (#18044)

For this initial commit I only chose to apply the formatting to a
single JS file.
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 4254d5c..3612531 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -318,7 +318,9 @@
     steps:
       - checkout
       - npm-install
-      - run: npm run lint
+      - run: |
+          npm run lint
+          npm run check
   test-sanity:
     executor: bionic
     steps:
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 3ef9fb0..b14c501 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -3,7 +3,7 @@
   es2020: true
   node: true
 extends:
-  - google
+  - prettier
 parserOptions:
   ecmaVersion: 12
 ignorePatterns:
diff --git a/.prettierrc.yml b/.prettierrc.yml
new file mode 100644
index 0000000..32705ec
--- /dev/null
+++ b/.prettierrc.yml
@@ -0,0 +1,4 @@
+singleQuote: true
+bracketSpacing: false
+arrowParens: avoid
+printWidth: 100
diff --git a/package-lock.json b/package-lock.json
index 1e22fd8..461b1e1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -657,10 +657,10 @@
         }
       }
     },
-    "eslint-config-google": {
-      "version": "0.14.0",
-      "resolved": "https://registry.npmjs.org/eslint-config-google/-/eslint-config-google-0.14.0.tgz",
-      "integrity": "sha512-WsbX4WbjuMvTdeVL6+J3rK1RGhCTqjsFjX7UMSMgZiyxxaNLkoJENbrGExzERFeoTpGw3F3FypTiWAP9ZXzkEw==",
+    "eslint-config-prettier": {
+      "version": "8.5.0",
+      "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz",
+      "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==",
       "dev": true
     },
     "eslint-scope": {
@@ -1139,7 +1139,8 @@
     "lodash": {
       "version": "4.17.21",
       "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
-      "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
+      "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
+      "dev": true
     },
     "lodash.merge": {
       "version": "4.6.2",
@@ -1335,6 +1336,12 @@
       "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
       "dev": true
     },
+    "prettier": {
+      "version": "2.7.1",
+      "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
+      "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
+      "dev": true
+    },
     "process-nextick-args": {
       "version": "2.0.1",
       "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
diff --git a/package.json b/package.json
index f65543b..df49a6c 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,8 @@
   "devDependencies": {
     "es-check": "^6.2.1",
     "eslint": "^8.16.0",
-    "eslint-config-google": "^0.14.0",
+    "eslint-config-prettier": "^8.5.0",
+    "prettier": "^2.7.1",
     "source-map": "0.7.3",
     "ws": "^8.6.0"
   },
@@ -14,6 +15,8 @@
     "wasm2c": "1.0.0"
   },
   "scripts": {
-    "lint": "eslint ."
+    "lint": "eslint .",
+    "fmt": "prettier --write tools/acorn-optimizer.js",
+    "check": "prettier --check tools/acorn-optimizer.js"
   }
 }
diff --git a/tools/acorn-optimizer.js b/tools/acorn-optimizer.js
index 25950ce..59c5f61 100755
--- a/tools/acorn-optimizer.js
+++ b/tools/acorn-optimizer.js
@@ -63,7 +63,7 @@
 // Simple post-order walk, calling properties on an object by node type,
 // if the type exists.
 function simpleWalk(node, cs) {
-  visitChildren(node, function(child) {
+  visitChildren(node, function (child) {
     simpleWalk(child, cs);
   });
   if (node.type in cs) {
@@ -73,7 +73,7 @@
 
 // Full post-order walk, calling a single function for all types.
 function fullWalk(node, c) {
-  visitChildren(node, function(child) {
+  visitChildren(node, function (child) {
     fullWalk(child, c);
   });
   c(node);
@@ -84,7 +84,7 @@
 function recursiveWalk(node, cs) {
   (function c(node) {
     if (!(node.type in cs)) {
-      visitChildren(node, function(child) {
+      visitChildren(node, function (child) {
         recursiveWalk(child, cs);
       });
     } else {
@@ -145,8 +145,7 @@
 }
 
 function isLiteralString(node) {
-  return node.type === 'Literal' &&
-         (node.raw[0] === '"' || node.raw[0] === "'");
+  return node.type === 'Literal' && (node.raw[0] === '"' || node.raw[0] === "'");
 }
 
 function dump(node, text) {
@@ -179,7 +178,7 @@
 
 // Mark inner scopes temporarily as empty statements.
 function restoreInnerScopes(node, map) {
-  fullWalk(node, function(node) {
+  fullWalk(node, function (node) {
     if (map.has(node)) {
       node.type = map.get(node);
       map.delete(node);
@@ -218,7 +217,7 @@
   // Conservative analysis.
   const map = ignoreInnerScopes(node);
   let has = false;
-  fullWalk(node, function(node) {
+  fullWalk(node, function (node) {
     switch (node.type) {
       // TODO: go through all the ESTree spec
       case 'Literal':
@@ -243,8 +242,7 @@
       }
       case 'MemberExpression': {
         // safe if on Math (or other familiar objects, TODO)
-        if (node.object.type !== 'Identifier' ||
-            node.object.name !== 'Math') {
+        if (node.object.type !== 'Identifier' || node.object.name !== 'Math') {
           // console.error('because member on ' + node.object.name);
           has = true;
         }
@@ -254,16 +252,18 @@
         // default to unsafe, but can be safe on some familiar objects
         if (node.callee.type === 'Identifier') {
           const name = node.callee.name;
-          if (name === 'TextDecoder' ||
-              name === 'ArrayBuffer' ||
-              name === 'Int8Array' ||
-              name === 'Uint8Array' ||
-              name === 'Int16Array' ||
-              name === 'Uint16Array' ||
-              name === 'Int32Array' ||
-              name === 'Uint32Array' ||
-              name === 'Float32Array' ||
-              name === 'Float64Array') {
+          if (
+            name === 'TextDecoder' ||
+            name === 'ArrayBuffer' ||
+            name === 'Int8Array' ||
+            name === 'Uint8Array' ||
+            name === 'Int16Array' ||
+            name === 'Uint16Array' ||
+            name === 'Int32Array' ||
+            name === 'Uint32Array' ||
+            name === 'Float32Array' ||
+            name === 'Float64Array'
+          ) {
             // no side effects, but the arguments might (we walk them in
             // full walk as well)
             break;
@@ -320,7 +320,7 @@
         VariableDeclaration(node, c) {
           const old = node.declarations;
           let removedHere = 0;
-          node.declarations = node.declarations.filter(function(node) {
+          node.declarations = node.declarations.filter(function (node) {
             const curr = node.id.name;
             const value = node.init;
             const keep = !(curr in names) || (value && hasSideEffects(value));
@@ -363,7 +363,7 @@
         ensureData(scopes[scopes.length - 1], node.id.name).def = 1;
       }
       const scope = {};
-      node.params.forEach(function(param) {
+      node.params.forEach(function (param) {
         const name = param.name;
         ensureData(scope, name).def = 1;
         scope[name].param = 1;
@@ -398,7 +398,7 @@
       },
       ObjectExpression(node, c) {
         // ignore the property identifiers
-        node.properties.forEach(function(node) {
+        node.properties.forEach(function (node) {
           c(node.value);
         });
       },
@@ -440,7 +440,7 @@
     cleanUp(ast, names);
     return removed;
   }
-  while (iteration() && aggressive) { }
+  while (iteration() && aggressive) {}
 }
 
 // Aggressive JSDCE - multiple iterations
@@ -448,12 +448,15 @@
   runJSDCE(ast, /* aggressive= */ true);
 }
 
-function isAsmLibraryArgAssign(node) { // var asmLibraryArg = ..
-  return node.type === 'VariableDeclaration' &&
-         node.declarations.length === 1 &&
-         node.declarations[0].id.name === 'asmLibraryArg' &&
-         node.declarations[0].init &&
-         node.declarations[0].init.type === 'ObjectExpression';
+function isAsmLibraryArgAssign(node) {
+  // var asmLibraryArg = ..
+  return (
+    node.type === 'VariableDeclaration' &&
+    node.declarations.length === 1 &&
+    node.declarations[0].id.name === 'asmLibraryArg' &&
+    node.declarations[0].init &&
+    node.declarations[0].init.type === 'ObjectExpression'
+  );
 }
 
 function getAsmLibraryArgValue(node) {
@@ -461,16 +464,18 @@
 }
 
 function isAsmUse(node) {
-  return node.type === 'MemberExpression' &&
-         ((node.object.type === 'Identifier' && // asm['X']
-           node.object.name === 'asm' &&
-           node.property.type === 'Literal') ||
-          (node.object.type === 'MemberExpression' && // Module['asm']['X']
-           node.object.object.type === 'Identifier' &&
-           node.object.object.name === 'Module' &&
-           node.object.property.type === 'Literal' &&
-           node.object.property.value === 'asm' &&
-           isLiteralString(node.property)));
+  return (
+    node.type === 'MemberExpression' &&
+    ((node.object.type === 'Identifier' && // asm['X']
+      node.object.name === 'asm' &&
+      node.property.type === 'Literal') ||
+      (node.object.type === 'MemberExpression' && // Module['asm']['X']
+        node.object.object.type === 'Identifier' &&
+        node.object.object.name === 'Module' &&
+        node.object.property.type === 'Literal' &&
+        node.object.property.value === 'asm' &&
+        isLiteralString(node.property)))
+  );
 }
 
 function getAsmOrModuleUseName(node) {
@@ -478,29 +483,34 @@
 }
 
 function isModuleUse(node) {
-  return node.type === 'MemberExpression' && // Module['X']
-         node.object.type === 'Identifier' &&
-         node.object.name === 'Module' &&
-         isLiteralString(node.property);
+  return (
+    node.type === 'MemberExpression' && // Module['X']
+    node.object.type === 'Identifier' &&
+    node.object.name === 'Module' &&
+    isLiteralString(node.property)
+  );
 }
 
-function isModuleAsmUse(node) { // Module['asm'][..string..]
-  return node.type === 'MemberExpression' &&
-         node.object.type === 'MemberExpression' &&
-         node.object.object.type === 'Identifier' &&
-         node.object.object.name === 'Module' &&
-         node.object.property.type === 'Literal' &&
-         node.object.property.value === 'asm' &&
-         isLiteralString(node.property);
+function isModuleAsmUse(node) {
+  // Module['asm'][..string..]
+  return (
+    node.type === 'MemberExpression' &&
+    node.object.type === 'MemberExpression' &&
+    node.object.object.type === 'Identifier' &&
+    node.object.object.name === 'Module' &&
+    node.object.property.type === 'Literal' &&
+    node.object.property.value === 'asm' &&
+    isLiteralString(node.property)
+  );
 }
 
 // Apply import/export name changes (after minifying them)
 function applyImportAndExportNameChanges(ast) {
   const mapping = extraInfo.mapping;
-  fullWalk(ast, function(node) {
+  fullWalk(ast, function (node) {
     if (isAsmLibraryArgAssign(node)) {
       const assignedObject = getAsmLibraryArgValue(node);
-      assignedObject.properties.forEach(function(item) {
+      assignedObject.properties.forEach(function (item) {
         if (mapping[item.key.value]) {
           setLiteralValue(item.key, mapping[item.key.value]);
         }
@@ -514,7 +524,8 @@
           setLiteralValue(value.property, mapping[name]);
         }
       }
-    } else if (node.type === 'CallExpression' && isAsmUse(node.callee)) { // asm["___wasm_call_ctors"](); -> asm["M"]();
+    } else if (node.type === 'CallExpression' && isAsmUse(node.callee)) {
+      // asm["___wasm_call_ctors"](); -> asm["M"]();
       const callee = node.callee;
       const name = callee.property.value;
       if (mapping[name]) {
@@ -539,10 +550,12 @@
 // A static dyncall is dynCall('vii', ..), which is actually static even
 // though we call dynCall() - we see the string signature statically.
 function isStaticDynCall(node) {
-  return node.type === 'CallExpression' &&
-         node.callee.type === 'Identifier' &&
-         node.callee.name === 'dynCall' &&
-         isLiteralString(node.arguments[0]);
+  return (
+    node.type === 'CallExpression' &&
+    node.callee.type === 'Identifier' &&
+    node.callee.name === 'dynCall' &&
+    isLiteralString(node.arguments[0])
+  );
 }
 
 function getStaticDynCallName(node) {
@@ -557,12 +570,13 @@
 // as that prefix means we may be constructing a dynamic dyncall name
 // (dynCall and embind's requireFunction do this internally).
 function isDynamicDynCall(node) {
-  return (node.type === 'CallExpression' &&
-          node.callee.type === 'Identifier' &&
-          node.callee.name === 'dynCall' &&
-          !isLiteralString(node.arguments[0])) ||
-         (isLiteralString(node) &&
-          node.value === 'dynCall_');
+  return (
+    (node.type === 'CallExpression' &&
+      node.callee.type === 'Identifier' &&
+      node.callee.name === 'dynCall' &&
+      !isLiteralString(node.arguments[0])) ||
+    (isLiteralString(node) && node.value === 'dynCall_')
+  );
 }
 
 //
@@ -656,10 +670,10 @@
     }
   }
 
-  fullWalk(ast, function(node) {
+  fullWalk(ast, function (node) {
     if (isAsmLibraryArgAssign(node)) {
       const assignedObject = getAsmLibraryArgValue(node);
-      assignedObject.properties.forEach(function(item) {
+      assignedObject.properties.forEach(function (item) {
         let value = item.value;
         if (value.type === 'Literal' || value.type === 'FunctionExpression') {
           return; // if it's a numeric or function literal, nothing to do here
@@ -687,7 +701,7 @@
             // which looks like a wasm export being received. confirm with the asm use
             let found = 0;
             let asmName;
-            fullWalk(value.right, function(node) {
+            fullWalk(value.right, function (node) {
               if (isAsmUse(node)) {
                 found++;
                 asmName = getAsmOrModuleUseName(node);
@@ -727,8 +741,12 @@
     } else if (node.type === 'FunctionExpression') {
       // Check if this is the minimal runtime exports function, which looks like
       //   (output) => { var asm = output.instance.exports;
-      if (node.params.length === 1 && node.params[0].type === 'Identifier' &&
-          node.params[0].name === 'output' && node.body.type === 'BlockStatement') {
+      if (
+        node.params.length === 1 &&
+        node.params[0].type === 'Identifier' &&
+        node.params[0].name === 'output' &&
+        node.body.type === 'BlockStatement'
+      ) {
         const body = node.body.body;
         if (body.length >= 1) {
           const first = body[0];
@@ -739,8 +757,10 @@
             const decl = first.declarations[0];
             target = decl.id;
             value = decl.init;
-          } else if (first.type === 'ExpressionStatement' &&
-                     first.expression.type === 'AssignmentExpression') {
+          } else if (
+            first.type === 'ExpressionStatement' &&
+            first.expression.type === 'AssignmentExpression'
+          ) {
             const assign = first.expression;
             if (assign.operator === '=') {
               target = assign.left;
@@ -748,26 +768,30 @@
             }
           }
           if (target && target.type === 'Identifier' && target.name === 'asm' && value) {
-            if (value.type === 'MemberExpression' &&
-                value.object.type === 'MemberExpression' &&
-                value.object.object.type === 'Identifier' &&
-                value.object.object.name === 'output' &&
-                value.object.property.type === 'Identifier' &&
-                value.object.property.name === 'instance' &&
-                value.property.type === 'Identifier' &&
-                value.property.name === 'exports') {
+            if (
+              value.type === 'MemberExpression' &&
+              value.object.type === 'MemberExpression' &&
+              value.object.object.type === 'Identifier' &&
+              value.object.object.name === 'output' &&
+              value.object.property.type === 'Identifier' &&
+              value.object.property.name === 'instance' &&
+              value.property.type === 'Identifier' &&
+              value.property.name === 'exports'
+            ) {
               // This looks very much like what we are looking for.
               assert(!foundMinimalRuntimeExports);
               for (let i = 1; i < body.length; i++) {
                 const item = body[i];
-                if (item.type === 'ExpressionStatement' &&
-                    item.expression.type === 'AssignmentExpression' &&
-                    item.expression.operator === '=' &&
-                    item.expression.left.type === 'Identifier' &&
-                    item.expression.right.type === 'MemberExpression' &&
-                    item.expression.right.object.type === 'Identifier' &&
-                    item.expression.right.object.name === 'asm' &&
-                    item.expression.right.property.type === 'Literal') {
+                if (
+                  item.type === 'ExpressionStatement' &&
+                  item.expression.type === 'AssignmentExpression' &&
+                  item.expression.operator === '=' &&
+                  item.expression.left.type === 'Identifier' &&
+                  item.expression.right.type === 'MemberExpression' &&
+                  item.expression.right.object.type === 'Identifier' &&
+                  item.expression.right.object.name === 'asm' &&
+                  item.expression.right.property.type === 'Literal'
+                ) {
                   const name = item.expression.left.name;
                   const asmName = item.expression.right.property.value;
                   saveAsmExport(name, asmName);
@@ -782,7 +806,10 @@
     }
   });
   // must find the info we need
-  assert(foundAsmLibraryArgAssign, 'could not find the assigment to "asmLibraryArg". perhaps --pre-js or --post-js code moved it out of the global scope? (things like that should be done after emcc runs, as they do not need to be run through the optimizer which is the special thing about --pre-js/--post-js code)');
+  assert(
+    foundAsmLibraryArgAssign,
+    'could not find the assigment to "asmLibraryArg". perhaps --pre-js or --post-js code moved it out of the global scope? (things like that should be done after emcc runs, as they do not need to be run through the optimizer which is the special thing about --pre-js/--post-js code)'
+  );
   // Read exports that were declared in extraInfo
   if (extraInfo) {
     for (const exp of extraInfo.exports) {
@@ -797,11 +824,11 @@
   const infos = {}; // the graph name of the item => info for it
   for (const import_ of imports) {
     const name = getGraphName(import_, 'import');
-    const info = infos[name] = {
+    const info = (infos[name] = {
       name: name,
       import: ['env', import_],
       reaches: {},
-    };
+    });
     if (nameToGraphName.hasOwnProperty(import_)) {
       info.reaches[nameToGraphName[import_]] = 1;
     } // otherwise, it's a number, ignore
@@ -868,15 +895,15 @@
       }
     }
   }
-  defuns.forEach((defun) => {
+  defuns.forEach(defun => {
     const name = getGraphName(defun.id.name, 'defun');
-    const info = infos[name] = {
+    const info = (infos[name] = {
       name: name,
       reaches: {},
-    };
-    fullWalk(defun.body, (node) => visitNode(node, info));
+    });
+    fullWalk(defun.body, node => visitNode(node, info));
   });
-  fullWalk(ast, (node) => visitNode(node, null));
+  fullWalk(ast, node => visitNode(node, null));
   // Final work: print out the graph
   // sort for determinism
   function sortedNamesFromMap(map) {
@@ -887,7 +914,7 @@
     names.sort();
     return names;
   }
-  sortedNamesFromMap(infos).forEach((name) => {
+  sortedNamesFromMap(infos).forEach(name => {
     const info = infos[name];
     info.reaches = sortedNamesFromMap(info.reaches);
     graph.push(info);
@@ -899,10 +926,10 @@
 function applyDCEGraphRemovals(ast) {
   const unused = new Set(extraInfo.unused);
 
-  fullWalk(ast, (node) => {
+  fullWalk(ast, node => {
     if (isAsmLibraryArgAssign(node)) {
       const assignedObject = getAsmLibraryArgValue(node);
-      assignedObject.properties = assignedObject.properties.filter((item) => {
+      assignedObject.properties = assignedObject.properties.filter(item => {
         const name = item.key.value;
         const value = item.value;
         const full = 'emcc$import$' + name;
@@ -915,8 +942,7 @@
         const name = getAsmOrModuleUseName(target);
         const full = 'emcc$export$' + name;
         const value = node.right;
-        if (unused.has(full) &&
-            (isAsmUse(value) || !hasSideEffects(value))) {
+        if (unused.has(full) && (isAsmUse(value) || !hasSideEffects(value))) {
           // This will be in a var init, and we just remove that value.
           convertToNothingInVarInit(node);
         }
@@ -926,9 +952,7 @@
       // In the minimal runtime code pattern we have just
       //   x = asm['x']
       // and never in a var.
-      if (expr.operator === '=' &&
-          expr.left.type === 'Identifier' &&
-          isAsmUse(expr.right)) {
+      if (expr.operator === '=' && expr.left.type === 'Identifier' && isAsmUse(expr.right)) {
         const name = expr.left.name;
         if (name === getAsmOrModuleUseName(expr.right)) {
           const full = 'emcc$export$' + name;
@@ -994,8 +1018,7 @@
   recursiveWalk(ast, {
     FunctionDeclaration: (node, c) => {
       // do not recurse into LE_HEAP_STORE, LE_HEAP_LOAD functions
-      if (!(node.id.type === 'Identifier' &&
-          node.id.name.startsWith('LE_HEAP'))) {
+      if (!(node.id.type === 'Identifier' && node.id.name.startsWith('LE_HEAP'))) {
         c(node.body);
       }
     },
@@ -1046,7 +1069,7 @@
             makeCallExpression(node, 'LE_HEAP_STORE_F64', [multiply(idx, 8), value]);
             break;
           }
-        };
+        }
       }
     },
     MemberExpression: (node, c) => {
@@ -1093,7 +1116,7 @@
             makeCallExpression(node, 'LE_HEAP_LOAD_F64', [multiply(idx, 8)]);
             break;
           }
-        };
+        }
       }
     },
   });
@@ -1104,18 +1127,17 @@
 // in each access), see #8365.
 function growableHeap(ast) {
   recursiveWalk(ast, {
-    AssignmentExpression: (node) => {
-      if (node.left.type === 'Identifier' &&
-          isEmscriptenHEAP(node.left.name)) {
+    AssignmentExpression: node => {
+      if (node.left.type === 'Identifier' && isEmscriptenHEAP(node.left.name)) {
         // Don't transform initial setup of the arrays.
         return;
       }
       growableHeap(node.left);
       growableHeap(node.right);
     },
-    VariableDeclaration: (node) => {
+    VariableDeclaration: node => {
       // Don't transform the var declarations for HEAP8 etc
-      node.declarations.forEach(function(decl) {
+      node.declarations.forEach(function (decl) {
         // but do transform anything that sets a var to
         // something from HEAP8 etc
         if (decl.init) {
@@ -1123,7 +1145,7 @@
         }
       });
     },
-    Identifier: (node) => {
+    Identifier: node => {
       if (node.name.startsWith('HEAP')) {
         // Turn HEAP8 into GROWABLE_HEAP_I8() etc
         switch (node.name) {
@@ -1159,7 +1181,8 @@
             makeCallExpression(node, 'GROWABLE_HEAP_F64', []);
             break;
           }
-          default: {}
+          default: {
+          }
         }
       }
     },
@@ -1202,20 +1225,20 @@
     };
   }
 
-  fullWalk(ast, function(node) {
+  fullWalk(ast, function (node) {
     if (node.type === 'MemberExpression') {
       // Check if this is HEAP*[?]
-      if (node.object.type === 'Identifier' &&
-          isHeap(node.object.name) &&
-          node.computed) {
+      if (node.object.type === 'Identifier' && isHeap(node.object.name) && node.computed) {
         node.property = unsign(node.property);
       }
     } else if (node.type === 'CallExpression') {
-      if (node.callee.type === 'MemberExpression' &&
-          node.callee.object.type === 'Identifier' &&
-          isHeap(node.callee.object.name) &&
-          node.callee.property.type === 'Identifier' &&
-          !node.computed) {
+      if (
+        node.callee.type === 'MemberExpression' &&
+        node.callee.object.type === 'Identifier' &&
+        isHeap(node.callee.object.name) &&
+        node.callee.property.type === 'Identifier' &&
+        !node.computed
+      ) {
         // This is a call on HEAP*.?. Specific things we need to fix up are
         // subarray, set, and copyWithin. TODO more?
         if (node.callee.property.name === 'set') {
@@ -1242,10 +1265,12 @@
 }
 
 function isHEAPAccess(node) {
-  return node.type === 'MemberExpression' &&
-         node.object.type === 'Identifier' &&
-         node.computed && // notice a[X] but not a.X
-         isEmscriptenHEAP(node.object.name);
+  return (
+    node.type === 'MemberExpression' &&
+    node.object.type === 'Identifier' &&
+    node.computed && // notice a[X] but not a.X
+    isEmscriptenHEAP(node.object.name)
+  );
 }
 
 // Replace direct HEAP* loads/stores with calls into C, in which ASan checks
@@ -1300,7 +1325,8 @@
             makeCallExpression(node, '_asan_js_store_d', [ptr, value]);
             break;
           }
-          default: {}
+          default: {
+          }
         }
       } else {
         c(target);
@@ -1346,7 +1372,8 @@
             makeCallExpression(node, '_asan_js_load_d', [ptr]);
             break;
           }
-          default: {}
+          default: {
+          }
         }
       }
     },
@@ -1366,10 +1393,12 @@
 function safeHeap(ast) {
   recursiveWalk(ast, {
     FunctionDeclaration(node, c) {
-      if (node.id.type === 'Identifier' &&
-          (node.id.name.startsWith('SAFE_HEAP') ||
-           node.id.name === 'setValue_safe' ||
-           node.id.name === 'getValue_safe')) {
+      if (
+        node.id.type === 'Identifier' &&
+        (node.id.name.startsWith('SAFE_HEAP') ||
+          node.id.name === 'setValue_safe' ||
+          node.id.name === 'getValue_safe')
+      ) {
         // do not recurse into this js impl function, which we use during
         // startup before the wasm is ready
       } else {
@@ -1391,20 +1420,36 @@
           }
           case 'HEAP16':
           case 'HEAPU16': {
-            makeCallExpression(node, 'SAFE_HEAP_STORE', [multiply(ptr, 2), value, createLiteral(2)]);
+            makeCallExpression(node, 'SAFE_HEAP_STORE', [
+              multiply(ptr, 2),
+              value,
+              createLiteral(2),
+            ]);
             break;
           }
           case 'HEAP32':
           case 'HEAPU32': {
-            makeCallExpression(node, 'SAFE_HEAP_STORE', [multiply(ptr, 4), value, createLiteral(4)]);
+            makeCallExpression(node, 'SAFE_HEAP_STORE', [
+              multiply(ptr, 4),
+              value,
+              createLiteral(4),
+            ]);
             break;
           }
           case 'HEAPF32': {
-            makeCallExpression(node, 'SAFE_HEAP_STORE_D', [multiply(ptr, 4), value, createLiteral(4)]);
+            makeCallExpression(node, 'SAFE_HEAP_STORE_D', [
+              multiply(ptr, 4),
+              value,
+              createLiteral(4),
+            ]);
             break;
           }
           case 'HEAPF64': {
-            makeCallExpression(node, 'SAFE_HEAP_STORE_D', [multiply(ptr, 8), value, createLiteral(8)]);
+            makeCallExpression(node, 'SAFE_HEAP_STORE_D', [
+              multiply(ptr, 8),
+              value,
+              createLiteral(8),
+            ]);
             break;
           }
         }
@@ -1429,30 +1474,55 @@
             break;
           }
           case 'HEAP16': {
-            makeCallExpression(node, 'SAFE_HEAP_LOAD', [multiply(ptr, 2), createLiteral(2), createLiteral(0)]);
+            makeCallExpression(node, 'SAFE_HEAP_LOAD', [
+              multiply(ptr, 2),
+              createLiteral(2),
+              createLiteral(0),
+            ]);
             break;
           }
           case 'HEAPU16': {
-            makeCallExpression(node, 'SAFE_HEAP_LOAD', [multiply(ptr, 2), createLiteral(2), createLiteral(1)]);
+            makeCallExpression(node, 'SAFE_HEAP_LOAD', [
+              multiply(ptr, 2),
+              createLiteral(2),
+              createLiteral(1),
+            ]);
             break;
           }
           case 'HEAP32': {
-            makeCallExpression(node, 'SAFE_HEAP_LOAD', [multiply(ptr, 4), createLiteral(4), createLiteral(0)]);
+            makeCallExpression(node, 'SAFE_HEAP_LOAD', [
+              multiply(ptr, 4),
+              createLiteral(4),
+              createLiteral(0),
+            ]);
             break;
           }
           case 'HEAPU32': {
-            makeCallExpression(node, 'SAFE_HEAP_LOAD', [multiply(ptr, 4), createLiteral(4), createLiteral(1)]);
+            makeCallExpression(node, 'SAFE_HEAP_LOAD', [
+              multiply(ptr, 4),
+              createLiteral(4),
+              createLiteral(1),
+            ]);
             break;
           }
           case 'HEAPF32': {
-            makeCallExpression(node, 'SAFE_HEAP_LOAD_D', [multiply(ptr, 4), createLiteral(4), createLiteral(0)]);
+            makeCallExpression(node, 'SAFE_HEAP_LOAD_D', [
+              multiply(ptr, 4),
+              createLiteral(4),
+              createLiteral(0),
+            ]);
             break;
           }
           case 'HEAPF64': {
-            makeCallExpression(node, 'SAFE_HEAP_LOAD_D', [multiply(ptr, 8), createLiteral(8), createLiteral(0)]);
+            makeCallExpression(node, 'SAFE_HEAP_LOAD_D', [
+              multiply(ptr, 8),
+              createLiteral(8),
+              createLiteral(0),
+            ]);
             break;
           }
-          default: {}
+          default: {
+          }
         }
       }
     },
@@ -1461,7 +1531,24 @@
 
 // Name minification
 
-const RESERVED = new Set(['do', 'if', 'in', 'for', 'new', 'try', 'var', 'env', 'let', 'case', 'else', 'enum', 'void', 'this', 'void', 'with']);
+const RESERVED = new Set([
+  'do',
+  'if',
+  'in',
+  'for',
+  'new',
+  'try',
+  'var',
+  'env',
+  'let',
+  'case',
+  'else',
+  'enum',
+  'void',
+  'this',
+  'void',
+  'with',
+]);
 const VALID_MIN_INITS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
 const VALID_MIN_LATERS = VALID_MIN_INITS + '0123456789';
 
@@ -1520,7 +1607,7 @@
     const newNames = new Map();
 
     // The names in use, that must not be collided with.
-    const usedNames = new Set;
+    const usedNames = new Set();
 
     // Put the function name aside. We don't want to traverse it as it is not
     // in the scope of itself.
@@ -1651,9 +1738,12 @@
   // analysis here. FIXME
 
   // We must run on a singleton instantiate() function as described above.
-  assert(ast.type === 'Program' && ast.body.length === 1 &&
-         ast.body[0].type === 'FunctionDeclaration' &&
-         ast.body[0].id.name === 'instantiate');
+  assert(
+    ast.type === 'Program' &&
+      ast.body.length === 1 &&
+      ast.body[0].type === 'FunctionDeclaration' &&
+      ast.body[0].id.name === 'instantiate'
+  );
   const fun = ast.body[0];
 
   // Swap the function's name away so that we can then minify everything else.
@@ -1752,11 +1842,13 @@
   const symbols = [];
 
   // Collect all code symbols
-  ast.walk(new terser.TreeWalker(function(node) {
-    if (node.start && node.start.pos) {
-      symbols.push(node);
-    }
-  }));
+  ast.walk(
+    new terser.TreeWalker(function (node) {
+      if (node.start && node.start.pos) {
+        symbols.push(node);
+      }
+    })
+  );
 
   // Sort them by ascending line number
   symbols.sort((a, b) => a.start.pos - b.start.pos);
@@ -1778,24 +1870,26 @@
     if (!Array.isArray(symbols[j].start.comments_before)) {
       symbols[j].start.comments_before = [];
     }
-    symbols[j].start.comments_before.push(new terser.AST_Token({
-      end: undefined,
-      quote: undefined,
-      raw: undefined,
-      file: '0',
-      comments_after: undefined,
-      comments_before: undefined,
-      nlb: false,
-      endpos: undefined,
-      endcol: undefined,
-      endline: undefined,
-      pos: undefined,
-      col: undefined,
-      line: undefined,
-      value: comments[i].value,
-      type: comments[i].type == 'Line' ? 'comment' : 'comment2',
-      flags: 0,
-    }));
+    symbols[j].start.comments_before.push(
+      new terser.AST_Token({
+        end: undefined,
+        quote: undefined,
+        raw: undefined,
+        file: '0',
+        comments_after: undefined,
+        comments_before: undefined,
+        nlb: false,
+        endpos: undefined,
+        endcol: undefined,
+        endline: undefined,
+        pos: undefined,
+        col: undefined,
+        line: undefined,
+        value: comments[i].value,
+        type: comments[i].type == 'Line' ? 'comment' : 'comment2',
+        flags: 0,
+      })
+    );
   }
 }
 
@@ -1883,8 +1977,7 @@
     verbose = true;
   },
   // TODO: remove 'last' in the python driver code
-  last: () => {
-  },
+  last: () => {},
   dump: () => dump(ast),
   littleEndianHeap: littleEndianHeap,
   growableHeap: growableHeap,
@@ -1895,7 +1988,7 @@
   minifyGlobals: minifyGlobals,
 };
 
-passes.forEach((pass) => registry[pass](ast));
+passes.forEach(pass => registry[pass](ast));
 
 if (!noPrint) {
   const terserAst = terser.AST_Node.from_mozilla_ast(ast);