ESLint plugin enforcing newlines in object destructuring assignments when the number of properties exceeds a configurable threshold. Current version 1.2.2 works with ESLint >=7.2.0, released in a stable series that added a `consistent` option in v1.1.0. Key differentiator: specifically targets destructuring patterns (not general object expressions), offering granular control via `items`, `itemsWithRest`, `maxLength`, `consistent`, and `allowAllPropertiesOnSameLine` options. Lightweight, zero runtime dependencies beyond ESLint peer dependency. Useful for teams wanting consistent formatting of destructuring statements without adopting a full formatter like Prettier.
npm install eslint-plugin-newline-destructuringVerified import paths — ran on the pinned version, not inferred.
Basic ESLint configuration to enforce newlines in destructuring with custom options, plus sample passing and failing destructuring code.
If upgrading from <1.1.0, set 'consistent' explicitly to false to retain original behavior.
Ensure the rule is used for object destructuring; for other patterns, use other ESLint rules like 'object-curly-newline'.
Upgrade ESLint to version 7.2.0 or higher, or use an older version of the plugin (e.g., 0.0.4).
To always break when exceeding 'items', set 'allowAllPropertiesOnSameLine' to false and ensure 'consistent' is false.
Install the plugin: npm install eslint-plugin-newline-destructuring --save-dev and add 'newline-destructuring' to the plugins array.
Run: npm install eslint-plugin-newline-destructuring --save-dev
Ensure the rule config is an object, e.g., ["error", { "items": 2 }]Use numeric severity: 2 instead of "error" if using ESLint < 7. Or upgrade ESLint.