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?

4

1 回答 1

2

关闭特定 linter 的正确语法是将其(例如)添加到 vimrc:

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

这不在文档中。我不得不在 github 上挖掘一些旧的(已关闭的)问题才能找到它。

此外,lintr::lint确实希望linters参数有一个命名列表,但现在将接受一个未命名列表(参见https://github.com/jimhester/lintr/issues/224)。所以这应该可以从头开始制作一个列表:

let g:syntastic_r_lintr_linters = "list(assignment_linter, single_quotes_linter")
于 2017-03-20T21:29:12.067 回答