Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Commit

Permalink
Run prettier 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andreogle committed Apr 1, 2020
1 parent f428921 commit 0a73482
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -43,7 +43,7 @@
},
"lint-staged": {
"*.js": [
"npm run prettier",
"npm run prettify",
"npm run lint"
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function getUserConfig(propNames) {
reporter,
reportName: utils.escapeTeamCityString(reportName),
errorStatisticsName: utils.escapeTeamCityString(errorStatisticsName),
warningStatisticsName: utils.escapeTeamCityString(warningStatisticsName)
warningStatisticsName: utils.escapeTeamCityString(warningStatisticsName),
};
}

Expand Down
54 changes: 27 additions & 27 deletions test/formatter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']"
Expand All @@ -29,70 +29,70 @@ 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']"
);
});
});

context('process.env', function() {
context('process.env', function () {
function cleanup() {
delete process.env.ESLINT_TEAMCITY_REPORTER;
delete process.env.ESLINT_TEAMCITY_REPORT_NAME;
Expand All @@ -103,30 +103,30 @@ 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(
"##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 () {
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(
"##teamcity[buildStatisticValue key='process.env errors' value='2']"
);
});

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(
Expand All @@ -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']");
Expand All @@ -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']"
Expand Down
22 changes: 11 additions & 11 deletions test/smoke.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand Down

0 comments on commit 0a73482

Please sign in to comment.