Skip to content

Add consistent option to comma-dangle #10350

@BridgeAR

Description

@BridgeAR

What rule do you want to change?

comma-dangle

Does this change cause the rule to produce more or fewer warnings?

That depends.

How will the change be implemented? (New option, new default behavior, etc.)?

This is a feature request from Node.js: it would be nice to add a consistent option to comma-dangle that checks if the whole file has a consistent style of either always having trailing commas or having no trailing commas at all. With the current options something like this is not possible.

Refs: nodejs/node#20703 (comment)

Please provide some example code that this change will affect:

const a = [
  1,
  2,
]

const b = [
  1,
  2
]
const a = {
  a: 1,
  b: 2,
}

const b = {
  a: 1,
  b: 2
}

What does the rule currently do for this code?

Using the only-multiline option results in no error. Using the always-multiline always reports errors.

What will the rule do after it's changed?

It should report an issue as long as both styles are used in a single file. If the file has either a consistent trailing comma style or no trailing commas, it should not report an issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    archived due to ageThis issue has been archived; please open a new issue for any further discussionauto closedThe bot closed this issueenhancementThis change enhances an existing feature of ESLintevaluatingThe team will evaluate this issue to decide whether it meets the criteria for inclusionruleRelates to ESLint's core rules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions