From 1746235d0d13300322de5e40f18ed3e714e791b7 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 7 Feb 2021 00:17:52 +0300 Subject: [PATCH] fix showLintHelp dialog --- edit/linter-dialogs.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/edit/linter-dialogs.js b/edit/linter-dialogs.js index fa0b8d0d..d06ae941 100644 --- a/edit/linter-dialogs.js +++ b/edit/linter-dialogs.js @@ -17,13 +17,10 @@ let popup; linterMan.showLintConfig = async () => { - linter = $('#editor.linter').value; + linter = await getLinter(); if (!linter) { return; } - if (!RULES[linter]) { - linterMan.worker.getRules(linter).then(res => (RULES[linter] = res)); - } await require([ '/vendor/codemirror/mode/javascript/javascript', '/vendor/codemirror/addon/lint/json-lint', @@ -66,16 +63,14 @@ }; linterMan.showLintHelp = async () => { - // FIXME: implement a linterChooser? - const linter = $('#editor.linter').value; + const linter = await getLinter(); const baseUrl = linter === 'stylelint' ? 'https://stylelint.io/user-guide/rules/' - // some CSSLint rules do not have a url - : 'https://github.com/CSSLint/csslint/issues/535'; + : ''; let headerLink, template; if (linter === 'csslint') { headerLink = $createLink('https://github.com/CSSLint/csslint/wiki/Rules', 'CSSLint'); - template = ({rule: ruleID}) => { + template = ruleID => { const rule = RULES.csslint.find(rule => rule.id === ruleID); return rule && $create('li', [ @@ -107,6 +102,14 @@ return depth; } + async function getLinter() { + const val = $('#editor.linter').value; + if (val && !RULES[val]) { + RULES[val] = await linterMan.worker.getRules(val); + } + return val; + } + function hint(cm) { const rules = RULES[linter]; let ruleIds, options;