Skip to content

← All questions

Linting only the staged feature files in a pre-commit hook — is --json stable enough?

Asked 96 views0 answers

Trying to keep the hook under a second on a repo with about four hundred feature files, so linting the whole project every commit is out. This is what I have:

bash
sdods lint -p shop --json --file projects/shop/features/cart/cart.feature
json
{
  "ok": false,
  "errors": [
    {
      "severity": "error",
      "rule": "tags/suite",
      "message": "Scenario must carry exactly one suite tag (@smoke, @regression, @sanity); found none.",
      "file": "features/cart/cart.feature",
      "line": 12,
      "project": "shop"
    }
  ],
  "warnings": [],
  "filesChecked": 1
}

Two things I cannot find an answer to. Is rule a stable identifier I can filter on — we want to allow outline/title-format through in the hook and block everything else — or is it an implementation detail that might get renamed? And is file always relative to the project root even though I passed an absolute path, because that is what it looks like here and my hook has to map it back to the repo path to annotate the diff.

Happy to be told the hook is the wrong shape and I should just run the whole project.

asked by Ingrid Solberg241 ·

No answers yet

Nobody has answered this one. If you have hit the same thing and worked it out, that is worth writing down.

Ask a related question

Have the same question?

Ask it with the command you ran and the output you got, and it will be answered here.

Ask a question

Related