gherkin-lint
Advanced tools
| /* eslint-disable no-console */ | ||
| function boldError(msg) { | ||
| console.error(`\x1b[31m\x1b[1m${msg}\x1b[0m`); | ||
| } | ||
| function error(msg) { | ||
| console.error(`\x1b[31m${msg}\x1b[0m`); | ||
| } | ||
| module.exports = { | ||
| error: error, | ||
| boldError: boldError | ||
| }; |
+2
-1
| language: node_js | ||
| node_js: | ||
| - "node" | ||
| - "7" | ||
| - "6" | ||
| - "5" | ||
| - "4" | ||
| - "0.12" | ||
| - "iojs" | ||
| script: "npm test" |
+2
-2
| { | ||
| "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 @@ |
+3
-1
@@ -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 @@ |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
67898
0.51%92
1.1%1362
1.41%