Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 946 Bytes

README.md

File metadata and controls

40 lines (32 loc) · 946 Bytes

eslint-import-resolver-vite

Vite module resolution plugin for eslint-plugin-import. This plugin will resolve the resolve.alias option.

Installation

npm install --save-dev eslint-import-resolver-vite

How to use

Vite config file

export const viteConfigObj = {
    resolve: {
        alias: {
            _: path.resolve(__dirname, "src")
        }
    },
};

ESLint config file

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.
            }
        }
    }
}