gxmari007 / vite-plugin-eslint

🚨 ESLint plugin for vite
MIT License
266 stars 44 forks source link

Error during build #3

Closed soetz closed 3 years ago

soetz commented 3 years ago

Hey. I wonder if I’m doing something wrong, but I don’t seem to be able to build because of this plugin, even though if I run npm run lint no eslint problem is reported.

I’ve tried it with both the vue and the vue-ts default vite templates. My configuration for JS Vue looks like this :

// vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import eslint from 'vite-plugin-eslint'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), eslint()]
})
// .eslintrc.js
module.exports = {
    extends: [
        "eslint:recommended",
        "plugin:vue/vue3-essential",
    ],
    parser: "vue-eslint-parser"
}
// package.json
{
  "name": "eslint-vite-vue-js-test",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint --ext .js,.vue src",
    "serve": "vite preview"
  },
  "dependencies": {
    "vue": "^3.0.5"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^1.2.1",
    "@vue/compiler-sfc": "^3.0.5",
    "eslint": "^7.24.0",
    "eslint-plugin-vue": "^7.9.0",
    "vite": "^2.1.5",
    "vite-plugin-eslint": "^1.1.0"
  }
}

The error I got is the following :

vite v2.1.5 building for production...
✓ 0 modules transformed.
[vite:eslint] 
/Users/soetz/Projects/eslint-vite-vue-js-test/index.html
  13:8  error  clear  vue/comment-directive

✖ 1 problem (1 error, 0 warnings)

file: /Users/soetz/Projects/eslint-vite-vue-js-test/index.html
error during build:
Error: 
/Users/soetz/Projects/eslint-vite-vue-js-test/index.html
  13:8  error  clear  vue/comment-directive

✖ 1 problem (1 error, 0 warnings)

    at error (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/rollup/dist/shared/rollup.js:5305:30)
    at throwPluginError (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/rollup/dist/shared/rollup.js:18033:12)
    at Object.error (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/rollup/dist/shared/rollup.js:18659:20)
    at Object.error (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/rollup/dist/shared/rollup.js:18202:38)
    at Object.transform (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/vite-plugin-eslint/dist/index.js:64:14)
    at async ModuleLoader.addModuleSource (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/rollup/dist/shared/rollup.js:18396:30)
    at async ModuleLoader.fetchModule (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/rollup/dist/shared/rollup.js:18452:9)
    at async Promise.all (index 0)

If I add **/*.html to the .eslintignore file, it becomes this one :

vite v2.1.5 building for production...
✓ 1 modules transformed.
[vite:eslint] No files matching 'vite/dynamic-import-polyfill' were found.
file: vite/dynamic-import-polyfill
error during build:
Error: No files matching 'vite/dynamic-import-polyfill' were found.
    at FileEnumerator.iterateFiles (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/eslint/lib/cli-engine/file-enumerator.js:317:27)
    at iterateFiles.next (<anonymous>)
    at CLIEngine.executeOnFiles (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/eslint/lib/cli-engine/cli-engine.js:770:48)
    at ESLint.lintFiles (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/eslint/lib/eslint/eslint.js:530:23)
    at Object.transform (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/vite-plugin-eslint/dist/index.js:53:35)
    at async ModuleLoader.addModuleSource (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/rollup/dist/shared/rollup.js:18396:30)
    at async ModuleLoader.fetchModule (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/rollup/dist/shared/rollup.js:18452:9)
    at async Promise.all (index 0)
    at async ModuleLoader.fetchStaticDependencies (/Users/soetz/Projects/eslint-vite-vue-js-test/node_modules/rollup/dist/shared/rollup.js:18478:34)
    at async Promise.all (index 0)

Thanks anyway!

bschelling commented 3 years ago

Same Problem here. Removing the plugin from the vite.config.js will make the build work again.

Dhentai commented 3 years ago

I try to exclude the index.html in option and it work.

JJBocanegra commented 3 years ago

I have this same issue using Vue3 + Typescript with the parser @typescript-eslint/parser.

If I add the rule 'vue/comment-directive': 'off', that error goes away but a most confusing one shows up:

[vite:eslint] No files matching 'vite/preload-helper' were found.
file: vite/preload-helper
error during build:
Error: No files matching 'vite/preload-helper' were found.
    at FileEnumerator.iterateFiles (C:\Users\User\Documents\Proyectos\justos\pas\node_modules\eslint\lib\cli-engine\file-enumerator.js:317:27)
    at iterateFiles.next (<anonymous>)
    at CLIEngine.executeOnFiles (C:\Users\User\Documents\Proyectos\justos\pas\node_modules\eslint\lib\cli-engine\cli-engine.js:765:48)
    at ESLint.lintFiles (C:\Users\User\Documents\Proyectos\justos\pas\node_modules\eslint\lib\eslint\eslint.js:530:23)
    at Object.transform (C:\Users\User\Documents\Proyectos\justos\pas\node_modules\vite-plugin-eslint\dist\index.js:53:35)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ModuleLoader.addModuleSource (C:\Users\User\Documents\Proyectos\justos\pas\node_modules\rollup\dist\shared\rollup.js:19013:30)
    at async ModuleLoader.fetchModule (C:\Users\User\Documents\Proyectos\justos\pas\node_modules\rollup\dist\shared\rollup.js:19069:9)
    at async Promise.all (index 0)
    at async ModuleLoader.fetchStaticDependencies (C:\Users\User\Documents\Proyectos\justos\pas\node_modules\rollup\dist\shared\rollup.js:19095:34)

I tried even this configuration in vite.config.ts:

eslintPlugin({
      exclude: ['node_modules', 'index.html', 'vite/preload-helper']
    }),

But can't make it to work...

gxmari007 commented 3 years ago

Fix it, now include prop default to src/**/*