lintr icon indicating copy to clipboard operation
lintr copied to clipboard

allow_avoidable_escapes (?) in single_quotes_linter()

Open MichaelChirico opened this issue 2 years ago • 2 comments

A handy parameter for single_quotes_linter() would throw a lint on literals that use " but have escaped " that could be avoided by using ' instead:

"a string" # fine
'another' # lint, uses '
"a third \"string\" that escapes double-quotes" # lint: " is avoidable by using '
"a fourth \"string\" that 'escapes' both quotes" # fine -- both quote characters are used; let the user choose which quote to use

open to names on the parameter

MichaelChirico avatar Oct 17 '22 22:10 MichaelChirico

Further down, it could suggest raw strings in case there are many chars to escape. Maybe the feature could be called use_smart_escaping = TRUE?

AshesITR avatar Oct 18 '22 05:10 AshesITR

I do like the idea but worry about suggesting an R 4 dependency, maybe off by default until 4.x.y is released? or even 5.0.0?

MichaelChirico avatar Oct 18 '22 05:10 MichaelChirico