From 8b02e2d98c6355fea0f0c000e28ee6ec49b8d8c5 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Thu, 20 Oct 2016 10:53:05 +0100 Subject: [PATCH] MDL-56519 behat: Lint gherkin files --- .gherkin-lintrc | 20 ++++++++++++++++++++ Gruntfile.js | 23 ++++++++++++++++++++++- npm-shrinkwrap.json | 10 ++++++++++ package.json | 1 + 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .gherkin-lintrc diff --git a/.gherkin-lintrc b/.gherkin-lintrc new file mode 100644 index 00000000000..04ef52ba3e1 --- /dev/null +++ b/.gherkin-lintrc @@ -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" +} diff --git a/Gruntfile.js b/Gruntfile.js index 5852cc46b74..eae1f66b77c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -106,7 +106,6 @@ module.exports = function(grunt) { return libs; }; - // Project configuration. grunt.initConfig({ eslint: { @@ -178,6 +177,11 @@ module.exports = function(grunt) { paths: [cwd] } }, + gherkinlint: { + options: { + files: ['**/tests/behat/*.feature'], + } + }, stylelint: { less: { options: { @@ -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') { @@ -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']); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index affc9f5c5ae..1fd46483b19 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -915,6 +915,16 @@ } } }, + "gherkin": { + "version": "4.0.0", + "from": "gherkin@4.0.0", + "resolved": "https://registry.npmjs.org/gherkin/-/gherkin-4.0.0.tgz" + }, + "gherkin-lint": { + "version": "1.1.3", + "from": "gherkin-lint@>=1.1.3 <2.0.0", + "resolved": "https://registry.npmjs.org/gherkin-lint/-/gherkin-lint-1.1.3.tgz" + }, "glob": { "version": "7.0.5", "from": "https://registry.npmjs.org/glob/-/glob-7.0.5.tgz", diff --git a/package.json b/package.json index 01dc1dcba4f..2a7d142ca14 100644 --- a/package.json +++ b/package.json @@ -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", -- 2.43.0