diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000000..30e619afd3 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,30 @@ +# TODO https://github.com/nf-core/tools/issues/3140 +# - id: lint-modules +# name: Lint nf-core modules +# # description: This hook trims trailing whitespace. +# entry: nf-core --hide-progress modules lint +# language: python +# types: [text] +# files: ^modules/[^/]+$ +# pass_filenames: true +# args: [] +# NOTE See https://github.com/nf-core/modules/pull/7084 for reasoning +- id: lint-subworkflows + name: Lint nf-core subworkflows + description: Runs linting on all the subworkflows + entry: nf-core --hide-progress subworkflows lint -a + language: python + types: [text] + files: ^subworkflows/[^/]+$ + alias: sw + pass_filenames: false + # args: [] +- id: lint-pipeline + name: Lint nf-core pipeline + description: Check pipeline code against nf-core guidelines. + entry: nf-core --hide-progress pipelines lint + language: python + types: [text] + pass_filenames: false + stages: [pre-push, manual] + # args: ["--fix"] diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a16435057..67af20ccec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -187,6 +187,7 @@ - Update pre-commit hook pre-commit/mirrors-mypy to v1.11.1 ([#3091](https://github.com/nf-core/tools/pull/3091)) - Update to pytest v8 and move it to dev dependencies ([#3058](https://github.com/nf-core/tools/pull/3058)) - Update minimal textual version and snapshots ([#2998](https://github.com/nf-core/tools/pull/2998)) +- Create pre-commit hooks ([#3141](https://github.com/nf-core/tools/pull/3141)) ## [v2.14.1 - Tantalum Toad - Patch](https://github.com/nf-core/tools/releases/tag/2.14.1) - [2024-05-09] diff --git a/nf_core/pipeline-template/.pre-commit-config.yaml b/nf_core/pipeline-template/.pre-commit-config.yaml index 9e9f0e1c4e..aeb7ab00a8 100644 --- a/nf_core/pipeline-template/.pre-commit-config.yaml +++ b/nf_core/pipeline-template/.pre-commit-config.yaml @@ -11,3 +11,7 @@ repos: hooks: - id: editorconfig-checker alias: ec + - repo: https://github.com/nf-core/tools + rev: "3.1.0" + hooks: + - id: lint-pipeline