fix showLintHelp dialog
This commit is contained in:
parent
94cf673f68
commit
1746235d0d
|
@ -17,13 +17,10 @@
|
||||||
let popup;
|
let popup;
|
||||||
|
|
||||||
linterMan.showLintConfig = async () => {
|
linterMan.showLintConfig = async () => {
|
||||||
linter = $('#editor.linter').value;
|
linter = await getLinter();
|
||||||
if (!linter) {
|
if (!linter) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!RULES[linter]) {
|
|
||||||
linterMan.worker.getRules(linter).then(res => (RULES[linter] = res));
|
|
||||||
}
|
|
||||||
await require([
|
await require([
|
||||||
'/vendor/codemirror/mode/javascript/javascript',
|
'/vendor/codemirror/mode/javascript/javascript',
|
||||||
'/vendor/codemirror/addon/lint/json-lint',
|
'/vendor/codemirror/addon/lint/json-lint',
|
||||||
|
@ -66,16 +63,14 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
linterMan.showLintHelp = async () => {
|
linterMan.showLintHelp = async () => {
|
||||||
// FIXME: implement a linterChooser?
|
const linter = await getLinter();
|
||||||
const linter = $('#editor.linter').value;
|
|
||||||
const baseUrl = linter === 'stylelint'
|
const baseUrl = linter === 'stylelint'
|
||||||
? 'https://stylelint.io/user-guide/rules/'
|
? 'https://stylelint.io/user-guide/rules/'
|
||||||
// some CSSLint rules do not have a url
|
: '';
|
||||||
: 'https://github.com/CSSLint/csslint/issues/535';
|
|
||||||
let headerLink, template;
|
let headerLink, template;
|
||||||
if (linter === 'csslint') {
|
if (linter === 'csslint') {
|
||||||
headerLink = $createLink('https://github.com/CSSLint/csslint/wiki/Rules', '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);
|
const rule = RULES.csslint.find(rule => rule.id === ruleID);
|
||||||
return rule &&
|
return rule &&
|
||||||
$create('li', [
|
$create('li', [
|
||||||
|
@ -107,6 +102,14 @@
|
||||||
return depth;
|
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) {
|
function hint(cm) {
|
||||||
const rules = RULES[linter];
|
const rules = RULES[linter];
|
||||||
let ruleIds, options;
|
let ruleIds, options;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user