Awesome
vfile-messages-to-vscode-diagnostics
Convert VFile#messages
into an Array
of VS Code diagnostics
const VFile = require('vfile');
const vFileMessagesToVSCodeDiagnostics = require('vfile-messages-to-vscode-diagnostics');
vFileMessagesToVSCodeDiagnostics(new VFile().message('warning!', {line: 10, column: 2}));
/* =>
[{
message: 'warning!',
severity: 2,
range: {
start: {line: 9, character: 1},
end: {line: 9, character: 1}
}
}]
*/
Installation
npm install vfile-messages-to-vscode-diagnostics
API
const vFileMessagesToVSCodeDiagnostics = require('vfile-messages-to-vscode-diagnostics');
vFileMessagesToVSCodeDiagnostics(messages)
messages: <Iterable<VFileMessage>>
except for string
and Map
Return: Diagnostics[]
const VFile = require('vfile');
const vFileMessagesToVSCodeDiagnostics = require('vfile-messages-to-vscode-diagnostics');
const file = new VFile();
file.message('warning1');
file.message('warning2', {
position: {
start: {line: 23, column: 5},
end: {line: 23, column: 11}
}
});
vFileMessagesToVSCodeDiagnostics(file.messages);
/* =>
[{
message: 'warning1',
severity: 2,
range: {
start: {line: 0, character: 0},
end: {line: 0, character: 0}
}
}, {
message: 'warning2',
severity: 2,
range: {
start: {line: 22, character: 4},
end: {line: 22, character: 10}
}
}]
*/
License
ISC License © 2018 Shinnosuke Watanabe