{"id":19841,"library":"eslint-plugin-newline-destructuring","title":"eslint-plugin-newline-destructuring","description":"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.","status":"active","version":"1.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/urielvan/eslint-plugin-newline-destructuring","tags":["javascript","eslint","eslint-plugin","eslintplugin","lint","destructuring"],"install":[{"cmd":"npm install eslint-plugin-newline-destructuring","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-newline-destructuring","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-newline-destructuring","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: plugin requires ESLint >=7.2.0 as a peer dependency to function as an ESLint rule","package":"eslint","optional":false}],"imports":[{"note":"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.","wrong":"const newlineDestructuring = require('eslint-plugin-newline-destructuring')","symbol":"plugin","correct":"import newlineDestructuring from 'eslint-plugin-newline-destructuring'"},{"note":"The rule name is scoped under the plugin name. Use 'newline-destructuring/newline' not just 'newline-destructuring'.","wrong":"rules: { 'newline-destructuring': 'error' }","symbol":"rule 'newline'","correct":"rules: { 'newline-destructuring/newline': 'error' }"},{"note":"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.","wrong":"plugins: ['eslint-plugin-newline-destructuring']","symbol":"config type","correct":"plugins: ['newline-destructuring']"}],"quickstart":{"code":"// .eslintrc.json\n{\n  \"plugins\": [\"newline-destructuring\"],\n  \"rules\": {\n    \"newline-destructuring/newline\": [\"error\", {\n      \"items\": 2,\n      \"itemsWithRest\": 1,\n      \"maxLength\": 80,\n      \"consistent\": true,\n      \"allowAllPropertiesOnSameLine\": false\n    }]\n  }\n}\n\n// Example destructuring that passes\nconst { a, b, c } = obj;\n\n// Example that triggers error (more than 2 non-rest items)\nconst { a, b, c, d } = obj;\n// Should be:\nconst {\n  a,\n  b,\n  c,\n  d\n} = obj;","lang":"javascript","description":"Basic ESLint configuration to enforce newlines in destructuring with custom options, plus sample passing and failing destructuring code."},"warnings":[{"fix":"If upgrading from <1.1.0, set 'consistent' explicitly to false to retain original behavior.","message":"The 'consistent' option was added in v1.1.0 and may change behavior for existing configurations that do not set it.","severity":"deprecated","affected_versions":"<1.1.0"},{"fix":"Ensure the rule is used for object destructuring; for other patterns, use other ESLint rules like 'object-curly-newline'.","message":"The rule only applies to object destructuring patterns, not array destructuring or object expressions.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade ESLint to version 7.2.0 or higher, or use an older version of the plugin (e.g., 0.0.4).","message":"ESLint peer dependency requirement jumped to >=7.2.0 starting from v1.0.0; earlier versions might not be compatible.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"To always break when exceeding 'items', set 'allowAllPropertiesOnSameLine' to false and ensure 'consistent' is false.","message":"The '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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install the plugin: npm install eslint-plugin-newline-destructuring --save-dev and add 'newline-destructuring' to the plugins array.","cause":"The plugin is not installed or not loaded in the ESLint config.","error":"Definition for rule 'newline-destructuring/newline' was not found"},{"fix":"Run: npm install eslint-plugin-newline-destructuring --save-dev","cause":"The plugin is not installed in the project.","error":"ESLint couldn't find the plugin \"eslint-plugin-newline-destructuring\"."},{"fix":"Ensure the rule config is an object, e.g., [\"error\", { \"items\": 2 }]","cause":"Using incorrect rule options (e.g., passing an array where an object is expected).","error":"TypeError: Cannot read properties of undefined (reading 'getStaticValue')"},{"fix":"Use numeric severity: 2 instead of \"error\" if using ESLint < 7. Or upgrade ESLint.","cause":"Using string severity in older ESLint versions where numeric severity is expected.","error":"Configuration for rule \"newline-destructuring/newline\" is invalid: Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '\"error\"')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}