rvisual-studio-code

How to control the behaviour of lintr in Visual Studio Code?


Switching from Rstudio to VS Code. Biggest problem right now: the linters are constantly bothering me! Take the snippet as an example:

enter image description here

object_name_linter is trying to make me name my variable as group_markers instead of group.markers. However, in the R community, it's rather common to see . within variable names. I couldn't figure out a good way to turn off this linter.


Solution

  • To turn off this specific linter globally, create a config file ~/.lintr

    linters: with_defaults(
        object_name_linter = NULL
      )
    

    A list of linters: https://lintr.r-lib.org/reference/linters.html

    For example, to also disable the linter for maximum line length = 80, the config file ~/.lintr should be:

    linters: with_defaults(
        object_name_linter = NULL,
        line_length_linter = NULL
      )