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

Support Lodash and lodash/fp at the same time with _.noConflict #68

Closed
scic opened this issue Apr 20, 2016 · 2 comments
Closed

Support Lodash and lodash/fp at the same time with _.noConflict #68

scic opened this issue Apr 20, 2016 · 2 comments

Comments

@scic
Copy link

scic commented Apr 20, 2016

I use lodash and lodash/fp at the same time with the use of _.noConflict. Thus I have lodash bound to _ and lodash/fp bound on fp.

<script src='path/to/lodash.js'></script>
<script src='path/to/lodash.fp.js'></script>
<script>
// lodash is already on _
var fp = _.noConflict();
_.map(['6', '8', '10'], parseInt); // use standard lodash on _
fp.map(parseInt)(['6', '8', '10']); // this will give error
</script>

Now prefer-lodash-method will mark fp.map as error. Which is wrong.

There is the pragma setting with it I could set lodash to be on fp but then it is no longer on _. One possible solution would be to accept an array for pragma where I could define:

pragma: ['_', 'fp']

Or how should both be used together?

BTW: We do have lots of code in lodash already but want to use lodash/fp for the newer code. So it has to be used together.

@ganimomer
Copy link
Contributor

This is an interesting problem.
Like we said in issue #35, this plugin doesn't support lodash/fp.
This means that the rules shouldn't be applied to fp instances, so an array of pragma isn't what we want.
However, what happens in your example is an actual problem, specifically in prefer-lodash-method, which has an except array for methods, but not for objects.

I think what would solve the problem is adding an ignoreObjects array.
Something like:

 "lodash/prefer-lodash-method": [2, {ignoreObjects: ["fp"]}]

@scic
Copy link
Author

scic commented Apr 20, 2016

The proposed solution sounds good to me. Since this will ensure cooperability with _ and fp used together - at least for prefer-lodash-method. But so far I did not come across other rules interfering.

So we have eslint-plugin-lodash to validate the use of _ and we have eslint-plugin-lodash-fp to validate the use of fp. This looks like a reasonable split to me.

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

2 participants