Skip to content

Commit e95d5cd

Browse files
committed
feat: add TypeScript types for the main lint-staged Node.js API
1 parent a8ec1dd commit e95d5cd

File tree

2 files changed

+93
-1
lines changed

2 files changed

+93
-1
lines changed

.changeset/brown-pumpkins-matter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'lint-staged': minor
33
---
44

5-
_Lint-staged_ now ships with TypeScript types for the configuration. You can use the JSDoc syntax in your JS configuration files:
5+
_Lint-staged_ now ships with TypeScript types for the configuration and main Node.js API. You can use the JSDoc syntax in your JS configuration files:
66

77
```js
88
/**

lib/types.d.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,95 @@ type FunctionTask = SyncFunctionTask | AsyncFunctionTask
77
export type Configuration =
88
| Record<string, string | FunctionTask | (string | FunctionTask)[]>
99
| 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

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy