Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-teamcity

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-teamcity - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

2

package.json
{
"name": "eslint-teamcity",
"version": "1.2.1",
"version": "1.3.0",
"description": "An ESLint formatter plugin for TeamCity",

@@ -5,0 +5,0 @@ "main": "index.js",

# eslint-teamcity
[![npm version](https://badge.fury.io/js/eslint-teamcity.svg)](https://badge.fury.io/js/eslint-teamcity)
[![npm version](https://badge.fury.io/js/eslint-teamcity.svg)](https://www.npmjs.com/package/eslint-teamcity)
[![Build Status](https://travis-ci.org/andreogle/eslint-teamcity.svg?branch=master)](https://travis-ci.org/andreogle/eslint-teamcity)
[![Coverage Status](https://coveralls.io/repos/github/andreogle/eslint-teamcity/badge.svg?branch=master)](https://coveralls.io/github/andreogle/eslint-teamcity?branch=master)
[![npm downloads](https://img.shields.io/npm/dm/eslint-teamcity.svg)](https://www.npmjs.com/package/eslint-teamcity)

@@ -54,2 +55,9 @@ > A small [eslint](https://github.com/eslint/eslint) formatter plugin.

## Extras
eslint-teamcity will also output statistic values which you can use in TeamCity to track your progress in resolving errors!
Graphs can be setup from the Builds -> Statistics tab.
![Example Statistics Output](http://i.imgur.com/oHbiuZE.png)
## Issues

@@ -60,14 +68,1 @@

Any pull requests are also welcome!
## Configuration
You can add `eslint-teamcity` section to `package.json`. As of now 2 parameters are supported:
```
details: boolean // defaults to true
summary: boolean // defaults to false
```
If `summary` is set to true then total error and warning count will be reported to TeamCity statistics.
If `details` is set to false then detailed file breakdown will not be reported.

@@ -8,4 +8,2 @@ /**

var utils = require('./utils');
//------------------------------------------------------------------------------

@@ -40,18 +38,2 @@ // Helpers

var options = {
details: {
default: true
},
summary: {
default: false
}
};
function getOptionValue(config, optionName) {
if (optionName in config) {
return config[optionName];
}
return options[optionName].default;
}
//------------------------------------------------------------------------------

@@ -61,8 +43,2 @@ // Public Interface

module.exports = function(results) {
var config = JSON.parse(utils.loadConfig())['eslint-teamcity'] || {};
var optionDetails = getOptionValue(config, 'details');
var optionSummary = getOptionValue(config, 'summary');
var output = '';

@@ -72,5 +48,3 @@ var errorCount = 0;

if (optionDetails) {
output += '##teamcity[testSuiteStarted name=\'' + reportName + '\']\n';
}
output += '##teamcity[testSuiteStarted name=\'' + reportName + '\']\n';

@@ -84,6 +58,4 @@ results.forEach(function(result) {

if (optionDetails) {
output += '##teamcity[testStarted name=\'' + reportName + ': ' +
escapeTeamCityString(result.filePath) + '\']\n';
}
output += '##teamcity[testStarted name=\'' + reportName + ': ' +
escapeTeamCityString(result.filePath) + '\']\n';

@@ -95,3 +67,4 @@ var errorsList = [];

var userMessage = 'line ' + (message.line || 0) +
', col ' + (message.column || 0) + ', ' + message.message + (message.ruleId ? ' (' + message.ruleId + ')' : '');
', col ' + (message.column || 0) +
', ' + message.message + (message.ruleId ? ' (' + message.ruleId + ')' : '');

@@ -107,31 +80,25 @@ if (message.fatal || message.severity === 2) {

if (optionDetails) {
if (errorsList.length) {
output += '##teamcity[testFailed name=\'' + reportName + ': ' +
escapeTeamCityString(result.filePath) + '\' message=\'' +
escapeTeamCityString(errorsList.join('\n')) + '\']\n';
} else if (warningsList.length) {
output += '##teamcity[testStdOut name=\'' + reportName + ': ' +
escapeTeamCityString(result.filePath) + '\' out=\'warning: ' +
escapeTeamCityString(warningsList.join('\n')) + '\']\n';
}
output += '##teamcity[testFinished name=\'' + reportName + ': ' +
escapeTeamCityString(result.filePath) + '\']\n';
if (errorsList.length) {
output += '##teamcity[testFailed name=\'' + reportName + ': ' +
escapeTeamCityString(result.filePath) + '\' message=\'' +
escapeTeamCityString(errorsList.join('\n')) + '\']\n';
} else if (warningsList.length) {
output += '##teamcity[testStdOut name=\'' + reportName + ': ' +
escapeTeamCityString(result.filePath) + '\' out=\'warning: ' +
escapeTeamCityString(warningsList.join('\n')) + '\']\n';
}
output += '##teamcity[testFinished name=\'' + reportName + ': ' +
escapeTeamCityString(result.filePath) + '\']\n';
});
if (optionDetails) {
output += '##teamcity[testSuiteFinished name=\'' + reportName + '\']\n';
}
output += '##teamcity[testSuiteFinished name=\'' + reportName + '\']\n';
if (optionSummary) {
if (errorCount !== 0) {
output += '##teamcity[buildStatisticValue key=\'ESLintErrorCount\' value=\'' + errorCount +'\' ]\n';
}
if (warningCount !== 0) {
output += '##teamcity[buildStatisticValue key=\'ESLintWarningCount\' value=\'' + warningCount +'\' ]\n';
}
if (errorCount !== 0) {
output += '##teamcity[buildStatisticValue key=\'ESLintErrorCount\' value=\'' + errorCount +'\' ]\n';
}
if (warningCount !== 0) {
output += '##teamcity[buildStatisticValue key=\'ESLintWarningCount\' value=\'' + warningCount +'\' ]\n';
}
return output;
};
var expect = require('chai').expect;
var sinon = require('sinon');
var format = require('../src/formatter');
var utils = require('../src/utils');

@@ -26,41 +25,41 @@ var createDummyError = function() {

}
)
);
};
var createFatalError = function () {
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'
}
)
{
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 () {
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'
}
)
{
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'
}
);
};

@@ -97,3 +96,3 @@

"##teamcity[testStarted name=\'ESLint Violations: testfile.js\']"
)
);
});

@@ -104,3 +103,3 @@

"##teamcity[testFinished name=\'ESLint Violations: testfile.js\']"
)
);
});

@@ -122,4 +121,4 @@

expect(format(results)).to.contain(
"##teamcity[testStarted name=\'ESLint Violations: testfile-fatal.js\']"
)
"##teamcity[testStarted name=\'ESLint Violations: testfile-fatal.js\']"
);
});

@@ -129,4 +128,4 @@

expect(format(results)).to.contain(
"##teamcity[testFinished name=\'ESLint Violations: testfile-fatal.js\']"
)
"##teamcity[testFinished name=\'ESLint Violations: testfile-fatal.js\']"
);
});

@@ -136,3 +135,3 @@

expect(format(results)).to.contain(
"message='line 1, col 1, Some fatal error'"
"message='line 1, col 1, Some fatal error'"
);

@@ -150,3 +149,3 @@ });

"##teamcity[testStarted name='ESLint Violations: testfile-warning.js']"
)
);
});

@@ -157,3 +156,3 @@

"##teamcity[testFinished name=\'ESLint Violations: testfile-warning.js\']"
)
);
});

@@ -168,75 +167,20 @@

describe('default output', function() {
describe('build statistics', function() {
beforeEach(function() {
results.push(createDummyWarning());
});
it('should not contain total warning count', function() {
expect(format(results)).to.not.contain(
"##teamcity[buildStatisticValue key=\'ESLintWarningCount\'"
)
});
it('should not contain total error count', function() {
expect(format(results)).to.not.contain(
"##teamcity[buildStatisticValue key=\'ESLintErrorCount\'"
)
});
});
describe('not configured with package.json', function() {
before(function() {
var configStub = sinon.stub(utils, 'loadConfig');
configStub.returns('{ "otherPackageJsonKeys": "value" }');
});
beforeEach(function() {
results.push(createDummyWarning());
});
after(function() {
utils.loadConfig.restore();
});
it('output should not contain total warning count', function() {
expect(format(results)).to.not.contain(
"##teamcity[buildStatisticValue key=\'ESLintWarningCount\'"
)
});
});
describe('configured with package.json', function() {
before(function() {
var configStub = sinon.stub(utils, 'loadConfig');
configStub.returns('{ "eslint-teamcity": { "summary": true, "details": false } }');
});
beforeEach(function() {
results.push(createDummyWarning());
results.push(createDummyError());
});
after(function() {
utils.loadConfig.restore();
});
it('output should contain total warning count with summary enabled', function() {
it('should contain total warning count', function() {
expect(format(results)).to.contain(
"##teamcity[buildStatisticValue key=\'ESLintWarningCount\' value=\'2\'"
)
);
});
it('output should contain total error count with summary enabled', function() {
it('should contain total error count', function() {
expect(format(results)).to.contain(
"##teamcity[buildStatisticValue key=\'ESLintErrorCount\' value=\'2\'"
)
);
});
it('output should not contain detailed stats', function() {
expect(format(results)).to.not.contain(
"This is a test error"
)
});
});
});

@@ -243,0 +187,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc