-
-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathtypes.ts
More file actions
191 lines (163 loc) · 4.61 KB
/
types.ts
File metadata and controls
191 lines (163 loc) · 4.61 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
import type { Linter } from 'eslint'
import type {
ImportSettings,
PluginName,
PluginSettings,
} from 'eslint-import-context'
import type { MinimatchOptions } from 'minimatch'
import type { ImportType as ImportType_ } from './utils/index.js'
export type {
LegacyResolver,
// ResolverName
LegacyResolverName,
LegacyResolverName as ResolverName,
// ImportResolver
LegacyImportResolver,
LegacyImportResolver as ImportResolver,
// ResolverResolve
LegacyResolverResolve,
LegacyResolverResolve as ResolverResolve,
// ResolverResolveImport
LegacyResolverResolveImport,
LegacyResolverResolveImport as ResolverResolveImport,
// ResolverRecord
LegacyResolverRecord,
LegacyResolverRecord as ResolverRecord,
// ResolverObject
LegacyResolverObject,
LegacyResolverObject as ResolverObject,
NodeResolverOptions,
WebpackResolverOptions,
TsResolverOptions,
NewResolverResolve,
NewResolver,
FileExtension,
DocStyle,
ResultNotFound,
ResultFound,
Resolver,
ResolvedResult,
ImportSettings,
WithPluginName,
PluginSettings,
RuleContext,
ChildContext,
} from 'eslint-import-context'
export type ImportType = ImportType_ | 'object' | 'type'
export type Arrayable<T> = T | readonly T[]
export interface PluginConfig extends Linter.LegacyConfig {
plugins?: [PluginName]
settings?: PluginSettings
rules?: Record<`${PluginName}/${string}`, TSESLint.ClassicConfig.RuleEntry>
}
export interface PluginFlatBaseConfig extends TSESLint.FlatConfig.Config {
settings?: PluginSettings
rules?: Record<`${PluginName}/${string}`, TSESLint.FlatConfig.RuleEntry>
}
export interface PluginFlatConfig extends PluginFlatBaseConfig {
name?: `${PluginName}/${string}`
}
export interface ParseError extends Error {
lineNumber: number
column: number
}
export interface CustomESTreeNode<Type extends string>
extends Omit<TSESTree.BaseNode, 'type'> {
type: Type
}
export type ExportDefaultSpecifier = CustomESTreeNode<'ExportDefaultSpecifier'>
export interface ExportNamespaceSpecifier
extends CustomESTreeNode<'ExportNamespaceSpecifier'> {
exported: TSESTree.Identifier
}
export interface PathGroup {
pattern: string
group: ImportType
patternOptions?: MinimatchOptions
position?: 'before' | 'after'
}
export type ExportAndImportKind = 'value' | 'type'
export type NewLinesOptions =
| 'always'
| 'always-and-inside-groups'
| 'ignore'
| 'never'
export type NamedTypes = 'mixed' | 'types-first' | 'types-last'
export interface NamedOptions {
enabled?: boolean
import?: boolean
export?: boolean
require?: boolean
cjsExports?: boolean
types?: NamedTypes
}
export interface AlphabetizeOptions {
caseInsensitive: boolean
order: 'ignore' | 'asc' | 'desc'
orderImportKind: 'ignore' | 'asc' | 'desc'
}
export type ImportEntryType = 'import:object' | 'import' | 'require' | 'export'
export type LiteralNodeValue =
| string
| number
| bigint
| boolean
| RegExp
| null
export interface ImportEntry {
type: ImportEntryType
node: TSESTree.Node & {
importKind?: ExportAndImportKind
exportKind?: ExportAndImportKind
}
value: LiteralNodeValue
alias?: string
kind?: ExportAndImportKind
displayName?: LiteralNodeValue
}
export interface ImportEntryWithRank extends ImportEntry {
rank: number
isMultiline?: boolean
}
export interface RanksPathGroup {
pattern: string
patternOptions?: MinimatchOptions
group: string
position?: number
}
export type RanksGroups = Record<string, number>
export interface Ranks {
omittedTypes: string[]
groups: RanksGroups
pathGroups: RanksPathGroup[]
maxPosition: number
}
export interface CjsRequire extends NodeJS.Require {
<T>(id: string): T
}
export type SetValue<T extends Set<unknown>> =
T extends Set<infer U> ? U : never
export interface NormalizedCacheSettings
extends NonNullable<ImportSettings['cache']> {
lifetime: number
}
/**
* Minimal subset of package.json fields used by this plugin.
* Defined inline to avoid a runtime dependency solely for type information.
*/
export interface PackageJson {
name?: string
version?: string
private?: boolean
main?: string
bin?: string | Record<string, string>
browser?: string | Record<string, string | false>
dependencies?: Record<string, string>
devDependencies?: Record<string, string>
optionalDependencies?: Record<string, string>
peerDependencies?: Record<string, string>
/** Array form per npm spec; object form is non-standard but intentionally supported by this rule */
bundleDependencies?: string[] | Record<string, string>
bundledDependencies?: string[] | Record<string, string>
}