forked from publint/publint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
102 lines (97 loc) · 2.87 KB
/
index.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
95
96
97
98
99
100
101
102
export type MessageType = 'suggestion' | 'warning' | 'error'
interface BaseMessage<Code extends string, Args = Record<string, string>> {
/**
* The message code to narrow the message type
*/
code: Code
/**
* Arguments used to be the final message
*/
args: Args
/**
* The path to the key in the package.json which triggered this message
*/
path: string[]
/**
* The type of message for sorting
*/
type: MessageType
}
export type Message =
| BaseMessage<
'IMPLICIT_INDEX_JS_INVALID_FORMAT',
{ actualFormat: string; expectFormat: string }
>
| BaseMessage<
'FILE_INVALID_FORMAT',
{
actualFormat: string
expectFormat: string
actualExtension: string
expectExtension: string
actualFilePath?: string
}
>
| BaseMessage<
'FILE_INVALID_EXPLICIT_FORMAT',
{
actualFormat: string
expectFormat: string
actualExtension: string
expectExtension: string
actualFilePath?: string
}
>
| BaseMessage<'FILE_DOES_NOT_EXIST', { filePath: string }> // TODO: remove `filePath`
| BaseMessage<'FILE_NOT_PUBLISHED'>
| BaseMessage<'MODULE_SHOULD_BE_ESM'>
| BaseMessage<'HAS_MODULE_BUT_NO_EXPORTS'>
| BaseMessage<'HAS_ESM_MAIN_BUT_NO_EXPORTS'>
| BaseMessage<'EXPORTS_GLOB_NO_MATCHED_FILES'>
| BaseMessage<
'EXPORTS_GLOB_NO_DEPRECATED_SUBPATH_MAPPING',
{
expectPath: string[]
expectValue: string
}
>
| BaseMessage<'EXPORTS_TYPES_SHOULD_BE_FIRST'>
| BaseMessage<'EXPORTS_DEFAULT_SHOULD_BE_LAST'>
| BaseMessage<'EXPORTS_MODULE_SHOULD_BE_ESM'>
| BaseMessage<'EXPORTS_VALUE_INVALID', { suggestValue: string }>
| BaseMessage<'USE_EXPORTS_BROWSER'>
| BaseMessage<'TYPES_NOT_EXPORTED', { typesFilePath: string }>
export interface Options {
/**
* Path to your package that contains a package.json file.
* Defaults to `process.cwd()` in node, `/` in browser.
*/
pkgDir?: string
/**
* A virtual file-system object that handles fs/path operations.
* This field is required if you're using in the browser.
*/
vfs?: Vfs
/**
* The level of messages to log (default: `'suggestion'`).
* - `suggestion`: logs all messages
* - `warning`: logs only `warning` and `error` messages
* - `error`: logs only `error` messages
*/
level?: 'suggestion' | 'warning' | 'error'
/**
* Report warnings as errors.
*/
strict?: boolean
}
export interface Vfs {
readFile: (path: string) => Promise<string>
readDir: (path: string) => Promise<string[]>
isPathDir: (path: string) => Promise<boolean>
isPathExist: (path: string) => Promise<boolean>
pathJoin: (...paths: string[]) => string
pathRelative: (from: string, to: string) => string
getDirName: (path: string) => string
getExtName: (path: string) => string
}
export declare function publint(options?: Options): Promise<Message[]>