Fix: expose some simple states to global
This commit is contained in:
parent
a7ccda3aad
commit
b6df55b1fe
|
@ -1,9 +1,6 @@
|
||||||
/* global importScripts parseMozFormat parserlib CSSLint require */
|
/* global importScripts parseMozFormat parserlib CSSLint require */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const loadScript = createLoadScript();
|
|
||||||
const loadParserLib = createLoadParserLib();
|
|
||||||
|
|
||||||
createAPI({
|
createAPI({
|
||||||
csslint: (code, config) => {
|
csslint: (code, config) => {
|
||||||
loadParserLib();
|
loadParserLib();
|
||||||
|
@ -75,25 +72,19 @@ function getStylelintRules() {
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createLoadParserLib() {
|
function loadParserLib() {
|
||||||
let loaded = false;
|
if (typeof parserlib !== 'undefined') {
|
||||||
return () => {
|
return;
|
||||||
if (loaded) {
|
}
|
||||||
return;
|
importScripts('/vendor-overwrites/csslint/parserlib.js');
|
||||||
}
|
parserlib.css.Tokens[parserlib.css.Tokens.COMMENT].hide = false;
|
||||||
importScripts('/vendor-overwrites/csslint/parserlib.js');
|
|
||||||
parserlib.css.Tokens[parserlib.css.Tokens.COMMENT].hide = false;
|
|
||||||
loaded = true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createLoadScript() {
|
const loadedUrls = new Set();
|
||||||
const loaded = new Set();
|
function loadScript(urls) {
|
||||||
return urls => {
|
urls = urls.filter(u => !loadedUrls.has(u));
|
||||||
urls = urls.filter(u => !loaded.has(u));
|
importScripts(...urls);
|
||||||
importScripts(...urls);
|
urls.forEach(u => loadedUrls.add(u));
|
||||||
urls.forEach(u => loaded.add(u));
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createAPI(methods) {
|
function createAPI(methods) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user