eslint-plugin-destructuring
raw JSON → 2.2.1 verified Sat Apr 25 auth: no javascript
ESLint plugin providing destructuring-specific linting rules, currently at version 2.2.1. It focuses on enforcing consistency and best practices around object and array destructuring patterns, with rules like 'no-rename', 'in-params', and 'in-methods-params'. The plugin is maintained and integrates via ESLint's plugin system, supporting a recommended configuration. It requires ESLint as a peer dependency and is published under the MIT license. Notably, it is one of the few plugins dedicated solely to destructuring, offering targeted rules not found in ESLint core or popular configs like eslint-config-airbnb. Release cadence has slowed since 2019, but it remains functional for ESLint 5/6/7.
Common errors
error Configuration for rule "destructuring/no-rename" is invalid: Value ["error",{"forbid":"all"}] is not a valid rule configuration. ↓
cause Invalid option value for 'forbid' (should be an array or string, not 'all').
fix
Use 'destructuring/no-rename': ['error', { forbid: ['someName'] }] or remove the option.
error ESLint couldn't find the plugin "eslint-plugin-destructuring". ↓
cause Plugin not installed or not in node_modules.
fix
Run 'npm install eslint-plugin-destructuring --save-dev'.
error Cannot find module 'eslint-plugin-destructuring' ↓
cause Plugin not installed, or ESLint is running from a different directory.
fix
Ensure the plugin is installed locally: 'npm install eslint-plugin-destructuring --save-dev'.
Warnings
deprecated The 'no-rename' rule's 'forbid' option with value 'all' is deprecated in favor of explicit 'allow' list. ↓
fix Use 'no-rename': ['error', { allow: [] }] to forbid all renames.
breaking ESLint 8+ requires plugins to export a 'meta' object with 'name' and 'version'. This plugin may need update. ↓
fix Check plugin compatibility; for ESLint 8+, consider using an alternative or patching the plugin.
gotcha The 'in-methods-params' rule may conflict with other plugins like '@typescript-eslint' if method parameters use destructuring. ↓
fix Disable 'in-methods-params' if using TypeScript or other parameter-handling rules.
Install
npm install eslint-plugin-destructuring yarn add eslint-plugin-destructuring pnpm add eslint-plugin-destructuring Imports
- plugin object (default) wrong
require('eslint-plugin-destructuring') // direct require in config file won't work; use plugins arraycorrectmodule.exports = { plugins: ['destructuring'], rules: { 'destructuring/no-rename': 'error' } } - Recommended config wrong
{ extends: ['eslint-plugin-destructuring/recommended'] } // wrong prefix, must use 'plugin:'correct{ extends: ['plugin:destructuring/recommended'] } - Rule configuration wrong
{ rules: { 'no-rename': 'error' } } // missing plugin prefix 'destructuring/'correct{ rules: { 'destructuring/no-rename': ['error', { forbid: 'all' }] } }
Quickstart
// .eslintrc.js
module.exports = {
plugins: ['destructuring'],
extends: ['plugin:destructuring/recommended'],
rules: {
'destructuring/no-rename': 'error',
'destructuring/in-params': ['error', { enforce: 'always' }],
},
};