Skip to content

Request: add option for no-fallthrough with newlines #15703

@SheetJSDev

Description

@SheetJSDev

Environment

Node version: v16.14.0
npm version: v8.3.1
Local ESLint version: v8.11.0 (Currently used)
Global ESLint version: v7.23.0
Operating System: darwin 21.1.0

What parser are you using?

Default (Espree)

What did you do?

var x = 3;
switch(x){
  case 0:
  case 1: break;

  case 2:
    
  case 3:
    break;
}

ESLint Demo Link

What did you expect to happen?

No errors

What actually happened?

  8:3  error  Expected a 'break' statement before 'case'  no-fallthrough

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

It might also make sense to support comments:

switch(x) {
  // currently accepted
  case 0:
  case 1:
    break;

  // this issue
  case 2:

  case 3:
    break;

  // general proposal
  /* a note about 4 */
  case 4:
  /* a note about 5 */
  case 5:
    break;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionenhancementThis change enhances an existing feature of ESLintruleRelates to ESLint's core rules

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions