From f6a90ad16640e8d3151983c534db6e9b6e8259c4 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 6 Aug 2018 15:10:42 +0300 Subject: [PATCH] suppress stylelint warning for stylus-lang's @css block fixes #459 --- edit/lint-codemirror-helper.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/edit/lint-codemirror-helper.js b/edit/lint-codemirror-helper.js index 7b43a0d3..835be8db 100644 --- a/edit/lint-codemirror-helper.js +++ b/edit/lint-codemirror-helper.js @@ -15,9 +15,9 @@ severity, }).filter(Boolean), - stylelint: ({results}) => - !results[0] && [] || - results[0].warnings.map(({line, column: ch, text, severity}) => ({ + stylelint({results}, cm) { + if (!results[0]) return []; + const output = results[0].warnings.map(({line, column: ch, text, severity}) => ({ from: {line: line - 1, ch: ch - 1}, to: {line: line - 1, ch}, message: text @@ -26,12 +26,18 @@ .replace(/\s*\([^(]+\)$/, ''), // strip the rule, rule: text.replace(/^.*?\s*\(([^(]+)\)$/, '$1'), severity, - })), + })); + return cm.doc.mode.name !== 'stylus' ? + output : + output.filter(({message}) => + !message.includes('"@css"') || !message.includes('(at-rule-no-unknown)')); + }, }; - function invokeHelper(code) { + function invokeHelper(code, options, cm) { const config = linterConfig.getCurrent(); + const cook = cookResults[linterConfig.getName()]; return linterConfig.invokeWorker({code, config}) - .then(cookResults[linterConfig.getName()]); + .then(data => cook(data, cm)); } })();