如何设置jshint/jsxhint"esnext" Atom中的选项 [英] How to set jshint/jsxhint "esnext" option in Atom
问题描述
我正在使用Atom的linter
,react
和linter-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
警告:导入"仅在ES6中可用(使用esnext选项). (W119)
Warning: 'import' is only available in ES6 (use esnext option). (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 .jshintrc
if 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会在多个位置查找此配置,并在第一个正匹配项处停止:
jshint will look for this configuration in a number of locations, stopping at the first positive match:
-
用--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
位于当前用户"home"目录中的名为.jshintrc的文件.目录(已定义)
A file named .jshintrc located in the current user's "home" directory (where defined)
这篇关于如何设置jshint/jsxhint"esnext" Atom中的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!