Bug 1340146 - Process js/src/shell JavaScript files as self-hosted in eslint plugin. r=evilpie
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];
}