fix showLintHelp dialog
This commit is contained in:
parent
94cf673f68
commit
1746235d0d
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user