lib/template-generator.js
function renderSourceCode(sourceCode, messages, parentIndex) {
	return codeWrapperTemplate({
		parentIndex,
		sourceCode: _.map(sourceCode.split('\n'), function(code, lineNumber) {
			const lineMessages = _.filter(messages, {line: lineNumber + 1}),
				severity = _.get(lineMessages[0], 'severity') || 0;

			let template = '';

			// checks if there is a problem on the current line and renders it
			if (!_.isEmpty(lineMessages)) {
				template += _.map(lineMessages, renderIssue).join('');
			}

			// adds a line of code to the template (with line number and severity color if appropriate
			template += codeTemplate({
				lineNumber: lineNumber + 1,
				code,
				severity: severityString(severity)
			});

			return template;
		}).join('\n')
	});
}
function renderSourceCode(sourceCode, messages, parentIndex) {
	return codeWrapperTemplate({
		parentIndex,
		sourceCode: _.map(sourceCode.split('\n'), function(code, lineNumber) {
			const lineMessages = _.filter(messages, {line: lineNumber + 1}),
				severity = _.get(lineMessages[0], 'severity') || 0;

			let template = '';

			// checks if there is a problem on the current line and renders it
			if (!_.isEmpty(lineMessages)) {
				template += _.map(lineMessages, renderIssue).join('');
			}

			// adds a line of code to the template (with line number and severity color if appropriate
			template += codeTemplate({
				lineNumber: lineNumber + 1,
				code,
				severity: severityString(severity)
			});

			return template;
		}).join('\n')
	});
}
function renderSourceCode ( sourceCode , messages , parentIndex ) { return codeWrapperTemplate ( { parentIndex , sourceCode : _ . map ( sourceCode . split ( '\n' ) , function ( code , lineNumber ) { const lineMessages = _ . filter ( messages , { line : lineNumber + 1 } ) , severity = _ . get ( lineMessages [ 0 ] , 'severity' ) || 0 ; let template = '' ; // checks if there is a problem on the current line and renders it if ( ! _ . isEmpty ( lineMessages ) ) { template += _ . map ( lineMessages , renderIssue ) . join ( '' ) ; } // adds a line of code to the template (with line number and severity color if appropriate template += codeTemplate ( { lineNumber : lineNumber + 1 , code , severity : severityString ( severity ) } ) ; return template ; } ) . join ( '\n' ) } ) ; }
Renders the source code for the files that have issues and marks the lines that have problems
@param {string} sourceCode source code string
@param {array} messages array of messages with the problems in a file
@param {int} parentIndex file index
@returns {string} HTML string of the code file that is being linted
Renders the source code for the files that have issues and marks the lines that have problems