# no-empty-pattern

> Disallow destructuring patterns that bind nothing

`const {} = user` looks like a declaration but doesn't create a variable. The usual cause is one wrong character. `{ settings: {} }` destructures `settings` into nothing, while `{ settings = {} }` would give it a default value.

This rule is on by default.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

On by default as a warning. To turn it off:

```toml bunfig.toml
[lint.rules]
"no-empty-pattern" = "off" # or "error"
```

Every option, set to its default:

```toml bunfig.toml
[lint.rules]
"no-empty-pattern" = ["warn", {
  allowObjectPatternsAsParameters = true,
}]
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 3} */}
```js
const { settings: {} } = user;
const [] = items;

function render([]) {
  return "<div></div>";
}
```

Not reported:

{/* good */}
```js
const { settings = {} } = user;
const [first] = items;

function render({ title }) {
  return `<div>${title}</div>`;
}
```

## Options

| Option | Default | What it does |
| --- | --- | --- |
| `allowObjectPatternsAsParameters` | `true` | Allow `{}` as a function parameter, with no default value or with the default `{}`. |

This is for a function that's called with an object it doesn't need, but that uses a later parameter. Playwright requires the `{}` in a fixture that uses no other fixture. With an ESLint config file the default is ESLint's, `false`.

{/* good */}
```js
function withServer({}, use) {
  return use(startServer());
}

function withDatabase({} = {}, use) {
  return use(openDatabase());
}
```

{/* bad {"options": [{"allowObjectPatternsAsParameters": false}]} */}
```js
function withServer({}, use) {
  return use(startServer());
}
```

An empty array pattern as a parameter is still reported:

{/* bad */}
```js
function withServer([], use) {
  return use(startServer());
}
```
