Closed matthew-dean closed 10 months ago
Before I answer your question, you can try the latest 2.0.0-beta.2 version. To avoid the ESM-CJS issue, version 2.x moved the responsibility of loading the Vite config to the users. The 2.x will accept the Vite config object, you can choose how you want to load the Vite config file suitable for your setups. Please see the how-to-use section.
npm install --save-dev eslint-import-resolver-vite@2.0.0-beta.2
Now, to answer your question (or if you want to keep using 1.x), this plugin is a resolver for eslint-plugin-import
. it interacts with your vite config, it doesn't matter if it's JS or TS. The default vite config file for this plugin is vite.config.js
. If you use a different config file name, such as vite.config.ts
, you will need to specify it in the options.
// your eslint config file
settings: {
"import/resolver": {
vite: {
configPath: "./vite.config.ts"
}
}
}
Current ESLint 8.x
doesn't play well with ESM, they official doc says:
Note that ESLint does not support ESM configuration at this time.
close due to inactivity
Vite / Nuxt support a config file in TypeScript. However, this plugin seems to neither support ESM nor TypeScript. It fails with:
SyntaxError: Cannot use import statement outside a module