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
linters for a complete list of linters available in lintr.
Examples
# will produce lints
lint(
text = "c('a', 'b')",
linters = quotes_linter()
)
#> ::warning file=<text>,line=1,col=3::file=<text>,line=1,col=3,[quotes_linter] Only use double-quotes.
#> ::warning file=<text>,line=1,col=8::file=<text>,line=1,col=8,[quotes_linter] Only use double-quotes.
# okay
lint(
text = 'c("a", "b")',
linters = quotes_linter()
)
code_lines <- "paste0(x, '\"this is fine\"')"
writeLines(code_lines)
#> paste0(x, '"this is fine"')
lint(
text = code_lines,
linters = quotes_linter()
)
# okay
lint(
text = "c('a', 'b')",
linters = quotes_linter(delimiter = "'")
)