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 401782 fa863968ae186830f3469acf5353c4e40afaae90
parent 401781 24ad2a1d481c910bb31d254c9666290767d627de
child 401783 0b3b7652756f8242d1bca5ef800b84b765393961
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [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"
   ],