javascript 带有语法和 eslint 的 vim:显示警告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27625061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 07:43:39  来源:igfitidea点击:

vim with syntastic and eslint: show warnings

javascriptvimsyntasticeslint

提问by Jonathan.Brink

I'm using Vim with the syntasticplugin and eslint.

我将 Vim 与Syntastic插件和 eslint 一起使用。

When I save a JavaScript file, I can see errors come up just fine, but I can't get the warnings to show.

当我保存 JavaScript 文件时,我可以看到错误出现得很好,但我无法显示警告。

Here's what I have in my .vimrc:

这是我的 .vimrc 中的内容:

let g:syntastic_javascript_checkers = ['eslint']

让 g:syntastic_javascript_checkers = ['eslint']

I installed eslint with:

我安装了 eslint:

npm install eslint -g

npm 安装 eslint -g

I'm running Linux Mint 17

我正在运行 Linux Mint 17

How do I get warnings to appear?

如何让警告出现?

采纳答案by Jonathan.Brink

It turns out the issue here was that the "warnings" I thought I had in my file were not actually warnings. When I put an actualwarning in my file it showed up correctly.

事实证明,这里的问题是我认为我的文件中的“警告”实际上并不是警告。当我在文件中添加实际警告时,它显示正确。

Some advice I learned though was to first run the file on the command-line directly using eslint similar to this:

我学到的一些建议是首先使用类似于以下的 eslint 在命令行上直接运行文件:

eslint /path/to/file.js

Then compare those results to what you see in Vim.

然后将这些结果与您在 Vim 中看到的结果进行比较。

Another tip is that you can change rules on the fly with comment syntax like this:

另一个提示是,您可以使用如下注释语法动态更改规则:

/*eslint <rule>=1*/

回答by ruhanbidart

I really don't know if it will help you, but I will put it here. I had a similar problem but in my case it was related to the version of syntastic, so a simple git pullsolved it. My vim configuration is somewhat canonical, so I will share that:

我真的不知道它是否对你有帮助,但我会把它放在这里。我有一个类似的问题,但在我的情况下它与 Syntastic 的版本有关,所以一个简单的git pull解决了它。我的 vim 配置有点规范,所以我将分享:

let g:syntastic_mode_map = { 'mode': 'active',
                            \ 'active_filetypes': ['python', 'javascript'],
                            \ 'passive_filetypes': [] }

set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_javascript_checkers = ['eslint']

When you open your file that contains some mistakes, it should show that into the error window.

当您打开包含一些错误的文件时,它应该将其显示在错误窗口中。