# no-fallthrough

Rule `sonarjs/no-fallthrough`. Switch cases should end with an unconditional "break" statement

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1269 by reach, #570 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-fallthrough` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-128/) |

## Code examples

### Incorrect: the rule reports this

```js
switch (myVariable) {
  case 1:
    foo();
    break;
  case 2:  // Both 'doSomething()' and 'doSomethingElse()' will be executed. Is it on purpose ?
    doSomething();
  default:
    doSomethingElse();
    break;
}
```

### Correct: the rule accepts this

```js
switch (myVariable) {
  case 1:
    foo();
    break;
  case 2:
    doSomething();
    break;
  default:
    doSomethingElse();
    break;
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/no-fallthrough": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [eslint/no-fallthrough](https://lintradar.dev/rules/eslint/no-fallthrough.md): Disallow fallthrough of `case` statements
- [sonarjs/no-extra-arguments](https://lintradar.dev/rules/sonarjs/no-extra-arguments.md): Function calls should not pass extra arguments
- [sonarjs/no-fixed-wait-in-tests](https://lintradar.dev/rules/sonarjs/no-fixed-wait-in-tests.md): Fixed waits should not be used in tests
- [sonarjs/no-exclusive-tests](https://lintradar.dev/rules/sonarjs/no-exclusive-tests.md): Exclusive tests should not be committed to version control
- [sonarjs/no-floating-point-equality](https://lintradar.dev/rules/sonarjs/no-floating-point-equality.md): Floating point numbers should not be tested for equality
- [sonarjs/no-equals-in-for-termination](https://lintradar.dev/rules/sonarjs/no-equals-in-for-termination.md): Equality operators should not be used in "for" loop termination conditions

---

Web page: https://lintradar.dev/rules/sonarjs/no-fallthrough. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
