Bug 1259184 - eslint-plugin-mozilla: import-globals-from throws errors in Atom editor. r=pbro
authorJarda Snajdr <jsnajdr@gmail.com>
Wed, 23 Mar 2016 12:32:00 +0100
changeset 290853 55a506e5ae4ed3dc008be28a812ca4c0e45be7be
parent 290852 1b45c030f024b195ad68b3680306e873bc11deb1
child 290854 078fb73f17c26edffad5a5051991771e14f94d35
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1259184
milestone48.0a1
Bug 1259184 - eslint-plugin-mozilla: import-globals-from throws errors in Atom editor. r=pbro
testing/eslint-plugin-mozilla/lib/helpers.js
--- a/testing/eslint-plugin-mozilla/lib/helpers.js
+++ b/testing/eslint-plugin-mozilla/lib/helpers.js
@@ -410,16 +410,20 @@ module.exports = {
     var fileName = this.cleanUpPath(context.getFilename());
     var cwd = process.cwd();
 
     if (path.isAbsolute(fileName)) {
       // Case 2: executed from the repo's root with mach:
       //   fileName: /path/to/mozilla/repo/a/b/c/d.js
       //   cwd: /path/to/mozilla/repo
       return fileName;
+    } else if (path.basename(fileName) == fileName) {
+      // Case 1b: executed from a nested directory, fileName is the base name
+      // without any path info (happens in Atom with linter-eslint)
+      return path.join(cwd, fileName);
     } else {
       // Case 1: executed form in a nested directory, e.g. from a text editor:
       //   fileName: a/b/c/d.js
       //   cwd: /path/to/mozilla/repo/a/b/c
       var dirName = path.dirname(fileName);
       return cwd.slice(0, cwd.length - dirName.length) + fileName;
     }
   },