ricardofbarros / linter-js-standard

Atom linter plugin for JavaScript, using JavaScript Standard Style
https://atom.io/packages/linter-js-standard
MIT License
99 stars 48 forks source link

`"$" is undefined ` errors when using JQuery #63

Closed ckib16 closed 8 years ago

ckib16 commented 9 years ago

Hey all - noob questions that I couldn't find an answer for.

1) I'm getting multiple "$" is undefined errors from the linter when entering standard JQuery code. Do I have to add $ to the "ignored list", or is there better integration with JQuery that I'm missing to avoid these errors?

2) I found out how to stop the errors in each file with /* global $ */. But how do I find the file package.json to ignore $ permanently? And is permanently ignoring $ a wise move?

Thanks, Chris screen shot 2015-10-21 at 17 20 53

shaungrady commented 9 years ago

In your package.json, add $ to your globals array.

{
  "name": "Example",
  "version": "1.0.0",
  "description": "Example package.json",

  "standard": {
    "globals": [
      "$"
    ]
  }
}
ricardofbarros commented 9 years ago

@shaungrady is absolutely correct :smiley:

ckib16 commented 9 years ago

Thanks guys, much appreciated. I will investigate the whole package.json thing. Take care.

ckib16 commented 8 years ago

Hey all,

Quick follow up question - I'm still getting multiple '$' is undefined errors even after modifying my ~/.atom/packages/linter-js-standard/package.json file as described above.

Here is my package.json:

...
  "devDependencies": {
    "standard": "^5.2.1"
  },
  "standard": {
    "globals": [
      "atom",
      "$"
    ]
  },
  "package-deps": [
    "linter"
  ],
...

The atom line was already inside the globals array, so I didn't want to mess with it. I just added in "$" below it. I also tried:

Any ideas? Syntax error in my package.json file?

shaungrady commented 8 years ago

You shouldn't be modifying the package.json of the Atom package. You should adding/modifying rules in the package.json associated with whatever project you're working on. E.g., ~/My Repositories/my-project/package.json

ckib16 commented 8 years ago

Ah...

Ok, I'm trying to use it to lint JS inside of a Rails app, so I don't have a package.json. I'll have to experiment to see if there's a way to integrate it into Rails.

Any tips appreciated if someone has done this before. Thanks for the help,

shaungrady commented 8 years ago

package.json is for configuring npm, it doesn't directly relate to ESLint. For your Rails app, simply create a .eslintrc.js file at the root of your project. See the ESLint docs for more information: http://eslint.org/docs/user-guide/configuring#configuration-file-formats

ckib16 commented 8 years ago

Wow, thanks @shaungrady . I would never have found that. I'll take it from here, much appreciated!

shaungrady commented 8 years ago

No problem, happy coding

timobleeker commented 8 years ago

I'm having the same problem as @ckib16, and I'm not sure what to put into .eslintrc.js to make it work.