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

Bug 495742

Summary: [eslint][quickfix] no-unsued-vars rule needs option to mark global var as used/exported in another file plus quickfix
Product: [ECD] Orion Reporter: Jenny Han <jhan>
Component: JS ToolsAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public
Version: unspecified   
Target Milestone: 13.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Jenny Han CLA 2016-06-08 15:17:36 EDT
1. Copy and paste: var test = "check"; into one .js file
2. Copy and paste var another = test; into another .js file in the same directory

In the first .js file, the variable test will have a warning "'test' is unread."
It not expected to have this warning.
Comment 1 Curtis Windatt CLA 2016-06-08 15:30:57 EDT
no-unused-vars only considers the contents of the file in which it is defined.  If you are using a module system you would have mark the variable as exported if it was going to be used in another file.  In this case you are adding things to the global scope which happens to be used in another file.

The ESLint upstream implementation of the rule requires you to mark implicit exports like this with a /* exported */ comment.
http://eslint.org/docs/rules/no-unused-vars

We could do the same for our rule with a matching quick fix to mark global vars with the comment.
Comment 2 Curtis Windatt CLA 2016-07-14 16:58:44 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=631bec75104df498b9b52da861dc3577a79d97e1
Fixed in master with tests

However, I did not add a new quickfix which makes this feature not very discoverable.  Our quickfixes plugin is set up to provide one quickfix for a given problem id and the 'remove unused var' quickfix is far more helpful.  Supporting exported keyword is worthwhile to keep us inline with the upstream eslint rule.