工作中遇到的vscode配合eslint完成保存为eslint格式
vscode个人设置
// vscode的个人设置配置
{
"workbench.iconTheme": "vscode-icons",
"workbench.colorTheme": "Dracula Italics",
"vetur.format.defaultFormatter.js": "prettier",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"editor.quickSuggestions": {
"strings": true
},
"eslint.autoFixOnSave": true,
// "eslint.nodePath": "D:/develop/nvm/nodejs",
"editor.formatOnSave": true,
"editor.tabSize": 2,
"eslint.options": {
"plugins": [
"html"
],
"configFile": "项目目录下.eslintrc.js绝对路径"
},
"eslint.validate": [
"javascript",
"javascriptreact",
"html",
"vue",
{
"language": "vue",
"autoFix": true
},
{
"language": "html",
"autoFix": true
}
],
"prettier.disableLanguages": [
"vue",
"js"
],
"prettier.singleQuote": true,
"prettier.semi": false,
"prettier.stylelintIntegration": true,
}
// eslintrc.js配置
module.exports = {
root: true,
// EsLint默认使用esprima做脚本解析,也可以切换他,比如切换成babel-eslint解析
parser: 'babel-eslint',
parserOptions: {
//指定来源的类型,有两种”script”或”module”
sourceType: 'module'
},
// Environment可以预设好的其他环境的全局变量,如brower、node环境变量、es6环境变量、mocha环境变量等
env: {
browser: true
},
// Extends是EsLint默认推荐的验证,你可以使用配置选择哪些校验是你所需要的,可以登录npmjs.com查看
extends: 'standard',
// required to lint *.vue files
plugins: ['vue', 'html'],
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// 箭头函数的参数使用圆括号,0是关闭规则"off",1是警告"warn",2是报错"error"
'arrow-parens': 0,
// 强制 generator 函数中 * 号周围使用一致的空格
'generator-star-spacing': 0,
// 函数周围空格的设置
'space-before-function-paren': [
'error',
{
anonymous: 'never',
named: 'never',
asyncArrow: 'always'
}
],
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// 要求使用error对象作为promise拒绝的原因
'prefer-promise-reject-errors': 'off',
'padded-blocks': 0
}
}
vscode插件安装
- beautify 美化代码 好像没用到 安全起见先加上
- Bracket Pair Colorizer 美化括号 让你的括号看起来更好看
- Dracula theme 一个主题 随便装不装
- Dracula Theme with Italic keywords 刚才那个主题的配套设施,内容看起来是斜体,有点意思
- EditorConfig for Visual Studio Code 代码风格配置插件
- eslint 不多说 就装吧
- JavaScript standard style standard标准编码风格
- Path Intellisense 自动完善路径
- prettier 代码格式化
- veture vue大礼包
- vscode-icons 美化图标
需要的项目环境
- npm install eslint eslint-plugin-html babel-eslint eslint-plugin-vue eslint-config-standard eslint-friendly-formatter --save-dev
- npm install eslint-loader eslint-plugin-import eslint-plugin-node eslint-plugin-promise --save-dev
- 可以全局装 也可以项目装,不要全局安装和本地安装混合,那样在执行命令的时候全局容易找不到本地的配置,本地找不到全局的包
- node_modules/.bin/eslint --fix path/to/要eslint的文件 可以对文件进行eslint规则修复
参考文档
工作中遇到的vscode配合eslint完成保存为eslint格式的更多相关文章
- 工作中遇到的问题--Hibernate一对多保存简化Service层代码
在创建一方的entity是添加一个增加多方的方法: package com.sim.mfg.data.domain; import java.io.Serializable;import java.u ...
- Matlab中使用Java api画图图形并保存为jpeg格式
直接上代码: close all; import java.io.*; import java.awt.*; import java.awt.image.BufferedImage; import j ...
- git 工作中常用命令(结合vscode学习git 命令)
作为一名前端开发,大家在工作中常常使用什么开发工具呢,我觉得我首选的是vscode,他配合git使用起来非常方便. 工作中常用三个命令: git终端常使用: git add . git commit ...
- VSCode配合ESLint自动修复格式化
开发Vue或者React的项目的时候,我们经常用到ESLint进行代码的校验,当代码出现不符合规范的格式的时候,ESLint会在控制台提示相关的异常信息. ESLint极大的提高了团队代码的一致性和规 ...
- 运维工作中sed常规操作命令梳理
sed是一个流编辑器(stream editor),一个非交互式的行编辑器.它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为"模式空间",接着用sed命令处理缓冲 ...
- 工作中常用Git指令操作
常用Git指令总结 前阵子有几天好不顺,可谓是喝水都呛着,更何况被Git给呛着了,还不轻,哈哈.所以打算总结一下自己在工作使用到Git相关的东西以及和大家探讨使用GIt的心得体会.于是,关于Git的的 ...
- 转摘Linux命令工作中常用总结
Linux命令工作中常用总结 1. 搜索 在vi和vim中如果打开一个很大的文件,不容易找到对应的内容,可以使用自带的搜索关键字进行搜索定位: 在vi和vim界面中输入:"/" ...
- Linux 运维工作中的经典应用ansible(批量管理)Docker容器技术(环境的快速搭建)
一 Ansible自动化运维工具 Python 在运维工作中的经典应用 ansible(批量管理操作) .安装ansible(需要bese epel 2种源) wget -O /etc/yum.rep ...
- Linux命令工作中常用总结
1. 搜索 在vi和vim中如果打开一个很大的文件,不容易找到对应的内容,可以使用自带的搜索关键字进行搜索定位: 在vi和vim界面中输入:"/"(反斜杠),之后会出现一个输入框让 ...
随机推荐
- 用SQL玩转数据挖掘之MADlib(一)——安装
一.MADlib简介 MADlib是Pivotal公司与伯克利大学合作的一个开源机器学习库,提供了精确的数据并行实现.统计和机器学习方法对结构化和非结构化数据进行分析,主要目的是扩展数据库的分析能力, ...
- 出现epoll failed: Bad file descriptor的原因
今天遇到了这个问题,之前找了半天原来是IO事件的socket描述符在epoll_ctl()处理之前关闭了. if(epoll_ctl(epollFd, EPOLL_CTL_DEL, ev->fd ...
- CF581C Developing Skills 模拟
Petya loves computer games. Finally a game that he's been waiting for so long came out! The main cha ...
- D - Frogger
Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sit ...
- Tomcat故障
1.1 故障日志 31-May-2018 16:11:41.136 INFO [http-nio-8017-exec-5] org.apache.coyote.http11.AbstractHttp1 ...
- Django ORM 字段合集
AutoField(Field) - int自增列,必须填入参数 primary_key=True BigAutoField(AutoField) - bigint自增列,必须填入参数 primary ...
- 问题解决Determine IP information for eth0.. no link present check cable
网上方法都没有解决:简单粗暴编辑里还原了默认设置OK了 网上方法1 一般解决办法: 第一步: 到/etc/sysconfig/network-scripts/ifcfg-eth<n>/et ...
- 转 windows下安装pycharm并连接Linux的python环境 以及 windows 下notepad ++编辑 linux 的文件
######sample 1:windows下安装pycharm并连接Linux的python环境 https://www.cnblogs.com/junxun/p/8287998.html wind ...
- 转 使用SwingBench 对Oracle RAC DB性能 压力测试
###########说明1: 1 Swingbench 简述 1.1 概述 这是Oracle UK的一个员工在一个被抛弃的项目的基础上开发的.目前稳定版本2.2,最新版本2.3,基于JDK1.5.该 ...
- 安装 Office project 2013 时提示找不到 Office.zh-cn\OfficeLR.cab
昨天在安装project 时总是弹出下图中的提示框,在网上搜索了很多办法但是没有解决这个问题. 后来进入到office.zh-cn的文件夹中,在officemui.msi文件中右键卸载,然后在重新安装 ...