Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make accessible as pre-commit hook #287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

raspe88
Copy link

@raspe88 raspe88 commented Jun 9, 2023

To ease the automated local usage and the usage within CI-pipelines using pre-commit (https://pre-commit.com/), a .pre-commit-hooks.yaml has been added, providing a basic configuration that should be usable for a wide range of projects.

To ease the automated local usage and the usage within CI-pipelines using pre-commit (https://pre-commit.com/), a .pre-commit-hooks.yaml has been added, providing a basic configuration that should be usable for a wide range of projects.
@andrewnicols
Copy link
Member

I may be mis-understanding the purpose of this, but doens't this need to go on your project?

Won't the pre-commit hook in this PR only apply to pushes to this repository (gherkin-lint/gherkin-lint)?

@puddlewitt
Copy link

This would be great to have, assuming it works.

@andrewnicols This is so that consumers can create an entry in their .pre-commit-config.yaml files...

  - repo: https://github.com/gherkin-lint/gherkin-lint
    rev: v4.2.4
    hooks:
      - id: gherkin-lint
        files: 'blah/.*(\.feature)$'

see https://pre-commit.com/index.html#new-hooks

@puddlewitt
Copy link

puddlewitt commented Dec 21, 2023

my .pre-commit-config.yaml

  - repo: https://github.com/gherkin-lint/gherkin-lint
    rev: d6f0b264842d20d147c17b9fa58e86338b66ca4b
    hooks:
      - id: gherkin-lint
        files: 'blah/.*(\.feature)$'
        args: [-cblah/.gherkin-lintrc]

my .gherkin-lintrc

{
  "indentation": "on"
}
pre-commit run gherkin-lint --all-files
gherkin-lint.............................................................Failed
- hook id: gherkin-lint
- exit code: 1

/blah/a-test.feature
  6    Wrong indentation for "Scenario", expected indentation level of 0, but got 2    indentation

Fixed the issues and ran pre-commit run gherkin-lint --all-files
image


Seems to work.

@jongracecox
Copy link

For those still looking for this feature, you can create a local config (not my preferred approach):

- repo: local
  hooks:
    - id: gherkin-lint
      name: Gherkin Lint
      description: Check whether your feature-files are consistingly following a given set of rules.
      entry: gherkin-lint
      additional_dependencies:
        - gherkin-lint
      language: node
      files: \.feature$

This uses the additional_dependencies and language to tell pre-commit to install gherkin-lint. You can add additional command line args using the args option.

I prefer to use published pre-commit hooks, so hoping this PR can be merged, but in the mean time I'll be doing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants