index.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. type Pathname = string
  2. interface TestResult {
  3. ignored: boolean
  4. unignored: boolean
  5. }
  6. export interface Ignore {
  7. /**
  8. * Adds a rule rules to the current manager.
  9. * @param {string | Ignore} pattern
  10. * @returns IgnoreBase
  11. */
  12. add(pattern: string | Ignore): this
  13. /**
  14. * Adds several rules to the current manager.
  15. * @param {string[]} patterns
  16. * @returns IgnoreBase
  17. */
  18. add(patterns: (string | Ignore)[]): this
  19. /**
  20. * Filters the given array of pathnames, and returns the filtered array.
  21. * NOTICE that each path here should be a relative path to the root of your repository.
  22. * @param paths the array of paths to be filtered.
  23. * @returns The filtered array of paths
  24. */
  25. filter(pathnames: Pathname[]): Pathname[]
  26. /**
  27. * Creates a filter function which could filter
  28. * an array of paths with Array.prototype.filter.
  29. */
  30. createFilter(): (pathname: Pathname) => boolean
  31. /**
  32. * Returns Boolean whether pathname should be ignored.
  33. * @param {string} pathname a path to check
  34. * @returns boolean
  35. */
  36. ignores(pathname: Pathname): boolean
  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. interface Options {
  45. ignorecase?: boolean
  46. }
  47. /**
  48. * Creates new ignore manager.
  49. */
  50. declare function ignore(options?: Options): Ignore
  51. declare namespace ignore {
  52. export function isPathValid (pathname: string): boolean
  53. }
  54. export default ignore