diff --git a/package.json b/package.json index a6511db..7f7b632 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "lint": "eslint .", - "prettier": "prettier --write ./**/*.js", + "prettify": "prettier --write ./**/*.js", "test": "mocha \"./test/**/*.spec.js\"", "test:travis": "nyc npm test && nyc report --reporter=text-lcov | coveralls" }, @@ -43,7 +43,7 @@ }, "lint-staged": { "*.js": [ - "npm run prettier", + "npm run prettify", "npm run lint" ] }, diff --git a/src/formatter.js b/src/formatter.js index d35f1b2..f60af2a 100644 --- a/src/formatter.js +++ b/src/formatter.js @@ -41,7 +41,7 @@ function getUserConfig(propNames) { reporter, reportName: utils.escapeTeamCityString(reportName), errorStatisticsName: utils.escapeTeamCityString(errorStatisticsName), - warningStatisticsName: utils.escapeTeamCityString(warningStatisticsName) + warningStatisticsName: utils.escapeTeamCityString(warningStatisticsName), }; } diff --git a/test/formatter.spec.js b/test/formatter.spec.js index 4c084d0..e906406 100644 --- a/test/formatter.spec.js +++ b/test/formatter.spec.js @@ -6,20 +6,20 @@ const { createDummyError } = require('./helpers/eslint-factory'); const utils = require('../src/utils/index'); const format = require('../src/formatter'); -describe('formatter', function() { - describe('config', function() { +describe('formatter', function () { + describe('config', function () { let eslintInput = []; - beforeEach(function() { + beforeEach(function () { eslintInput.push(createDummyError()); }); - afterEach(function() { + afterEach(function () { eslintInput = []; }); - context('prop names', function() { - it('sets the reporter', function() { + context('prop names', function () { + it('sets the reporter', function () { const output = format(eslintInput, { reporter: 'inspections' }); expect(output).to.include( "##teamcity[inspectionType id='no-console' category='ESLint Violations' name='no-console' description='ESLint Violations']" @@ -29,62 +29,62 @@ describe('formatter', function() { ); }); - it('sets the report name', function() { + it('sets the report name', function () { const output = format(eslintInput, { reportName: 'prop report name' }); expect(output).to.include("##teamcity[testSuiteStarted name='prop report name']"); expect(output).to.include("##teamcity[testSuiteFinished name='prop report name']"); }); - it('sets the error count name', function() { + it('sets the error count name', function () { const output = format(eslintInput, { errorStatisticsName: 'prop errors' }); expect(output).to.include("##teamcity[buildStatisticValue key='prop errors' value='2']"); }); - it('sets the warning count name', function() { + it('sets the warning count name', function () { const output = format(eslintInput, { warningStatisticsName: 'prop warnings' }); expect(output).to.include("##teamcity[buildStatisticValue key='prop warnings' value='0']"); }); }); - context('package.json', function() { - beforeEach(function() { + context('package.json', function () { + beforeEach(function () { const jsonConfig = JSON.stringify({ 'eslint-teamcity': { reporter: 'inspections', 'report-name': 'package.json report', 'error-statistics-name': 'package.json errors', - 'warning-statistics-name': 'package.json warnings' - } + 'warning-statistics-name': 'package.json warnings', + }, }); sinon.stub(utils, 'loadPackageJson').callsFake(() => jsonConfig); }); - afterEach(function() { + afterEach(function () { utils.loadPackageJson.restore(); }); - it('sets the report type', function() { + it('sets the report type', function () { const output = format(eslintInput); expect(output).to.include( "##teamcity[inspection typeId='no-console' message='line 1, col 1, |'|n|r|x|l|p|||[|]' file='testfile.js' line='1' SEVERITY='ERROR']" ); }); - it('sets the report name', function() { + it('sets the report name', function () { const output = format(eslintInput); expect(output).to.include( "##teamcity[inspectionType id='no-console' category='package.json report' name='no-console' description='package.json report']" ); }); - it('sets the error count name', function() { + it('sets the error count name', function () { const output = format(eslintInput); expect(output).to.include( "##teamcity[buildStatisticValue key='package.json errors' value='2']" ); }); - it('sets the warning count name', function() { + it('sets the warning count name', function () { const output = format(eslintInput); expect(output).to.include( "##teamcity[buildStatisticValue key='package.json warnings' value='0']" @@ -92,7 +92,7 @@ describe('formatter', function() { }); }); - context('process.env', function() { + context('process.env', function () { function cleanup() { delete process.env.ESLINT_TEAMCITY_REPORTER; delete process.env.ESLINT_TEAMCITY_REPORT_NAME; @@ -103,7 +103,7 @@ describe('formatter', function() { beforeEach(() => cleanup()); afterEach(() => cleanup()); - it('sets the report type', function() { + it('sets the report type', function () { process.env.ESLINT_TEAMCITY_REPORTER = 'inspections'; const output = format(eslintInput); expect(output).to.include( @@ -111,14 +111,14 @@ describe('formatter', function() { ); }); - it('sets the report name', function() { + it('sets the report name', function () { process.env.ESLINT_TEAMCITY_REPORT_NAME = 'process.env report'; const output = format(eslintInput); expect(output).to.include("##teamcity[testSuiteStarted name='process.env report']"); expect(output).to.include("##teamcity[testSuiteFinished name='process.env report']"); }); - it('sets the error count name', function() { + it('sets the error count name', function () { process.env.ESLINT_TEAMCITY_ERROR_STATISTICS_NAME = 'process.env errors'; const output = format(eslintInput); expect(output).to.include( @@ -126,7 +126,7 @@ describe('formatter', function() { ); }); - it('sets the warning count name', function() { + it('sets the warning count name', function () { process.env.ESLINT_TEAMCITY_WARNING_STATISTICS_NAME = 'process.env warnings'; const output = format(eslintInput); expect(output).to.include( @@ -135,13 +135,13 @@ describe('formatter', function() { }); }); - context('defaults', function() { - it('uses the error reporter', function() { + context('defaults', function () { + it('uses the error reporter', function () { const output = format(eslintInput); expect(output).to.include("##teamcity[testSuiteStarted name='ESLint Violations']"); }); - it('sets the report name', function() { + it('sets the report name', function () { const output = format(eslintInput); expect(output).to.include("##teamcity[testSuiteStarted name='ESLint Violations']"); expect(output).to.include("##teamcity[testSuiteFinished name='ESLint Violations']"); @@ -154,7 +154,7 @@ describe('formatter', function() { ); }); - it('sets the warning count name', function() { + it('sets the warning count name', function () { const output = format(eslintInput); expect(output).to.include( "##teamcity[buildStatisticValue key='ESLint Warning Count' value='0']" diff --git a/test/smoke.spec.js b/test/smoke.spec.js index 901cd71..f9fb447 100644 --- a/test/smoke.spec.js +++ b/test/smoke.spec.js @@ -10,26 +10,26 @@ const basePath = path.resolve(__dirname, '..'); const pathToTestJson = path.resolve(__dirname, 'result.json'); const pathToIndex = path.resolve(__dirname, '..', 'index.js'); -describe('smoke tests', function() { - describe('support interface', function() { +describe('smoke tests', function () { + describe('support interface', function () { let esLintOutput = []; - beforeEach(function() { + beforeEach(function () { esLintOutput.push(createDummyError()); }); - afterEach(function() { + afterEach(function () { esLintOutput = []; }); - describe('cmd', function() { - it('as eslint formatter plugin', function() { + describe('cmd', function () { + it('as eslint formatter plugin', function () { this.timeout(8000); const result = sh.exec(`eslint --format '${pathToIndex}' ${pathToIndex}`); expect(result.stdout).to.contain('##teamcity'); }); - it('as standalone', function() { + it('as standalone', function () { fs.writeJSONSync(pathToTestJson, esLintOutput); const result = sh.exec(`cd ${basePath}; node index.js ${pathToTestJson}`); expect(result.stdout).to.contain('##teamcity'); @@ -39,16 +39,16 @@ describe('smoke tests', function() { }); }); - describe('requirejs', function() { - it('basic', function() { + describe('requirejs', function () { + it('basic', function () { const result = require(pathToIndex)(esLintOutput); expect(result).to.contain('##teamcity'); }); - it('with parameters', function() { + it('with parameters', function () { const teamcityPropNames = { errorStatisticsName: 'EslintInspectionStatsE', - warningStatisticsName: 'EslintInspectionStatsW' + warningStatisticsName: 'EslintInspectionStatsW', }; const result = require(pathToIndex)(esLintOutput, teamcityPropNames);