gherkin-lint
Advanced tools
Comparing version 2.10.0 to 2.11.0
@@ -5,3 +5,3 @@ 'use strict'; | ||
var verifyConfig = require('./config-verifier.js'); | ||
var logger = require('./logger.js'); | ||
var defaultConfigFileName = '.gherkin-lintrc'; | ||
@@ -12,7 +12,9 @@ | ||
if (!fs.existsSync(configPath)) { | ||
throw new Error('Could not find specified config file "' + configPath + '"'); | ||
logger.boldError('Could not find specified config file "' + configPath + '"'); | ||
return 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.'); | ||
return process.exit(1); | ||
} | ||
@@ -22,11 +24,10 @@ configPath = defaultConfigFileName; | ||
var config = JSON.parse(fs.readFileSync(configPath)); | ||
var errors = verifyConfig(config, additionalRulesDirs); | ||
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 +34,0 @@ |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var path = require('path'); | ||
var logger = require('./logger.js'); | ||
var defaultIgnoreFileName = '.gherkin-lintignore'; | ||
@@ -36,3 +38,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); | ||
} | ||
@@ -39,0 +42,0 @@ |
@@ -83,2 +83,5 @@ 'use strict'; | ||
rule = 'one-feature-per-file'; | ||
} else if (error.message.indexOf('expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #ScenarioOutlineLine, #Comment, #Empty, got \'Examples:\'') > -1) { | ||
errorMsg = 'Cannot use "Examples" in a "Scenario", use a "Scenario Outline" instead'; | ||
rule = 'no-examples-in-scenarios'; | ||
} else if (error.message.indexOf('expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #ScenarioOutlineLine, #Comment, #Empty, got') > -1 || error.message.indexOf('expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #ScenarioOutlineLine, #Comment, #Empty, got') > -1) { | ||
@@ -85,0 +88,0 @@ errorMsg = 'Steps should begin with "Given", "When", "Then", "And" or "But". Multiline steps are dissallowed'; |
@@ -8,2 +8,3 @@ #!/usr/bin/env node | ||
var configParser = require('./config-parser.js'); | ||
var logger = require('./logger.js'); | ||
@@ -45,5 +46,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); | ||
} |
'use strict'; | ||
var _ = require('lodash'); | ||
var logger = require('./../logger.js'); | ||
var rule = 'new-line-at-eof'; | ||
@@ -10,3 +11,4 @@ | ||
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.'); | ||
logger.boldError(rule + ' requires an extra configuration value.\nAvailable configurations: ' + availableConfigs.join(', ') + '\nFor syntax please look at the documentation.'); | ||
process.exit(1); | ||
} | ||
@@ -13,0 +15,0 @@ |
@@ -7,15 +7,16 @@ 'use strict'; | ||
var errors = []; | ||
feature.children.forEach(function (child) { | ||
var previousKeyword = undefined; | ||
child.steps.forEach(function (step) { | ||
if (step.keyword === 'And ') { | ||
return; | ||
} | ||
if (step.keyword === previousKeyword) { | ||
errors.push(createError(step)); | ||
} | ||
previousKeyword = step.keyword; | ||
if (feature && feature.children) { | ||
feature.children.forEach(function (child) { | ||
var previousKeyword = undefined; | ||
child.steps.forEach(function (step) { | ||
if (step.keyword === 'And ') { | ||
return; | ||
} | ||
if (step.keyword === previousKeyword) { | ||
errors.push(createError(step)); | ||
} | ||
previousKeyword = step.keyword; | ||
}); | ||
}); | ||
}); | ||
} | ||
@@ -22,0 +23,0 @@ return errors; |
{ | ||
"name": "gherkin-lint", | ||
"version": "2.10.0", | ||
"version": "2.11.0", | ||
"description": "A Gherkin linter/validator written in javascript", | ||
@@ -5,0 +5,0 @@ "author": "Vasiliki Siakka", |
@@ -34,2 +34,3 @@ # Gherkin lint | ||
| `no-multiline-steps` * | Disallows mutiline Steps | | ||
| `no-examples-in-scenarios` | Disallow the use of "Examples" in scenarios | | ||
| | | | ||
@@ -36,0 +37,0 @@ | [`indentation`](#indentation) | Allows the user to specify indentation rules | |
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
46158
38
1067
162