From b89fb440f7d7daf3db3ee5c9e16f67c3bfc59325 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Fri, 18 Aug 2017 10:44:19 -0500 Subject: [PATCH] Replace try/catch with tryJSONparse --- edit/lint.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/edit/lint.js b/edit/lint.js index 365a644f..bf3336a8 100644 --- a/edit/lint.js +++ b/edit/lint.js @@ -207,13 +207,14 @@ function showLintHelp() { function setupStylelintSettingsEvents() { let timer; $('#help-popup .save').addEventListener('click', () => { - try { - setStylelintRules(JSON.parse($('#help-popup textarea').value).rules); + const json = tryJSONparse($('#help-popup textarea').value); + if (json && json.rules) { + setStylelintRules(json.rules); // it is possible to have stylelint rules popup open & switch to csslint if (prefs.get('editor.linter') === 'stylelint') { updateLinter('stylelint'); } - } catch (err) { + } else { $('#help-popup .error').classList.add('show'); clearTimeout(timer); timer = setTimeout(() => {