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

Add --root argument to lintr hook #600

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion inst/hooks/exported/lintr.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@

"Run lintr on R files during a precommit.
Usage:
lintr [--warn_only] <files>...
lintr [--warn_only] [--root=<root_>] <files>...
Options:
--warn_only Print lint warnings instead of blocking the commit. Should be
used with `verbose: True` in `.pre-commit-config.yaml`.
Otherwise, lints will never be shown to the user.
--root=<root_> Path relative to the git root that contains the R package root [default: .].
" -> doc

arguments <- precommit::precommit_docopt(doc)
arguments$files <- normalizePath(arguments$files) # because working directory changes to root
setwd(normalizePath(arguments$root))

lintr_staged <- grepl(
"modified:.*\\.lintr", system2("git", "status", stdout = TRUE)
Expand Down
Loading