Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.
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'
|
146
node_modules/vfile-message/lib/index.d.ts
generated
vendored
Normal file
146
node_modules/vfile-message/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* Message.
|
||||
*/
|
||||
export class VFileMessage extends Error {
|
||||
constructor(reason: string, options?: Options | null | undefined)
|
||||
constructor(
|
||||
reason: string,
|
||||
parent: Node | NodeLike | null | undefined,
|
||||
origin?: string | null | undefined
|
||||
)
|
||||
constructor(
|
||||
reason: string,
|
||||
place: Point | Position | null | undefined,
|
||||
origin?: string | null | undefined
|
||||
)
|
||||
constructor(reason: string, origin?: string | null | undefined)
|
||||
constructor(
|
||||
cause: Error | VFileMessage,
|
||||
parent: Node | NodeLike | null | undefined,
|
||||
origin?: string | null | undefined
|
||||
)
|
||||
constructor(
|
||||
cause: Error | VFileMessage,
|
||||
place: Point | Position | null | undefined,
|
||||
origin?: string | null | undefined
|
||||
)
|
||||
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 Node = import('unist').Node
|
||||
export type Point = import('unist').Point
|
||||
export type Position = import('unist').Position
|
||||
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
|
||||
}
|
318
node_modules/vfile-message/lib/index.js
generated
vendored
Normal file
318
node_modules/vfile-message/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,318 @@
|
||||
/**
|
||||
* @typedef {import('unist').Node} Node
|
||||
* @typedef {import('unist').Point} Point
|
||||
* @typedef {import('unist').Position} Position
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
||||
/* eslint-disable no-unused-expressions */
|
||||
/**
|
||||
* 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
|
||||
|
||||
/**
|
||||
* Suggest acceptable values that can be used instead of `actual`.
|
||||
*
|
||||
* @type {Array<string> | undefined}
|
||||
*/
|
||||
this.expected
|
||||
|
||||
/**
|
||||
* Long form description of the message (you should use markdown).
|
||||
*
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
this.note
|
||||
|
||||
/**
|
||||
* 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
|
||||
/* eslint-enable no-unused-expressions */
|
||||
}
|
||||
}
|
||||
|
||||
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) 2017 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.
|
77
node_modules/vfile-message/package.json
generated
vendored
Normal file
77
node_modules/vfile-message/package.json
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"name": "vfile-message",
|
||||
"version": "4.0.2",
|
||||
"description": "vfile utility to create a virtual message",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"vfile",
|
||||
"vfile-util",
|
||||
"util",
|
||||
"utility",
|
||||
"virtual",
|
||||
"file",
|
||||
"message"
|
||||
],
|
||||
"repository": "vfile/vfile-message",
|
||||
"bugs": "https://github.com/vfile/vfile-message/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"files": [
|
||||
"lib/",
|
||||
"index.d.ts",
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/unist": "^3.0.0",
|
||||
"unist-util-stringify-position": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.0.0",
|
||||
"c8": "^8.0.0",
|
||||
"prettier": "^2.0.0",
|
||||
"remark-cli": "^11.0.0",
|
||||
"remark-preset-wooorm": "^9.0.0",
|
||||
"type-coverage": "^2.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
"xo": "^0.54.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prepack": "npm run build && npm run format",
|
||||
"build": "tsc --build --clean && tsc --build && type-coverage",
|
||||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
|
||||
"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"
|
||||
},
|
||||
"prettier": {
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"useTabs": false
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"remark-preset-wooorm"
|
||||
]
|
||||
},
|
||||
"typeCoverage": {
|
||||
"atLeast": 100,
|
||||
"detail": true,
|
||||
"ignoreCatch": true,
|
||||
"strict": true
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true
|
||||
}
|
||||
}
|
264
node_modules/vfile-message/readme.md
generated
vendored
Normal file
264
node_modules/vfile-message/readme.md
generated
vendored
Normal file
@@ -0,0 +1,264 @@
|
||||
# vfile-message
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
|
||||
Create [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)
|
||||
* [Types](#types)
|
||||
* [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][esm].
|
||||
In Node.js (version 16+), install with [npm][]:
|
||||
|
||||
```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`?',
|
||||
{source: 'spell', ruleId: 'typo', place: {line: 1, column: 8}}
|
||||
)
|
||||
|
||||
console.log(message)
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```txt
|
||||
[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.
|
||||
|
||||
### `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`][mdn-error].
|
||||
|
||||
###### Returns
|
||||
|
||||
Instance of `VFileMessage`.
|
||||
|
||||
###### Fields
|
||||
|
||||
* `ancestors` ([`Array<Node>`][unist-node] or `undefined`)
|
||||
— stack of (inclusive) ancestor nodes surrounding the message
|
||||
* `cause` ([`Error`][mdn-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`][unist-point], [`Position`][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>`][unist-node], optional)
|
||||
— stack of (inclusive) ancestor nodes surrounding the message
|
||||
* `cause` ([`Error`][mdn-error], optional)
|
||||
— original error cause of the message
|
||||
* `place` ([`Point`][unist-point] or [`Position`][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][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)
|
||||
|
||||
## Types
|
||||
|
||||
This package is fully typed with [TypeScript][].
|
||||
It exports the additional type [`Options`][api-options].
|
||||
|
||||
## 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`][contributing] in [`vfile/.github`][health] for ways to
|
||||
get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://github.com/vfile/vfile-message/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/vfile/vfile-message/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/vfile/vfile-message.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/vfile/vfile-message
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/vfile-message.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/vfile-message
|
||||
|
||||
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=vfile-message
|
||||
|
||||
[size]: https://bundlejs.com/?q=vfile-message
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/vfile/vfile/discussions
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[contributing]: https://github.com/vfile/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/vfile/.github/blob/main/support.md
|
||||
|
||||
[health]: https://github.com/vfile/.github
|
||||
|
||||
[coc]: https://github.com/vfile/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[mdn-error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
|
||||
|
||||
[unist-node]: https://github.com/syntax-tree/unist#node
|
||||
|
||||
[unist-point]: https://github.com/syntax-tree/unist#point
|
||||
|
||||
[unist-position]: https://github.com/syntax-tree/unist#position
|
||||
|
||||
[vfile]: https://github.com/vfile/vfile
|
||||
|
||||
[util]: https://github.com/vfile/vfile#utilities
|
||||
|
||||
[api-options]: #options
|
||||
|
||||
[api-vfile-message]: #vfilemessagereason-options
|
Reference in New Issue
Block a user