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

ignored globals in package.json #58

Closed nikmartin closed 9 years ago

nikmartin commented 9 years ago

I added this to the package.json file in the root of my node.js app:

  "semistandard": {
    "global": [ "__base" ]
  }

and in hundreds of files in the project, I have this:

var util = require(__base + '/models/schemas/util');

But still continually get this message: screenshot from 2015-10-09 09-03-47

sandnuggah commented 9 years ago
{
  "semistandard": {
    "globals": [ "__base" ] // the key is `globals`, not `global`
  }
}

Restart Atom for changes to have effect.

nikmartin commented 9 years ago

OK, I couldn't find any docs, so I went to the source, lib/style-settings.js: 66 and found this: styleSettings.global = styleSettings.global || styleSettings.globals So I just took the first option global and used it.

nikmartin commented 9 years ago

Also, That didn't have any effect:

"semistandard": {
    "globals": [
      "__base"
    ]
  }

screenshot from 2015-10-13 08-01-19

sandnuggah commented 9 years ago

Have a look here

https://github.com/feross/standard/blob/master/README.md#i-use-a-library-that-pollutes-the-global-namespace-how-do-i-prevent-variable-is-not-defined-errors

nikmartin commented 9 years ago

I don't know why it's not honoring the setting then, I have tried it both as:

"semistandard": {
    "globals": [
      "__base"
    ]
  }

and

"semistandard": {
    "global": [
      "__base"
    ]
  }

Restarting each time, and the warnings never go away.

ricardofbarros commented 9 years ago

Hey guys, thanks for your help @sandnuggah.

Hmm that's awkward, let me take a look.

nikmartin commented 9 years ago

If you need me to debug anything, let me know.

ricardofbarros commented 9 years ago

Can you do something for me? cd /to/the/directory/where/is/your/file and run semistandard yourFilename.js and tell me if it shows the same warning on the terminal.

nikmartin commented 9 years ago

In a file with only a single 'not defined' warning I get no warnings running semistandard on the command line. In a file with a 'not defined' + other warnings, I only get the other warnings.

ricardofbarros commented 9 years ago

What settings you have ticked on linter-js-standard plugin settings?

nikmartin commented 9 years ago

None are selected at the moment:

"linter-js-standard":
    style: "semi-standard"
ricardofbarros commented 9 years ago

Well if you want your style settings to be honoured you need to tick the Honor Style Settings

ricardofbarros commented 9 years ago

So did it worked?

nikmartin commented 9 years ago

I checked Honor Style Settings and it is working now. I took the README literally, and since it says:

Current style settings supported:
- `ignore`
- `parser`

I didn't think it applied to globals. Should I add some documentation about it and submit a pull request? I didn't even know how to add support for globals until I read the source code and the standard lib's readme.

ricardofbarros commented 9 years ago

Sure @nikmartin I would appreciate that :)

ricardofbarros commented 9 years ago

66 Merged, thanks for the PR @nikmartin