eslint是一个语法格式检测的工具,对于规范开发有好处,培养严格的书写习惯,但是对于新手来说,非常的痛苦,有时候没有语法错误,仅仅是格式中tab,space区分不严格或者少了一个space,多了两个space,就会报错,甚至编译不过,出现警告,很烦人。
相信大家可能都遇到过如下所示的警告:
Unexpected tab character
Mixed spaces and tabs
Trailing spaces not allowed
在<script></script>中的警告,我们可以通过 注解/*eslint-disable*/来解决,但是<template></template>部分的警告就很痛苦,解决办法是有的,就是将eslint不加载。
我们在webpack.base.config.js文件中会注意到这么一段代码:
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: [...(c