https://github.com/appsilon/box.linters
lintr-compatible linters for box modules in R
https://github.com/appsilon/box.linters
box linter r rhinoverse shiny
Last synced: 6 months ago
JSON representation
lintr-compatible linters for box modules in R
- Host: GitHub
- URL: https://github.com/appsilon/box.linters
- Owner: Appsilon
- Created: 2024-04-24T05:39:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-15T07:19:07.000Z (6 months ago)
- Last Synced: 2025-07-15T16:50:07.612Z (6 months ago)
- Topics: box, linter, r, rhinoverse, shiny
- Language: R
- Homepage: https://appsilon.github.io/box.linters/
- Size: 2.36 MB
- Stars: 10
- Watchers: 9
- Forks: 2
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
Awesome Lists containing this project
README
> _lintr-compatible linters for box modules in R_
[](https://cran.r-project.org/package=box.linters)
[](https://github.com/Appsilon/box.linters/actions/workflows/ci.yml)
[](https://app.codecov.io/gh/Appsilon/box.linters)
`box.linters` is an R package that provides the [`{lintr}` package](https://github.com/r-lib/lintr/) compatibility with [`{box}` package](https://github.com/klmr/box) modules. In addition to providing code-styling checks for `box::use()` function calls, `box.linters` includes a collection of linter functions to replace [`lintr::object_usage_linter()`](https://lintr.r-lib.org/reference/object_usage_linter.html).
While the primary purpose of `{box.linters}` is for use with the [`{rhino}`](https://appsilon.github.io/rhino/) package, its functions and features are available for use with any R code or project that uses the `{box}` package for modular R code.
## Motivation
`lintr::object_usage_linter` is not compatible with `{box}` modules.
```r
# use of box modules
box::use(
stringr[...]
)
some_function <- function() {
str_trim(" String with trailing and leading white space\t")
}
```
```
> lintr::lint(box-module.R)
:6:3: warning: [object_usage_linter] no visible global function definition for 'str_trim'
str_trim(" String with trailing and leading white space ")
^~~~~~~~
```
In order to use `lintr` and `box` together, it was necessary to disable `lintr::object_usage_linter()`:
```r
lintr::lint(box-module.R,
linters = lintr::linters_with_defaults(object_usage_linter = NULL))
```
However, this meant we lose the functionality provided by `lintr::object_usage_linter()`.
## Installation
Stable version:
```r
install.packages("box.linters")
```
Development version:
```r
# install.packages("remotes")
remotes::install_github("Appsilon/box.linters")
```
## Usage
Create a configuration file and run selected linters:
### .lintr setup
```r
# create a .lintr file
box.linters::use_box_lintr()
# a file:
lintr::lint(filename.R)
# in a project:
lintr::lint_dir()
```
### Manually
Or, use `box.linters` manually with `lintr`:
```r
# a file:
lintr::lint(filename.R, linters = box.linters::box_default_linters)
# in a project:
lintr::lint_dir(linters = box.linters::box_default_linters)
```
### Rhino
Or, use `box.linters` from within a `{rhino}` project:
```r
# a .lintr file should already exist when a rhino project is created
# box.linters::use_box_lintr(type = "rhino")
# in a rhino project:
rhino::lint_r()
```
## {glue} String Interpolation
`{box.linters}` also looks inside `{glue}` strings. The default opening and closing delimiters are "`{`" and "`}`". `{glue}` provides a way to [customize delimiters](https://glue.tidyverse.org/reference/glue.html). Support for custom `{glue}` delimiters are provided *project-wide* by setting `glue.open` and `glue.close` options in the following manner:
```r
options(
list(
glue.open = "<<",
glue.close = ">>"
)
)
```
This is consistent with [`glue::glue()`](https://glue.tidyverse.org/reference/glue.html), doubling the full delimiter escapes it.
Because setting `glue.open` and `glue.close` will be *global* or *project-wide*, it is advised to invoke `glue` in the following manner to avoid confusion:
```r
glue::glue(..., .open = getOption("glue.open"), .close = getOption("glue.close"))
```
## Contribute
If you want to contribute to this project, please submit a regular PR, once you're done with the new feature or bug fix.
Reporting a bug is also helpful - please use [Github issues](https://github.com/Appsilon/box.linters/issues) and describe your problem as detailed as possible.
## Appsilon

Appsilon is a **Posit (formerly RStudio) Full Service Certified Partner**.
Learn more at [appsilon.com](https://appsilon.com).
Get in touch [opensource@appsilon.com](mailto:opensource@appsilon.com)
Explore the [Rhinoverse](https://rhinoverse.dev) - a family of R packages built around [Rhino](https://appsilon.github.io/rhino/)!
