本文介绍了如何设置jshint/jsxhint“esnext"Atom 中的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Atom 的 linterreactlinter-jshint/linter-jsxhint.在我的 JSX 文件中,我不断收到警告

I am using Atom's linter, react, and linter-jshint/linter-jsxhint.In my JSX files, I keep getting the warning

警告:'import' 仅在 ES6 中可用(使用 esnext 选项).(W119)

这很简单.我做了一些搜索,发现可以在 package.json 中的 jshintConfig 选项下设置(使用 NPM 时).我的项目使用 NPM,我有一个 package.json.我补充说:

That's pretty straightforward. I did some searching, and found that this can be set under the jshintConfig option in package.json (when using NPM). My project uses NPM and I have a package.json. I added:

"jshintConfig": {
  "esnext": true
}

在那之后,我重新加载,但警告仍然存在.我还在 Atom (config.cson) 中修改了我的 linter-jshint/linter-jsxhint 配置:

After that, I did a reload but the warnings persist. I also modified my linter-jshint/linter-jsxhint config in Atom (config.cson) with:

"linter-jshint":
  harmony: true
  esnext: true

"linter-jsxhint":
  harmony: true
  esnext: true

并重新加载,但这也无济于事.

And did a reload but that didn't help it either.

所以:当使用 linter-jshint/linter-jsxhint 作为 Atom 包时,如何设置 esnext 选项?

So: when using linter-jshint/linter-jsxhint as Atom packages, how to I set the esnext option?

推荐答案

第一种可能性,推荐:你可以在你的主目录中创建一个 .jshintrc 并且 jshint 会读取如果项目目录中没有.之后您可能需要重新启动 Atom.

First possibility, recommended : you can create a .jshintrc in you home directory and jshint will read it in case there is none in the project directory. You might need to restart Atom after.

另一种可能性不推荐:如果出于某种原因您不想要,您还可以更改 Atom 中 jshint 的配置并指定全局 .jshintrc 的位置将其放入带有标志 --config

Another possibility not recommended : you could also change the config of jshint in Atom and specify the location of your global .jshintrcif for some reason you don't want to put it in your home directory with the flag --config

'linter-jshint':
  'jshintExecutablePath': /path/to/jshint --config /path/to/.jshinrc

运行'which jshint'来查找路径.不推荐这样做,因为所有其他 .jshinrc 文件(在项目中等)都将被忽略:

Run 'which jshint' to find the path.It is not recommended because every other .jshinrc file (in the project, etc.) will be ignore:

jshint 将在多个位置查找此配置,在第一个正匹配时停止:

  • 使用 --config 标志指定的位置

  • The location specified with the --config flag

位于当前目录或当前目录的任何父目录中的名为 package.json 的文件(配置应声明为该文件的 JSON 值的 jshintConfig 属性)

A file named package.json located in the current directory or any parent of the current directory (the configuration should be declared as the jshintConfig attribute of that file's JSON value)

位于当前目录或当前目录的任何父目录中的名为 .jshintrc 的文件

A file named .jshintrc located in the current directory or any parent of the current directory

一个名为 .jshintrc 的文件位于当前用户的家"中目录(定义的地方)

A file named .jshintrc located in the current user's "home" directory (where defined)

这篇关于如何设置jshint/jsxhint“esnext"Atom 中的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 14:29