Vite module resolution plugin for eslint-plugin-import
. This plugin will resolve the resolve.alias
option.
npm install --save-dev eslint-import-resolver-vite
export const viteConfigObj = {
resolve: {
alias: {
_: path.resolve(__dirname, "src")
}
},
};
NOTE:
- Since
eslint-plugin-import
doesn't support an async resolver, Vite's ResolvedConfig API cannot be utilized. - This plugin accepts a Vite config object to accommodate various setups, e.g. CJS, ESM, or mixed.
module.exports = {
settings: {
"import/resolver": {
vite: {
viteConfig: require("./vite.config").viteConfigObj, // named export of the Vite config object.
}
}
}
}