linnarsson-lab / loom-viewer

Tool for sharing, browsing and visualizing single-cell data stored in the Loom file format
BSD 2-Clause "Simplified" License
35 stars 6 forks source link

Choosing a JavaScript linter + configuration #16

Closed JobLeonard closed 8 years ago

JobLeonard commented 8 years ago

@slinnarsson, I noticed that you also use Visual Studio Code. Since we're both using the same tool, let's install a linter and configure it to make life easier for us.

From a quick search, ESLint seems ilke the best option, since it is the only one with JSX support at the moment. It would also still work if we switch editors

http://eslint.org/

Here is the VSC plugin:

https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint

However, ESLint needs configuring before it works properly, so let's make sure we agree on the options. I've added a .eslintrc to the /js/ folder, with rules that I think make sense. Most of them will be fixed automatically (enforcing semi-colons, consistent use of ' or " around strings - if you prefer one over the other let me know) and the rest I will do manually. It also enforces some consistent coding styles; I've learned from the past that this is good because once we get used to it, it will be easier to read each other's code (and reading code is 90% of programming).

Here is the documentation for configuring ESlint, if you see any other options you'd like to add just modify the .eslintrc file accordingly:

http://eslint.org/docs/user-guide/configuring http://eslint.org/docs/rules/

slinnarsson commented 8 years ago

Sure. I have no strong opinions on the style, although I prefer tabs to spaces for indentation if that’s ok with you.

However, to get me started we’d need to merge branches, as I’m still on the dockerized branch where the .eslintrc doesn’t exist.

Btw the python plugin to VS Code is also excellent. That and the git integration made me switch from Sublime Text.

/Sten

Sten Linnarsson, PhD Professor of Molecular Systems Biology Karolinska Institutet Unit of Molecular Neurobiology Department of Medical Biochemistry and Biophysics Scheeles väg 1, 171 77 Stockholm, Sweden +46 8 52 48 75 77 (office) +46 70 399 32 06 (mobile)

On 27 Apr 2016, at 11:58, Job van der Zwan notifications@github.com<mailto:notifications@github.com> wrote:

Sten, I noticed that you also use Visual Studio Code. Since we're both using the same tool, let's install a linter and configure it to make life easier for us.

From a quick search, ESLint seems ilke the best option, since it is the only one with JSX support at the moment. It would also still work if we switch editors

http://eslint.org/

Here is the VSC plugin:

https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint

However, ESLint needs configuring before it works properly, so let's make sure we agree on the options. I've added a .eslintrc to the /js/ foler, with rules that I think make sense. Most of them will be fixed automatically (enforcing semi-colons, consistent use of ' or " around strings - if you prefer one over the other let me know) and the rest I will do manually. It also enforces some consistent coding styles; I've learned from the past that this is good because once we get used to it, it will be easier to read each other's code (and reading code is 90% of programming).

Here is the documentation for configuring ESlint, if you see any other options you'd like to add just modify the .eslintrc file accordingly:

http://eslint.org/docs/user-guide/configuring http://eslint.org/docs/rules/

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHubhttps://github.com/linnarsson-lab/Loom/issues/16

JobLeonard commented 8 years ago

although I prefer tabs to spaces for indentation if that’s ok with you.

Even better than that: we are in agreement there! Will add it to the configuration.

But then I'll first see if I can get the Google Cloud branch to work, and then we'll merge.

JobLeonard commented 8 years ago

So my linter kept complaining that JSX components were unused, even though they were. Since incorrect warnings kind of ruin the purpose of the linter I googled for a solution and found this:

https://github.com/yannickcr/eslint-plugin-react

Install with:

npm install eslint-plugin-react

NOTE: if you installed eslint globally, this plugin needs to be installed globally too!

I already added a bunch of rules consistent with the coding style I have been using to .eslintrc, so no other set-up is required.