一、package.json里配置添加

1.scripts里添加快捷eslint检查命令

"lint": "eslint --ext .js,.vue src"

2.添加eslint依赖包

    "babel-eslint": "^8.2.1",
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",

二、根目录下添加检测配置js文件.eslintrc.js

// https://eslint.org/docs/user-guide/configuring

module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}

三、添加忽略检测配置文件.eslintignore

/build/
/config/
/dist/
/*.js

四、webpack.base.conf.js rules里添加eslint-loader配置

const createLintingRule = () => ({
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter'),
emitWarning: !config.dev.showEslintErrorsInOverlay
}
})
module.exports = {
//.......
module: {
rules: [
...(config.dev.useEslint ? [createLintingRule()] : []),
//.....

五、config->index.js的dev里添加

useEslint: true,
showEslintErrorsInOverlay: false,

vue-cli构建的项目手动添加eslint配置的更多相关文章

  1. @vue/cli 构建得项目eslint配置

    如下:package.json // package.json { "name": "ecommerce-mall-front", "version& ...

  2. @vue/cli 构建得项目eslint配置2

    使用ESLint+Prettier来统一前端代码风格 加分号还是不加分号?tab还是空格?你还在为代码风格与同事争论得面红耳赤吗? 正文之前,先看个段子放松一下: 去死吧!你这个异教徒! 想起自己刚入 ...

  3. 如何在VUE项目中添加ESLint

    如何在VUE项目中添加ESLint 1. 首先在项目的根目录下 新建 .eslintrc.js文件,其配置规则可以如下:(自己小整理了一份),所有的代码如下: // https://eslint.or ...

  4. 用vue ui创建的项目怎么关闭eslint校验

    在Vue Cli的控制面板找到配置-ESLint configuration,然后关闭保存时检查就可以了

  5. vue cli创建typescript项目

    使用最新的Vue CLI @vue/cli创建typescript项目,使用vue -V查看当前的vue cli版本 安装命令 npm install -g @vue-cli 创建项目 vue cre ...

  6. vue + iview 怎样在vue项目下添加ESLint

    参考:https://segmentfault.com/a/1190000012019019?utm_source=tag-newest 使用iview框架的MenuGroup标签,vscode报红, ...

  7. @vue/cli 3.x项目脚手架 webpack 配置

    @vue/cli  是一个基于 Vue.js 进行快速开发的完整系统. @vue/cli   基于node服务  需要8.9以上版本 可以使用 nvm等工具来控制node版本  构建于 webpack ...

  8. Vue+webpack构建一个项目

    1.安装CLI命令的工具  推荐用淘宝的镜像 npm install -g @vue/cli @vue/cli-init 2.使用命令构建一个名为myapp的项目 vue init webpack m ...

  9. Vue CLI 3开发中屏蔽的EsLint错误 (.eslintrc.js 在vue3+中 修改这个)

    1.关闭eslint校验有了eslint的校验,可以来规范开发人员的代码,是挺好的.但是有些像缩进.空格.空白行之类的规范,在开发过程中一直报错,未免太过于苛刻了.所以,我还是会选择关闭eslint校 ...

随机推荐

  1. win10在ip变动之后重启ftp

    自己的笔记本拿去公司工作一周后,回到家里发现自己的ftp服务器没办法访问了. 首先,确定自己的ftp服务是打开的 接着搜索internet information service打开 接着点击网站查看 ...

  2. DataGridView 导出Excel (封装)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...

  3. BZOJ 5305: [Haoi2018]苹果树 组合计数

    一定要注意要乘阶乘,细节很多. code: #include <bits/stdc++.h> #define ll long long #define setIO(s) freopen(s ...

  4. zabbix server内存突然飙升

    2019年10月16日22:20:58 十点二十突然内存占满,top查询一个httpd进程占了79%,查询httpd.error.log发现 [Wed Oct 16 10:24:57.578643 2 ...

  5. CSPS_109

    T1 状压+位运算解决 T2 打完暴力后感到了迷茫.. 不过看这张表里1的数目占了一半之多,应该合法情况挺多的 拿出了从未用过的srand(time(0)); 结果撞上正解了(笑)(rp--) 现在$ ...

  6. 干货 | 10分钟掌握branch and cut(分支剪界)算法原理附带C++求解TSP问题代码

    00 前言 branch and cut其实还是和branch and bound脱离不了干系的.所以,在开始本节的学习之前,请大家还是要务必掌握branch and bound算法的原理. 01 应 ...

  7. mysql 修改表名

    //重命名表 rename table table1 to table2; //重命名多个表 rename table table1 to table2,table3 to table4,table5 ...

  8. MySQL的ROUND函数

    ROUND(X) ROUND(X,D) 返回参数X, 其值接近于最近似的整数.在有两个参数的情况下,返回 X ,其值保留到小数点后D位,而第D位的保留方式为四舍五入.若要接保留X值小数点左边的D 位, ...

  9. 测试linux下磁盘的读写速率

    1) 通过df -h命令查看磁盘情况 Filesystem            Size  Used Avail Use% Mounted on/dev/sda4             289G  ...

  10. centos7安装sql-server2017

    1.  关闭selinux Vim /etc/selinux/conf 将selinux=enable 改成selinux=disabled 2.  清空/关闭iptables策略 Iptables ...