question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"newline-per-chained-call" doesn't allow first method to start on new line

See original GitHub issue

What rule do you want to change? I want to change the newline-per-chained-call rule to allow for ignoreChainWithDepth to be set to 0, so every new method chained is on a new line instead of skipping the first method.

Does this change cause the rule to produce more or fewer warnings? The rule will produce fewer warnings by adhering to user’s preference of coding style.

How will the change be implemented? (New option, new default behavior, etc.)? Basically you just need to change the ignoreChainWithDepth option to allow for 0 instead of only >= 1.

Please provide some example code that this change will affect:

Input:

myPromise.then(() => {

}).catch(() => {

});

myObject.get(documentID).insert({ test: true }).run().then(() => {

}).catch(() => {

});

myObject.myProperty.get(documentID).insert({ test: true }).run().then(() => {

}).catch(() => {

});

Expected output:

myPromise
	.then(() => {

	})
	.catch(() => {

	});

myObject
	.get(documentID)
	.insert({ test: true })
	.run()
	.then(() => {

	})
	.catch(() => {

	});

myObject.myProperty
	.get(documentID)
	.insert({ test: true })
	.run()
	.then(() => {

	})
	.catch(() => {

	});

Actual output:

myPromise.then(() => {

})
	.catch(() => {

	});

myObject.get(documentID)
	.insert({ test: true })
	.run()
	.then(() => {

	})
	.catch(() => {

	});

myObject.myProperty.get(documentID)
	.insert({ test: true })
	.run()
	.then(() => {

	})
	.catch(() => {

	});

What does the rule currently do for this code? The ignoreChainWithDepth rule is only allowed to range from 1 to 10. I think this number should be allowed to be set from 0-10, allowing for the first method to be put on a new line instead of being on the same line as the variable/object it’s being called from.

What will the rule do after it’s changed? I’ve included examples above to what it will look like.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
PassTheMayocommented, Oct 28, 2018

@kaicataldo Yeah, I can do that sometime tomorrow. Thanks!

0reactions
eslint-github-bot[bot]commented, Oct 11, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"newline-per-chained-call" doesn't allow first method to start ...
What rule do you want to change? I want to change the newline-per-chained-call rule to allow for ignoreChainWithDepth to be set to 0 ......
Read more >
newline-per-chained-call - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
How to correctly use Eslint rule newline-per-chained-call with ...
I get error Delete ⏎↹↹↹ eslint (prettier/prettier). in VSCode which I don't want to have. How can I fix the configuration to allow...
Read more >
[eslint] newline-after-var, newline-before-return, newline-per ...
40 40 const errmsg 43 + 43 44 logger.error(errmsg) 44 45 throw new Error(errmsg)
Read more >
newline-per-chained-call, prettier skip next line, visual studio ...
Rule: newline-per-chained-call Requires that chained method calls be broken ... The first time you open a workspace that defines any of these settings, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found