Skip to contents

This is a convenience wrapper around lintr::lint_dir() which is tailored to a typical R Markdown package. To use this function, the lintr package is required.

Usage

lint_rmd(
  path = ".",
  linters = default_linters,
  cache = FALSE,
  relative_path = TRUE,
  exclusions = default_exclusions(excl_vignettes = TRUE),
  pattern = "\\.[Rr]([Mm][Dd])?$",
  parse_settings = TRUE,
  show_progress = NULL
)

Arguments

path

Path to the root of the package directory.

linters

A named list of linter functions to apply. See linters for a full list of default and available linters.

cache

When logical, toggle caching of lint results. If passed a character string, store the cache in this directory.

relative_path

if TRUE, file paths are printed using their path relative to the base directory. If FALSE, use the full absolute path.

exclusions

exclusions for exclude(), relative to the package path.

pattern

pattern for files, by default it will take files with any of the extensions .R, .Rmd, .qmd, .Rnw, .Rhtml, .Rrst, .Rtex, .Rtxt allowing for lowercase r (.r, ...).

parse_settings

Logical, default TRUE. Whether to try and parse the settings. Otherwise, the default_settings() are used.

show_progress

Logical controlling whether to show linting progress with a simple text progress bar via utils::txtProgressBar(). The default behavior is to show progress in interactive() sessions not running a testthat suite.

Value

An object of class c("lints", "list"), each element of which is a "list" object.

Details

To avoid unnecessary noise, all the the generated R/*.gen.R files as well as R Markdown vignettes under vignettes/*.Rmd are excluded from linting.

This function is registered as an RStudio add-in, allowing RStudio users to assign a custom shortcut to it and to invoke it from the command palette.

See also