first commit
This commit is contained in:
2
node_modules/vfile-message/index.d.ts
generated
vendored
Normal file
2
node_modules/vfile-message/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export { VFileMessage } from "./lib/index.js";
|
||||
export type Options = import("./lib/index.js").Options;
|
||||
5
node_modules/vfile-message/index.js
generated
vendored
Normal file
5
node_modules/vfile-message/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @typedef {import('./lib/index.js').Options} Options
|
||||
*/
|
||||
|
||||
export {VFileMessage} from './lib/index.js'
|
||||
508
node_modules/vfile-message/lib/index.d.ts
generated
vendored
Normal file
508
node_modules/vfile-message/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,508 @@
|
||||
/**
|
||||
* Message.
|
||||
*/
|
||||
export class VFileMessage extends Error {
|
||||
/**
|
||||
* Create a message for `reason`.
|
||||
*
|
||||
* > 🪦 **Note**: also has obsolete signatures.
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Options | null | undefined} [options]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @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
|
||||
* @param {Options | null | undefined} [options]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @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
|
||||
* @param {Options | null | undefined} [options]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @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
|
||||
* @param {Options | null | undefined} [options]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @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
|
||||
* @param {Options | null | undefined} [options]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @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
|
||||
* @param {Options | null | undefined} [options]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @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
|
||||
* @param {Options | null | undefined} [options]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @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';
|
||||
314
node_modules/vfile-message/lib/index.js
generated
vendored
Normal file
314
node_modules/vfile-message/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,314 @@
|
||||
/**
|
||||
* @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
|
||||
* @param {Options | null | undefined} [options]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {string} reason
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Node | NodeLike | null | undefined} parent
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {Point | Position | null | undefined} place
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @overload
|
||||
* @param {Error | VFileMessage} cause
|
||||
* @param {string | null | undefined} [origin]
|
||||
* @returns
|
||||
*
|
||||
* @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 && 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.
|
||||
*/
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
VFileMessage.prototype.file = ''
|
||||
VFileMessage.prototype.name = ''
|
||||
VFileMessage.prototype.reason = ''
|
||||
VFileMessage.prototype.message = ''
|
||||
VFileMessage.prototype.stack = ''
|
||||
VFileMessage.prototype.column = undefined
|
||||
VFileMessage.prototype.line = undefined
|
||||
VFileMessage.prototype.ancestors = undefined
|
||||
VFileMessage.prototype.cause = undefined
|
||||
VFileMessage.prototype.fatal = undefined
|
||||
VFileMessage.prototype.place = undefined
|
||||
VFileMessage.prototype.ruleId = undefined
|
||||
VFileMessage.prototype.source = undefined
|
||||
22
node_modules/vfile-message/license
generated
vendored
Normal file
22
node_modules/vfile-message/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
80
node_modules/vfile-message/package.json
generated
vendored
Normal file
80
node_modules/vfile-message/package.json
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"bugs": "https://github.com/vfile/vfile-message/issues",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/unist": "^3.0.0",
|
||||
"unist-util-stringify-position": "^4.0.0"
|
||||
},
|
||||
"description": "vfile utility to create a virtual message",
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.0.0",
|
||||
"c8": "^10.0.0",
|
||||
"prettier": "^3.0.0",
|
||||
"remark-cli": "^12.0.0",
|
||||
"remark-preset-wooorm": "^11.0.0",
|
||||
"type-coverage": "^2.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
"xo": "^1.0.0"
|
||||
},
|
||||
"exports": "./index.js",
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"keywords": [
|
||||
"file",
|
||||
"message",
|
||||
"utility",
|
||||
"util",
|
||||
"vfile-util",
|
||||
"vfile",
|
||||
"virtual"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "vfile-message",
|
||||
"prettier": {
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"useTabs": false
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"remark-preset-wooorm"
|
||||
]
|
||||
},
|
||||
"repository": "vfile/vfile-message",
|
||||
"scripts": {
|
||||
"build": "tsc --build --clean && tsc --build && type-coverage",
|
||||
"format": "remark --frail --output --quiet -- . && prettier --log-level warn --write -- . && xo --fix",
|
||||
"prepack": "npm run build && npm run format",
|
||||
"test-api": "node --conditions development test.js",
|
||||
"test-coverage": "c8 --100 --reporter lcov -- npm run test-api",
|
||||
"test": "npm run build && npm run format && npm run test-coverage"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"typeCoverage": {
|
||||
"atLeast": 100,
|
||||
"ignoreCatch": true
|
||||
},
|
||||
"type": "module",
|
||||
"version": "4.0.3",
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"rules": {
|
||||
"prefer-destructuring": "off",
|
||||
"unicorn/prefer-at": "off"
|
||||
},
|
||||
"space": true
|
||||
}
|
||||
}
|
||||
252
node_modules/vfile-message/readme.md
generated
vendored
Normal file
252
node_modules/vfile-message/readme.md
generated
vendored
Normal file
@@ -0,0 +1,252 @@
|
||||
# vfile-message
|
||||
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
|
||||
Create [vfile][github-vfile] messages.
|
||||
|
||||
## Contents
|
||||
|
||||
* [What is this?](#what-is-this)
|
||||
* [When should I use this?](#when-should-i-use-this)
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`VFileMessage(reason[, options])`](#vfilemessagereason-options)
|
||||
* [`Options`](#options)
|
||||
* [Well-known](#well-known)
|
||||
* [Compatibility](#compatibility)
|
||||
* [Contribute](#contribute)
|
||||
* [License](#license)
|
||||
|
||||
## What is this?
|
||||
|
||||
This package provides a (lint) message format.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
In most cases,
|
||||
you can use `file.message` from `VFile` itself,
|
||||
but in some cases you might not have a file,
|
||||
and still want to emit warnings or errors,
|
||||
in which case this can be used directly.
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npmjs-install]:
|
||||
|
||||
```sh
|
||||
npm install vfile-message
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
|
||||
```js
|
||||
import {VFileMessage} from 'https://esm.sh/vfile-message@4'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import {VFileMessage} from 'https://esm.sh/vfile-message@4?bundle'
|
||||
</script>
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
```js
|
||||
import {VFileMessage} from 'vfile-message'
|
||||
|
||||
const message = new VFileMessage(
|
||||
'Unexpected unknown word `braavo`, did you mean `bravo`?',
|
||||
{place: {column: 8, line: 1}, ruleId: 'typo', source: 'spell'}
|
||||
)
|
||||
|
||||
console.log(message)
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```text
|
||||
[1:8: Unexpected unknown word `braavo`, did you mean `bravo`?] {
|
||||
reason: 'Unexpected unknown word `braavo`, did you mean `bravo`?',
|
||||
line: 1,
|
||||
column: 8,
|
||||
ancestors: undefined,
|
||||
cause: undefined,
|
||||
fatal: undefined,
|
||||
place: {line: 1, column: 8},
|
||||
ruleId: 'typo',
|
||||
source: 'spell'
|
||||
}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This package exports the identifier [`VFileMessage`][api-vfile-message].
|
||||
There is no default export.
|
||||
It exports the additional [TypeScript][] type [`Options`][api-options].
|
||||
|
||||
### `VFileMessage(reason[, options])`
|
||||
|
||||
Create a message for `reason`.
|
||||
|
||||
> 🪦 **Note**: also has obsolete signatures.
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `reason` (`string`)
|
||||
— reason for message (should use markdown)
|
||||
* `options` ([`Options`][api-options], optional)
|
||||
— configuration.
|
||||
|
||||
###### Extends
|
||||
|
||||
[`Error`][developer-mozilla-error].
|
||||
|
||||
###### Returns
|
||||
|
||||
Instance of `VFileMessage`.
|
||||
|
||||
###### Fields
|
||||
|
||||
* `ancestors` ([`Array<Node>`][github-unist-node] or `undefined`)
|
||||
— stack of (inclusive) ancestor nodes surrounding the message
|
||||
* `cause` ([`Error`][developer-mozilla-error] or `undefined`)
|
||||
— original error cause of the message
|
||||
* `column` (`number` or `undefined`)
|
||||
— starting column of message
|
||||
* `fatal` (`boolean` or `undefined`)
|
||||
— state of problem; `true`: error, file not usable; `false`: warning,
|
||||
change may be needed; `undefined`: info, change likely not needed
|
||||
* `line` (`number` or `undefined`)
|
||||
— starting line of message
|
||||
* `place` ([`Point`][github-unist-point], [`Position`][github-unist-position]
|
||||
or `undefined`)
|
||||
— place of message
|
||||
* `reason` (`string`)
|
||||
— reason for message (should use markdown)
|
||||
* `ruleId` (`string` or `undefined`, example: `'my-rule'`)
|
||||
— category of message
|
||||
* `source` (`string` or `undefined`, example: `'my-package'`)
|
||||
— namespace of message
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `ancestors` ([`Array<Node>`][github-unist-node], optional)
|
||||
— stack of (inclusive) ancestor nodes surrounding the message
|
||||
* `cause` ([`Error`][developer-mozilla-error], optional)
|
||||
— original error cause of the message
|
||||
* `place` ([`Point`][github-unist-point] or [`Position`][github-unist-position],
|
||||
optional)
|
||||
— place of message
|
||||
* `ruleId` (`string`, optional, example: `'my-rule'`)
|
||||
— category of message
|
||||
* `source` (`string`, optional, , example: `'my-package'`)
|
||||
— namespace of who sent the message
|
||||
|
||||
### Well-known
|
||||
|
||||
It’s OK to store custom data directly on the `VFileMessage`, some of those are
|
||||
handled by [utilities][github-vfile-util].
|
||||
The following fields are documented and typed here.
|
||||
|
||||
###### Fields
|
||||
|
||||
* `actual` (`string`, optional)
|
||||
— specify the source value that’s being reported, which is deemed incorrect
|
||||
* `expected` (`Array<string>`, optional)
|
||||
— suggest acceptable values that can be used instead of `actual`
|
||||
* `url` (`string`, optional)
|
||||
— link to docs for the message (this must be an absolute URL that can be
|
||||
passed as `x` to `new URL(x)`)
|
||||
* `note` (`string`, optional)
|
||||
— long form description of the message (you should use markdown)
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
|
||||
When we cut a new major release, we drop support for unmaintained versions of
|
||||
Node.
|
||||
This means we try to keep the current release line, `vfile-message@^4`,
|
||||
compatible with Node.js 16.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][health-contributing] in [`vfile/.github`][health]
|
||||
for ways to get started.
|
||||
See [`support.md`][health-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][health-coc].
|
||||
By interacting with this repository,
|
||||
organization,
|
||||
or community you agree to abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][file-license] © [Titus Wormer][wooorm]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[api-options]: #options
|
||||
|
||||
[api-vfile-message]: #vfilemessagereason-options
|
||||
|
||||
[badge-build-image]: https://github.com/vfile/vfile-message/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/vfile/vfile-message/actions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/vfile/vfile-message.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/vfile/vfile-message
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/vfile-message.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/vfile-message
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/vfile-message
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=vfile-message
|
||||
|
||||
[developer-mozilla-error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[file-license]: license
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-unist-node]: https://github.com/syntax-tree/unist#node
|
||||
|
||||
[github-unist-point]: https://github.com/syntax-tree/unist#point
|
||||
|
||||
[github-unist-position]: https://github.com/syntax-tree/unist#position
|
||||
|
||||
[github-vfile]: https://github.com/vfile/vfile
|
||||
|
||||
[github-vfile-util]: https://github.com/vfile/vfile#utilities
|
||||
|
||||
[health]: https://github.com/vfile/.github
|
||||
|
||||
[health-coc]: https://github.com/vfile/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[health-contributing]: https://github.com/vfile/.github/blob/main/contributing.md
|
||||
|
||||
[health-support]: https://github.com/vfile/.github/blob/main/support.md
|
||||
|
||||
[npmjs-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
||||
[wooorm]: https://wooorm.com
|
||||
Reference in New Issue
Block a user