Bug 1357546 - Fix how relative paths are handled in Windows for the ESLint import-browser-window-globals rule. r?Mossop draft
authorMark Banner <standard8@mozilla.com>
Tue, 18 Apr 2017 21:29:46 +0100
changeset 564698 268f87ac0cc2018d8f5f268f39cfa5e7f2b82e04
parent 564697 24ad2a1d481c910bb31d254c9666290767d627de
child 624803 6e1890744fd5509dc149700037d0216de208f517
push id54666
push userbmo:standard8@mozilla.com
push dateTue, 18 Apr 2017 21:12:38 +0000
reviewersMossop
bugs1357546
milestone55.0a1
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"
   ],