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

Bug 497468

Summary: [eslint] Make eslint aware of envs if the corresponding index is loaded in Tern
Product: [ECD] Orion Reporter: Sebastian Pahnke <pahnke.sebastian>
Component: JS ToolsAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public, Michael_Rennie, Olivier_Thomann
Version: 13.0   
Target Milestone: 13.0   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Bug Depends on:    
Bug Blocks: 496701, 497870    

Description Sebastian Pahnke CLA 2016-07-07 05:49:13 EDT
If you load a tern index file like 'browser' in your .tern-project file, you used to also add an eslint-env directive to your code to enable content assist. Content assist is now enabled automatically if the index is loaded, however, you need to add the eslint-env directive anyway to get rid of any 'undefined variable' errors.

This is because eslint has its own env definitions and does not share them from Tern. Eslint should be made aware of any envs defined by Tern indexes.

This should also help fix this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=496701
Comment 1 Curtis Windatt CLA 2016-07-12 16:22:10 EDT
I think the fix is simpler than adding all defs to the environment.  If we can find type definition for the var/function then we don't mark a problem.  There is no need to check the eslint-env at all.

The question then is what we want the quick fixes to do. Quickfixes on console will add browser to eslint-env, foo() will add foo to globals, require will add amd to eslint-env.  The fixes will still remove the problem marker but they will not fix the project setup (like adding browser to to the .tern-project defs).  Are we ok with this?
Comment 2 Curtis Windatt CLA 2016-07-12 16:47:01 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=aa586d472bcf8c145b39fccf8e0f4302351df948
All tests pass with this change so I've pushed it to master.  Give it a try and see whether this behaviour is satisfactory.

If we can, I'd like to replace the add to eslint-env quickfix with the 'fix your project setup' quick fix we already use.  Currently we don't support it at all for missing definitions and it ends up being a two step process (add to eslint-env, get warning there, quickfix to fix project setup) for missing plugins such as using require() without node started.
Comment 3 Curtis Windatt CLA 2016-07-13 16:01:29 EDT
*** Bug 496701 has been marked as a duplicate of this bug. ***
Comment 4 Curtis Windatt CLA 2016-07-13 16:08:50 EDT
I opened Bug 497870 to follow up on the quick fix update.  I'm marking this as fixed as the problems do not get reported anymore.