From df6dd95cbb23d4cc16ecbb7f07332bd3467d370f Mon Sep 17 00:00:00 2001 From: Jack Kennedy Date: Tue, 21 May 2024 10:59:09 +0100 Subject: [PATCH 1/6] feat: lint .qmd docs --- .pre-commit-hooks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 30f0085cb..fb5d37061 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -110,7 +110,7 @@ description: check if a `.R` file is lint free (using {lintr}) entry: Rscript inst/hooks/exported/lintr.R language: r - files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' + files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw\.[qQ]md)$' exclude: 'renv/activate\.R' minimum_pre_commit_version: "2.13.0" - id: pkgdown From e52f86a9cbada912700308abcfc0f08202f6f4bf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 10:02:14 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- inst/pre-commit-hooks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/pre-commit-hooks.yaml b/inst/pre-commit-hooks.yaml index 30f0085cb..fb5d37061 100644 --- a/inst/pre-commit-hooks.yaml +++ b/inst/pre-commit-hooks.yaml @@ -110,7 +110,7 @@ description: check if a `.R` file is lint free (using {lintr}) entry: Rscript inst/hooks/exported/lintr.R language: r - files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' + files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw\.[qQ]md)$' exclude: 'renv/activate\.R' minimum_pre_commit_version: "2.13.0" - id: pkgdown From be1e81e4f5d31ca510563873175c4f233cc80642 Mon Sep 17 00:00:00 2001 From: Jack Kennedy <57638616+jcken95@users.noreply.github.com> Date: Tue, 21 May 2024 16:37:16 +0100 Subject: [PATCH 3/6] fix: typo in files regex Co-authored-by: Lorenz Walthert <10477073+lorenzwalthert@users.noreply.github.com> --- .pre-commit-hooks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index fb5d37061..ddbe9a1a7 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -110,7 +110,7 @@ description: check if a `.R` file is lint free (using {lintr}) entry: Rscript inst/hooks/exported/lintr.R language: r - files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw\.[qQ]md)$' + files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw|\.[qQ]md)$' exclude: 'renv/activate\.R' minimum_pre_commit_version: "2.13.0" - id: pkgdown From e1e9c3e3f8322c66508c653cd414658e6717e6f9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 15:38:03 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- inst/pre-commit-hooks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/pre-commit-hooks.yaml b/inst/pre-commit-hooks.yaml index fb5d37061..ddbe9a1a7 100644 --- a/inst/pre-commit-hooks.yaml +++ b/inst/pre-commit-hooks.yaml @@ -110,7 +110,7 @@ description: check if a `.R` file is lint free (using {lintr}) entry: Rscript inst/hooks/exported/lintr.R language: r - files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw\.[qQ]md)$' + files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw|\.[qQ]md)$' exclude: 'renv/activate\.R' minimum_pre_commit_version: "2.13.0" - id: pkgdown From c35a0c8f67b3ed65030e5c1c04dc8bc6c2ab580b Mon Sep 17 00:00:00 2001 From: Jack Kennedy Date: Wed, 22 May 2024 07:47:19 +0100 Subject: [PATCH 5/6] feat: test linting of qmd --- tests/testthat/in/lintr-fail.qmd | 8 ++++++++ tests/testthat/in/lintr-success.qmd | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/testthat/in/lintr-fail.qmd create mode 100644 tests/testthat/in/lintr-success.qmd diff --git a/tests/testthat/in/lintr-fail.qmd b/tests/testthat/in/lintr-fail.qmd new file mode 100644 index 000000000..129ea60a9 --- /dev/null +++ b/tests/testthat/in/lintr-fail.qmd @@ -0,0 +1,8 @@ +--- +title: "Test doc: fail lintr" +format: html +--- + +```{r} +sum(1,2) +``` diff --git a/tests/testthat/in/lintr-success.qmd b/tests/testthat/in/lintr-success.qmd new file mode 100644 index 000000000..0a7e8632f --- /dev/null +++ b/tests/testthat/in/lintr-success.qmd @@ -0,0 +1,8 @@ +--- +title: "Test doc: success lintr" +format: html +--- + +```{r} +sum(1, 2) +``` From ea57e1aea27b2b4f8f26c32251be0cc78f0bc75d Mon Sep 17 00:00:00 2001 From: Jack Kennedy Date: Wed, 22 May 2024 08:10:02 +0100 Subject: [PATCH 6/6] fix: update lint test --- tests/testthat/test-hook-lintr.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/testthat/test-hook-lintr.R b/tests/testthat/test-hook-lintr.R index 1a5574190..a44fcb23c 100644 --- a/tests/testthat/test-hook-lintr.R +++ b/tests/testthat/test-hook-lintr.R @@ -1,3 +1,5 @@ +# .R ---- + # success run_test("lintr", suffix = "-success.R", @@ -12,3 +14,11 @@ run_test( "lintr", suffix = "-fail.R", cmd_args = "--warn_only", std_err = NULL ) + +# .qmd ---- + +# success +run_test("lintr", suffix = "-success.qmd", std_err = NULL) + +# failure +run_test("lintr", suffix = "-fail.qmd", std_err = "not lint free")