Registry / testing / eslint-plugin-newline-destructuring

eslint-plugin-newline-destructuring

JSON →
library1.2.2jsnpmunverified

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-destructuring
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-NEWL
E
eslint-plugin-newline-destructuring
testingjavascriptv1.2.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
import newlineDestructuring from 'eslint-plugin-newline-destructuring'
const newlineDestructuring = require('eslint-plugin-newline-destructuring')
ESLint plugins are typically loaded via require in config files, but ESM import works in modern ESLint. The plugin is commonly referenced by name in the plugins array.
rule 'newline'
rules: { 'newline-destructuring/newline': 'error' }
rules: { 'newline-destructuring': 'error' }
The rule name is scoped under the plugin name. Use 'newline-destructuring/newline' not just 'newline-destructuring'.
config type
plugins: ['newline-destructuring']
plugins: ['eslint-plugin-newline-destructuring']
When using ESLint's plugin shorthand, omit the 'eslint-plugin-' prefix. However, in some configurations (e.g., flat config), the full package name may be used.

Basic ESLint configuration to enforce newlines in destructuring with custom options, plus sample passing and failing destructuring code.

// .eslintrc.json { "plugins": ["newline-destructuring"], "rules": { "newline-destructuring/newline": ["error", { "items": 2, "itemsWithRest": 1, "maxLength": 80, "consistent": true, "allowAllPropertiesOnSameLine": false }] } } // Example destructuring that passes const { a, b, c } = obj; // Example that triggers error (more than 2 non-rest items) const { a, b, c, d } = obj; // Should be: const { a, b, c, d } = obj;
Debug
Known issues
deprecatedThe 'consistent' option was added in v1.1.0 and may change behavior for existing configurations that do not set it.
fix
If upgrading from <1.1.0, set 'consistent' explicitly to false to retain original behavior.
affects: <1.1.0
gotchaThe rule only applies to object destructuring patterns, not array destructuring or object expressions.
fix
Ensure the rule is used for object destructuring; for other patterns, use other ESLint rules like 'object-curly-newline'.
affects: >=1.0.0
breakingESLint peer dependency requirement jumped to >=7.2.0 starting from v1.0.0; earlier versions might not be compatible.
fix
Upgrade ESLint to version 7.2.0 or higher, or use an older version of the plugin (e.g., 0.0.4).
affects: >=1.0.0
gotchaThe 'items' option sets the threshold for non-rest properties; if the count is exactly equal to 'items', the statement may still be kept on one line unless 'maxLength' is violated.
fix
To always break when exceeding 'items', set 'allowAllPropertiesOnSameLine' to false and ensure 'consistent' is false.
affects: >=1.0.0
Errors
Common errors & fixes
Definition for rule 'newline-destructuring/newline' was not found
The plugin is not installed or not loaded in the ESLint config.
fix
Install the plugin: npm install eslint-plugin-newline-destructuring --save-dev and add 'newline-destructuring' to the plugins array.
ESLint couldn't find the plugin "eslint-plugin-newline-destructuring".
The plugin is not installed in the project.
fix
Run: npm install eslint-plugin-newline-destructuring --save-dev
TypeError: Cannot read properties of undefined (reading 'getStaticValue')
Using incorrect rule options (e.g., passing an array where an object is expected).
fix
Ensure the rule config is an object, e.g., ["error", { "items": 2 }]
Configuration for rule "newline-destructuring/newline" is invalid: Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '"error"')
Using string severity in older ESLint versions where numeric severity is expected.
fix
Use numeric severity: 2 instead of "error" if using ESLint < 7. Or upgrade ESLint.
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies
eslintrequiredpeer dependency: plugin requires ESLint >=7.2.0 as a peer dependency to function as an ESLint rule
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-newline-destructuring — npm install eslint-plugin-newline-destructuring · libregistry