This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 467903 - [eslint] Consume rules from eslint library
Summary: [eslint] Consume rules from eslint library
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: JS Tools (show other bugs)
Version: 8.0   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: 11.0   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 484515
  Show dependency tree
 
Reported: 2015-05-21 13:04 EDT by Curtis Windatt CLA
Modified: 2015-12-16 15:12 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Curtis Windatt CLA 2015-05-21 13:04:10 EDT
https://dev.eclipse.org/ipzilla/show_bug.cgi?id=8420
Due to lack of a CLA we have been unable to use the rules from ESLint in Orion.  However, we can apply for an exception.  This bug is to capture the pros and cons of doing so.
Comment 1 Curtis Windatt CLA 2015-05-21 13:16:52 EDT
On the Orion dev mailing list, Max noted that Eclipse approved usage of momemt.js and Bootstrap UI which had similar(ish?) IP issues.  Mike Milinkovich also pointed out the exceptions in the IP process.

Pros:
- Less code to maintain in Orion
- Get any bug fixes and new rules for 'free'.

Cons:
- The eslint rules are delivered in separate files.  This caused timeout issues for us previously when loading all the rule files using require.js.
- We have solid test coverage for our existing rules.  Our rules are integrated into other tooling (settings page and the content assist proposals for inline eslint settings for example).
- We would need to more frequently do the CQ process to update ESLint versions.
- Some (many?) of the rules we don't currently implement are formatting rules which we may not want to use (or at least will require a quickfix).
Comment 2 Mark Macdonald CLA 2015-05-21 13:22:25 EDT
pro:
+ larger ruleset than Orion's
+ good ES6 support across rules (Orion's is patchy)

con: 
- upstream ESLint's rules are not externalized for i18n
- their context#report() API doesn't support flagging the problematic token. (I believe you are limited to flagging an AST node, though this may've changed since I last looked.)
- IIRC some Orion rules instrument their reported problems to make it easier to provide quick fixes.. this would be lost
Comment 3 Michael Rennie CLA 2015-05-21 13:55:18 EDT
All of the above, plus: not really a pro or con - we would still have to edit eslint to accept ASTs rather than text, leading to...

cons

- eslint now uses their own parser, so we have to shake out (fix) incompatibility issues (espree vs. esprima, if any).
Comment 4 Carolyn MacLeod CLA 2015-05-21 15:01:52 EDT
Assigning to Mike to determine priority.
Comment 5 Michael Rennie CLA 2015-05-22 13:59:32 EDT
(In reply to Carolyn MacLeod from comment #4)
> Assigning to Mike to determine priority.

I'm going to leave this as normal priority. To be honest I am undecided about the benefits of using the upstream rules. 

1. We have built a lot of features around our rules, which we would lose, 
2. We would have to tackle the timeout problems again (for loading N rule files vs. our one 'rule' file)
3. we would still have to wire all of the rules up for prefs, etc (or they will not be used)
4. we have already implemented most of the rules we think would be useful in the IDE (we are always adding more though)
5. either way we will still have to modify eslint to make it work in Orion
Comment 6 Max Rydahl Andersen CLA 2015-05-22 15:07:14 EDT
Any reason for why we haven't contributed back to eslint esprima support and/or have a way to bundle up the rules in one file automatically ?

wouldn't those things back in eslint reduce the overhead orion would have to maintain ?
Comment 7 Michael Rennie CLA 2015-05-25 10:07:53 EDT
(In reply to Max Rydahl Andersen from comment #6)
> Any reason for why we haven't contributed back to eslint esprima support
> and/or have a way to bundle up the rules in one file automatically ?
> 

ESlint used to run on Esprima, but now they use their own parser Espree (which is a fork of Esprima, and still Mozilla-spec compliant). The rule-loading-timeout issue is really only prevalent in target sites, making it more of an annoyance than a critical problem (its all minified and combined in our build anyway), so to be honest, there hasn't been anything for us to contribute back in this space, which is why we haven't.

We have opened an issue for allowing ASTs to be used rather than source (https://github.com/eslint/eslint/issues/1025), and we should probably open issues for the context.report() API update as well.
Comment 8 Michael Rennie CLA 2015-11-26 13:55:03 EST
The CQ for ESLint 1.9.0 (bug 482505) also gave us the green light to directly consume the upstream rules. We should start by trying out a few of the upstream rules the we wrote our own version for and run the unit tests + smoke tests to see whats happening.
Comment 9 Olivier Thomann CLA 2015-12-15 17:46:12 EST
I am preparing a first set of new rules for:
		'accessor-pairs'
		'no-control-regex'
		'no-duplicate-case'
		'no-empty-character-class'
		'no-extra-boolean-cast'
		'no-extra-parens'
		'no-invalid-regexp'
		'no-negated-in-lhs'
		'no-obj-calls'
		'no-eq-null'
		'no-else-return'
Comment 10 Eclipse Genie CLA 2015-12-15 17:48:08 EST
New Gerrit change created: https://git.eclipse.org/r/62771
Comment 11 Eclipse Genie CLA 2015-12-15 17:51:15 EST
New Gerrit change created: https://git.eclipse.org/r/62774
Comment 12 Olivier Thomann CLA 2015-12-15 17:53:33 EST
(In reply to Eclipse Genie from comment #10)
> New Gerrit change created: https://git.eclipse.org/r/62771
This is abandonned. I forgot to enable all the tests again. I was running only the validator tests when adding new tests for the new rules.
Comment 13 Eclipse Genie CLA 2015-12-16 10:08:03 EST
New Gerrit change created: https://git.eclipse.org/r/62830
Comment 15 Curtis Windatt CLA 2015-12-16 12:47:40 EST
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=194790e72101239a03941a9ad11eab6b97760152
Gerrit patch has been merged with master

Great work Olivier.  We now exceed 2000 tests in our suite.  The consumption of the rules looks good and the change removes the need for an Orion change in ESLint.  I have some minor concerns with the rules themselves which I will bring up in another bug if substantiated.  Also, the wiki page needs to be updated with the new rules.

https://wiki.eclipse.org/Orion/ESLint

As we add more rules from ESLint we will open new bugs as necessary.
Comment 16 Curtis Windatt CLA 2015-12-16 15:12:44 EST
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=ede415417c37de69bff53990fe03a00dcefff0b9
Had to change how we loaded the rules.