Skip to content

Add trailing_blank_lines_linter() test for .qmd files when no code and no terminal newline present? #1488

@IndrajeetPatil

Description

@IndrajeetPatil

For .Rmd, this test produces no error in the document, and so we get only 1 (expected) lint:

tmp4 <- withr::local_tempfile(fileext = ".Rmd")
  cat(
    trim_some(
      '---
      title: "Some file"
      ---
      No code and no terminal newline'
    ),
    file = tmp4
  )
  expect_lint(content = NULL, file = tmp4, list(
    message = msg2,
    line_number = 5L,
    # We can't get 4 here because the line is NA-masked in get_source_expressions(), so no line length info exists.
    column_number = 1L
  ), linter)

Screenshot 2022-07-29 at 18 48 30

For .qmd, the code in question leads to an error (and therefore 2 lints are produced):

tmp6 <- withr::local_tempfile(fileext = ".qmd")
  cat(
    trim_some(
      '---
      title: "Some file"
      ---
      No code and no terminal newline'
    ),
    file = tmp6
  )
  expect_lint(content = NULL, file = tmp6, list(
    message = msg2,
    line_number = 5L,
    # We can't get 4 here because the line is NA-masked in get_source_expressions(), so no line length info exists.
    column_number = 1L
  ), linter)

Screenshot 2022-07-29 at 18 47 54

Do we need to have this test for Quarto documents?

If yes, how should we go about it? Just change the test to expect 2 lints?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorrmdtesting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions