Skip to content

Commit

Permalink
chore: Update NEWS and add links to the styel guide in the documentat…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
jakubnowicki committed Feb 21, 2024
1 parent d9fb633 commit 3a30d82
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* `box_universal_import_linter` checks if all imports are explicit.
* `box_trailing_commas_linter` checks if statements include trailing commas.
* `box_func_import_count_linter` checks if the number of function imports does not exceed the limit.
* `box_separate_calls_linter` checks if packages and modules are imported in separate statements.
2. Major refactor of `rhino::app()`:
* The `request` parameter is now correctly forwarded to the UI function
when using a `legacy_entrypoint` ([#395](https://github.com/Appsilon/rhino/issues/395)).
Expand Down
16 changes: 16 additions & 0 deletions R/box_linters.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# nolint start: line_length_linter
#' `box` library function import count linter
#'
#' Checks that function imports do not exceed the defined `max`.
#' See the [Explanation: Rhino style guide](https://appsilon.github.io/rhino/articles/explanation/rhino-style-guide.html)
#' to learn about the details.
#'
#' @param max Maximum function imports allowed between `[` and `]`. Defaults to 8.
#'
Expand Down Expand Up @@ -30,6 +33,7 @@
#' )
#'
#' @export
# nolint end
box_func_import_count_linter <- function(max = 8L) {
xpath <- glue::glue("//SYMBOL_PACKAGE[
(text() = 'box' and
Expand Down Expand Up @@ -67,9 +71,12 @@ box_func_import_count_linter <- function(max = 8L) {
})
}

# nolint start: line_length_linter
#' `box` library separate packages and module imports linter
#'
#' Checks that packages and modules are imported in separate `box::use()` statements.
#' See the [Explanation: Rhino style guide](https://appsilon.github.io/rhino/articles/explanation/rhino-style-guide.html)
#' to learn about the details.
#'
#' @return A custom linter function for use with `r-lib/lintr`
#'
Expand All @@ -93,6 +100,7 @@ box_func_import_count_linter <- function(max = 8L) {
#' )
#'
#' @export
# nolint end
box_separate_calls_linter <- function() {
xpath <- "
//SYMBOL_PACKAGE[(text() = 'box' and following-sibling::SYMBOL_FUNCTION_CALL[text() = 'use'])]
Expand Down Expand Up @@ -127,11 +135,14 @@ box_separate_calls_linter <- function() {
})
}

# nolint start: line_length_linter
#' `box` library trailing commas linter
#'
#' 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](https://appsilon.github.io/rhino/articles/explanation/rhino-style-guide.html)
#' to learn about the details.
#'
#' @param check_functions Boolean flag to include function imports between `[` and `]`.
#' Defaults to FALSE.
Expand Down Expand Up @@ -166,6 +177,7 @@ box_separate_calls_linter <- function() {
#' )
#'
#' @export
# nolint end
box_trailing_commas_linter <- function(check_functions = FALSE) {
base_xpath <- "//SYMBOL_PACKAGE[
(
Expand Down Expand Up @@ -230,9 +242,12 @@ box_trailing_commas_linter <- function(check_functions = FALSE) {
})
}

# nolint start: line_length_linter
#' `box` library universal import linter
#'
#' Checks that all function imports are explicit. `package[...]` is not used.
#' See the [Explanation: Rhino style guide](https://appsilon.github.io/rhino/articles/explanation/rhino-style-guide.html)
#' to learn about the details.
#'
#' @return A custom linter function for use with `r-lib/lintr`
#'
Expand Down Expand Up @@ -260,6 +275,7 @@ box_trailing_commas_linter <- function(check_functions = FALSE) {
#' )
#'
#' @export
# nolint end
box_universal_import_linter <- function() {
lint_message <- "Explicitly declare imports rather than universally import with `...`."

Expand Down
2 changes: 2 additions & 0 deletions man/box_func_import_count_linter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/box_separate_calls_linter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/box_trailing_commas_linter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/box_universal_import_linter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3a30d82

Please sign in to comment.