From f0ff4a6efa0cbb87e8335163c5b29983650047e0 Mon Sep 17 00:00:00 2001 From: Ethan Brown Date: Mon, 13 Jan 2014 23:26:30 -0800 Subject: [PATCH 1/2] Added line numbers to match output. --- tasks/lint_pattern.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tasks/lint_pattern.js b/tasks/lint_pattern.js index 50f8f9a..5c3be08 100644 --- a/tasks/lint_pattern.js +++ b/tasks/lint_pattern.js @@ -46,23 +46,30 @@ module.exports = function(grunt) { } }).map(function(filepath) { // Read file source. - var src = grunt.file.read(filepath); + var srcLines = grunt.file.read(filepath).split(/\r?\n/); for (i = 0; i < options.rules.length; i++) { rule = options.rules[i]; var matchingFilesForRule = matchingFiles[i]; - if (src.match(rule.pattern)) { - matchingFilesForRule.push(filepath); + for (var ln = 0; ln < srcLines.length; ln++) { + var line = srcLines[ln]; + if (line.match(rule.pattern)) { + matchingFilesForRule.push({ file: filepath, lineNumber: ln+1 }); + } } } }); }); + function formatMatch(match) { + return match.file + ':' + match.lineNumber; + } + for (i = 0; i < options.rules.length; i++) { rule = options.rules[i]; var matchingFilesForRule = matchingFiles[i]; if (matchingFilesForRule.length > 0) { var message = rule.message || 'The pattern ' + rule.pattern + 'is not allowed'; - message += '\n' + matchingFilesForRule.join('\n') + '\n'; + message += '\n' + matchingFilesForRule.map(formatMatch).join('\n') + '\n'; grunt.fail.warn(message); } } From e6b04c7220a84e5a63acb685fa4bba0dff4c7879 Mon Sep 17 00:00:00 2001 From: Ethan Brown Date: Mon, 13 Jan 2014 23:33:07 -0800 Subject: [PATCH 2/2] Corrected typo in README.md. --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fed6405..50c34cb 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,9 @@ grunt.initConfig({ ], }, files: { - '**.js', + src: [ + '**.js', + ] }, }, your_target: { @@ -52,7 +54,9 @@ grunt.initConfig({ ], }, files: { - '**.css', + src: [ + '**.css', + ] }, }, },