Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions addon/lint/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
function clearMarks(cm) {
var state = cm.state.lint;
if (state.hasGutter) cm.clearGutter(GUTTER_ID);
if (isHighlightErrorLinesEnabled(state)) clearErrorLines(cm);
if (state.options.highlightLines) clearErrorLines(cm);
for (var i = 0; i < state.marked.length; ++i)
state.marked[i].clear();
state.marked.length = 0;
Expand All @@ -90,10 +90,6 @@
})
}

function isHighlightErrorLinesEnabled(state) {
return state.options.highlightLines;
}

function makeMarker(cm, labels, severity, multiple, tooltips) {
var marker = document.createElement("div"), inner = marker;
marker.className = "CodeMirror-lint-marker CodeMirror-lint-marker-" + severity;
Expand Down Expand Up @@ -155,7 +151,8 @@
function startLinting(cm) {
var state = cm.state.lint;
if (!state) return;
var options = state.options;
var options = JSON.parse(JSON.stringify(state.options)); // deep clone object
delete options.highlightLines;
/*
* Passing rules in `options` property prevents JSHint (and other linters) from complaining
* about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc.
Expand All @@ -182,6 +179,7 @@
clearMarks(cm);

var annotations = groupByLine(annotationsNotSorted);
var highlightLines = state.options.highlightLines;

for (var line = 0; line < annotations.length; ++line) {
var anns = annotations[line];
Expand Down Expand Up @@ -213,7 +211,7 @@
cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1,
state.options.tooltips));

if (isHighlightErrorLinesEnabled(state))
if (highlightLines)
cm.addLineClass(line, "wrap", LINT_LINE_ID + maxSeverity);
}
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
Expand Down