eslint-teamcity
Advanced tools
Comparing version
{ | ||
"name": "eslint-teamcity", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "An ESLint formatter plugin for TeamCity", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "./node_modules/mocha/bin/mocha ./test/", | ||
"test-travis": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -R spec ./test/*" | ||
}, | ||
@@ -25,4 +26,6 @@ "repository": { | ||
"chai": "^3.5.0", | ||
"coveralls": "^2.11.8", | ||
"istanbul": "^0.4.2", | ||
"mocha": "^2.4.5" | ||
} | ||
} |
# eslint-teamcity | ||
[](https://badge.fury.io/js/eslint-teamcity) | ||
[](https://travis-ci.org/andreogle/eslint-teamcity) | ||
[](https://coveralls.io/github/andreogle/eslint-teamcity?branch=master) | ||
@@ -5,0 +6,0 @@ > A small [eslint](https://github.com/eslint/eslint) formatter plugin. |
@@ -55,17 +55,24 @@ /** | ||
var messageList = []; | ||
var errorsList = []; | ||
var warningsList = []; | ||
messages.forEach(function(message) { | ||
if (message.severity === 2) { | ||
messageList.push( | ||
'line ' + message.line + | ||
', col ' + message.column + ', ' + message.message | ||
); | ||
var userMessage = 'line ' + (message.line || 0) + | ||
', col ' + (message.column || 0) + ', ' + message.message + (message.ruleId ? ' (' + message.ruleId + ')' : ''); | ||
if (message.fatal || message.severity === 2) { | ||
errorsList.push(userMessage); | ||
} else { | ||
warningsList.push(userMessage); | ||
} | ||
}); | ||
if (messageList.length) { | ||
if (errorsList.length) { | ||
output += '##teamcity[testFailed name=\'' + reportName + ': ' + | ||
escapeTeamCityString(result.filePath) + '\' message=\'' + | ||
escapeTeamCityString(messageList.join('\n')) + '\']\n'; | ||
escapeTeamCityString(errorsList.join('\n')) + '\']\n'; | ||
} else if (warningsList.length) { | ||
output += '##teamcity[testStdOut name=\'' + reportName + ': ' + | ||
escapeTeamCityString(result.filePath) + '\' out=\'warning: ' + | ||
escapeTeamCityString(warningsList.join('\n')) + '\']\n'; | ||
} | ||
@@ -72,0 +79,0 @@ |
@@ -18,10 +18,49 @@ var expect = require('chai').expect; | ||
column: 1, | ||
message: 'This is a test error.' | ||
message: 'This is a test error.', | ||
ruleId: 'no-unreachable' | ||
} | ||
], | ||
filePath: 'testfile.js', | ||
filePath: 'testfile.js' | ||
} | ||
) | ||
} | ||
}; | ||
var createFatalError = function () { | ||
return ( | ||
{ | ||
messages: [ | ||
{ | ||
fatal: true, // usually omitted, but will be set to true if there's a parsing error (not related to a rule) | ||
line: 1, | ||
column: 1, | ||
message: 'Some fatal error' | ||
} | ||
], | ||
filePath: 'testfile-fatal.js' | ||
} | ||
) | ||
}; | ||
var createDummyWarning = function () { | ||
return ( | ||
{ | ||
messages: [ | ||
{ | ||
severity: 1, // warning | ||
line: 1, | ||
column: 1, | ||
message: 'Some warning' | ||
}, | ||
{ | ||
severity: 1, // warning | ||
line: 2, | ||
column: 2, | ||
message: 'This is a test warning.' | ||
} | ||
], | ||
filePath: 'testfile-warning.js' | ||
} | ||
) | ||
}; | ||
describe('formatting', function() { | ||
@@ -67,6 +106,54 @@ var results = []; | ||
expect(format(results)).to.contain( | ||
"message='line 1, col 1, |'|n|r|x|l|p|||[|]|nline 2, col 1, This is a test error.'" | ||
"message='line 1, col 1, |'|n|r|x|l|p|||[|]|nline 2, col 1, This is a test error. (no-unreachable)'" | ||
); | ||
}); | ||
}); | ||
describe('file fatal error output', function() { | ||
beforeEach(function() { | ||
results.push(createFatalError()); | ||
}); | ||
it('should include filename at the start of each file test', function() { | ||
expect(format(results)).to.contain( | ||
"##teamcity[testStarted name=\'ESLint Violations: testfile-fatal.js\']" | ||
) | ||
}); | ||
it('should include filename at the end of each file test', function() { | ||
expect(format(results)).to.contain( | ||
"##teamcity[testFinished name=\'ESLint Violations: testfile-fatal.js\']" | ||
) | ||
}); | ||
it('should include all errors within their respective file', function() { | ||
expect(format(results)).to.contain( | ||
"message='line 1, col 1, Some fatal error'" | ||
); | ||
}); | ||
}); | ||
describe('file warning output', function() { | ||
beforeEach(function() { | ||
results.push(createDummyWarning()); | ||
}); | ||
it('should include filename at the start of each file test', function() { | ||
expect(format(results)).to.contain( | ||
"##teamcity[testStarted name='ESLint Violations: testfile-warning.js']" | ||
) | ||
}); | ||
it('should include filename at the end of each file test', function() { | ||
expect(format(results)).to.contain( | ||
"##teamcity[testFinished name=\'ESLint Violations: testfile-warning.js\']" | ||
) | ||
}); | ||
it('should include all warnings within their respective file', function() { | ||
expect(format(results)).to.contain( | ||
"##teamcity[testStdOut name='ESLint Violations: testfile-warning.js' out='warning: line 1, col 1, Some warning|nline 2, col 2, This is a test warning.'" | ||
); | ||
}); | ||
}); | ||
}); | ||
@@ -73,0 +160,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
11682
39.67%219
61.03%59
1.72%4
100%