UNPKG

1.5 kBTypeScriptView Raw
1type Pathname = string
2
3interface TestResult {
4 ignored: boolean
5 unignored: boolean
6}
7
8export interface Ignore {
9 /**
10 * Adds one or several rules to the current manager.
11 * @param {string[]} patterns
12 * @returns IgnoreBase
13 */
14 add(patterns: string | Ignore | readonly (string | Ignore)[]): this
15
16 /**
17 * Filters the given array of pathnames, and returns the filtered array.
18 * NOTICE that each path here should be a relative path to the root of your repository.
19 * @param paths the array of paths to be filtered.
20 * @returns The filtered array of paths
21 */
22 filter(pathnames: readonly Pathname[]): Pathname[]
23
24 /**
25 * Creates a filter function which could filter
26 * an array of paths with Array.prototype.filter.
27 */
28 createFilter(): (pathname: Pathname) => boolean
29
30 /**
31 * Returns Boolean whether pathname should be ignored.
32 * @param {string} pathname a path to check
33 * @returns boolean
34 */
35 ignores(pathname: Pathname): boolean
36
37 /**
38 * Returns whether pathname should be ignored or unignored
39 * @param {string} pathname a path to check
40 * @returns TestResult
41 */
42 test(pathname: Pathname): TestResult
43}
44
45export interface Options {
46 ignorecase?: boolean
47 // For compatibility
48 ignoreCase?: boolean
49 allowRelativePaths?: boolean
50}
51
52/**
53 * Creates new ignore manager.
54 */
55declare function ignore(options?: Options): Ignore
56
57declare namespace ignore {
58 export function isPathValid (pathname: string): boolean
59}
60
61export default ignore
62
\No newline at end of file