Skip to content

Add a Parameter to commas_linter to Allow Comma Followed by Closing Bracket Without Space #2102

Closed

Description

@MEO265

Currently, the commas_linter marks an expression like x[1,] as incorrect, expecting a space after the comma. This is because the default behavior enforces a space after each comma in an expression. However, there is a common convention, where a comma followed directly by a closing bracket does not necessitate a space. This writing style is even utilized in the official base R documentation, specifically in the matrix section.

To cater to this, I propose adding a new parameter to the commas_linter function which allows users to specify whether a comma followed immediately by a closing bracket should be marked as incorrect or not. For instance:

commas_linter(allow_trailing_comma = TRUE)

When allow_trailing_comma is set to TRUE, commas_linter would not mark x[1,] as incorrect.

Activity

  1. AshesITR commented on Sep 4, 2023

    @AshesITR
    Collaborator

    Nice idea. Noting the the default should be FALSE, though, since we try to line up our defaults with the tidyverse styleguide.

    https://style.tidyverse.org/syntax.html#commas

    A PR is welcome if you'd like to give it a try.

  2. added
    help wanted ❤️
    feature
    on Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurehelp wanted ❤️

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions