1

I cannot figure out how to turn off specific linters using lintr. The documentation offers an example (for vim/syntastic, which is what I'm using), which is not very clear:

let g:syntastic_r_lintr_linters = "with_defaults(line_length_linter(120))"

Apparently all this does is change a default. Do I need to list all the linters I want to use here? Is there a way to exclude just a couple?

I assume there's something like

let g:syntastic_r_lintr_linters_nonportable_path_linter = 0

but I can't find the right syntax.

Apparently g:syntastic_r_lintr_linters is supposed to be a list of linters. But it's not clear what syntax is supposed to work.

If we forget about the vim syntax and head right to the R package lintr (which vim/syntastic calls) and the linters argument of lint then this works:

lint(file.R, linters=assignment_linter)

This doesn't (no error, but doesn't catch mistakes in code):

lint(file.R, linters=list(assignment_linter, single_quotes_linter))

Nor does this (errors out):

lint(file.R, linters=list('assignment_linter', 'single_quotes_linter'))

But this does:

lint('file.R',linters=list('assignment_linter'=assignment_linter,'single_quotes_linter'=single_quotes_linter))

So maybe it's supposed to be a named list?

Jesse Anderson
  • 4,507
  • 26
  • 36
  • `g:syntastic_r_lintr_linters` is supposed to be an R list of linters, `with_defaults()` is just a convenient way to build this list. This is more or less [documented](https://github.com/jimhester/lintr/tree/master/man). – lcd047 Mar 20 '17 at 22:10
  • Yeah I've read that, but a list of linters doesn't work. See edits above – Jesse Anderson Mar 21 '17 at 01:51

1 Answers1

2

The correct syntax to turn off specific linters is to add this (for example) to vimrc:

let g:syntastic_r_lintr_linters = "with_defaults(single_quotes_linter=NULL)"

This is not in the documentation. I had to dig through some old (closed) issues on github to find this.

Furthermore, lintr::lint does indeed expect a named list for the linters argument, but will now accept an unnamed list (see https://github.com/jimhester/lintr/issues/224). So this should work to make a list from scratch:

let g:syntastic_r_lintr_linters = "list(assignment_linter, single_quotes_linter")
Jesse Anderson
  • 4,507
  • 26
  • 36
  • 1
    alternatively, you can take a named subset of the default linter list as follows: `let g:syntastic_r_lintr_linters = "default_linters[c('assignment_linter', 'single_quotes_linter')]"` – Russ Hyde Jan 13 '20 at 10:24