From 1fc17861dbfef6f3f437c58a3d0b46fd94b58ea0 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Sun, 20 Aug 2017 15:41:07 -0500 Subject: [PATCH] Remove "Unexpected" from stylelint messages --- edit/lint.js | 12 +++++++----- vendor-overwrites/codemirror/addon/lint/css-lint.js | 8 +++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/edit/lint.js b/edit/lint.js index fec621f4..93eed72e 100644 --- a/edit/lint.js +++ b/edit/lint.js @@ -91,10 +91,12 @@ function updateLintReport(cm, delay) { const info = mark.__annotation; const isActiveLine = info.from.line === cm.getCursor().line; const pos = isActiveLine ? 'cursor' : (info.from.line + ',' + info.from.ch); - // stylelint rule added in parentheses at the end - const rule = linter === 'stylelint' ? - info.message.substring(info.message.lastIndexOf('('), info.message.length).replace(/[()]/g, '') : - / at line \d.+$/; + // stylelint rule added in parentheses at the end; extract it out for the stylelint info popup + const stylelintRule = linter === 'stylelint' ? ` data-rule ="${ + info.message + .substring(info.message.lastIndexOf('('), info.message.length) + .replace(/[()]/g, '')}"` + : ''; // csslint const title = escapeHtml(info.message); const message = title.length > 100 ? title.substr(0, 100) + '...' : title; @@ -103,7 +105,7 @@ function updateLintReport(cm, delay) { } newMarkers[pos] = message; return ` - +
${info.severity}
${info.from.line + 1} diff --git a/vendor-overwrites/codemirror/addon/lint/css-lint.js b/vendor-overwrites/codemirror/addon/lint/css-lint.js index 89302d62..9adec55e 100644 --- a/vendor-overwrites/codemirror/addon/lint/css-lint.js +++ b/vendor-overwrites/codemirror/addon/lint/css-lint.js @@ -94,13 +94,19 @@ const warnings = output.results.length ? output.results[0].warnings : []; const len = warnings.length; let warning; + let message; if (len) { for (let i = 0; i < len; i++) { warning = warnings[i]; + message = warning.text + .replace('Unexpected ', '') + .replace(/^./, function (firstLetter) { + return firstLetter.toUpperCase(); + }); found.push({ from: CodeMirror.Pos(warning.line - 1, warning.column - 1), to: CodeMirror.Pos(warning.line - 1, warning.column), - message: warning.text, + message, severity : warning.severity }); }