Skip to content

Commit 8b02e2d

Browse files
danpoltawskiRajesh Taneja
authored and
Rajesh Taneja
committedJan 3, 2017
MDL-56519 behat: Lint gherkin files
1 parent c4cf1c6 commit 8b02e2d

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed
 

‎.gherkin-lintrc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"no-files-without-scenarios" : "on",
3+
"no-unamed-features": "on",
4+
"no-unamed-scenarios": "on",
5+
"no-dupe-scenario-names": "off",
6+
"no-dupe-feature-names": "on",
7+
"no-partially-commented-tag-lines": "on",
8+
"indentation": ["on",{
9+
"Feature": 0,
10+
"Background": 2,
11+
"Scenario": 0,
12+
"Step": 4,
13+
"given": 4,
14+
"and": 4
15+
}],
16+
"no-trailing-spaces": "on",
17+
"no-multiple-empty-lines": "on",
18+
"no-empty-file": "on",
19+
"no-scenario-outlines-without-examples": "on"
20+
}

‎Gruntfile.js

+22-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ module.exports = function(grunt) {
106106
return libs;
107107
};
108108

109-
110109
// Project configuration.
111110
grunt.initConfig({
112111
eslint: {
@@ -178,6 +177,11 @@ module.exports = function(grunt) {
178177
paths: [cwd]
179178
}
180179
},
180+
gherkinlint: {
181+
options: {
182+
files: ['**/tests/behat/*.feature'],
183+
}
184+
},
181185
stylelint: {
182186
less: {
183187
options: {
@@ -318,6 +322,22 @@ module.exports = function(grunt) {
318322
}, done);
319323
};
320324

325+
tasks.gherkinlint = function() {
326+
var done = this.async(),
327+
options = grunt.config('gherkinlint.options');
328+
329+
var args = grunt.file.expand(options.files);
330+
args.unshift(path.normalize(__dirname + '/node_modules/.bin/gherkin-lint'));
331+
grunt.util.spawn({
332+
cmd: 'node',
333+
args: args,
334+
opts: {stdio: 'inherit', env: process.env}
335+
}, function(error, result, code) {
336+
// Propagate the exit code.
337+
done(code);
338+
});
339+
};
340+
321341
tasks.startup = function() {
322342
// Are we in a YUI directory?
323343
if (path.basename(path.resolve(cwd, '../../')) == 'yui') {
@@ -360,6 +380,7 @@ module.exports = function(grunt) {
360380

361381
// Register JS tasks.
362382
grunt.registerTask('shifter', 'Run Shifter against the current directory', tasks.shifter);
383+
grunt.registerTask('gherkinlint', 'Run gherkinlint against the current directory', tasks.gherkinlint);
363384
grunt.registerTask('ignorefiles', 'Generate ignore files for linters', tasks.ignorefiles);
364385
grunt.registerTask('yui', ['eslint:yui', 'shifter']);
365386
grunt.registerTask('amd', ['eslint:amd', 'uglify']);

‎npm-shrinkwrap.json

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"devDependencies": {
66
"async": "1.5.2",
77
"eslint": "3.7.1",
8+
"gherkin-lint": "1.1.3",
89
"grunt": "1.0.1",
910
"grunt-contrib-less": "1.3.0",
1011
"grunt-contrib-uglify": "1.0.1",

0 commit comments

Comments
 (0)
Please sign in to comment.