.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / vfile-message / readme.md
1 # vfile-message
2
3 [![Build][build-badge]][build]
4 [![Coverage][coverage-badge]][coverage]
5 [![Downloads][downloads-badge]][downloads]
6 [![Chat][chat-badge]][chat]
7
8 Create [vfile][] messages.
9
10 ## Installation
11
12 [npm][]:
13
14 ```bash
15 npm install vfile-message
16 ```
17
18 ## Usage
19
20 ```js
21 var VMessage = require('vfile-message')
22
23 var message = new VMessage(
24   '`braavo` is misspelt; did you mean `bravo`?',
25   {line: 1, column: 8},
26   'spell:typo'
27 )
28
29 console.log(message)
30 ```
31
32 Yields:
33
34 ```js
35 { [1:8: `braavo` is misspelt; did you mean `bravo`?]
36   reason: '`braavo` is misspelt; did you mean `bravo`?',
37   fatal: null,
38   line: 1,
39   column: 8,
40   location:
41    { start: { line: 1, column: 8 },
42      end: { line: null, column: null } },
43   source: 'spell',
44   ruleId: 'typo' }
45 ```
46
47 ## API
48
49 ### `VMessage(reason[, position][, origin])`
50
51 Constructor of a message for `reason` at `position` from `origin`.  When
52 an error is passed in as `reason`, copies the stack.
53
54 ##### Parameters
55
56 ###### `reason`
57
58 Reason for message (`string` or `Error`).  Uses the stack and message of the
59 error if given.
60
61 ###### `position`
62
63 Place at which the message occurred in a file ([`Node`][node],
64 [`Position`][position], or [`Point`][point], optional).
65
66 ###### `origin`
67
68 Place in code the message originates from (`string`, optional).
69
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
72 (`'source:rule'`).
73
74 ##### Extends
75
76 [`Error`][error].
77
78 ##### Returns
79
80 An instance of itself.
81
82 ##### Properties
83
84 ###### `reason`
85
86 Reason for message (`string`).
87
88 ###### `fatal`
89
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
92 `undefined`.
93
94 ###### `line`
95
96 Starting line of error (`number?`).
97
98 ###### `column`
99
100 Starting column of error (`number?`).
101
102 ###### `location`
103
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
106 `number?`.
107
108 ###### `source`
109
110 Namespace of warning (`string?`).
111
112 ###### `ruleId`
113
114 Category of message (`string?`).
115
116 ###### `stack`
117
118 Stack of message (`string?`).
119
120 ##### Custom properties
121
122 It’s OK to store custom data directly on the `VMessage`, some of those are
123 handled by [utilities][util].
124
125 ###### `file`
126
127 You may add a `file` property with a path of a file (used throughout the
128 [**VFile**][vfile] ecosystem).
129
130 ###### `note`
131
132 You may add a `note` property with a long form description of the message
133 (supported by [`vfile-reporter`][reporter]).
134
135 ###### `url`
136
137 You may add a `url` property with a link to documentation for the message.
138
139 ## Contribute
140
141 See [`contributing.md` in `vfile/vfile`][contributing] for ways to get started.
142
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.
145
146 ## License
147
148 [MIT][license] © [Titus Wormer][author]
149
150 <!-- Definitions -->
151
152 [build-badge]: https://img.shields.io/travis/vfile/vfile-message.svg
153
154 [build]: https://travis-ci.org/vfile/vfile-message
155
156 [coverage-badge]: https://img.shields.io/codecov/c/github/vfile/vfile-message.svg
157
158 [coverage]: https://codecov.io/github/vfile/vfile-message
159
160 [downloads-badge]: https://img.shields.io/npm/dm/vfile-message.svg
161
162 [downloads]: https://www.npmjs.com/package/vfile-message
163
164 [chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
165
166 [chat]: https://spectrum.chat/unified/vfile
167
168 [npm]: https://docs.npmjs.com/cli/install
169
170 [license]: license
171
172 [author]: https://wooorm.com
173
174 [error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
175
176 [node]: https://github.com/syntax-tree/unist#node
177
178 [position]: https://github.com/syntax-tree/unist#position
179
180 [point]: https://github.com/syntax-tree/unist#point
181
182 [vfile]: https://github.com/vfile/vfile
183
184 [contributing]: https://github.com/vfile/vfile/blob/master/contributing.md
185
186 [coc]: https://github.com/vfile/vfile/blob/master/code-of-conduct.md
187
188 [util]: https://github.com/vfile/vfile#utilities
189
190 [reporter]: https://github.com/vfile/vfile-reporter
191
192 [ruleid]: #ruleid
193
194 [source]: #source