Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESlint in Eclipse

Tags:

eclipse

eslint

I have been given a web project at work that has a .eslintrc file in it and was told to use it.

I gather that this enforces code styles and sounds like a good idea, but I have never done this before.

I just switched to Eclipse Neon. But I can find no tutorials on how to use it. I did find something that says eslint is now the default linter for Eclipse but that was for Orion. Can someone tell me how to use my .eslintrc file for all my .js files in Eclipse?

like image 614
mmaceachran Avatar asked Jul 01 '16 18:07

mmaceachran


People also ask

What is ESLint used for?

ESLint is a static code analysis tool for identifying problematic patterns found in JavaScript code. It was created by Nicholas C. Zakas in 2013. Rules in ESLint are configurable, and customized rules can be defined and loaded.

How do I enable ESLint?

To configure ESLint automatically in all new projects, open the Settings for New Projects dialog (File | New Projects Setup | Settings/Preferences for New Projects) , go to Languages & Frameworks | JavaScript | Code Quality Tools | ESLint, and select the Automatic ESLint configuration option.


2 Answers

According to this, you have to install Tern into your Eclipse, then configure it to use the ESLint linter. It's not clear (to me) whether or not the plugin will use your .eslintrc for configuration; it talks about an ESLint JSON configuration file instead.

like image 181
E-Riz Avatar answered Sep 30 '22 21:09

E-Riz


I'm using Neon myself, and this is how you configure ESLint:

  1. Create an ESLint JSON configuration file by following these instructions.

  2. Go to Project / Properties / JavaScript / Tern / Validation / ESLint and check "Use config files":

    enter image description here

  3. Enter the path to your eslint.json file (or whatever you named the file you created from step 1) and press OK.

If you want to disable ESLint (or any other module), go to Project / Properties / JavaScript / Tern / Modules and uncheck it.

like image 24
thdoan Avatar answered Sep 30 '22 20:09

thdoan