简体   繁体   English

js 语法的“快速修复”不适用于“syntastic”中的“eslint”

[英]'quickfix' for js syntax not working with 'eslint' in 'syntastic'

All:全部:

I'm having a problem.我有问题。

I use syntastic for javascript syntax check.我使用 Syntastic 进行 javascript 语法检查。 but quickfix is not working.但快速修复不起作用。

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

let g:syntastic_auto_loc_list = 1 " 自动拉起窗口,不需要手动调用:Errors
let g:syntastic_check_on_open = 1 " 打开文件的时候检查
let g:syntastic_error_symbol = '✗' " 错误显示的字符
let g:syntastic_warning_symbol = '⚠' " 警告显示的字符
let g:go_list_type = "quickfix" " 选择quick'fix
let g:syntastic_check_on_wq = 0 " 保存退出时不检查语法
let g:syntastic_javascript_checkers = ['eslint']
let s:eslint_path =system('PATH=$(npm bin):$PATH && which eslint') "定义eslint_path变量
let b:syntastic_javascript_eslint_exec = substitute(s:eslint_path, '^\n*\s*\(.\{-}\)\n*\s*$', '\1', '')

when i use jslint has this: npm install -g jslint当我使用 jslint 时有这个: npm install -g jslint

在此处输入图片说明

when i use eslint has this: npm install eslint -g and touch ~/.eslintrc give some options.当我使用 eslint 时有这个: npm install eslint -g and touch ~/.eslintrc give some options.

在此处输入图片说明

Where is the error.错误在哪里。 show E42: No Errors显示 E42:没有错误

Issuing cmd :SyntasticInfo in buffer, I see:在缓冲区中发出 cmd :SyntasticInfo ,我看到:

Syntastic version: 3.7.0-180 (Vim 704, Darwin)
Info for filetype: javascript
Global mode: active
Filetype javascript is active
The current file will be checked automatically
Available checkers: eslint jshint jslint
Currently enabled checker: eslint

For me, there was a need to do:对我来说,有必要做:

eslint --init

That generates an .eslintrc.js configuration file describing the rules to check for the specific project.这会生成一个 .eslintrc.js 配置文件,描述检查特定项目的规则。 Running eslint on the cli outside of vim gave the message for that need.在 vim 之外的 cli 上运行 eslint 提供了满足该需求的信息。

$ eslint test.js

Oops! Something went wrong! :(

ESLint couldn't find a configuration file. To set up a configuration file for this project, please run:

    eslint --init

解决:

npm install babel-eslint -g

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

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