3 [![Build][build-badge]][build]
4 [![Coverage][coverage-badge]][coverage]
5 [![Downloads][downloads-badge]][downloads]
6 [![Chat][chat-badge]][chat]
8 Create [vfile][] messages.
15 npm install vfile-message
21 var VMessage = require('vfile-message')
23 var message = new VMessage(
24 '`braavo` is misspelt; did you mean `bravo`?',
35 { [1:8: `braavo` is misspelt; did you mean `bravo`?]
36 reason: '`braavo` is misspelt; did you mean `bravo`?',
41 { start: { line: 1, column: 8 },
42 end: { line: null, column: null } },
49 ### `VMessage(reason[, position][, origin])`
51 Constructor of a message for `reason` at `position` from `origin`. When
52 an error is passed in as `reason`, copies the stack.
58 Reason for message (`string` or `Error`). Uses the stack and message of the
63 Place at which the message occurred in a file ([`Node`][node],
64 [`Position`][position], or [`Point`][point], optional).
68 Place in code the message originates from (`string`, optional).
70 Can either be the [`ruleId`][ruleid] (`'rule'`), or a string with both a
71 [`source`][source] and a [`ruleId`][ruleid] delimited with a colon
80 An instance of itself.
86 Reason for message (`string`).
90 If `true`, marks associated file as no longer processable (`boolean?`). If
91 `false`, necessitates a (potential) change. The value can also be `null` or
96 Starting line of error (`number?`).
100 Starting column of error (`number?`).
104 Full range information, when available ([`Position`][position]). Has `start`
105 and `end` properties, both set to an object with `line` and `column`, set to
110 Namespace of warning (`string?`).
114 Category of message (`string?`).
118 Stack of message (`string?`).
120 ##### Custom properties
122 It’s OK to store custom data directly on the `VMessage`, some of those are
123 handled by [utilities][util].
127 You may add a `file` property with a path of a file (used throughout the
128 [**VFile**][vfile] ecosystem).
132 You may add a `note` property with a long form description of the message
133 (supported by [`vfile-reporter`][reporter]).
137 You may add a `url` property with a link to documentation for the message.
141 See [`contributing.md` in `vfile/vfile`][contributing] for ways to get started.
143 This organisation has a [Code of Conduct][coc]. By interacting with this
144 repository, organisation, or community you agree to abide by its terms.
148 [MIT][license] © [Titus Wormer][author]
152 [build-badge]: https://img.shields.io/travis/vfile/vfile-message.svg
154 [build]: https://travis-ci.org/vfile/vfile-message
156 [coverage-badge]: https://img.shields.io/codecov/c/github/vfile/vfile-message.svg
158 [coverage]: https://codecov.io/github/vfile/vfile-message
160 [downloads-badge]: https://img.shields.io/npm/dm/vfile-message.svg
162 [downloads]: https://www.npmjs.com/package/vfile-message
164 [chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
166 [chat]: https://spectrum.chat/unified/vfile
168 [npm]: https://docs.npmjs.com/cli/install
172 [author]: https://wooorm.com
174 [error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
176 [node]: https://github.com/syntax-tree/unist#node
178 [position]: https://github.com/syntax-tree/unist#position
180 [point]: https://github.com/syntax-tree/unist#point
182 [vfile]: https://github.com/vfile/vfile
184 [contributing]: https://github.com/vfile/vfile/blob/master/contributing.md
186 [coc]: https://github.com/vfile/vfile/blob/master/code-of-conduct.md
188 [util]: https://github.com/vfile/vfile#utilities
190 [reporter]: https://github.com/vfile/vfile-reporter