the editable site (validation-lab)
This commit is contained in:
commit
3ac81d5a52
13454 files changed
+2227005
No files matched your search
+684
@@ -0,0 +1,684 @@
|
||||
/**
|
||||
* Message.
|
||||
*/
|
||||
export class VFileMessage extends Error {
|
||||
/**
|
||||
* Create a message for `reason`.
|
||||
*
|
||||
* > 🪦 **Note**: also has obsolete signatures.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @param {Error | VFileMessage | string} causeOrReason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
|
||||
* Configuration (optional).
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (example:
|
||||
* `'my-package:my-rule'` or `'my-rule'`).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*/
|
||||
constructor(reason: string, options?: Options | null | undefined);
|
||||
/**
|
||||
* Create a message for `reason`.
|
||||
*
|
||||
* > 🪦 **Note**: also has obsolete signatures.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @param {Error | VFileMessage | string} causeOrReason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
|
||||
* Configuration (optional).
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (example:
|
||||
* `'my-package:my-rule'` or `'my-rule'`).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*/
|
||||
constructor(reason: string, parent: Node | NodeLike | null | undefined, origin?: string | null | undefined);
|
||||
/**
|
||||
* Create a message for `reason`.
|
||||
*
|
||||
* > 🪦 **Note**: also has obsolete signatures.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @param {Error | VFileMessage | string} causeOrReason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
|
||||
* Configuration (optional).
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (example:
|
||||
* `'my-package:my-rule'` or `'my-rule'`).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*/
|
||||
constructor(reason: string, place: Point | Position | null | undefined, origin?: string | null | undefined);
|
||||
/**
|
||||
* Create a message for `reason`.
|
||||
*
|
||||
* > 🪦 **Note**: also has obsolete signatures.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @param {Error | VFileMessage | string} causeOrReason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
|
||||
* Configuration (optional).
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (example:
|
||||
* `'my-package:my-rule'` or `'my-rule'`).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*/
|
||||
constructor(reason: string, origin?: string | null | undefined);
|
||||
/**
|
||||
* Create a message for `reason`.
|
||||
*
|
||||
* > 🪦 **Note**: also has obsolete signatures.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @param {Error | VFileMessage | string} causeOrReason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
|
||||
* Configuration (optional).
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (example:
|
||||
* `'my-package:my-rule'` or `'my-rule'`).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*/
|
||||
constructor(cause: Error | VFileMessage, parent: Node | NodeLike | null | undefined, origin?: string | null | undefined);
|
||||
/**
|
||||
* Create a message for `reason`.
|
||||
*
|
||||
* > 🪦 **Note**: also has obsolete signatures.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @param {Error | VFileMessage | string} causeOrReason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
|
||||
* Configuration (optional).
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (example:
|
||||
* `'my-package:my-rule'` or `'my-rule'`).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*/
|
||||
constructor(cause: Error | VFileMessage, place: Point | Position | null | undefined, origin?: string | null | undefined);
|
||||
/**
|
||||
* Create a message for `reason`.
|
||||
*
|
||||
* > 🪦 **Note**: also has obsolete signatures.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @param {Error | VFileMessage | string} causeOrReason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
|
||||
* Configuration (optional).
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (example:
|
||||
* `'my-package:my-rule'` or `'my-rule'`).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*/
|
||||
constructor(cause: Error | VFileMessage, origin?: string | null | undefined);
|
||||
/**
|
||||
* Stack of ancestor nodes surrounding the message.
|
||||
*
|
||||
* @type {Array<Node> | undefined}
|
||||
*/
|
||||
ancestors: Array<Node> | undefined;
|
||||
/**
|
||||
* Starting column of message.
|
||||
*
|
||||
* @type {number | undefined}
|
||||
*/
|
||||
column: number | undefined;
|
||||
/**
|
||||
* State of problem.
|
||||
*
|
||||
* * `true` — error, file not usable
|
||||
* * `false` — warning, change may be needed
|
||||
* * `undefined` — change likely not needed
|
||||
*
|
||||
* @type {boolean | null | undefined}
|
||||
*/
|
||||
fatal: boolean | null | undefined;
|
||||
/**
|
||||
* Path of a file (used throughout the `VFile` ecosystem).
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
file: string | undefined;
|
||||
/**
|
||||
* Starting line of error.
|
||||
*
|
||||
* @type {number | undefined}
|
||||
*/
|
||||
line: number | undefined;
|
||||
/**
|
||||
* Place of message.
|
||||
*
|
||||
* @type {Point | Position | undefined}
|
||||
*/
|
||||
place: Point | Position | undefined;
|
||||
/**
|
||||
* Reason for message, should use markdown.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
reason: string;
|
||||
/**
|
||||
* Category of message (example: `'my-rule'`).
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
ruleId: string | undefined;
|
||||
/**
|
||||
* Namespace of message (example: `'my-package'`).
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
source: string | undefined;
|
||||
/**
|
||||
* Specify the source value that’s being reported, which is deemed
|
||||
* incorrect.
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
actual: string | undefined;
|
||||
/**
|
||||
* Suggest acceptable values that can be used instead of `actual`.
|
||||
*
|
||||
* @type {Array<string> | undefined}
|
||||
*/
|
||||
expected: Array<string> | undefined;
|
||||
/**
|
||||
* Long form description of the message (you should use markdown).
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
note: string | undefined;
|
||||
/**
|
||||
* Link to docs for the message.
|
||||
*
|
||||
* > 👉 **Note**: this must be an absolute URL that can be passed as `x`
|
||||
* > to `new URL(x)`.
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
url: string | undefined;
|
||||
}
|
||||
export type NodeLike = object & {
|
||||
type: string;
|
||||
position?: Position | undefined;
|
||||
};
|
||||
/**
|
||||
* Configuration.
|
||||
*/
|
||||
export type Options = {
|
||||
/**
|
||||
* Stack of (inclusive) ancestor nodes surrounding the message (optional).
|
||||
*/
|
||||
ancestors?: Array<Node> | null | undefined;
|
||||
/**
|
||||
* Original error cause of the message (optional).
|
||||
*/
|
||||
cause?: Error | null | undefined;
|
||||
/**
|
||||
* Place of message (optional).
|
||||
*/
|
||||
place?: Point | Position | null | undefined;
|
||||
/**
|
||||
* Category of message (optional, example: `'my-rule'`).
|
||||
*/
|
||||
ruleId?: string | null | undefined;
|
||||
/**
|
||||
* Namespace of who sent the message (optional, example: `'my-package'`).
|
||||
*/
|
||||
source?: string | null | undefined;
|
||||
};
|
||||
import type { Node } from 'unist';
|
||||
import type { Point } from 'unist';
|
||||
import type { Position } from 'unist';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"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"}
|
||||
+344
@@ -0,0 +1,344 @@
|
||||
/**
|
||||
* @import {Node, Point, Position} from 'unist'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object & {type: string, position?: Position | undefined}} NodeLike
|
||||
*
|
||||
* @typedef Options
|
||||
* Configuration.
|
||||
* @property {Array<Node> | null | undefined} [ancestors]
|
||||
* Stack of (inclusive) ancestor nodes surrounding the message (optional).
|
||||
* @property {Error | null | undefined} [cause]
|
||||
* Original error cause of the message (optional).
|
||||
* @property {Point | Position | null | undefined} [place]
|
||||
* Place of message (optional).
|
||||
* @property {string | null | undefined} [ruleId]
|
||||
* Category of message (optional, example: `'my-rule'`).
|
||||
* @property {string | null | undefined} [source]
|
||||
* Namespace of who sent the message (optional, example: `'my-package'`).
|
||||
*/
|
||||
|
||||
import {stringifyPosition} from 'unist-util-stringify-position'
|
||||
|
||||
/**
|
||||
* Message.
|
||||
*/
|
||||
export class VFileMessage extends Error {
|
||||
/**
|
||||
* Create a message for `reason`.
|
||||
*
|
||||
* > 🪦 **Note**: also has obsolete signatures.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* Node or node-like, used for `ancestors` and `place`.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* Place of message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* Original error cause of the message.
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (optional).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*
|
||||
* @param {Error | VFileMessage | string} causeOrReason
|
||||
* Reason for message, should use markdown.
|
||||
* @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
|
||||
* Configuration (optional).
|
||||
* @param {string | null | undefined} [origin]
|
||||
* Place in code where the message originates (example:
|
||||
* `'my-package:my-rule'` or `'my-rule'`).
|
||||
* @returns
|
||||
* Instance of `VFileMessage`.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
constructor(causeOrReason, optionsOrParentOrPlace, origin) {
|
||||
super()
|
||||
|
||||
if (typeof optionsOrParentOrPlace === 'string') {
|
||||
origin = optionsOrParentOrPlace
|
||||
optionsOrParentOrPlace = undefined
|
||||
}
|
||||
|
||||
/** @type {string} */
|
||||
let reason = ''
|
||||
/** @type {Options} */
|
||||
let options = {}
|
||||
let legacyCause = false
|
||||
|
||||
if (optionsOrParentOrPlace) {
|
||||
// Point.
|
||||
if (
|
||||
'line' in optionsOrParentOrPlace &&
|
||||
'column' in optionsOrParentOrPlace
|
||||
) {
|
||||
options = {place: optionsOrParentOrPlace}
|
||||
}
|
||||
// Position.
|
||||
else if (
|
||||
'start' in optionsOrParentOrPlace &&
|
||||
'end' in optionsOrParentOrPlace
|
||||
) {
|
||||
options = {place: optionsOrParentOrPlace}
|
||||
}
|
||||
// Node.
|
||||
else if ('type' in optionsOrParentOrPlace) {
|
||||
options = {
|
||||
ancestors: [optionsOrParentOrPlace],
|
||||
place: optionsOrParentOrPlace.position
|
||||
}
|
||||
}
|
||||
// Options.
|
||||
else {
|
||||
options = {...optionsOrParentOrPlace}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof causeOrReason === 'string') {
|
||||
reason = causeOrReason
|
||||
}
|
||||
// Error.
|
||||
else if (!options.cause && causeOrReason) {
|
||||
legacyCause = true
|
||||
reason = causeOrReason.message
|
||||
options.cause = causeOrReason
|
||||
}
|
||||
|
||||
if (!options.ruleId && !options.source && typeof origin === 'string') {
|
||||
const index = origin.indexOf(':')
|
||||
|
||||
if (index === -1) {
|
||||
options.ruleId = origin
|
||||
} else {
|
||||
options.source = origin.slice(0, index)
|
||||
options.ruleId = origin.slice(index + 1)
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.place && options.ancestors) {
|
||||
const parent = options.ancestors[options.ancestors.length - 1]
|
||||
|
||||
if (parent) {
|
||||
options.place = parent.position
|
||||
}
|
||||
}
|
||||
|
||||
const start =
|
||||
options.place && 'start' in options.place
|
||||
? options.place.start
|
||||
: options.place
|
||||
|
||||
/**
|
||||
* Stack of ancestor nodes surrounding the message.
|
||||
*
|
||||
* @type {Array<Node> | undefined}
|
||||
*/
|
||||
this.ancestors = options.ancestors || undefined
|
||||
|
||||
/**
|
||||
* Original error cause of the message.
|
||||
*
|
||||
* @type {Error | undefined}
|
||||
*/
|
||||
this.cause = options.cause || undefined
|
||||
|
||||
/**
|
||||
* Starting column of message.
|
||||
*
|
||||
* @type {number | undefined}
|
||||
*/
|
||||
this.column = start ? start.column : undefined
|
||||
|
||||
/**
|
||||
* State of problem.
|
||||
*
|
||||
* * `true` — error, file not usable
|
||||
* * `false` — warning, change may be needed
|
||||
* * `undefined` — change likely not needed
|
||||
*
|
||||
* @type {boolean | null | undefined}
|
||||
*/
|
||||
this.fatal = undefined
|
||||
|
||||
/**
|
||||
* Path of a file (used throughout the `VFile` ecosystem).
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
this.file = ''
|
||||
|
||||
// Field from `Error`.
|
||||
/**
|
||||
* Reason for message.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.message = reason
|
||||
|
||||
/**
|
||||
* Starting line of error.
|
||||
*
|
||||
* @type {number | undefined}
|
||||
*/
|
||||
this.line = start ? start.line : undefined
|
||||
|
||||
// Field from `Error`.
|
||||
/**
|
||||
* Serialized positional info of message.
|
||||
*
|
||||
* On normal errors, this would be something like `ParseError`, buit in
|
||||
* `VFile` messages we use this space to show where an error happened.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.name = stringifyPosition(options.place) || '1:1'
|
||||
|
||||
/**
|
||||
* Place of message.
|
||||
*
|
||||
* @type {Point | Position | undefined}
|
||||
*/
|
||||
this.place = options.place || undefined
|
||||
|
||||
/**
|
||||
* Reason for message, should use markdown.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.reason = this.message
|
||||
|
||||
/**
|
||||
* Category of message (example: `'my-rule'`).
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
this.ruleId = options.ruleId || undefined
|
||||
|
||||
/**
|
||||
* Namespace of message (example: `'my-package'`).
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
this.source = options.source || undefined
|
||||
|
||||
// Field from `Error`.
|
||||
/**
|
||||
* Stack of message.
|
||||
*
|
||||
* This is used by normal errors to show where something happened in
|
||||
* programming code, irrelevant for `VFile` messages,
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.stack =
|
||||
legacyCause && options.cause && typeof options.cause.stack === 'string'
|
||||
? options.cause.stack
|
||||
: ''
|
||||
|
||||
// The following fields are “well known”.
|
||||
// Not standard.
|
||||
// Feel free to add other non-standard fields to your messages.
|
||||
|
||||
/**
|
||||
* Specify the source value that’s being reported, which is deemed
|
||||
* incorrect.
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
this.actual = undefined
|
||||
|
||||
/**
|
||||
* Suggest acceptable values that can be used instead of `actual`.
|
||||
*
|
||||
* @type {Array<string> | undefined}
|
||||
*/
|
||||
this.expected = undefined
|
||||
|
||||
/**
|
||||
* Long form description of the message (you should use markdown).
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
this.note = undefined
|
||||
|
||||
/**
|
||||
* Link to docs for the message.
|
||||
*
|
||||
* > 👉 **Note**: this must be an absolute URL that can be passed as `x`
|
||||
* > to `new URL(x)`.
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
this.url = undefined
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line unicorn/no-top-level-side-effects -- our own class.
|
||||
Object.defineProperties(VFileMessage.prototype, {
|
||||
file: {configurable: true, enumerable: true, value: '', writable: true},
|
||||
name: {configurable: true, enumerable: true, value: '', writable: true},
|
||||
reason: {configurable: true, enumerable: true, value: '', writable: true},
|
||||
message: {configurable: true, enumerable: true, value: '', writable: true},
|
||||
stack: {configurable: true, enumerable: true, value: '', writable: true},
|
||||
column: {configurable: true, enumerable: true, writable: true},
|
||||
line: {configurable: true, enumerable: true, writable: true},
|
||||
ancestors: {configurable: true, enumerable: true, writable: true},
|
||||
cause: {configurable: true, enumerable: true, writable: true},
|
||||
fatal: {configurable: true, enumerable: true, writable: true},
|
||||
place: {configurable: true, enumerable: true, writable: true},
|
||||
ruleId: {configurable: true, enumerable: true, writable: true},
|
||||
source: {configurable: true, enumerable: true, writable: true}
|
||||
})
|
||||
Reference in new issue
Block a user