Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docs about how to list and use all linters #1576

Merged
merged 6 commits into from
Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
* `object_usage_linter()` gains `skip_with` argument to skip code in `with()` expressions.
To be consistent with `R CMD check`, it defaults to `TRUE` (#941, #1458, @IndrajeetPatil).

* `unused_import_linter()` can detect datasets from imported packages and no longer
warns when a package is imported only for its datasets (#1545, @IndrajeetPatil).

## New and improved features

* New `get_r_string()` helper to get the R-equivalent value of a string, especially useful for R-4-style raw strings.
Previously an internal `lintr` helper, now exported to facilitate writing custom linters (#1493, @MichaelChirico).

* `object_usage_linter()` improves lint metadata when detecting undefined infix operators, e.g. `%>%` or `:=` (#1497, @MichaelChirico)

* `unused_import_linter()` can detect datasets from imported packages and no longer
warns when a package is imported only for its datasets (#1545, @IndrajeetPatil).
IndrajeetPatil marked this conversation as resolved.
Show resolved Hide resolved

### New linters

* `unnecessary_lambda_linter()`: detect unnecessary lambdas (anonymous functions), e.g.
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# lintr
[![R build status](https://github.com/r-lib/lintr/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/lintr/actions)
[![codecov.io](https://codecov.io/github/r-lib/lintr/coverage.svg?branch=master)](https://codecov.io/github/r-lib/lintr?branch=master)
[![codecov.io](https://codecov.io/github/r-lib/lintr/coverage.svg?branch=main)](https://codecov.io/github/r-lib/lintr?branch=main)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/lintr)](https://cran.r-project.org/package=lintr)
[![Join the chat at https://gitter.im/jimhester-lintr/Lobby](https://badges.gitter.im/jimhester-lintr/Lobby.svg)](https://gitter.im/jimhester-lintr/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand Down Expand Up @@ -38,6 +38,16 @@ usethis::use_github_action("lint")
lintr::lint_package()
IndrajeetPatil marked this conversation as resolved.
Show resolved Hide resolved
```

To see a list of linters included for each configuration:

```R
# tidyverse (default)
names(lintr::linters_with_defaults())

# full
names(lintr::linters_with_tags(tags = NULL))
```

You can also run lintr during continuous integration or within your IDE or text editor. See `vignette("continuous-integration")` and `vignette("editors")` for more details.

Without further configuration, this will run the [default linters](https://lintr.r-lib.org/reference/default_linters.html). See `vignette("lintr")` to learn how to modify these defaults.
2 changes: 1 addition & 1 deletion vignettes/creating_linters.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ testing. You can run all of the currently available tests using
`filter` argument to `devtools::test()`.

Linter tests should be put in the
[tests/testthat/](https://github.com/r-lib/lintr/tree/master/tests/testthat)
[tests/testthat/](https://github.com/r-lib/lintr/tree/main/tests/testthat)
folder. The test filename should be the linter name prefixed by `test-`, e.g.
`test-pipe_continuation_linter.R`.

Expand Down
26 changes: 26 additions & 0 deletions vignettes/lintr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,32 @@ defaults_table <- data.frame(
knitr::kable(defaults_table)
```

#### Using all available linters

The default lintr configuration includes only linters relevant to the tidyverse style guide, but there are many other linters available in `{lintr}`. You can see a list of all available linters using-
IndrajeetPatil marked this conversation as resolved.
Show resolved Hide resolved

```{r}
names(lintr::linters_with_tags(tags = NULL))
```

If you want to use all available linters, you can include this in your `.lintr` file:

```r
linters: linters_with_defaults(
defaults = linters_with_tags(tags = NULL)
)
```

If you want to use all available linters *except* a few, you can exclude them using `NULL`:

```r
linters: linters_with_defaults(
commented_code_linter = NULL,
implicit_integer_linter = NULL,
defaults = linters_with_tags(tags = NULL)
)
```

#### Advanced: programmatic retrieval of linters

For some use cases, it may be useful to specify linters by string instead of by name, i.e. `"assignment_linter"` instead of writing out `assignment_linter()`.
Expand Down