Vue中使用eslint

使用单引号,然后不用分号

1、.eslintrc.js

  module.exports = {
	root: true,
	parserOptions: {
	  parser: 'babel-eslint'
	},
	env: {
	  browser: true,
	},
	extends: [
	  'plugin:vue/essential',
	  'standard'
	],
	// required to lint *.vue files
	plugins: [
	  'vue'
	],
	// add your custom rules here
	rules: {
	  'no-multiple-empty-lines': 0,
	  'no-new':0,
	  indent: [1,"tab"],
	  'no-tabs': 0,
	  // allow async-await
	  'generator-star-spacing': 'off',
	  // allow debugger during development
	  'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 1,
	  // 禁止重复 import
	  "space-before-function-paren": ["off", "always"]
	}
  }

2、webpack.config加入如下代码

            {
				test: /\.(js|vue)$/,
				loader: 'eslint-loader',
				enforce: 'pre',
				include: [resolve('src'), resolve('test'), resolve('module')],
				exclude: /node_modules/,
				options: {
					formatter: require('eslint-friendly-formatter'),
					//不符合Eslint规则时只警告(默认运行出错)
					emitWarning: true
				}
			}

3、.editorconfig

root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false

4、配置不希望eslint监测的文件.eslintignore

# /node_modules/* and /bower_components/* in the project root are ignored by default

# Ignore built files except build/index.js
dist/*
!dist/index.js
module/*/vendor.js
README.md

如果还报错的话就下载editorconfig插件(直接在vscode里搜索安装就好)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值