From 81a7bb9ac925061586f458a5608400b8ad92006f Mon Sep 17 00:00:00 2001 From: eight Date: Mon, 1 Oct 2018 22:56:25 +0800 Subject: [PATCH] Add: editorWorker.metalint --- edit/editor-worker.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/edit/editor-worker.js b/edit/editor-worker.js index cfc7bfe5..03ad6c97 100644 --- a/edit/editor-worker.js +++ b/edit/editor-worker.js @@ -1,4 +1,4 @@ -/* global importScripts parseMozFormat parserlib CSSLint require workerUtil */ +/* global importScripts workerUtil CSSLint require usercssMeta */ 'use strict'; importScripts('/js/worker-util.js'); @@ -14,6 +14,19 @@ createAPI({ loadScript('/vendor/stylelint-bundle/stylelint-bundle.min.js'); return require('stylelint').lint({code, config}); }, + metalint: code => { + loadScript('/vendor/usercss-meta/usercss-meta.min.js'); + const result = usercssMeta.parse(code, {allowErrors: true, unknownKey: 'throw'}); + // extract needed info + result.errors = result.errors.map(err => + ({ + code: err.code, + message: err.message, + index: err.index + }) + ); + return result; + }, getStylelintRules, getCsslintRules });