Bug 1357546 - Fix how relative paths are handled in Windows for the ESLint import-browser-window-globals rule. r=mossop
authorMark Banner <standard8@mozilla.com>
Tue, 18 Apr 2017 21:29:46 +0100
changeset 353665 fa863968ae186830f3469acf5353c4e40afaae90
parent 353664 24ad2a1d481c910bb31d254c9666290767d627de
child 353666 0b3b7652756f8242d1bca5ef800b84b765393961
push id31675
push usercbook@mozilla.com
push dateWed, 19 Apr 2017 08:28:05 +0000
treeherdermozilla-central@245811243903 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1357546
milestone55.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 1357546 - Fix how relative paths are handled in Windows for the ESLint import-browser-window-globals rule. r=mossop MozReview-Commit-ID: Q8YcLRSpkQ
tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-browser-window-globals.js
tools/lint/eslint/eslint-plugin-mozilla/package.json
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-browser-window-globals.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-browser-window-globals.js
@@ -21,16 +21,21 @@ module.exports = function(context) {
   // ---------------------------------------------------------------------------
   // Public
   // ---------------------------------------------------------------------------
 
   return {
     Program(node) {
       let filePath = helpers.getAbsoluteFilePath(context);
       let relativePath = path.relative(helpers.rootDir, filePath);
+      // We need to translate the path on Windows, due to the change
+      // from \ to /, and browserjsScripts assumes Posix.
+      if (path.win32) {
+        relativePath = relativePath.split(path.sep).join("/");
+      }
 
       if (browserWindowEnv.browserjsScripts &&
           browserWindowEnv.browserjsScripts.includes(relativePath)) {
         for (let global in browserWindowEnv.globals) {
           helpers.addVarToScope(global, context.getScope(),
                                 browserWindowEnv.globals[global]);
         }
       }
--- a/tools/lint/eslint/eslint-plugin-mozilla/package.json
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package.json
@@ -1,11 +1,11 @@
 {
   "name": "eslint-plugin-mozilla",
-  "version": "0.2.40",
+  "version": "0.2.41",
   "description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
   "keywords": [
     "eslint",
     "eslintplugin",
     "eslint-plugin",
     "mozilla",
     "firefox"
   ],