Update empty stylelint rules on initial load

This commit is contained in:
Rob Garrison 2017-08-20 11:23:11 -05:00
parent f36ce5c625
commit 92a49759a9

View File

@ -15,11 +15,12 @@ function initLint() {
BG.chromeLocal.getValue('editorStylelintRules').then(rules => setStylelintRules(rules)); BG.chromeLocal.getValue('editorStylelintRules').then(rules => setStylelintRules(rules));
} }
function setStylelintRules(rules = '') { function setStylelintRules(rules = []) {
if (Object.keys(rules).length === 0 && typeof stylelintDefaultConfig !== 'undefined') { if (Object.keys(rules).length === 0 && typeof stylelintDefaultConfig !== 'undefined') {
rules = deepCopy(stylelintDefaultConfig.rules); rules = deepCopy(stylelintDefaultConfig.rules);
} }
BG.chromeLocal.setValue('editorStylelintRules', rules); BG.chromeLocal.setValue('editorStylelintRules', rules);
return rules;
} }
function getLinterConfigForCodeMirror(name) { function getLinterConfigForCodeMirror(name) {
@ -248,7 +249,10 @@ function setupStylelintSettingsEvents(popup) {
} }
function openStylelintSettings() { function openStylelintSettings() {
BG.chromeLocal.getValue('editorStylelintRules').then((rules = stylelintDefaultConfig.rules) => { BG.chromeLocal.getValue('editorStylelintRules').then(rules => {
if (rules.length === 0) {
rules = setStylelintRules(rules);
}
const rulesString = JSON.stringify({rules: rules}, null, 2); const rulesString = JSON.stringify({rules: rules}, null, 2);
setupStylelintPopup(rulesString); setupStylelintPopup(rulesString);
}); });