Change: use editorWorker.metalint
This commit is contained in:
parent
5778d5c858
commit
f47d57aea8
|
@ -1,4 +1,4 @@
|
||||||
/* global linter */
|
/* global linter editorWorker */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function createMetaCompiler(cm) {
|
function createMetaCompiler(cm) {
|
||||||
|
@ -18,25 +18,23 @@ function createMetaCompiler(cm) {
|
||||||
if (match[0] === meta && match.index === metaIndex) {
|
if (match[0] === meta && match.index === metaIndex) {
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
return API.parseUsercss({sourceCode: match[0], metaOnly: true})
|
return editorWorker.metalint(match[0])
|
||||||
.then(result => result.usercssData)
|
.then(({metadata, errors}) => {
|
||||||
.then(result => {
|
if (!errors.length) {
|
||||||
for (const cb of updateListeners) {
|
for (const cb of updateListeners) {
|
||||||
cb(result);
|
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];
|
meta = match[0];
|
||||||
metaIndex = match.index;
|
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;
|
return cache;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user