diff --git a/edit/linter-meta.js b/edit/linter-meta.js index 4233c402..a51f267c 100644 --- a/edit/linter-meta.js +++ b/edit/linter-meta.js @@ -1,4 +1,4 @@ -/* global linter */ +/* global linter editorWorker */ 'use strict'; function createMetaCompiler(cm) { @@ -18,25 +18,23 @@ function createMetaCompiler(cm) { if (match[0] === meta && match.index === metaIndex) { return cache; } - return API.parseUsercss({sourceCode: match[0], metaOnly: true}) - .then(result => result.usercssData) - .then(result => { - for (const cb of updateListeners) { - cb(result); + return editorWorker.metalint(match[0]) + .then(({metadata, errors}) => { + if (!errors.length) { + for (const cb of updateListeners) { + cb(metadata); + } } + cache = errors.map(err => + ({ + from: cm.posFromIndex((err.index || 0) + match.index), + to: cm.posFromIndex((err.index || 0) + match.index), + message: err.message, + severity: err.code === 'unknownMeta' ? 'warning' : 'error' + }) + ); meta = match[0]; metaIndex = match.index; - cache = []; - return cache; - }, err => { - meta = match[0]; - metaIndex = match.index; - cache = [{ - from: cm.posFromIndex((err.index || 0) + match.index), - to: cm.posFromIndex((err.index || 0) + match.index), - message: err.message, - severity: 'error' - }]; return cache; }); });