28

I have a .jshintrc at the root of my project with the following configuration:

{
  "node": true,
  "smarttabs": true,
  "undef": true,
  "unused": true
}

This is fine for all the node related stuff I have in the project, but not for the browser related scripts. Which are sitting in a subfolder.
Is it possible overwrite just the node option while preserving the other options for a whole folder?

If I create another .jshintrc file for the browser side folder I have to tell JSHint again about all my configurations, although I actually just want to unset the node option.

I know that I can set this option in every file but I actually would like to avoid that.

Many thanks in advance!

4

1 回答 1

42

是的,jshint v2.5.1中有一个“扩展”功能,对于您的示例,这可能是这样的:

/.jshintrc

{
  "smarttabs": true,
  "undef": true,
  "unused": true
}

/server/.jshintrc

{
  "extends": "../.jshintrc",
  "node": true
}

/client/.jshintrc

{
  "extends": "../.jshintrc",
  "browser": true
}

您可以在此处阅读有关此功能的更多信息: https ://github.com/jshint/jshint/releases/tag/2.5.1

于 2014-08-08T23:51:45.287 回答