eslint\prettier|eslint-plugin-vue 对于vue文件没有起格式检查作用

背景:自己用webpack 搭建了 一个类似 vue-cli 的脚手架,
就在配置 …eslintrc文件时 使用了 eslint-plugin-vue,

module.exports = { root: true, env: { browser: true, es6: true }, // extends: [ "plugin:@vue/essential","plugin:prettier/recommended", "plugin:vue/recommended"], extends: ["plugin:vue/essential", "plugin:prettier/recommended"], plugins: ["prettier", "vue"], parserOptions: { parser: "babel-eslint" }, // add your custom rules here rules: { // 0 = off, 1 = warn, 2 = error "prettier/prettier": 1 // "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" } };

使用后 ,.js文件能够被检测到格式
但是 发现vue文件,eslint 检测不到 代码格式
【eslint\prettier|eslint-plugin-vue 对于vue文件没有起格式检查作用】解决: eslintrc 文件是没有问题的
我的问题出在了 webpack.config.js里面 的 eslint-loader
没有配置vue文件
代码如下
{ enforce: "pre", test: /\.(js|vue)$/, exclude: /node_modules/, loader: "eslint-loader" },

加上vue 就可以了

    推荐阅读