javascript - JSHint with Atom editor - ignore warnings - Stack Overflow

I am using the linter-jshint plugin for Atom editor.I want to disable showing a couple of specific erro

I am using the linter-jshint plugin for Atom editor.

I want to disable showing a couple of specific errors/warnings. For example: W003 - 'functionName' was used before it was defined..

Is it possible to specify an array of ignored errors/warnings somewhere in Atom's config.cson?

Basically I am asking if it's possible to do the same thing like in PyDev (Eclipse), where you can specify a list of errors/warnings to be ignored by pep8.

NOTE: I read the linter-jshint documentation but still don't know how to do this.

I am using the linter-jshint plugin for Atom editor.

I want to disable showing a couple of specific errors/warnings. For example: W003 - 'functionName' was used before it was defined..

Is it possible to specify an array of ignored errors/warnings somewhere in Atom's config.cson?

Basically I am asking if it's possible to do the same thing like in PyDev (Eclipse), where you can specify a list of errors/warnings to be ignored by pep8.

NOTE: I read the linter-jshint documentation but still don't know how to do this.

Share edited Nov 21, 2016 at 8:03 Dušan Maďar asked Mar 18, 2016 at 14:35 Dušan MaďarDušan Maďar 9,9596 gold badges56 silver badges71 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

It can be done with .jshintrc.

You need to prefix the warning code with -, e.g. -W003, and use true/false to turn it off/on.

At the very bottom of my .jshintrc:

  ...

  // Ignored Warnings
  "-W003": true
}

Source: https://gist.github./amatiasq/db597053f0f891ff7abc

The linter-js-hint suggests you modify the config.cson file by editing ~/.atom/config.cson. However, I would take a different approach. If you don't have a .jshintrc at the root level of your directory, I would create one.

What is a .jshintrc file? It'a a configuration file with rules that tell JSHint which rules to enforce. JSHint will start looking for this file in the same directory as the file that's being linted. If not found, it will move one level up the directory tree all the way up to the filesystem root.

Here is a standard .jshintrc file you can copy-paste and modify to your needs.

I remember not too long ago, I had linter-jshint in Atom warning me that I had a few variables that weren't defined in a file like jQuery or Angular, so I simply added & disabled my configuration file.

Example: at the bottom of my .jshintrc I added angular to my list of globals.

{

  "jquery": false,
   //.....more rules..
   // Custom Globals
   "globals": {        // additional predefined global variables
      "angular": false
    }
}

In general, I think it's a great practice to have a .jshintrc or eslintrc file in your project so if another developer inherits your codebase, their code editor can automatically enforce the rules in your .jshintrc file.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745060632a4608944.html

相关推荐

  • javascript - JSHint with Atom editor - ignore warnings - Stack Overflow

    I am using the linter-jshint plugin for Atom editor.I want to disable showing a couple of specific erro

    19小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信