All files / src/rules no-trailing-whitespace.ts

100% Statements 4/4
100% Branches 2/2
100% Functions 2/2
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18      1x           7x       19x 4x      
import { Rule, RuleReport, RuleParserProxy } from '../rule';
import { WhitespaceEvent } from '../event';
 
export = {
	name: 'no-trailing-whitespace',
	init,
} as Rule;
 
function init(parser: RuleParserProxy){
	parser.on('whitespace', validate);
}
 
function validate(event: WhitespaceEvent, report: RuleReport){
	if (event.text.match(/^[ \t]+\n$/)){
		report(undefined, "Trailing whitespace", event.location);
	}
}