From 92a49759a940d694f2b58a2f63401b2602a38b41 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Sun, 20 Aug 2017 11:23:11 -0500 Subject: [PATCH] Update empty stylelint rules on initial load --- edit/lint.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/edit/lint.js b/edit/lint.js index 7c3182db..b12a0b66 100644 --- a/edit/lint.js +++ b/edit/lint.js @@ -15,11 +15,12 @@ function initLint() { BG.chromeLocal.getValue('editorStylelintRules').then(rules => setStylelintRules(rules)); } -function setStylelintRules(rules = '') { +function setStylelintRules(rules = []) { if (Object.keys(rules).length === 0 && typeof stylelintDefaultConfig !== 'undefined') { rules = deepCopy(stylelintDefaultConfig.rules); } BG.chromeLocal.setValue('editorStylelintRules', rules); + return rules; } function getLinterConfigForCodeMirror(name) { @@ -248,7 +249,10 @@ function setupStylelintSettingsEvents(popup) { } 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); setupStylelintPopup(rulesString); });