eslint+sublime text 3 配置和使用(全)

由于Vue老项目中没有使用eslint,但是新组件代码需要使用eslint,所以最好的办法发就是在编辑器里面配置eslint代码风格检查,不然项目都启不了,所以今天踩了一天的坑,在sublimetext 3 配置 使用 eslint

1.全局安装ESlint

cnpm install eslint -g

2.在项目目录初始化.eslintrc.js配置文件

D:\me\web\case03\kdew_internet_website>eslint --init
? How would you like to configure ESLint? Answer questions about your style
? Which version of ECMAScript do you use? ES2017
? Are you using ES6 modules? Yes
? Where will your code run? (Press <space> to select, <a> to toggle all, <i> to invert selection)Browser
? Do you use CommonJS? Yes
? Do you use JSX? Yes
? Do you use React? No
? What style of indentation do you use? Tabs
? What quotes do you use for strings? Single
? What line endings do you use? Windows
? Do you require semicolons? No
? What format do you want your config file to be in? JavaScript
Successfully created .eslintrc.js file in D:\me\web\case03\xxxxx_project

3. eslint 命令行的使用

(1)检测js脚本

eslint  xxx1.js xxx2.js

(2)查看eslint命令帮助文档

eslint --help

(3)sublime 编辑器配置 eslint

配置参考文档:
1.https://www.jianshu.com/p/b25a8fe4c708 *
2.https://github.com/SublimeLinter/SublimeLinter-eslint *
3.https://github.com/SuperAL/vueAdmin-template/blob/master/.eslintrc.js *
4.https://blog.csdn.net/messagebox_/article/details/82115559
5.https://blog.csdn.net/xueboren001/article/details/53389221

:可以在sublime中安装eslint插件,该插件配置如下:

{
  // The directory location of your `node` executable lives. If this is not
  "node_path": "E:/others/node",

  // The directory location of global `node_modules` via `npm`. If this
  // Example for Windows: "%APPDATA%/npm/node_modules"
  "node_modules_path": "",  // 不填写则默认走项目下的node_modules

  // The location of your configuration file.
  // Example: "/path/to/.eslintrc.js"
  "config_file": "" // 不填写则默认走项目下的.eslintrc.js配置文件
}

成功配置后,效果如下:

sublime eslint

(4)VsCode编辑器配置

配置参考文档:https://juejin.im/post/5a15402a6fb9a045167cd624

猜你喜欢

转载自blog.csdn.net/WU5229485/article/details/85325730
今日推荐