wp-cli-tests icon indicating copy to clipboard operation
wp-cli-tests copied to clipboard

Add linting for Behat feature files

Open danielbachhuber opened this issue 1 year ago • 3 comments

To ensure consistent formatting of the feature files, it would be nice to add a linter.

https://github.com/j13k/yaml-lint looks like a good candidate.

Related https://github.com/j13k/yaml-lint/issues/81

Done is:

  • Behat feature file linting is applied across all repositories.

danielbachhuber avatar Aug 24 '23 14:08 danielbachhuber

It seems we have already implemented Gherkin Linter in scaffold package command https://github.com/wp-cli/scaffold-package-command/blob/main/package.json#L8

ernilambar avatar Aug 09 '24 11:08 ernilambar

I was testing the linter. Here is one example.

name: Gherkin Linting

on:
  pull_request:
    branches:
      - main
      - master
  workflow_dispatch:
  workflow_call:

jobs:

  gherkin-lint:
    name: Lint Gherkin Feature files
    runs-on: ubuntu-latest
    steps:
      - name: Check out source code
        uses: actions/checkout@v4

      - name: Setup node
        uses: actions/setup-node@v4

      - name: Download lint rules
        run: curl https://gist.githubusercontent.com/ernilambar/a7a30af6f6f6bd5be238d5499993233a/raw/3b8f54e2d36be33706947ce6ce44c5a888cee464/gherkin-lintrc.json -o .gherkin-lintrc

      - name: Run lint
        run: npx --yes gherkin-lint

We could keep Gherkin lint rule file in our central repo. Currently I have pulled from my Gist.

ernilambar avatar Aug 13 '24 12:08 ernilambar

I have drafted a PR here - https://github.com/wp-cli/core-command/pull/268

ernilambar avatar Aug 14 '24 11:08 ernilambar