tests/testthat/test-use_box_lintr.R

test_that("use_box_lintr works as expected", {
  tmp <- withr::local_tempdir()

  lintr_file <- use_box_lintr(path = tmp)
  expect_true(file.exists(lintr_file))

  expect_identical(
    normalizePath(lintr_file, winslash = "/"),
    file.path(normalizePath(tmp, winslash = "/"), ".lintr")
  )

  lints <- lintr::lint_dir(tmp)
  expect_length(lints, 0L)
})

test_that("use_box_lintr with type = rhino also works", {
  tmp <- withr::local_tempdir()

  lintr_file <- use_box_lintr(path = tmp, type = "rhino")
  expect_true(file.exists(lintr_file))

  expect_identical(
    normalizePath(lintr_file, winslash = "/"),
    file.path(normalizePath(tmp, winslash = "/"), ".lintr")
  )

  lints <- lintr::lint_dir(tmp)
  expect_length(lints, 0L)
})

Try the box.linters package in your browser

Any scripts or data that you put into this service are public.

box.linters documentation built on June 26, 2025, 5:07 p.m.