Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chaining rule doesn’t work when chain is imported from lodash/chain #246

Open
jaydenseric opened this issue Jun 18, 2020 · 2 comments
Open

Comments

@jaydenseric
Copy link

The lodash/chaining rule doesn’t work when using a deep import, which is a best practice for bundle-size:

import chain from 'lodash/chain'

It only works when chain is imported as a named import from lodash:

import { chain } from 'lodash'

Or when _.chain is used from the main default import:

import _ from 'lodash'

_.chain(
  // …
) // …
@blimmer
Copy link

blimmer commented Sep 28, 2021

As a workaround you can use no-restricted-imports:

"no-restricted-imports": [
  "error",
  {
    "paths": [
      {
        // lodash/chaining should catch this, but there's a bug: https://github.com/wix/eslint-plugin-lodash/issues/246
        "name": "lodash/chain",
        "message": "Do not use lodash/chain, as it breaks tree-shaking. Please nest your calls to lodash."
      }
    ]
  }
]

@vasilismantz
Copy link

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants