Continue Discussion 37 replies
Apr '16

philipmjohnson

I am trying to set up ESLint for Meteor and IntelliJ IDEA (i.e. WebStorm). I can run ESLint with the Meteor command just fine following the directions. My issue is with IntelliJ IDEA. First, I suggest that you make it explicit that you need to install ESLint a second time for IntelliJ, and to do this you need to install node/npm globally, plus (at least in my case), you need to run the following command so that IntelliJ can find the eslint airbnb package:

npm install -g eslint-config-airbnb

Once I got through all this, I wondered why I couldn’t configure IntelliJ to use the version of node/npm installed with Meteor. After some searching, I found the path to the Meteor version of node here:

.meteor/packages/meteor-tool/1.3.1/mt-os.osx.x86_64/dev_bundle/bin

However, I could not find the eslint package anywhere in the ~/.meteor directory, or in my app’s .meteor directory.

If someone could figure out the correct configuration for IntelliJ to use Meteor’s version of node and libraries, I think that would be an improvement.

1 reply
Apr '16 ▶ philipmjohnson

tmeasday

Hi @philipmjohnson,

Is there any way to point Webstorm at the local npm packages? That would be ideal (allows different projects to use different plugins+versions from npm without having to install them all globally).

If you figure it out, please please send a PR to the guide!

Apr '16

philipmjohnson

I just realized that as of 1.3 there’s a project-specific node_modules/ directory…

It looks like configuring IntelliJ to use Meteor’s node installation (as opposed to the global one) is quite simple: point IntelliJ’s project-specific preferences at the node binary installed in ~/.meteor, and at <project>/node_modules/eslint. See the following image:

So far, so good. I don’t want to submit a PR until I’ve used this a bit more. :slight_smile:

Apr '16

seanbannister

I’m wondering if the Code Style documentation should also include a recommendation for JavaScript documentation, I believe Meteor core uses JSDoc?

1 reply
Apr '16

will

I’m thinking eslint shouldn’t give errors when following the guide, eg after creating a new default app. Or to be more precise – I was expecting it not to give errors, and it did.

Eg running:

meteor create myapp
meteor npm install
meteor npm install --save-dev eslint eslint-plugin-react eslint-plugin-meteor eslint-config-airbnb

and populating scripts and eslintConfig as above in package.json, then "meteor npm run lint" gave me:

> myapp@ lint /opt/www/sites/me/myapp
> eslint .


/opt/www/sites/me/myapp/client/main.js
   1:26  error  Unable to resolve path to module 'meteor/templating'    import/no-unresolved
   2:29  error  Unable to resolve path to module 'meteor/reactive-var'  import/no-unresolved
  18:25  error  Invalid parameter name, use "templateInstance" instead  meteor/eventmap-params

/opt/www/sites/me/myapp/server/main.js
  1:24  error  Unable to resolve path to module 'meteor/meteor'  import/no-unresolved

✖ 4 problems (4 errors, 0 warnings)

I eventually made it quiet with rules in package.json:

"rules": {
  "meteor/eventmap-params": [
    2, { "templateInstanceParamName": "instance" }
  ],
  "import/no-unresolved": [
    2, { "ignore": ["^meteor/"] }
  ]
}

Should that be included or noted?

2 replies
Apr '16 ▶ will

sashko MDG Staff

Yeah we should definitely either fix this or mention it in the guide. If you have a moment, please submit a PR to add your config to the guide!

Apr '16

suhaila

This type of import works in Meteor

import xxx from ‘/client/xxx’

but it is shown as import/no-unresolved when linting. This can be solved using ignore rule in eslintrc. Is there any other way to satisfy this rule instead of ignoring it.

1 reply
Apr '16 ▶ suhaila

sashko MDG Staff

@suhaila yeah check the bottom of this section, it tells you how to ignore only meteor/*: http://guide.meteor.com/code-style.html#eslint-installing

Apr '16

trajano

Perhaps we can add something about meteor lint and use something like https://atmospherejs.com/dburles/eslint to perform the linting for us. I say “something like” as I get Error: No os unibuild for null! when using eslint as noted by https://github.com/meteor/meteor/issues/6843#issuecomment-215804381

May '16

trajano

Instead of defining the ignores yourself I recommend adding https://github.com/clayne11/eslint-import-resolver-meteor this will reduce your rules to {}

Here’s the relevant PR https://github.com/meteor/guide/pull/434 perhaps someone can take the time to update the todo app?

However if you need an example of this, I have it on https://github.com/trajano/meteor-boilerplate/blob/meteor-skeleton-1.0.3/.eslintrc.json

The angular branch of my boilerplate has an unstyled todo app written in AngularJS1 since angular1 doesn’t seem to get enough love here :slight_smile:

1 reply