From f09ec4647715b2ff97d4870338c116e9897f2aca Mon Sep 17 00:00:00 2001 From: gnoblet Date: Wed, 2 Jul 2025 09:53:53 +0200 Subject: [PATCH] Add pre-commit configuration and ignore its config file --- .Rbuildignore | 29 +++++++++------- .pre-commit-config.yaml | 76 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.Rbuildignore b/.Rbuildignore index 6615a54..bc72ae3 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,13 +1,16 @@ -^renv$ -^renv\.lock$ -^.*\.Rproj$ -^\.Rproj\.user$ -^LICENSE\.md$ -^README\.Rmd -^pkgdown\.css -^docs -^_pkgdown\.yml$ -^docs$ -^pkgdown$ -^data-raw$ -^test-example.R +^.*\.Rproj$ +^LICENSE\.md$ +^README\.Rmd +^\.Rproj\.user$ +^\.pre-commit-config\.yaml$ +^_pkgdown\.yml$ +^data-raw$ +^docs +^docs$ +^pkgdown$ +^pkgdown\.css +^renv$ +^renv$ +^renv\.lock$ +^renv\.lock$ +^test-example.R diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..96ae29e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,76 @@ +# All available hooks: https://pre-commit.com/hooks.html +# R specific hooks: https://github.com/lorenzwalthert/precommit +repos: +- repo: https://github.com/lorenzwalthert/precommit + rev: v0.4.3.9012 + hooks: + - id: style-files + args: [--style_pkg=styler, --style_fun=tidyverse_style] + - id: roxygenize + # codemeta must be above use-tidy-description when both are used + # - id: codemeta-description-updated + - id: use-tidy-description + - id: spell-check + exclude: > + (?x)^( + .*\.[rR]| + .*\.feather| + .*\.jpeg| + .*\.pdf| + .*\.png| + .*\.py| + .*\.RData| + .*\.rds| + .*\.Rds| + .*\.Rproj| + .*\.sh| + (.*/|)\.gitignore| + (.*/|)\.gitlab-ci\.yml| + (.*/|)\.lintr| + (.*/|)\.pre-commit-.*| + (.*/|)\.Rbuildignore| + (.*/|)\.Renviron| + (.*/|)\.Rprofile| + (.*/|)\.travis\.yml| + (.*/|)appveyor\.yml| + (.*/|)NAMESPACE| + (.*/|)renv/settings\.dcf| + (.*/|)renv\.lock| + (.*/|)WORDLIST| + \.github/workflows/.*| + data/.*| + )$ + - id: lintr + - id: readme-rmd-rendered + - id: parsable-R + - id: no-browser-statement + - id: no-print-statement + - id: no-debug-statement + - id: deps-in-desc + - id: pkgdown +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + args: ['--maxkb=200'] + - id: file-contents-sorter + files: '^\.Rbuildignore$' + - id: end-of-file-fixer + exclude: '\.Rd' +- repo: https://github.com/pre-commit-ci/pre-commit-ci-config + rev: v1.6.1 + hooks: + # Only required when https://pre-commit.ci is used for config validation + - id: check-pre-commit-ci-config +- repo: local + hooks: + - id: forbid-to-commit + name: Don't commit common R artifacts + entry: Cannot commit .Rhistory, .RData, .Rds or .rds. + language: fail + files: '\.(Rhistory|RData|Rds|rds)$' + # `exclude: ` to allow committing specific files + +ci: + autoupdate_schedule: monthly + skip: [pkgdown]