Vue取消eslint語法限制


由於vue對語法的限制過於嚴格,以至於在我第一次編譯運行的時候一直編譯失敗,當然也包括一些警告

➜ myproject npm run dev 

> testapp@1.0.0 dev /Users/test/myproject
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

95% emitting 

WARNING Compiled with 1 warnings 5:00:12 PM


✘ http://eslint.org/docs/rules/indent Expected indentation of 0 spaces but found 2 
src/components/Message.vue:46:1
export default {
^

✘ http://eslint.org/docs/rules/indent Expected indentation of 2 spaces but found 4 
src/components/Message.vue:47:1
data() {
^


✘ http://eslint.org/docs/rules/indent Expected indentation of 2 spaces but found 4 
src/components/Message.vue:65:1
}
^

✘ http://eslint.org/docs/rules/indent Expected indentation of 0 spaces but found 2 
src/components/Message.vue:66:1
}
^23 problems (23 errors, 0 warnings)


Errors:
21 http://eslint.org/docs/rules/indent
2 http://eslint.org/docs/rules/space-before-function-paren

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.

 

這里出現警告和錯誤的原因是eslint是一個語法檢查工具,但是限制很嚴格,vue文件里面很多空格都會導致紅線警告,解決方法就是關閉語法限制。

在build/webpack.base.conf.js文件中,注釋或者刪除掉:module->rules中有關eslint的規則

module: {
  rules: [
    //...(config.dev.useEslint ? [createLintingRule()] : []), // 注釋或者刪除
    {
      test: /\.vue$/,
      loader: 'vue-loader',
      options: vueLoaderConfig
    },
    ...
    }
  ]
}

重新運行一下npm run dev或者構建命令 npm run build就可以了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM