@arabasta/eslint-plugin-no-destructuring-arrays-as-objects
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

@arabasta/eslint-plugin-no-destructuring-arrays-as-objects

NPM Version NPM License

ESLint plugin that disallows destructuring arrays as objects.

Note This plugin utilizes the awesome power of TypeScript's type checking.
These rules are slower to run and and you will need to specify a path to your tsconfig.json file in the "project" property of "parserOptions".
For more information see: https://typescript-eslint.io/getting-started/typed-linting

Installation

Assuming you already have ESLint installed, run:

# npm
npm install --save-dev @arabasta/eslint-plugin-no-destructuring-arrays-as-objects

# yarn
yarn add --dev @arabasta/eslint-plugin-no-destructuring-arrays-as-objects

# pnpm
pnpm add --save-dev @arabasta/eslint-plugin-no-destructuring-arrays-as-objects

Usage

Flat config (eslint.config.js)

// ...
import noDestructuringArraysAsObjects from '@arabasta/eslint-plugin-no-destructuring-arrays-as-objects';

export default [
  // ...
  {
    ...noDestructuringArraysAsObjects.configs.recommended,
    languageOptions: {
      parserOptions: {
        project: './tsconfig.json',
      },
    },
  },
];

Legacy config (.eslintrc)

{
  "extends": [
    // ...
    "plugin:@arabasta/no-destructuring-arrays-as-objects/recommended-legacy"
  ],
  // ...
  "parserOptions": {
    "project": "tsconfig.json"
  }
}

Rules

✅ Set in the recommended configuration

Rule Description
no-destructuring-arrays-as-objects Disallow destructuring arrays as objects

no-destructuring-arrays-as-objects

Examples of incorrect code for this rule:

const foo = [];
const { length } = foo;

Examples of correct code for this rule:

const foo = { bar: true };
const { bar } = foo;

License

MIT

Package Sidebar

Install

npm i @arabasta/eslint-plugin-no-destructuring-arrays-as-objects

Weekly Downloads

6

Version

1.0.4

License

MIT

Unpacked Size

10.1 kB

Total Files

6

Last publish

Collaborators

  • stoyan.a.kolev