-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheslint-import-resolver-vite.d.ts
94 lines (82 loc) · 2.35 KB
/
eslint-import-resolver-vite.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
declare module "eslint-import-resolver-vite" {
/**
* An alias entry for Vite configuration.
*/
export interface ViteAliasEntry {
find: string;
replacement: string;
}
/**
* The alias configuration can either be an object mapping strings to strings or an array of alias entries.
*/
export type ViteAlias = { [key: string]: string } | ViteAliasEntry[]
/**
* Options for Vite's resolve configuration.
*/
export interface ViteResolveOptions {
alias?: ViteAlias;
extensions?: string[];
}
/**
* Minimal subset of Vite configuration required by the resolver.
*/
export interface ViteConfig {
resolve?: ViteResolveOptions;
root?: string;
publicDir?: string | false;
}
/**
* Configuration object expected by the resolver.
*/
export interface ResolverConfig {
viteConfig: ViteConfig;
}
/**
* The result object when a module is successfully resolved.
*/
export interface ResolveResultFound {
found: true;
/**
* The absolute path to the resolved module, or null for core modules.
*/
path: string | null;
}
/**
* The result object when the module could not be resolved.
*/
export interface ResolveResultNotFound {
found: false;
}
/**
* The result type for module resolution.
*/
export type ResolveResult = ResolveResultFound | ResolveResultNotFound
/**
* The interface version of the resolver.
*/
export const interfaceVersion: number
/**
* Resolves a module using the given Vite configuration.
* @param source - The module source string.
* @param file - The file path from which the module is being resolved.
* @param config - The resolver configuration containing a Vite config object.
* @returns An object indicating whether the module was found and its resolved path.
*/
export function resolve(
source: string,
file: string,
config: ResolverConfig
): ResolveResult
/**
* Creates an import resolver object for ESLint that adheres to resolver interface v3.
* @param config - The resolver configuration containing a Vite config object.
* @returns An object with the resolver interface.
*/
export function createViteImportResolver(
config: ResolverConfig
): {
interfaceVersion: 3;
name: "eslint-import-resolver-vite";
resolve(source: string, file: string): ResolveResult;
}
}