Closed Bug 1259184 Opened 8 years ago Closed 8 years ago

eslint-plugin-mozilla: import-globals-from throws errors in Atom editor

Categories

(DevTools :: General, defect, P2)

defect

Tracking

(firefox48 fixed)

RESOLVED FIXED
Firefox 48
Tracking Status
firefox48 --- fixed

People

(Reporter: jsnajdr, Assigned: jsnajdr)

Details

(Whiteboard: [btpp-fix-later])

Attachments

(2 files)

Steps to reproduce:
1. Open the Mozilla project in Atom configured with ESLint (see the instructions at [1])
2. Open any file that uses import-globals-from and do something to trigger ESLint run

Actual result:
the eslint-plugin-mozilla throws an error that a file can't be found. See the attached screenshot.

- /devtools/client/animationinspector/animation-panel.js tries to import animation-controller.js
- ESLint tries to open /devtools/client/animation-controller.js with no success, because the path is one directory up!

After some debugging, I figured out that the helpers.getAbsoluteFilePath function returns malformed paths like:

/devtools/client/animationinspectoanimation-panel.js

and that happens when context.getFileName() returns a file name without any path info: "animation-panel.js". Then path.dirname of this is ".", but the code assumes that the dirname() result is always a prefix of the argument, which it isn't.
Attaching a patch - add a case when the filename doesn't have any path info. Fixes the problem in Atom for me.
Attachment #8734042 - Flags: review?(pbrosset)
Assignee: nobody → jsnajdr
Comment on attachment 8734042 [details] [diff] [review]
eslint-plugin-mozilla: import-globals-from throws errors in Atom editor

Review of attachment 8734042 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me. Tested on Sublime and Atom, worked fine for me.
Did you test that it still works from the command line with mach?
Attachment #8734042 - Flags: review?(pbrosset) → review+
(In reply to Patrick Brosset [:pbro] from comment #2)
> Did you test that it still works from the command line with mach?

Yes, command line invocation supplies the file names with absolute path.
Keywords: checkin-needed
Priority: -- → P2
Whiteboard: [btpp-fix-later]
https://hg.mozilla.org/mozilla-central/rev/55a506e5ae4e
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 48
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.