3

I'm trying to customize the linter settings in VSCode for R but I'm a little confused.

I've checked just about every source available, from SO questions to the lintr package vingette, but I'm stumbling on an issue. It could be that since I'm not a programmer I'm just not understanding something basic but essential.

A question about line length linter 80 characters

Disable R-linting in VScode

How to change the line length preference for warnings in Diagnostics? #3

Specify linters in lintr::lint

lintr github page

Lint R code in Visual Studio

lintr v2.0.0

Using lintr

It seems like I need to create a .lintr file in the folder that my script is in. Or possibly make changes in the .lintr file in the lintr package ~lintr/R/ folder?

I guess I'm just confused on the .lintr file. I tried creating files called "lintr", ".lintr" and "ScriptName.lintr", then added the following line to it, as described in the above sources:

linters: with_defaults(line_length_linter=line_length_linter(120L))

Then I reopened the script but whatever I do, lintr continues to default to 80 spaces. I think I'm doing something wrong with the .lintr file but I'm not sure what. I also tried changing file called "lintr" in the lintr package directory, but I can't save the file because it has no extension type (though it appears to be in the Debian Control Field Format, whatever that is). Windows keeps giving me a prompt to save as "txt".

I'd appreciate any step-by-step instructions to get past this issue.

hmhensen
  • 2,974
  • 3
  • 22
  • 43
  • are you able to install the development version of lintr? We've just added `lintr::use_lintr()` which is intended to simplify the setup process. see also https://github.com/r-lib/lintr/issues/902 – MichaelChirico May 11 '22 at 06:58
  • @MichaelChirico Unfortunately, my organization won't allow me to install the development version. – hmhensen May 11 '22 at 17:04
  • I see... you might try copy-pasting the function source then. you only need to run the function once or a few times I reckon – MichaelChirico May 11 '22 at 19:20
  • @MichaelChirico Where is the source? I'm not seeing the function in the github (https://github.com/r-lib/lintr) code. Thanks for your help! – hmhensen May 11 '22 at 20:51
  • sorry I spoke too soon! thought that PR was merged already. it's merged now – MichaelChirico May 16 '22 at 05:08
  • Using a .lintr file in the workspace directory with the line `linters: with_defaults(line_length_linter=line_length_linter(120L))` works for me once I restart VSCode. – fry May 09 '23 at 12:19

0 Answers0