How to configure ESLint on WebStorm for multiple projects - config

I open many projects in my WebStorm at once, each of them can have a different ESLint config.
I would like to configure WebStorm to run the correct ESLint package based on the working file.

Should be able to click shift twice and search for eslint. You can configure your rules for each project there.

Related

How do you get ESLint working with VSCode, NVM, and Vue?

TL;DR: ESlint loads, but doesn't lint my files in VSCode. I've tried:
ensuring the plugin is enabled
ensuring Eslint is running in lint output window in VSCode
disabling ESLint in VSCode, reloading it, enabling it, reloading it - no change
ensuring it's enabled, and then restarting machine
Running it on the command line - which works
Story:
I'm working in VSCode. Can't get ESLint to work (the way I want) on my project within VSCode, with one exception. There are some library files that it lints relentlessly - all the ones in src/ or other Vue project dir's, not so much. So I thought it was the eslintrc. To disprove this, however, I run yarn lint - and it lints all the files in the vue directories specified by my eslint.
So definitely seems like an integrating with VSCode issue. Here are the details that are likely getting in the way:
I use NVM for node version management. Maybe VSCode isn't using the right version?

Configure IntelliJ project when importing when importing a Gradle project

Is there a way to import a Gradle Java project into IntelliJ 2017.2.x and apply some settings like
code style
vcs settings
from the Gradle build.gradle on project level?
I noticed that e.g. the Grails Framework uses the idea-gradle-plugin but this only works in combination with the Gradle task idea.
gradlew idea
I don't want to generate IntelliJ project files using a Gradle task. I would like IntelliJ to fetch the settings from the build file whenever I import the build.gradle file.
Is this possible?
Afaik no. You can only set in build.gradle what is supported by the DSL that then also is understood by the IDEA integration. There is no way to set arbitrary settings this way.
To do this, as you already found out, you need to hook into the IDEA project file generation and generate the settings you want like code style settings and VCS settings (I do both for our projects and more) and then use the idea task to generate the project files.
You can also configure IDEA to automatically run some Gradle task before refreshing the project, so you can make IDEA automatically run the idea task before refreshing and this should work then. The initial IDEA setup to do this though has either to be generated with idea, set-up manually by all devs or configured once and then checked in. But if you check-in the IDEA files, you can of course also simply check-in the code-style and VCS settings. Most of the IDEA project files are meant to be checked in anyway. Just some like the workspace file are meant to be developer-specific and thus excluded from being checked in.

Typescript: Yarn Workspaces IDE Support (IntelliJ, VSCode ...)

Working on a larger typescript project we decided to move the code to a monorepo with yarn workspaces.
We use webpack to build and bundle and everything works well (especially the linking between local modules/packages).
Since yarn workspaces will store most of the node_modules in the mono repo's root folder, the IDE (IntelliJ as well as VSCode) have problems resolving the imports to any node_modules when coding inside a "inner" project (so called "package" of a monorepo).
The strange thing is that imports are not known but on the other hand most of the time you can navigate to the correct source / definition within the IDEs for the same import if you write it down manually.
We have tried to tell IntelliJ to look into another folder for node_modules, but still not satisfying.
Please share your experience with yarn workspaces / monorepo (e.g. lerna) and how you develop the code living in these monorepos.
Which IDE do you use?
Did you add any special configurations to the IDE and/or package.json, tsconfig.json?
https://github.com/Izhaki/mono.ts
It uses yarn workspaces and marry well with VSCode. I hope the README is clear enough.
Basically, use two (parallel) typescript configuration trees:
Pre-build - uses aliases (for VSCode, tests, webpack, etc).
Build - uses typescript 3 project references for publishing essentially.
IDEA doesn't provide any support for Yarn workspaces; if you miss it, please follow WEB-29250 and linked tickets for updates.
You can try adding path mappings to your tsconfig.json - see https://intellij-support.jetbrains.com/hc/en-us/community/posts/207656825/comments/115000529564
Upodate as of 2018.1.1 IntelliJ now supports yarn workspaces so if you use this there should not be a problem.
https://blog.jetbrains.com/webstorm/2018/04/webstorm-2018-1-1/
Please share your experience with yarn workspaces / monorepo (e.g. lerna) and how you develop the code living in these monorepos.
Which IDE do you use?
Since you are asking. I basically ran into the same issues as you did. One solution I was looking into was disable hoisting node modules as described here. Unfortunately it seems it is not yet in the stable release.
What I ended up was ditiching workspaces for now until they fix either the IDE or release the nohoist option. Instead I am using lerna for now. It is less convenient but it does not hoist so that both the build tools and the IDE are satisfied.
Oh, I am also using IntelliJ (ultimate)

How to import and run existing plugins from intellij community edition repo

I'm trying to import and run the IntelliJ git4idea (Git Integration) plugin in order to play around and contribute some of my own code.
I've pulled the Intellij community edition from the github repo, and imported the git4idea plugin as a project. I'm running the Intellij community edition
My main issue is this:
After importing all the modules, the git4idea module comes up as a general module type, and not a plugin module type.
This means that when trying to create a new run\debug configuration, I get [none] under "Use classpath of module", instead of of the ability to select the git4idea plugin. This obviously results in a "Run configuration error: no plugin module specified for configuration".
So the question is -
How can I change the general type of imported "git4idea" to plugin type?
Or better yet, what are the steps required in order to import and build/debug/run a plugin from the Intellij community edition repo?
I was able to solve this by manually reordering file directories, sorting out dependencies and editing the .iml file. The type of plugin is defined by changing type="JAVA_MODULE" to type="PLUGIN_MODULE".
...
This is the answer given by Dmitry Jemerov on the official Jetbrains plugin development forum:
The easiest answer to this is "don't". The IntelliJ IDEA Community
Edition project is set up to be developed as a whole, and the
dependencies are set up accordingly. If you want to hack on the Git
plugin, you simply run IDEA using the provided run configuration, it
runs with all plugins enabled, and you simply make whatever changes
you need and test them using the main run configuration.
If you really want, you can set up a new plugin module and point it to
the source code of the git4idea plugin inside the IntelliJ IDEA
Community Edition Git checkout. This is not too hard, but it's
something you'll need to do from scratch, and you can't use the
existing .iml file.
I had the same no plugin module specified for configuration issue. To work around it, instead of importing, I created a new plugin project and used the existing code directory.
when you import the intelij plugin projects
You should run the 'runIde' task in gradle.
Step-by-step instruction
Build your IDEA plugin (usually done with gradle build).
Start Intellij IDEA.
If you have any project opened, go to menu "File->Close all projects" to return to Intellij IDEA startup screen.
Install the plugin you've just built: on the left side of the "Welcome to Intellij IDEA" startup screen go to "Plugins", then click "gear" icon on the right side, it's located to the right of "Marketplace" and "Installed". From the pop-up menu select "Install Plugin from Disk...", navigate to plugin file (usually in build folder) and click "Ignore and continue" when you see the warning message saying something about signature.
Restart Intellij IDEA.
Open the folder with your IDEA plugin.
Wait until IDEA imported your Gradle project.
Put breakpoints inside your plugin code so you can debug it.
Go to menu "Run->Edit configurations".
In the "Run/Debug Configurations" window on the left side click "+".
Select "Gradle" from the pop-up menu.
On the right side change "Name" to "gradle-run-ide" (without quotes).
On the right side under "Run", inside "Tasks and arguments" field enter runIde ("i" must be capital, other letters small).
Click "OK" to save changes.
Go to menu "Run->Debug 'gradle-run-ide'".
A new, black-colored IDEA window should appear.
In this black-colored IDEA window do whatever you need to do in order to invoke methods of your plugin. When you invoke them, the first IDEA window should stop you on breakpoints you set previously.
Happy debugging.
After changing type="JAVA_MODULE" to type="PLUGIN_MODULE" in *.iml file I was getting following error -
Error running 'IdeaPlugin': Wrong SDK type for plugin module
To fix this go to -
Module Settings -> Platform settings -> SDKs.
Click on Add new SDK
Select Intellij Platform plugin SDK
For home directory select your Inetllij installation dir
Select JAVA SDK you want to use with it.
Once this is added got to Module Settings again
Module Settings -> Project settings -> project.
In Project SDK change the JAVA sdk to the SDK we just added in the above steps.
Run/Debug you plugin now.

How to generate JavaScript files from CoffeeScript in IntelliJ IDEA?

I'm trying out CoffeeScript support in IntelliJ, and although the highlighting/completion/refactoring support looks great, I can't figure out a way to automatically compile my .coffee files to their .js counterparts in order to use them in web pages, unit tests, etc.
The documentation mentions using Node for this purpose, but I'm primarily interested in writing client side code. I'd probably be able to create a run configuration that would use Cake to create my JS files, but this won't integrate nicely with IDEA's integrated unit test support, etc.
So... any help?
Use the IntelliJ IDEA plugin: File Watchers.
You would need to install coffee-script package in the global directory. (npm install -g coffee-script).
While you are editing the CoffeeScript file in IntelliJ editor, there would be a notification showing on the top.
Click "Add watcher" and the IDE will compile your code for you on the fly.
More advanced options could be accessed via Project Settings/File Watchers.
See also the official document.