forked from unplugin/unplugin-auto-import
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
150 lines (127 loc) · 3.09 KB
/
types.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import type { Arrayable, Awaitable } from '@antfu/utils'
import type { FilterPattern } from '@rollup/pluginutils'
import type { Import } from 'unimport'
import { PresetName } from './presets'
export interface ImportLegacy {
/**
* @deprecated renamed to `as`
*/
name?: string
/**
* @deprecated renamed to `name`
*/
importName?: string
/**
* @deprecated renamed to `from`
*/
path: string
sideEffects?: SideEffectsInfo
}
export interface ImportExtended extends Import {
sideEffects?: SideEffectsInfo
__source?: 'dir' | 'resolver'
}
export type ImportNameAlias = [string, string]
export type SideEffectsInfo = Arrayable<ResolverResult | string> | undefined
export interface ResolverResult {
as?: string
name?: string
from: string
}
export type ResolverFunction = (name: string) => Awaitable<string | ResolverResult | ImportExtended | null | undefined | void>
export interface ResolverResultObject {
type: 'component' | 'directive'
resolve: ResolverFunction
}
/**
* Given a identifier name, returns the import path or an import object
*/
export type Resolver = ResolverFunction | ResolverResultObject
/**
* module, name, alias
*/
export type ImportsMap = Record<string, (string | ImportNameAlias)[]>
export type ESLintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable'
export interface ESLintrc {
/**
* @default false
*/
enabled?: boolean
/**
* Filepath to save the generated eslint config
*
* @default './.eslintrc-auto-import.json'
*/
filepath?: string
/**
* @default true
*/
globalsPropValue?: ESLintGlobalsPropValue
}
export interface Options {
/**
* Preset names or custom imports map
*
* @default []
*/
imports?: Arrayable<ImportsMap | PresetName>
/**
* Identifiers to be ignored
*/
ignore?: (string | RegExp)[]
/**
* Path for directories to be auto imported
*/
dirs?: string[]
/**
* Pass a custom function to resolve the component importing path from the component name.
*
* The component names are always in PascalCase
*/
resolvers?: Arrayable<Arrayable<Resolver>>
/**
* Filepath to generate corresponding .d.ts file.
* Default enabled when `typescript` is installed locally.
* Set `false` to disable.
*
* @default './auto-imports.d.ts'
*/
dts?: string | boolean
/**
* Auto import inside Vue templates
*
* @see https://github.com/unjs/unimport/pull/15
* @see https://github.com/unjs/unimport/pull/72
* @default false
*/
vueTemplate?: boolean
/**
* Allow overriding imports sources from multiple presets.
*
* @default false
*/
presetOverriding?: boolean
/**
* Rules to include transforming target.
*
* @default [/\.[jt]sx?$/, /\.vue\??/]
*/
include?: FilterPattern
/**
* Rules to exclude transforming target.
*
* @default [/node_modules/, /\.git/]
*/
exclude?: FilterPattern
/**
* Generate source map.
*
* @default false
*/
sourceMap?: boolean
/**
* Generate corresponding .eslintrc-auto-import.json file.
*/
eslintrc?: ESLintrc
}
export { PresetName }