Bug 1340146 - Part 2: Process js/src/shell JavaScript files as self-hosted in eslint plugin. r=evilpie
authorAndré Bargull <andre.bargull@gmail.com>
Mon, 27 Feb 2017 09:55:21 -0800
changeset 394300 bf500219a0fc2686ef6c669cedf6b7b0d15fb0d4
parent 394299 fb3ac97e6e79798e44b489465b4cb0b303a01d8b
child 394301 36040e95313752e6862dec18a18036785baf21c2
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs1340146
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1340146 - Part 2: Process js/src/shell JavaScript files as self-hosted in eslint plugin. r=evilpie
js/src/shell/.eslintrc.js
js/src/shell/ModuleLoader.js
tools/lint/eslint/eslint-plugin-mozilla/lib/processors/self-hosted.js
new file mode 100644
--- /dev/null
+++ b/js/src/shell/.eslintrc.js
@@ -0,0 +1,12 @@
+"use strict";
+
+module.exports = {
+  "extends": [
+    "../../../toolkit/.eslintrc.js"
+  ],
+
+  "rules": {
+    // SpiderMonkey's style doesn't match any of the possible options.
+    "brace-style": "off",
+  }
+};
--- a/js/src/shell/ModuleLoader.js
+++ b/js/src/shell/ModuleLoader.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* global getModuleLoadPath setModuleResolveHook parseModule os */
+
 // A basic synchronous module loader for testing the shell.
 {
 // Save standard built-ins before scripts can modify them.
 const ArrayPrototypeJoin = Array.prototype.join;
 const MapPrototypeGet = Map.prototype.get;
 const MapPrototypeHas = Map.prototype.has;
 const MapPrototypeSet = Map.prototype.set;
 const ObjectDefineProperty = Object.defineProperty;
@@ -49,20 +51,23 @@ const ReflectLoader = new class {
 
         // Remove the drive letter, if present.
         let isalpha = c => ("A" <= c && c <= "Z") || ("a" <= c && c <= "z");
         let drive = "";
         if (path.length > 2 && isalpha(path[0]) && path[1] === ":" && path[2] === "\\") {
             drive = ReflectApply(StringPrototypeSubstring, path, [0, 2]);
             path = ReflectApply(StringPrototypeSubstring, path, [2]);
         }
+#endif
 
-        const pathsep = "\\";
+        const pathsep =
+#ifdef XP_WIN
+        "\\";
 #else
-        const pathsep = "/";
+        "/";
 #endif
 
         let n = 0;
         let components = [];
 
         // Normalize the path by removing redundant path components.
         // NB: See above for why we don't call String.prototype.split here.
         let lastSep = 0;
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/self-hosted.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/self-hosted.js
@@ -3,17 +3,17 @@
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 "use strict";
 
-const selfHostedRegex = /js\/src\/builtin\/.*?\.js$/;
+const selfHostedRegex = /js\/src\/(?:builtin|shell)\/.*?\.js$/;
 const macroRegex = /\s*\#(if|ifdef|else|elif|endif|include|define|undef).*/;
 
 module.exports = {
   preprocess: function(text, filename) {
     if (!selfHostedRegex.test(filename)) {
       return [text];
     }