Skip to content

Commit

Permalink
MDL-56519 behat: Lint gherkin files
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski authored and Rajesh Taneja committed Jan 3, 2017
1 parent c4cf1c6 commit 8b02e2d
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .gherkin-lintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"no-files-without-scenarios" : "on",
"no-unamed-features": "on",
"no-unamed-scenarios": "on",
"no-dupe-scenario-names": "off",
"no-dupe-feature-names": "on",
"no-partially-commented-tag-lines": "on",
"indentation": ["on",{
"Feature": 0,
"Background": 2,
"Scenario": 0,
"Step": 4,
"given": 4,
"and": 4
}],
"no-trailing-spaces": "on",
"no-multiple-empty-lines": "on",
"no-empty-file": "on",
"no-scenario-outlines-without-examples": "on"
}
23 changes: 22 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ module.exports = function(grunt) {
return libs;
};


// Project configuration.
grunt.initConfig({
eslint: {
Expand Down Expand Up @@ -178,6 +177,11 @@ module.exports = function(grunt) {
paths: [cwd]
}
},
gherkinlint: {
options: {
files: ['**/tests/behat/*.feature'],
}
},
stylelint: {
less: {
options: {
Expand Down Expand Up @@ -318,6 +322,22 @@ module.exports = function(grunt) {
}, done);
};

tasks.gherkinlint = function() {
var done = this.async(),
options = grunt.config('gherkinlint.options');

var args = grunt.file.expand(options.files);
args.unshift(path.normalize(__dirname + '/node_modules/.bin/gherkin-lint'));
grunt.util.spawn({
cmd: 'node',
args: args,
opts: {stdio: 'inherit', env: process.env}
}, function(error, result, code) {
// Propagate the exit code.
done(code);
});
};

tasks.startup = function() {
// Are we in a YUI directory?
if (path.basename(path.resolve(cwd, '../../')) == 'yui') {
Expand Down Expand Up @@ -360,6 +380,7 @@ module.exports = function(grunt) {

// Register JS tasks.
grunt.registerTask('shifter', 'Run Shifter against the current directory', tasks.shifter);
grunt.registerTask('gherkinlint', 'Run gherkinlint against the current directory', tasks.gherkinlint);
grunt.registerTask('ignorefiles', 'Generate ignore files for linters', tasks.ignorefiles);
grunt.registerTask('yui', ['eslint:yui', 'shifter']);
grunt.registerTask('amd', ['eslint:amd', 'uglify']);
Expand Down
10 changes: 10 additions & 0 deletions npm-shrinkwrap.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"devDependencies": {
"async": "1.5.2",
"eslint": "3.7.1",
"gherkin-lint": "1.1.3",
"grunt": "1.0.1",
"grunt-contrib-less": "1.3.0",
"grunt-contrib-uglify": "1.0.1",
Expand Down

0 comments on commit 8b02e2d

Please sign in to comment.