vite-plugin-eslint icon indicating copy to clipboard operation
vite-plugin-eslint copied to clipboard

error: eslintPlugin is not a function

Open quoc1707 opened this issue 3 years ago • 4 comments
trafficstars

Describe the bug 🐛

I'm currently refactoring a legacy project 👎 Everything is fine until I decide to add code linting. Because this application is powered by Vite, obviously I must add vite-plugin-eslint as a devDependency.

After running build command, I got error TypeError: eslintPlugin is not a function.

 

Reproduce

yarn add --dev vite-plugin-eslint

Changing vite.config.js to:

...
import eslintPlugin from 'vite-plugin-eslint'
...
export default defineConfig({
    plugins: [
        ...,
        eslintPlugin(),
    ],
})

Then running build command.

 

Logs

failed to load config from C:\Users\ASUSVIVOBOOK\OneDrive\Documents\GitHub\mac-os-monterey\vite.config.ts
error during build:
TypeError: eslintPlugin is not a function
    at file:///C:/Users/ASUSVIVOBOOK/OneDrive/Documents/GitHub/mac-os-monterey/vite.config.ts.js?t=1637721861012:47:5
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async loadConfigFromFile (C:\Users\ASUSVIVOBOOK\OneDrive\Documents\GitHub\mac-os-monterey\node_modules\vite\dist\node\chunks\dep-e0fe87f8.js:68598:31)
    at async resolveConfig (C:\Users\ASUSVIVOBOOK\OneDrive\Documents\GitHub\mac-os-monterey\node_modules\vite\dist\node\chunks\dep-e0fe87f8.js:68188:28)
    at async doBuild (C:\Users\ASUSVIVOBOOK\OneDrive\Documents\GitHub\mac-os-monterey\node_modules\vite\dist\node\chunks\dep-e0fe87f8.js:42986:20)
    at async build (C:\Users\ASUSVIVOBOOK\OneDrive\Documents\GitHub\mac-os-monterey\node_modules\vite\dist\node\chunks\dep-e0fe87f8.js:42974:16)
    at async CAC.<anonymous> (C:\Users\ASUSVIVOBOOK\OneDrive\Documents\GitHub\mac-os-monterey\node_modules\vite\dist\node\cli.js:737:9)

 

System information

System:
    OS: Windows 11 Version Dev
Binaries:
    Node: 16.11.1
    yarn: 3.1.0
Packages:
    "svelte": "^3.44.2",
    "typescript": "^4.5.2",
    "vite": "2.6.14",
    "rollup": "^2.60.1",
    "vite-plugin-eslint": "^1.3.0"

quoc1707 avatar Nov 24 '21 03:11 quoc1707

same issue

YankeeTube avatar Dec 28 '21 05:12 YankeeTube

I faced the same issue when I tried to use ES modules without babel.

AliakseiPuchyk avatar Mar 30 '22 16:03 AliakseiPuchyk

I got this to work with using eslintPlugin.default() instead. However I'm trying to use this with Svelte and don't get any linting errors showing up.

Jakobud avatar Apr 14 '22 16:04 Jakobud

I am dealing with the same problem when using "type": "module" in package.json for using esm modules. With that change this error occurs. but i need to change to ESM because quite some packages i use are ESM only in their newest versions. So.. seems like i cannot use linting?

@Jakobud sadly using eslintPlugin.default() does not fix it for me.

awacode21 avatar Apr 19 '22 20:04 awacode21

Now exports correctly according to different environments.

gxmari007 avatar Aug 19 '22 01:08 gxmari007