Use case where newline-per-chained-call doesn't work well
See original GitHub issueWhat rule do you want to change? newline-per-chained-call
Does this change cause the rule to produce more or fewer warnings? Fewer
How will the change be implemented? (New option, new default behavior, etc.)? My guess would be an option for it
Please provide some example code that this change will affect:
when(fn)
.mockReturnValue(mockSync)
.calledWith('param1').mockReturnValue(specificMockSync)
.calledWith('param2').mockReturnValue(anotherSpecificMockSync)
.calledWith('param3').mockReturnValue(yetAnotherSpecificMockSync);
According to the rule the code should be like this:
when(fn)
.mockReturnValue(mockSync)
.calledWith('param1').mockReturnValue(specificMockSync)
.calledWith('param2')
.mockReturnValue(anotherSpecificMockSync)
.calledWith('param3')
.mockReturnValue(yetAnotherSpecificMockSync);
Which doesn’t make logical sense, since the calledWith and mockReturnValue are linked (logically).
What does the rule currently do for this code?
Error for the last and second last mockReturnValue
What will the rule do after it’s changed? No error
Are you willing to submit a pull request to implement this change? I’m not sure how this will be implemented. But yes I would if I had some guidance/feedback.
What does everyone think/suggest for this use-case?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.
Thanks for contributing to ESLint and we appreciate your understanding.
I’ve got no idea of the inner workings of eslint. I was thinking of using some regex to get the name and then as long as it’s used previously it should be allowed.
However this wouldn’t handle the below case:
So yeh I’m not really sure there’s a possible solution. I’ll be disabling this rule most likely.