Fix: disable CSSLint option in stylus mode

This commit is contained in:
eight 2017-10-16 14:54:47 +08:00
parent 95902388a3
commit be4a896bc9
2 changed files with 31 additions and 18 deletions

View File

@ -456,6 +456,15 @@
"message": "(Set rule as: 0 = disabled; 1 = warning; 2 = error)", "message": "(Set rule as: 0 = disabled; 1 = warning; 2 = error)",
"description": "CSSLint rule config values" "description": "CSSLint rule config values"
}, },
"linterCSSLintIncompatible": {
"message": "CSSLint doesn't support $preprocessorname$ preprocessor",
"description": "The label to display when the preprocessor doesn't compatible with CSSLint",
"placeholders": {
"preprocessorname": {
"content": "$1"
}
}
},
"linterInvalidConfigError": { "linterInvalidConfigError": {
"message": "Not saved due to these invalid configuration settings:", "message": "Not saved due to these invalid configuration settings:",
"description": "Invalid linter config will show a message followed by a list of invalid entries" "description": "Invalid linter config will show a message followed by a list of invalid entries"

View File

@ -55,27 +55,31 @@ function createSourceEditor(style) {
// setup linter // setup linter
initLint(); initLint();
initLinterSwitch();
function initLinterSwitch() {
const linterEl = $('#editor.linter'); const linterEl = $('#editor.linter');
cm.on('optionChange', (cm, option) => { cm.on('optionChange', (cm, option) => {
if (option === 'mode' || option === 'lint') { if (option !== 'mode') {
const lint = cm.getOption('lint'); return;
const mode = cm.getOption('mode'); }
updateLinter();
update();
});
linterEl.addEventListener('change', update);
if (mode !== 'css' && linterConfig.getName(lint) === 'csslint') { function update() {
updateLinter({linter: 'stylelint'}); linterEl.value = linterConfig.getDefault();
linterEl.value = 'stylelint';
const cssLintOption = linterEl.querySelector('[value="csslint"]');
if (cm.getOption('mode') !== 'css') {
cssLintOption.disabled = true;
cssLintOption.title = t('linterCSSLintIncompatible', cm.getOption('mode'));
} else {
cssLintOption.disabled = false;
cssLintOption.title = '';
} }
} }
});
linterEl.addEventListener('change', () => {
if (cm.getOption('mode') !== 'css' && linterEl.value === 'csslint') {
setTimeout(() => {
linterEl.value = 'stylelint';
});
}
});
if (linterEl.value === 'csslint') {
linterEl.value = 'stylelint';
} }
function setupNewStyle(style) { function setupNewStyle(style) {