Configuring JavaScript code inspection for all developers on a project

I have a node.js project, and I am trying to get ESLint code inspection working and checked in to source control so that it works the same for all developers on the project.  I got things working well on my machine by creating a proper scope, downloading a bunch of @types files, and customizing the code inspection settings.

For source control, I notices all the @types files I downloaded showed up in site.iml, and that was already in source control.  I also added .idea/inspectionProfiles/Project_Default.xml and .idea/scopes/ESLint.xml to source control.

I shelved everything and unshelved it on a different Perforce client on the same machine to simulate what will happen when another developer on the project gets my changes.  Mostly, things work - my scope and inspection settings all appeared to transfer to the new project.  However, when I run Code > Inspect Code... I get 78 errors in the new location that I was not getting in the old location.  77 of the errors are unresolved process.env variables:

They are defined in the .env file in the project.  I don't understand why in one instance of this project on the same machine, these things are resolved, but not in the other.  If I go to the project that works and Ctrl+Click on LOG_LEVEL, it takes me to:

in %USER_PROFILE%\.WebStorm2018.1\config\javascript\extLibs\global-types\node_modules\@types\node\index.d.ts.

Maybe this is why:  In the project that works, if I go to Settings > Languages & Frameworks > JavaScript > Libraries, I see this:

But in the project that has the extra errors, that same screen looks like this:

The second project is missing Node.js core, plus most of the boxes for the @types are not checked.  Is there a way to keep this in sync for all developers on a project?  Is this why I seeing differences in code inspection?

Thanks,

Eric

 

0
10 comments

>Is there a way to keep this in sync for all developers on a project? 

library mappings are stored in project .idea folder, jsLibraryMappings.xml file. So you need to make sure to commit it to version control to share it with your co-workers

 

>Is this why I seeing differences in code inspection?

 

yes, likely. As it resolves to config\javascript\extLibs\global-types\node_modules\@types\node\index.d.ts, you need to make sure that @types/node library is enabled

0

Yes, I think .idea/jsLibraryMappings.xml is what I was missing. It was not in source control.

Follow up question:  What should that file look like?  Our project .iml file (site.iml) has a bunch of @types libraries listed:

<orderEntry type="library" name="@types/helmet" level="application" />
<orderEntry type="library" name="@types/entities" level="application" />
<orderEntry type="library" name="@types/bunyan" level="application" />
<orderEntry type="library" name="@types/express" level="application" />

jsLibraryMappings.xml has *some* of those listed in the <file url="PROJECT"/> element:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="PROJECT" libraries="{@types/jquery, @types/mongoose, @types/node, @types/passport, @types/request, @types/request-promise, @types/sequelize}" />
<includedPredefinedLibrary name="HTTP Response Handler" />
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>

but not all.of them are there. The ones listed in jsLibraryMappings.xml are what shows up in Languages & Frameworks > JavaScript > Libraries allowing you to "enable" them.  Should those lists pretty much match up?  Maybe they don't because I was checking in site.iml but not jsLibraryMappings.xml.

Thanks!

Eric

0

> Should those lists pretty much match up? 

 

yes; and both files have to be versioned

0

OK, I'm all set.  Thanks very much!

Eric

0

OK, I'm not all set.  I did all this stuff and checked it in.  My co-worker sync'd it, and none of the libraries show up.  All the libraries are in his site.iml and jsLibraryMappings.xml, but when he goes to Settings > Languages > JavaScript > Libraries, none of the libraries I added show up there.  Why aren't they getting picked up?

Eric

0

All your libraries are global, and needed typings are stored in IDE configuration folder (.WebStorm2018.1\config\javascript\extLibs\global-types\node_modules\). .idea project files just reference them. So, unless you co-worker has the same typings available in his Webstorm configuration directory, mappings will do nothing

0

So, if I want this to work, I need for my libraries to not be global?  I need them to be "Project"?  You've led me down the primrose path a bit here (well, the software, not you personally :-).  I'm playing around trying to make things "project" and it is definitely not intuitive.

Eric

0

Yes - you need either storing all libraries in your project or sharing your IDE configs with your co-workers.

Note that you can install all needed typings in your project node_modules folder using `npm i @types/<library name> --save-dev` - sharing your package.json will then be enough

0

OK, thanks, I'll use "npm i --save-dev" and save all the types locally.  Do I then need nothing in Languages and Frameworks > JavaScript > Libraries?

What about "Node.js Core"?  That is a "predefined" library.  That one did not show up for my co-worker either.  UPDATE: Maybe it's really @types/node that is the issue, and that will come through package.json.

What is the downside of sharing IDE settings (which I assume means checking in workspace.xml)?  I would like to do that so that we share configurations.  But most advice you find on the web suggests not checking in workspace.xml.

Thanks!

Eric

0

>Do I then need nothing in Languages and Frameworks > JavaScript > Libraries?

 

you won't need using them then

 

>What about "Node.js Core"?  That is a "predefined" library

 

he has to enable it in Settings | Languages & Frameworks | Node.js and NPM

 

>What is the downside of sharing IDE settings (which I assume means checking in workspace.xml)? 

No, nothing of the kind; workspace.xml is your project file that should never be version controlled as it stores your local info and changes each time you open/edit a file, etc. IDE settings are stored in IDE configiration directory (~/.WebStorm2018.1/config)

0

Please sign in to leave a comment.