Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const filePath = TextEditor.getPath();
const fileText = TextEditor.getText()
try {
MJMLDocument = documentParser(fileText)
} catch (e) {
reject(e)
}
const body = getMJBody(MJMLDocument)
if (!body || !body.children || body.children.length == 0) {
reject()
}
const report = MJMLValidator(body.children[0])
const formattedError = report.map(e => {
const line = e.line - 1
const currentLine = TextEditor.getBuffer().lineForRow(e.line - 1)
return {
filePath,
range: [[line, currentLine.indexOf('<')], [line, TextEditor.getBuffer().lineLengthForRow(line)]],
type: 'Error',
text: e.message
}
})
resolve(formattedError)
})
}