don't run CSS linters in the config dialog json
This commit is contained in:
parent
3d5383ceaf
commit
c7a0759216
36
edit/lint.js
36
edit/lint.js
|
@ -415,6 +415,7 @@ function setupLinterSettingsEvents(popup) {
|
||||||
}
|
}
|
||||||
linterConfig.save(json);
|
linterConfig.save(json);
|
||||||
linterConfig.showSavedMessage();
|
linterConfig.showSavedMessage();
|
||||||
|
popup.codebox.markClean();
|
||||||
updateLinter();
|
updateLinter();
|
||||||
} else {
|
} else {
|
||||||
showLinterErrorMessage(linter, t('linterJSONError'));
|
showLinterErrorMessage(linter, t('linterJSONError'));
|
||||||
|
@ -436,6 +437,7 @@ function setupLinterSettingsEvents(popup) {
|
||||||
function setupLinterPopup(config) {
|
function setupLinterPopup(config) {
|
||||||
const linter = prefs.get('editor.linter');
|
const linter = prefs.get('editor.linter');
|
||||||
const linterTitle = linter === 'stylelint' ? 'Stylelint' : 'CSSLint';
|
const linterTitle = linter === 'stylelint' ? 'Stylelint' : 'CSSLint';
|
||||||
|
|
||||||
function makeButton(className, text, options = {}) {
|
function makeButton(className, text, options = {}) {
|
||||||
return $element(Object.assign(options, {
|
return $element(Object.assign(options, {
|
||||||
tag: 'button',
|
tag: 'button',
|
||||||
|
@ -448,11 +450,9 @@ function setupLinterPopup(config) {
|
||||||
function makeLink(url, textContent) {
|
function makeLink(url, textContent) {
|
||||||
return $element({tag: 'a', target: '_blank', href: url, textContent});
|
return $element({tag: 'a', target: '_blank', href: url, textContent});
|
||||||
}
|
}
|
||||||
function setJSONMode(cm) {
|
|
||||||
cm.setOption('mode', 'application/json');
|
const title = t('linterConfigPopupTitle', linterTitle);
|
||||||
cm.setOption('lint', 'json');
|
const contents = $element({
|
||||||
}
|
|
||||||
const popup = showCodeMirrorPopup(t('linterConfigPopupTitle', linterTitle), $element({
|
|
||||||
appendChild: [
|
appendChild: [
|
||||||
$element({
|
$element({
|
||||||
tag: 'p',
|
tag: 'p',
|
||||||
|
@ -467,7 +467,7 @@ function setupLinterPopup(config) {
|
||||||
linter === 'csslint' ? ' ' + t('linterCSSLintSettings') : ''
|
linter === 'csslint' ? ' ' + t('linterCSSLintSettings') : ''
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
makeButton('save', 'styleSaveLabel'),
|
makeButton('save', 'styleSaveLabel', {disabled: true}),
|
||||||
makeButton('cancel', 'confirmCancel'),
|
makeButton('cancel', 'confirmCancel'),
|
||||||
makeButton('reset', 'genericResetLabel', {title: t('linterResetMessage')}),
|
makeButton('reset', 'genericResetLabel', {title: t('linterResetMessage')}),
|
||||||
$element({
|
$element({
|
||||||
|
@ -476,19 +476,25 @@ function setupLinterPopup(config) {
|
||||||
textContent: t('genericSavedMessage')
|
textContent: t('genericSavedMessage')
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
}));
|
});
|
||||||
const contents = $('.contents', popup);
|
const popup = showCodeMirrorPopup(title, contents, {lint: false});
|
||||||
const loadJSON = window.jsonlint ? [] : [
|
contents.parentNode.appendChild(contents);
|
||||||
'vendor/codemirror/mode/javascript/javascript.js',
|
|
||||||
'vendor/codemirror/addon/lint/json-lint.js',
|
|
||||||
'vendor/jsonlint/jsonlint.js'
|
|
||||||
];
|
|
||||||
contents.insertBefore(popup.codebox.display.wrapper, contents.firstElementChild);
|
|
||||||
popup.codebox.focus();
|
popup.codebox.focus();
|
||||||
popup.codebox.setValue(config);
|
popup.codebox.setValue(config);
|
||||||
popup.codebox.clearHistory();
|
popup.codebox.clearHistory();
|
||||||
onDOMscripted(loadJSON).then(() => setJSONMode(popup.codebox));
|
popup.codebox.markClean();
|
||||||
|
popup.codebox.on('change', cm => {
|
||||||
|
$('.save', popup).disabled = cm.isClean();
|
||||||
|
});
|
||||||
setupLinterSettingsEvents(popup);
|
setupLinterSettingsEvents(popup);
|
||||||
|
onDOMscripted([
|
||||||
|
'vendor/codemirror/mode/javascript/javascript.js',
|
||||||
|
'vendor/codemirror/addon/lint/json-lint.js',
|
||||||
|
'vendor/jsonlint/jsonlint.js'
|
||||||
|
]).then(() => {
|
||||||
|
popup.codebox.setOption('mode', 'application/json');
|
||||||
|
popup.codebox.setOption('lint', 'json');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadLinterAssets(name = prefs.get('editor.linter')) {
|
function loadLinterAssets(name = prefs.get('editor.linter')) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user