gxmari007 / vite-plugin-eslint

🚨 ESLint plugin for vite
MIT License
268 stars 48 forks source link

请问我如何配置可以使报错信息出现在浏览器上 #69

Closed huoher closed 1 year ago

huoher commented 1 year ago

感谢您的项目

我希望在浏览器中输出这些报错信息,请问我应该如何配置。

我阅读了文档,我现在的项目可以实现在开发的控制台中输出eslint的相关警告和报错信息,但是开发人员仍然可以忽略这些信息。

image

目前浏览器渲染正常,没有阻止开发人员。如果希望在浏览器可以阻止或者输出一些报错信息,请问应该如何配置,烦请不吝赐教

image

以下是我的一些配置,烦请不吝赐教。

我的package.json的devdependecy部分

"devDependencies": {
    "@vitejs/plugin-vue": "^4.1.0",
    "@vue/eslint-config-prettier": "^7.1.0",
    "eslint": "^8.39.0",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-vue": "^9.11.0",
    "prettier": "^2.8.7",
    "vite": "^4.3.0",
    "vite-plugin-eslint": "^1.8.1"
  }

我的.eslintrc.cjs

module.exports = {
    root: true,
    env: {
        node: true,
        browser: true,
        es6: true,
    },
    extends: [
        'plugin:vue/vue3-recommended',
        "plugin:vue/vue3-essential",
        "prettier",
    ],
    plugins: [
        "vue",
        'prettier'
    ],
    rules: {}
}

我的vite.config.js

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import eslintPlugin from 'vite-plugin-eslint';
export default defineConfig({
  plugins: [
    eslintPlugin({
      exclude: ['./node_modules/**'],
      include: ['src/**/*.js', 'src/**/*.vue', 'src/**/*.jsx'],
      cache: false,
    }),
    vue()
  ],
});
huoher commented 1 year ago

抱歉,是我的错误没有认真阅读文档,已经解决