Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 511478

Summary: .eslintrc file not found consistently
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: JS ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: curtis.windatt.public, steve_northover
Version: unspecified   
Target Milestone: 14.0   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Fix
none
updated fix
none
better fix none

Description Mark Macdonald CLA 2017-02-01 10:21:38 EST
1. git clone <contact me for the repo URL>
2. Launch the Orion electron app
3. File > Open Folder, select the cloned repo, hit OK
4. Open the file tests/ui-tests/createToolchain-page-tests.js in the editor

Now you should see warnings on lines 11-20 complaining about 'require' -- this suggests that Orion is not obeying the .eslintrc file at the top of the repo.

5. Use the navigator to open a different file, then return to createToolchain-page-tests.js
6. Now the errors from step 4 have disappeared.

At this point the linter works as expected, but if I reload the tab (Cmd + R), the warnings from step 4 appear again.

It seems that .eslintrc is not found in the "cold load" scenario, when you're editing a file for the first time in a particular tab.
Comment 1 Mark Macdonald CLA 2017-02-01 10:30:09 EST
I was running this build of the Orion electron app

> Build ID: 2017-01-31_14-51-08
Comment 2 Michael Rennie CLA 2017-02-01 11:35:32 EST
This is the result of a timing issue. With the new support to sniff around to find a project context, it can happen that we are still trying to figure out the project when the call to perform the linting happens - which has no project context yet, and therefore does not read the .eslintrc file correctly.
Comment 3 Michael Rennie CLA 2017-02-01 12:33:00 EST
Created attachment 266572 [details]
Fix

Here is the fix. Curtis, can you sanity-check this before I push it? I removed one layer of promise from the project resolution code, and cleaned up the lint file reading code.
Comment 4 Michael Rennie CLA 2017-02-01 13:37:52 EST
Created attachment 266573 [details]
updated fix

Updated patch
Comment 5 Michael Rennie CLA 2017-02-01 14:21:05 EST
Created attachment 266574 [details]
better fix

Here is a better fix that properly rejects the next chained promise while reducing. Also adds support that if we "sniffed" and came up empty, we just assume the project context is "/file/"
Comment 6 Curtis Windatt CLA 2017-02-01 15:20:56 EST
To reproduce I had to insert a timeout in the project file read, otherwise my first lint operation always took long than the read.  Once I forced the setup, testing the fix is relatively straight forward and it works as designed.

There are some lint warnings in the code that should be fixed.

+1