Add messages to a vfile bound to a plugin source.
const vsource = require('vsource')
const vfile = require('vfile')
const file = vfile({ path: 'package.json' })
const s = vsource('my-lint-plugin', file)
// Add error message to file
s.fail('Name must be lowercase', pos, 'lowercase-name')
Which is just a convenient shortcut for:
file.fail('Name must be lowercase', pos, 'my-lint-plugin:lowercase-name')
In addition, fail()
can be called multiple times to collect more than one error, unlike VFile#fail()
which immediately terminates the process. I'm taking a slightly different approach to linting (than remark-lint
et al): both error and warning messages are lint failures, but warnings can be ignored by the user. This behavior is closer to the standard
linter. While remark-lint
normally only produces warning messages, reserving error messages for unexpected exceptions.
If a file
argument is provided, it does not have to be passed into the below methods.
Add error message to file
, similar to VFile#fail()
. Sets message.fatal
to true
.
Add warning message to file
, same as VFile#message()
. Sets message.fatal
to false
.
Add info message to file
, same as VFile#info()
. Sets message.fatal
to null
.
With npm do:
npm install vsource
MIT © Vincent Weevers