# eslint-plugin-no-empty-statement

> disallow empty statement as the body of `if`, `for`, etc.

Latest version **0.1.1** (published 2021-02-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-plugin-no-empty-statement
pnpm add eslint-plugin-no-empty-statement
yarn add eslint-plugin-no-empty-statement
bun add eslint-plugin-no-empty-statement
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2021-02-01 |
| First published | 2021-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 0 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Zhenzhen Zhan |
| Maintainers | zhanzhenzhen |
| Keywords | eslint, eslintplugin |

## Links

- npm: https://www.npmjs.com/package/eslint-plugin-no-empty-statement
- Repository: https://github.com/zhanzhenzhen/eslint-plugin-no-empty-statement
- Homepage: https://github.com/zhanzhenzhen/eslint-plugin-no-empty-statement#readme
- Issues: https://github.com/zhanzhenzhen/eslint-plugin-no-empty-statement/issues
- npm.io page: https://npm.io/package/eslint-plugin-no-empty-statement

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2021-02-01
- 0.1.0 — 2021-02-01

## README

# Why?

It's possible that developers write these forms of code:

```js
if (falseCondition);
{
    console.log("It's not true.");
}
```

```js
for (let i = 0; i < 3; i++);
{
    doSomethingInLoop();
}
```

In the first example, the developer wants the `if` body to be executed only if `falseCondition` is met, but because he mistakenly typed a semicolon next to the parenthesis, the `{ ... }` block isn't treated as `if` body, so it always gets executed.

In the second example, the developer wants `doSomethingInLoop()` to be executed 3 times, but because he mistakenly typed a semicolon next to the parenthesis, the `{ ... }` block isn't treated as `for` body, so it gets executed only once.

If the `if` or `for` body is simply a semicolon, this semicolon is an "empty statement". Note that this is not "empty block", which is `{}`.

This rule disallows this form of semicolons.

# Usage

In your eslint config file:

```json
{
    "plugins": ["no-empty-statement"],
    "rules": {
        "no-empty-statement/no-empty-statement": "error"
    }
}
```

This rule has a string option:

- `"ignore-statement-list-item"` (default) allows "empty statement semicolons" in a container that can have multiple statements, for example an extra semicolon in the block `{ doSomething(); ; }`
- `"all"` disallows all "empty statement semicolons".

---
_Source: https://npm.io/package/eslint-plugin-no-empty-statement · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
