vue.js - 修改eslint

当我们使用vue开发项目时,发现经常报一些莫名的错误,什么空格没写、

什么双引号要改为单引号,这对于有强迫症的同学来说,真是有句mmp不知当讲不当讲。

因为vue版本的不同,所以不同版本的去掉eslint的方式也不同。因为网上没看到我这个版本的去除方法。

所以我斗胆上传我这个版本的方法1:

首先找到/build/webpack.base.conf.js文件,然后找到createLintingRule关键词所在地方

具体配置如下:

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
  // }
})

如上所示,把里面内容注释掉,然后npm run dev跑一跑。

没错只要你不犯原则上的错误,它都是可以原谅的。

如果你觉得上面的方法麻烦,没事还有一个简单点的方法:

首先找到config/index.js文件夹,打开,

 // Various Dev Server settings
    host: 'localhost', // can be overwritten by process.env.HOST
    port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: true,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

    // Use Eslint Loader?
    // If true, your code will be linted during bundling and
    // linting errors and warnings will be shown in the console.
    useEslint: false,  // 将这里改成false 就ok 了,默认是true。

上面两张方法任意一种都可以让你肆无忌惮的写代码了。

posted @ 2018-01-18 09:41  Lafitewu  阅读(671)  评论(0编辑  收藏  举报