MDL-56519 behat: Lint gherkin files
authorDan Poltawski <dan@moodle.com>
Thu, 20 Oct 2016 09:53:05 +0000 (10:53 +0100)
committerRajesh Taneja <rajesh@moodle.com>
Tue, 3 Jan 2017 01:12:54 +0000 (09:12 +0800)
.gherkin-lintrc [new file with mode: 0644]
Gruntfile.js
npm-shrinkwrap.json
package.json

diff --git a/.gherkin-lintrc b/.gherkin-lintrc
new file mode 100644 (file)
index 0000000..04ef52b
--- /dev/null
@@ -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"
+}
index 5852cc4..eae1f66 100644 (file)
@@ -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']);
index affc9f5..1fd4648 100644 (file)
         }
       }
     },
+    "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",
index 01dc1dc..2a7d142 100644 (file)
@@ -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",