index.d.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /**
  2. * Message.
  3. */
  4. export class VFileMessage extends Error {
  5. constructor(reason: string, options?: Options | null | undefined)
  6. constructor(
  7. reason: string,
  8. parent: Node | NodeLike | null | undefined,
  9. origin?: string | null | undefined
  10. )
  11. constructor(
  12. reason: string,
  13. place: Point | Position | null | undefined,
  14. origin?: string | null | undefined
  15. )
  16. constructor(reason: string, origin?: string | null | undefined)
  17. constructor(
  18. cause: Error | VFileMessage,
  19. parent: Node | NodeLike | null | undefined,
  20. origin?: string | null | undefined
  21. )
  22. constructor(
  23. cause: Error | VFileMessage,
  24. place: Point | Position | null | undefined,
  25. origin?: string | null | undefined
  26. )
  27. constructor(cause: Error | VFileMessage, origin?: string | null | undefined)
  28. /**
  29. * Stack of ancestor nodes surrounding the message.
  30. *
  31. * @type {Array<Node> | undefined}
  32. */
  33. ancestors: Array<Node> | undefined
  34. /**
  35. * Starting column of message.
  36. *
  37. * @type {number | undefined}
  38. */
  39. column: number | undefined
  40. /**
  41. * State of problem.
  42. *
  43. * * `true` — error, file not usable
  44. * * `false` — warning, change may be needed
  45. * * `undefined` — change likely not needed
  46. *
  47. * @type {boolean | null | undefined}
  48. */
  49. fatal: boolean | null | undefined
  50. /**
  51. * Path of a file (used throughout the `VFile` ecosystem).
  52. *
  53. * @type {string | undefined}
  54. */
  55. file: string | undefined
  56. /**
  57. * Starting line of error.
  58. *
  59. * @type {number | undefined}
  60. */
  61. line: number | undefined
  62. /**
  63. * Place of message.
  64. *
  65. * @type {Point | Position | undefined}
  66. */
  67. place: Point | Position | undefined
  68. /**
  69. * Reason for message, should use markdown.
  70. *
  71. * @type {string}
  72. */
  73. reason: string
  74. /**
  75. * Category of message (example: `'my-rule'`).
  76. *
  77. * @type {string | undefined}
  78. */
  79. ruleId: string | undefined
  80. /**
  81. * Namespace of message (example: `'my-package'`).
  82. *
  83. * @type {string | undefined}
  84. */
  85. source: string | undefined
  86. /**
  87. * Specify the source value that’s being reported, which is deemed
  88. * incorrect.
  89. *
  90. * @type {string | undefined}
  91. */
  92. actual: string | undefined
  93. /**
  94. * Suggest acceptable values that can be used instead of `actual`.
  95. *
  96. * @type {Array<string> | undefined}
  97. */
  98. expected: Array<string> | undefined
  99. /**
  100. * Long form description of the message (you should use markdown).
  101. *
  102. * @type {string | undefined}
  103. */
  104. note: string | undefined
  105. /**
  106. * Link to docs for the message.
  107. *
  108. * > 👉 **Note**: this must be an absolute URL that can be passed as `x`
  109. * > to `new URL(x)`.
  110. *
  111. * @type {string | undefined}
  112. */
  113. url: string | undefined
  114. }
  115. export type Node = import('unist').Node
  116. export type Point = import('unist').Point
  117. export type Position = import('unist').Position
  118. export type NodeLike = object & {
  119. type: string
  120. position?: Position | undefined
  121. }
  122. /**
  123. * Configuration.
  124. */
  125. export type Options = {
  126. /**
  127. * Stack of (inclusive) ancestor nodes surrounding the message (optional).
  128. */
  129. ancestors?: Array<Node> | null | undefined
  130. /**
  131. * Original error cause of the message (optional).
  132. */
  133. cause?: Error | null | undefined
  134. /**
  135. * Place of message (optional).
  136. */
  137. place?: Point | Position | null | undefined
  138. /**
  139. * Category of message (optional, example: `'my-rule'`).
  140. */
  141. ruleId?: string | null | undefined
  142. /**
  143. * Namespace of who sent the message (optional, example: `'my-package'`).
  144. */
  145. source?: string | null | undefined
  146. }