Skip to contents

Check that the desired quote delimiter is used for string constants.

Usage

quotes_linter(delimiter = c("\"", "'"))

Arguments

delimiter

Which quote delimiter to accept. Defaults to the tidyverse default of " (double-quoted strings).

See also

Examples

# will produce lints
lint(
  text = "c('a', 'b')",
  linters = quotes_linter()
)
#> <text>:1:3: style: [quotes_linter] Only use double-quotes.
#> c('a', 'b')
#>   ^~~
#> <text>:1:8: style: [quotes_linter] Only use double-quotes.
#> c('a', 'b')
#>        ^~~

# okay
lint(
  text = 'c("a", "b")',
  linters = quotes_linter()
)
#>  No lints found.

code_lines <- "paste0(x, '\"this is fine\"')"
writeLines(code_lines)
#> paste0(x, '"this is fine"')
lint(
  text = code_lines,
  linters = quotes_linter()
)
#>  No lints found.

# okay
lint(
  text = "c('a', 'b')",
  linters = quotes_linter(delimiter = "'")
)
#>  No lints found.