data.messages.forEach(m => messages.push({
explanation: '',
lastColumn: m.lastColumn,
lastLine: m.lastLine,
message: m.message,
messageid: '',
type: (m.subType === 'warning') ? 'warn' : (m.subType === 'info') ? 'info' : 'error'
}));
{
type: m.subType === 'warning' ? 'warn' : m.subType
}
{
type: m.subType,
}
const messages = [{
id: 1,
subType: 'warning'
},
{
id: 2,
subType: 'info'
},
{
id: 3,
subType: 'some'
},
];
const newMessages = messages.map(({id, subType}) => ({
explanation: '',
messageid: id,
type: (subType === 'warning') ? 'warn' : (subType === 'info') ? 'info' : 'error'
}));
console.log(newMessages);