Skip to content

Commit

Permalink
Merge pull request #51 from xgbuils/fix-1
Browse files Browse the repository at this point in the history
reporting errors like eslint
  • Loading branch information
xgbuils authored Jun 2, 2019
2 parents e5278f9 + 4786d9f commit 9a97aa8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 31 deletions.
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/linter/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const linterFactory = ({format, ignore, config, rulesDirs, args}, Gherkin) => {
return {
lint() {
return linter.lint().then(
(results) => ({
(failures) => ({
logType: 'log',
failures: {},
failures,
}),
(failures) => ({
logType: 'error',
Expand Down
10 changes: 4 additions & 6 deletions src/linter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ const lintFiles = (files, rules, fileLinter) => {
.then(flatten);

return outputPromise.then((output) => {
return output.length > 0
? Promise.reject({
type: 'lint-errors',
errors: output,
})
: Promise.resolve({});
return output.length > 0 ? {
type: 'lint-errors',
errors: output,
} : {};
});
};

Expand Down
14 changes: 7 additions & 7 deletions test/linter/factory/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const pathToOtherRules = path.join('test', 'linter', 'factory', 'other_rules');
const Gherkin = require('gherkin');

describe('Linter Factory', function() {
it('linter that fails', function() {
it('linter that report rule failures', function() {
const featureFile = 'failure.feature';
const linter = linterFactory({
config: path.join(__dirname, '.gherkin-lintrc'),
Expand All @@ -19,7 +19,7 @@ describe('Linter Factory', function() {
args: [featureFile],
}, Gherkin);
return linter.lint().then((result) => {
expect(result.logType).to.be.equal('error');
expect(result.logType).to.be.equal('log');
expect(result.exit).to.be.equal(1);
expect(result.errorLines[0]).to.include('failure.feature');
expect(result.errorLines[1]).to.include('Wrong indentation for "Feature", expected indentation level of 0, but got 4');
Expand All @@ -29,7 +29,7 @@ describe('Linter Factory', function() {
expect(result.errorLines[5]).to.include('\n');
expect(result.errorLines.length).to.be.equal(6);
}, () => {
expect.fail('linter must not fail');
expect.fail('linter factory must not fail');
});
});

Expand All @@ -48,7 +48,7 @@ describe('Linter Factory', function() {
errorLines: [],
});
}, () => {
expect.fail('linter must not fail');
expect.fail('linter factory must not fail');
});
});

Expand All @@ -67,7 +67,7 @@ describe('Linter Factory', function() {
expect(result.errorLines[0]).to.include('Could not find specified config file');
expect(result.errorLines[0]).to.include('.not-found-lintrc');
}, () => {
expect.fail('linter must not fail');
expect.fail('linter factory must not fail');
});
});

Expand All @@ -85,7 +85,7 @@ describe('Linter Factory', function() {
expect(result.errorLines[0]).to.include('Could not find default config file ".gherkin-lintrc" in the working directory.');
expect(result.errorLines[0]).to.include('To use a custom name/path provide the config file using the "-c" arg.');
}, () => {
expect.fail('linter must not fail');
expect.fail('linter factory must not fail');
});
});

Expand All @@ -102,7 +102,7 @@ describe('Linter Factory', function() {
expect(result.errorLines[0]).to.include('Could not find default config file ".gherkin-lintrc" in the working directory.');
expect(result.errorLines[0]).to.include('To use a custom name/path provide the config file using the "-c" arg.');
}, () => {
expect.fail('linter must not fail');
expect.fail('linter factory must not fail');
});
});
});
6 changes: 3 additions & 3 deletions test/linter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ describe('Linter', () => {
})
);

return linter.lint().then(() => {
expect.fail('linter must fail');
}, (result) => {
return linter.lint().then((result) => {
expect(result).to.be.deep.equal({
type: 'lint-errors',
errors: [{
message: firstFile.path,
errors: errorsFirstFeature,
}],
});
}, () => {
expect.fail('linter must not fail');
});
});
});
Expand Down

0 comments on commit 9a97aa8

Please sign in to comment.