From 8a8ccbb9a3dba1e64aeb00d16e200d00d206d3e7 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Mon, 27 Dec 2021 18:58:49 +0100 Subject: [PATCH] Add well-known `actual`, `expected` fields Closes GH-12. Reviewed-by: Titus Wormer --- index.js | 12 ++++++++++++ readme.md | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/index.js b/index.js index 9dcdb5c..b60dad1 100644 --- a/index.js +++ b/index.js @@ -111,6 +111,18 @@ export class VFileMessage extends Error { // Feel free to add other non-standard fields to your messages. /* eslint-disable no-unused-expressions */ + /** + * You can use this to specify the source value that’s being reported, which + * is deemed incorrect. + * @type {string?} + */ + this.actual + /** + * You can use this to suggest values that should be used instead of + * `actual`, one or more values that are deemed as acceptable. + * @type {Array?} + */ + this.expected /** * You may add a file property with a path of a file (used throughout the VFile ecosystem). * @type {string?} diff --git a/readme.md b/readme.md index 27e2105..2330b63 100644 --- a/readme.md +++ b/readme.md @@ -129,6 +129,16 @@ Stack of message (`string?`). It’s OK to store custom data directly on the `VFileMessage`, some of those are handled by [utilities][util]. +###### `actual` + +You can use this to specify the source value that’s being reported, which is +deemed incorrect. + +###### `expected` + +You can use this to suggest values that should be used instead of `actual`, one +or more values that are deemed as acceptable. + ###### `file` You may add a `file` property with a path of a file (used throughout the