Skip to content

Commit

Permalink
fix v-file-message types
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaap committed Apr 9, 2020
1 parent 0f0d431 commit 341d0a9
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 13 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ dist
/src/styles/vendor/
*.md
babel.i18next-extract.js
/built
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ client/dist
/.virtualgo
.vscode/
coverage.out

/built
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ examples/*/src/serviceWorker.js
/include/
/build/
build
/built
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"@types/braintree__sanitize-url": "^4.0.0",
"@types/seamless-immutable": "7.1.11",
"@types/uuid": "^3.4.5",
"@types/vfile-message": "^2.0.0",
"autoprefixer": "^9.4.3",
"babel-eslint": "^10.0.1",
"babel-loader": "8.0.6",
Expand Down
98 changes: 98 additions & 0 deletions src/@types/vfile-message.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// TypeScript Version: 3.0

import * as Unist from 'unist';

declare namespace vfileMessage {
/**
* Create a virtual message.
*/
interface VFileMessage extends Error {
/**
* Constructor of a message for `reason` at `position` from `origin`.
* When an error is passed in as `reason`, copies the `stack`.
*
* @param reason Reason for message (`string` or `Error`). Uses the stack and message of the error if given.
* @param position Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional).
* @param origin Place in code the message originates from (`string`, optional).
*/
(
reason: string | Error,
position?: Unist.Node | Unist.Position | Unist.Point,
origin?: string,
): VFileMessage;

/**
* Constructor of a message for `reason` at `position` from `origin`.
* When an error is passed in as `reason`, copies the `stack`.
*
* @param reason Reason for message (`string` or `Error`). Uses the stack and message of the error if given.
* @param position Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional).
* @param origin Place in code the message originates from (`string`, optional).
*/
new (
reason: string | Error,
position?: Unist.Node | Unist.Position | Unist.Point,
origin?: string,
): VFileMessage;

/**
* Category of message.
*/
ruleId: string | null;

/**
* Reason for message.
*/
reason: string;

/**
* Starting line of error.
*/
line: number | null;

/**
* Starting column of error.
*/
column: number | null;

/**
* Full range information, when available.
* Has start and end properties, both set to an object with line and column, set to number?.
*/
location: Unist.Position;

/**
* Namespace of warning.
*/
source: string | null;

/**
* If true, marks associated file as no longer processable.
*/
fatal?: boolean | null;

/**
* You may add a file property with a path of a file (used throughout the VFile ecosystem).
*/
file?: string;

/**
* You may add a note property with a long form description of the message (supported by vfile-reporter).
*/
note?: string;

/**
* You may add a url property with a link to documentation for the message.
*/
url?: string;

/**
* It’s OK to store custom data directly on the VMessage, some of those are handled by utilities.
*/
[key: string]: unknown;
}
}

declare const vfileMessage: vfileMessage.VFileMessage;

export = vfileMessage;
Loading

0 comments on commit 341d0a9

Please sign in to comment.