# eslint-plugin-lodash-imports

> Fix your lodash imports to avoid increasing bundle size

Latest version **1.1.0** (published 2023-07-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install eslint-plugin-lodash-imports
pnpm add eslint-plugin-lodash-imports
yarn add eslint-plugin-lodash-imports
bun add eslint-plugin-lodash-imports
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2023-07-28 |
| First published | 2023-07-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^14.17.0 \|\| ^16.0.0 \|\| >= 18.0.0 |
| Dependencies | 1 |
| Unpacked size | 17.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Mario Cadenas |
| Maintainers | mariocadenas |
| Keywords | eslint, eslintplugin, eslint-plugin |

## Links

- npm: https://www.npmjs.com/package/eslint-plugin-lodash-imports
- Repository: https://github.com/MarioCadenas/eslint-plugin-lodash-imports
- Homepage: https://github.com/MarioCadenas/eslint-plugin-lodash-imports#readme
- Issues: https://github.com/MarioCadenas/eslint-plugin-lodash-imports/issues
- npm.io page: https://npm.io/package/eslint-plugin-lodash-imports

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2023-07-28
- 1.0.0 — 2023-07-28

## README

# eslint-plugin-lodash-imports

## What's the purpose of this plugin?

Importing lodash incorrectly can come with an unexpected increase in the bundle size, for example, using any of the following
approaches:

```js
import { isEqual } from 'lodash';
```

```js
import isEqual from 'lodash.isequal';
```

```js
import _ from 'lodash';

_.isEqual('','');
```

will increase the bundle size unexpectedly when using only one function. As explained [here](https://lodash.com/per-method-packages)

Lodash provides a [babel plugin](https://github.com/lodash/babel-plugin-lodash) that transforms the code so you can directly import from 'lodash'.

The problem with this babel plugin is that it adds some KBs to your bundle.

This ESLint plugin will let you know when a Lodash import can be improved, and provides an autofixer so you don't have to do it yourself.

For example:

```js
import { isEqual, get } from 'lodash';
```

will be converted to:

```js
import isEqual from 'lodash/isEqual';
import get from 'lodash/get';
```

without adding more size than needed to your bundle.

It also supports default imports and per-method imports.


## Installation

You'll first need to install [ESLint](https://eslint.org/):

```sh
npm i eslint --save-dev
```

Next, install `eslint-plugin-lodash-imports`:

```sh
npm install eslint-plugin-lodash-imports --save-dev
```

## Usage

Add `lodash-imports` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:

```json
{
    "plugins": [
        "lodash-imports"
    ]
}
```


Then configure the rules you want to use under the rules section.

```json
{
    "rules": {
        "lodash-imports/rule-name": 2
    }
}
```

## Rules

<!-- begin auto-generated rules list -->

🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).

| Name                                                             | 🔧 |
| :--------------------------------------------------------------- | :- |
| [no-direct-lodash-import](docs/rules/no-direct-lodash-import.md) | 🔧 |

<!-- end auto-generated rules list -->

---
_Source: https://npm.io/package/eslint-plugin-lodash-imports · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
