wix-incubator / eslint-plugin-lodash

ESLint rules for lodash
MIT License
277 stars 65 forks source link

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

Open jaydenseric opened 4 years ago

jaydenseric commented 4 years ago

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 commented 3 years ago

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 commented 3 months ago

Any updates on this?