Skip to content
← Back to rules

unicorn/no-unreadable-array-destructuring Style

🚧 An auto-fix is planned for this rule, but not implemented at this time.

What it does ​

Disallows destructuring values from an array in ways that are difficult to read.

Why is this bad? ​

Destructuring can be very useful, but it can also make some code harder to read. This rule prevents ignoring consecutive values (e.g. let [,,foo] = array) when destructuring from an array.

Examples ​

Examples of incorrect code for this rule:

javascript
const [, , foo] = parts;
const [, , ...rest] = parts;

Examples of correct code for this rule:

javascript
const [foo] = parts;
const foo = parts[3];
const rest = parts.slice(2);

// One is fine
const [, foo] = parts;

How to use ​

To enable this rule using the config file or in the CLI, you can use:

json
{
  "rules": {
    "unicorn/no-unreadable-array-destructuring": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "unicorn/no-unreadable-array-destructuring": "error",
  },
});
bash
oxlint --deny unicorn/no-unreadable-array-destructuring

Version ​

This rule was added in v0.0.19.

References ​