Skip to content

Commit f7796cb

Browse files
committed
add error message if vite config file is not present
1 parent c05d9cb commit f7796cb

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = {
5959
- Required: No
6060
- Type: string
6161
- Default: [No Default]
62-
- **If you use a function as vite config, you must export a named vite config object.**
62+
- **If you use a function as vite config, you must export a named vite config object. This is a result of the limitation of `eslint-plugin-import`.**
6363
```js
6464
/**
6565
* vite config file

index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
const path = require("path");
22
const resolve = require("resolve");
3+
const fs = require("fs");
4+
const debug = require("debug");
35

4-
const log = require("debug")("eslint-plugin-import:resolver:vite");
6+
const namespace = "eslint-plugin-import:resolver:vite";
7+
8+
const log = debug(namespace);
9+
10+
const logError = (message) => {
11+
log(message);
12+
console.log(`[${namespace}] ${message}`);
13+
};
514

615
exports.interfaceVersion = 2;
716

@@ -22,7 +31,11 @@ exports.resolve = (source, file, config) => {
2231

2332
// load vite config
2433
const viteConfigPath = path.resolve(pluginConfig.configPath);
34+
if (!fs.existsSync(viteConfigPath)) {
35+
logError(`vite config file doesn't exist at '${viteConfigPath}'`);
36+
}
2537
const viteConfigFile = require(viteConfigPath);
38+
2639
let viteConfig;
2740
if (pluginConfig.namedExport) {
2841
viteConfig = viteConfigFile[pluginConfig.namedExport]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-import-resolver-vite",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "Vite module resolution plugin for eslint-plugin-import.",
55
"keywords": [
66
"eslint",

0 commit comments

Comments
 (0)