gherkin-lint
Advanced tools
Comparing version 2.5.0 to 2.5.1
{ | ||
"name": "gherkin-lint", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"description": "A Gherkin linter/validator written in javascript", | ||
@@ -57,3 +57,3 @@ "author": "Vasiliki Siakka", | ||
"lint": "eslint .", | ||
"mocha": "mocha --recursive", | ||
"mocha": "mocha --recursive --no-exit", | ||
"test": "npm run lint && npm run mocha" | ||
@@ -60,0 +60,0 @@ }, |
var fs = require('fs'); | ||
var rules = require('./rules.js'); | ||
var logger = require('./logger.js'); | ||
@@ -11,8 +12,10 @@ var defaultConfigFileName = '.gherkin-lintrc'; | ||
if (!fs.existsSync(configPath)) { | ||
throw new Error('Could not find specified config file "' + configPath + '"'); | ||
logger.boldError('Could not find specified config file "' + configPath + '"'); | ||
process.exit(1); | ||
} | ||
} else { | ||
if (!fs.existsSync(defaultConfigFileName)) { | ||
throw new Error('Could not find default config file "' + defaultConfigFileName +'" in the working ' + | ||
'directory. To use a custom name/location provide the config file using the "-c" arg'); | ||
logger.boldError('Could not find default config file "' + defaultConfigFileName +'" in the working ' + | ||
'directory.\nTo use a custom name/path provide the config file using the "-c" arg.'); | ||
process.exit(1); | ||
} | ||
@@ -26,7 +29,7 @@ configPath = defaultConfigFileName; | ||
if (errors.length > 0) { | ||
console.error('\x1b[31m\x1b[1mError(s) in configuration file:\x1b[0m'); // eslint-disable-line no-console | ||
logger.boldError('Error(s) in configuration file:'); | ||
errors.forEach(function(error){ | ||
console.error('\x1b[31m- ' + error + '\x1b[0m'); // eslint-disable-line no-console | ||
logger.error(`- ${error}`); | ||
}); | ||
throw new Error('Configuration error(s)'); | ||
process.exit(1); | ||
} | ||
@@ -33,0 +36,0 @@ |
var glob = require('glob'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var logger = require('./logger.js'); | ||
var defaultIgnoreFileName = '.gherkin-lintignore'; | ||
@@ -32,3 +34,4 @@ var defaultIgnoredFiles = 'node_modules/**'; // Ignore node_modules by default | ||
if (!fixedPattern) { | ||
throw new Error(`Invalid format of the feature file path/pattern: "${pattern}".\nTo run the linter please specify an existing feature file, directory or glob.`); | ||
logger.boldError(`Invalid format of the feature file path/pattern: "${pattern}".\nTo run the linter please specify an existing feature file, directory or glob.`); | ||
process.exit(1); | ||
} | ||
@@ -35,0 +38,0 @@ |
@@ -7,2 +7,3 @@ #!/usr/bin/env node | ||
var configParser = require('./config-parser.js'); | ||
var logger = require('./logger.js'); | ||
@@ -50,5 +51,6 @@ function list(val) { | ||
} else { | ||
throw new Error('Unsupported format. The supported formats are json and stylish.'); | ||
logger.boldError('Unsupported format. The supported formats are json and stylish.'); | ||
process.exit(1); | ||
} | ||
formatter.printResults(results); | ||
} |
var _ = require('lodash'); | ||
var logger = require('./../logger.js'); | ||
var rule = 'new-line-at-eof'; | ||
@@ -11,3 +12,5 @@ | ||
if (_.indexOf(availableConfigs, configuration) === -1) { | ||
throw new Error(rule + ' requires an extra configuration value.\nAvailable configurations: ' + availableConfigs.join(', ') + '\nFor syntax please look at the documentation.'); | ||
// eslint-disable-next-line no-console | ||
logger.boldError(rule + ' requires an extra configuration value.\nAvailable configurations: ' + availableConfigs.join(', ') + '\nFor syntax please look at the documentation.'); | ||
process.exit(1); | ||
} | ||
@@ -14,0 +17,0 @@ |
@@ -24,4 +24,3 @@ module.exports = | ||
'\x1b[31m- Rule "fake-rule" does not exist\x1b[0m' | ||
], | ||
'assertionMessage': 'Configuration error(s)' | ||
] | ||
}, | ||
@@ -28,0 +27,0 @@ 'config5': { |
@@ -6,2 +6,3 @@ var assert = require('chai').assert; | ||
/* eslint-disable */ | ||
require('mocha-sinon'); | ||
@@ -32,24 +33,23 @@ | ||
beforeEach(function() { | ||
var f = function() { | ||
// eslint-disable-next-line | ||
console.log('hi'); | ||
}; | ||
this.sinon.stub(console, 'error'); | ||
this.sinon.stub(process, 'exit', f); | ||
}); | ||
it('a non existing rule', function() { | ||
var actualAssertion; | ||
try { | ||
configParser.getConfiguration('./test/configuration-parser/test-data/config4'); | ||
} catch (e) { | ||
actualAssertion = e.message; | ||
} | ||
configParser.getConfiguration('./test/configuration-parser/test-data/config4'); | ||
var expected = expectedResults.config4; | ||
// verify the assertion message | ||
var expectedAssertion = expected.assertionMessage; | ||
assert.equal(actualAssertion, expectedAssertion); | ||
// verify the console logs | ||
var consoleErrorArgs = console.error.args.map(function (args) { // eslint-disable-line no-console | ||
return args[0]; | ||
}); | ||
expect(consoleErrorArgs).to.be.deep.equal(expected.consoleErrors); | ||
var expectedErrors = expected.consoleErrors; | ||
expect(expectedErrors).to.deep.equal(consoleErrorArgs); | ||
expect(process.exit.args[0][0]).to.equal(1); | ||
}); | ||
@@ -56,0 +56,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67898
92
1362