Don't show nested "rules" in config
This commit is contained in:
parent
53af483a18
commit
52af5c85c0
20
edit/lint.js
20
edit/lint.js
|
@ -278,13 +278,17 @@ function checkRules(linter, rules) {
|
||||||
return invalid;
|
return invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stringifyRules(rules) {
|
||||||
|
return JSON.stringify(rules, null, 2);
|
||||||
|
}
|
||||||
|
|
||||||
function setupLinterSettingsEvents(popup) {
|
function setupLinterSettingsEvents(popup) {
|
||||||
$('.save', popup).addEventListener('click', event => {
|
$('.save', popup).addEventListener('click', event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const linter = checkLinter(event.target.dataset.linter);
|
const linter = checkLinter(event.target.dataset.linter);
|
||||||
const json = tryJSONparse(popup.codebox.getValue());
|
const json = tryJSONparse(popup.codebox.getValue());
|
||||||
if (json && json.rules) {
|
if (json) {
|
||||||
const invalid = checkRules(linter, json.rules);
|
const invalid = checkRules(linter, json);
|
||||||
if (invalid.length) {
|
if (invalid.length) {
|
||||||
return showLinterErrorMessage(
|
return showLinterErrorMessage(
|
||||||
linter,
|
linter,
|
||||||
|
@ -292,9 +296,9 @@ function setupLinterSettingsEvents(popup) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (linter === 'stylelint') {
|
if (linter === 'stylelint') {
|
||||||
setStylelintRules(json.rules);
|
setStylelintRules(json);
|
||||||
} else {
|
} else {
|
||||||
setCSSLintRules(json.rules);
|
setCSSLintRules(json);
|
||||||
}
|
}
|
||||||
updateLinter(linter);
|
updateLinter(linter);
|
||||||
showSavedMessage();
|
showSavedMessage();
|
||||||
|
@ -308,12 +312,12 @@ function setupLinterSettingsEvents(popup) {
|
||||||
let rules;
|
let rules;
|
||||||
if (linter === 'stylelint') {
|
if (linter === 'stylelint') {
|
||||||
setStylelintRules();
|
setStylelintRules();
|
||||||
rules = {rules: stylelintDefaultConfig.rules};
|
rules = stylelintDefaultConfig.rules;
|
||||||
} else {
|
} else {
|
||||||
setCSSLintRules();
|
setCSSLintRules();
|
||||||
rules = {rules: csslintDefaultRuleset};
|
rules = csslintDefaultRuleset;
|
||||||
}
|
}
|
||||||
popup.codebox.setValue(JSON.stringify(rules, null, 2));
|
popup.codebox.setValue(stringifyRules(rules));
|
||||||
updateLinter(linter);
|
updateLinter(linter);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -330,7 +334,7 @@ function openStylelintSettings() {
|
||||||
? setStylelintRules(rules)
|
? setStylelintRules(rules)
|
||||||
: setCSSLintRules(rules);
|
: setCSSLintRules(rules);
|
||||||
}
|
}
|
||||||
const rulesString = JSON.stringify({rules: rules}, null, 2);
|
const rulesString = stringifyRules(rules);
|
||||||
setupLinterPopup(rulesString);
|
setupLinterPopup(rulesString);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user