eslint-plugin-lodash icon indicating copy to clipboard operation
eslint-plugin-lodash copied to clipboard

Combine rules for `import-scope`, accept both 'member' and 'method'

Open max-pod opened this issue 3 years ago • 2 comments

Hello, is it possible to accept both 'member' and 'method' for the rule import-scope, and if not, would you welcome a PR that lets you combine rules specifically on lodash/import-scope?

See: https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/import-scope.md

max-pod avatar Apr 29 '22 19:04 max-pod

what is the use case for allowing both?

idok avatar May 22 '22 13:05 idok

Would also be interested in being able to do this.

The use case is that we've enforced method imports for a long time due to tree shaking. In VS Code however automatic imports via autocomplete prefers the member style of import (e.g. if you type map and then use autocomplete to insert the import statement for you). This means that after autocompleting an import you then have to modify that import manually to conform with the ESLint rule.

Because we use NextJS we can modularize our imports so that member imports will be swapped out by the compiler for method imports automatically. This improves DX because we get tree shaking benefits even for member import, can therefore allow the member import style, and won't need to mess about with modifying imports after autocomplete.

Problem is that we have 100s of existing method imports. There's nothing technically wrong with allowing both member and method imports BUT I would like to disallow the full import style since allowing this could bloat our package size.

For now it seems like the only way to allow multiple import styles is to go nuclear and completely disable the rule but that opens us up to the possibility of full imports.

cbovis avatar Jul 12 '23 07:07 cbovis