简体   繁体   English

JSHint:覆盖整个文件夹的单个.jshintrc选项

[英]JSHint: Overwrite single .jshintrc option for whole folder

I have a .jshintrc at the root of my project with the following configuration: 我在项目的根目录下有一个.jshintrc ,具有以下配置:

{
  "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? 是否可以覆盖node选项,同时保留整个文件夹的其他选项?

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. 如果我为浏览器端文件夹创建另一个.jshintrc文件,我必须再次告诉.jshintrc我的所有配置,尽管我实际上只想取消设置node选项。

I know that I can set this option in every file but I actually would like to avoid that. 我知道我可以在每个文件中设置此选项,但实际上我想避免这种情况。

Many thanks in advance! 提前谢谢了!

Yes, there's a feature in jshint v2.5.1 that is "extends", for your example this could be like this: 是的, jshint v2.5.1中有一个“扩展”的功能,对于你的例子,这可能是这样的:

/.jshintrc /.jshintrc

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

/server/.jshintrc /server/.jshintrc

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

/client/.jshintrc /client/.jshintrc

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

You can read more about this feature here: https://github.com/jshint/jshint/releases/tag/2.5.1 您可以在此处阅读有关此功能的更多信息: https//github.com/jshint/jshint/releases/tag/2.5.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM