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

Question regarding reformatting of multi-line, chained function calls onto a single line #61

Closed
devillecodes opened this issue Apr 1, 2017 · 2 comments

Comments

@devillecodes
Copy link

Works great!

The only issue I've come across is where it reformats chained function calls onto the same line.

Any idea why it would reformat:

describe('root', () => {
	it('should have GET for health check', done => {
		request.get('/')
			.expect(200)
			.end(done);
	});
});

into this:

describe('root', () => {
	it('should have GET for health check', done => {
		request.get('/').expect(200).end(done);
	});
});

?

For additional context, I'm using the VS Code Plugin by Robin Malfait, and he suggested I ask here (see original issue).

As suggested by Robin, I tried overriding the newline-per-chained-call ESLint rule, but this didn't seem to have an effect on the formatting, although ESLint still picked up when I violated the rule.

@kentcdodds
Copy link
Member

It's most likely due to your max-len setting. The best way to troubleshoot the issues is to try things with prettier first, see what happens, then take that output and apply eslint --fix to it and that is what you'll get from prettier-eslint.

My guess is prettier puts it on one line and the eslint rule is not fixable. You could improve this by making the eslint rule fixable (make a PR) to the rule. Until that rule is fixable, I'm afraid it's not compatible with prettier and therefore won't work with prettier-eslint.

Because there's nothing we can do in prettier-eslint, I'm going to go ahead and close this issue. I encourage you to try to make that rule fixable! It would be very helpful to the community! Maybe this will help! Good luck!

@devillecodes
Copy link
Author

Thanks @kentcdodds! Although I'm all for creating a PR to fix an issue, I'm not sure where the issue currently lies. :)

After some further investigation I found that manually running prettier causes the behavior I showed in my OP, and then ESLint doesn't even report it as a problem, never mind fix it (based on the derived AirBnb rules we use).

I then found that there is an ongoing discussion on the Prettier repo about this, should anyone want to chime in.

Thanks again for responding! :)

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