Remove "Unexpected" from stylelint messages
This commit is contained in:
parent
d563495c26
commit
1fc17861db
12
edit/lint.js
12
edit/lint.js
|
@ -91,10 +91,12 @@ function updateLintReport(cm, delay) {
|
||||||
const info = mark.__annotation;
|
const info = mark.__annotation;
|
||||||
const isActiveLine = info.from.line === cm.getCursor().line;
|
const isActiveLine = info.from.line === cm.getCursor().line;
|
||||||
const pos = isActiveLine ? 'cursor' : (info.from.line + ',' + info.from.ch);
|
const pos = isActiveLine ? 'cursor' : (info.from.line + ',' + info.from.ch);
|
||||||
// stylelint rule added in parentheses at the end
|
// stylelint rule added in parentheses at the end; extract it out for the stylelint info popup
|
||||||
const rule = linter === 'stylelint' ?
|
const stylelintRule = linter === 'stylelint' ? ` data-rule ="${
|
||||||
info.message.substring(info.message.lastIndexOf('('), info.message.length).replace(/[()]/g, '') :
|
info.message
|
||||||
/ at line \d.+$/;
|
.substring(info.message.lastIndexOf('('), info.message.length)
|
||||||
|
.replace(/[()]/g, '')}"`
|
||||||
|
: '';
|
||||||
// csslint
|
// csslint
|
||||||
const title = escapeHtml(info.message);
|
const title = escapeHtml(info.message);
|
||||||
const message = title.length > 100 ? title.substr(0, 100) + '...' : title;
|
const message = title.length > 100 ? title.substr(0, 100) + '...' : title;
|
||||||
|
@ -103,7 +105,7 @@ function updateLintReport(cm, delay) {
|
||||||
}
|
}
|
||||||
newMarkers[pos] = message;
|
newMarkers[pos] = message;
|
||||||
return `<tr class="${info.severity}">
|
return `<tr class="${info.severity}">
|
||||||
<td role="severity" ${linter === 'stylelint' ? 'data-rule="' + rule + '"' : ''}>
|
<td role="severity" ${stylelintRule}>
|
||||||
<div class="CodeMirror-lint-marker-${info.severity}">${info.severity}</div>
|
<div class="CodeMirror-lint-marker-${info.severity}">${info.severity}</div>
|
||||||
</td>
|
</td>
|
||||||
<td role="line">${info.from.line + 1}</td>
|
<td role="line">${info.from.line + 1}</td>
|
||||||
|
|
|
@ -94,13 +94,19 @@
|
||||||
const warnings = output.results.length ? output.results[0].warnings : [];
|
const warnings = output.results.length ? output.results[0].warnings : [];
|
||||||
const len = warnings.length;
|
const len = warnings.length;
|
||||||
let warning;
|
let warning;
|
||||||
|
let message;
|
||||||
if (len) {
|
if (len) {
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
warning = warnings[i];
|
warning = warnings[i];
|
||||||
|
message = warning.text
|
||||||
|
.replace('Unexpected ', '')
|
||||||
|
.replace(/^./, function (firstLetter) {
|
||||||
|
return firstLetter.toUpperCase();
|
||||||
|
});
|
||||||
found.push({
|
found.push({
|
||||||
from: CodeMirror.Pos(warning.line - 1, warning.column - 1),
|
from: CodeMirror.Pos(warning.line - 1, warning.column - 1),
|
||||||
to: CodeMirror.Pos(warning.line - 1, warning.column),
|
to: CodeMirror.Pos(warning.line - 1, warning.column),
|
||||||
message: warning.text,
|
message,
|
||||||
severity : warning.severity
|
severity : warning.severity
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user