Checks that all box:use imports have a trailing comma. This applies to
package or module imports between ( and ), and, optionally, function imports between
[ and ]. Take note that lintr::commas_linter() may come into play.
See the Explanation: Rhino style guide
to learn about the details.
Arguments
- check_functions
Boolean flag to include function imports between
[and]. Defaults to FALSE.
Examples
# will produce lints
lintr::lint(
text = "box::use(base, rlang)",
linters = box_trailing_commas_linter()
)
#> ::warning file=<text>,line=1,col=21::file=<text>,line=1,col=21,[box_trailing_commas_linter] Always have a trailing comma at the end of imports, before a `)`.
lintr::lint(
text = "box::use(
dplyr[select, mutate]
)",
linters = box_trailing_commas_linter()
)
#> ::warning file=<text>,line=3,col=3::file=<text>,line=3,col=3,[box_trailing_commas_linter] Always have a trailing comma at the end of imports, before a `)`.
# okay
lintr::lint(
text = "box::use(base, rlang, )",
linters = box_trailing_commas_linter()
)
lintr::lint(
text = "box::use(
dplyr[select, mutate],
)",
linters = box_trailing_commas_linter()
)