@@ -7,3 +7,95 @@ type FunctionTask = SyncFunctionTask | AsyncFunctionTask
7
7
export type Configuration =
8
8
| Record < string , string | FunctionTask | ( string | FunctionTask ) [ ] >
9
9
| FunctionTask
10
+
11
+ export type Options = {
12
+ /**
13
+ * Allow empty commits when tasks revert all staged changes
14
+ * @default false
15
+ */
16
+ allowEmpty ?: boolean
17
+ /**
18
+ * The number of tasks to run concurrently, or `false` to run tasks serially
19
+ * @default true
20
+ */
21
+ concurrent ?: boolean | number
22
+ /**
23
+ * Manual task configuration; disables automatic config file discovery when used
24
+ */
25
+ config ?: Configuration
26
+ /**
27
+ * Path to single configuration file; disables automatic config file discovery when used
28
+ */
29
+ configPath ?: string
30
+ /**
31
+ * Working directory to run all tasks in, defaults to current working directory
32
+ */
33
+ cwd ?: string
34
+ /**
35
+ * Whether or not to enable debug output
36
+ * @default false
37
+ */
38
+ debug ?: boolean
39
+ /**
40
+ * Override the default `--staged` flag of `git diff` to get list of files.
41
+ * @warn changing this also implies `stash: false`.
42
+ * @example HEAD...origin/main
43
+ */
44
+ diff ?: string
45
+ /**
46
+ * Override the default `--diff-filter=ACMR` flag of `git diff` to get list of files
47
+ * @default "ACMR"
48
+ */
49
+ diffFilter ?: string
50
+ /**
51
+ * Maximum argument string length, by default automatically detected
52
+ */
53
+ maxArgLength ?: number
54
+ /**
55
+ * Disable lint-staged’s own console output
56
+ * @default false
57
+ */
58
+ quiet ?: boolean
59
+ /**
60
+ * Pass filepaths relative to `CWD` to tasks, instead of absolute
61
+ * @default false
62
+ */
63
+ relative ?: boolean
64
+ /**
65
+ * Skip parsing of tasks for better shell support
66
+ * @default false
67
+ */
68
+ shell ?: boolean
69
+ /**
70
+ * Enable the backup stash, and revert in case of errors.
71
+ * @warn Disabling this also implies `hidePartiallyStaged: false`.
72
+ * @default true
73
+ */
74
+ stash ?: boolean
75
+ /**
76
+ * Whether to hide unstaged changes from partially staged files before running tasks
77
+ * @default true
78
+ */
79
+ hidePartiallyStaged ?: boolean
80
+ /**
81
+ * Show task output even when tasks succeed; by default only failed output is shown
82
+ * @default false
83
+ */
84
+ verbose ?: boolean
85
+ }
86
+
87
+ type LogFunction = ( ...params : any ) => void
88
+
89
+ type Logger = {
90
+ log : LogFunction
91
+ warn : LogFunction
92
+ error : LogFunction
93
+ }
94
+
95
+ /**
96
+ * @returns {boolean } `true` when linting was successful, `false` when some tasks failed with errors
97
+ * @throws {Error } when failed to some other errors
98
+ */
99
+ type lintStaged = ( options : Options , logger ?: Logger ) => Promise < boolean >
100
+
101
+ export default lintStaged
0 commit comments