fix showLintHelp dialog

This commit is contained in:
tophf 2021-02-07 00:17:52 +03:00
parent 94cf673f68
commit 1746235d0d

View File

@ -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;