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.

Document comma-dangle: functions: always-multiline behaviour in promises

See original GitHub issue
  1. ESLint Version v3.13.1 (although this is documentation specific, not the linter itself

  2. The problem you want to solve. The behaviour of always-multiline comma dangle in promises isn’t clearly documented. As In #7786 @mysticatea described why a trailing comma is forced in some Promise.then situations

  3. Your take on the correct solution to problem. Update the documentation for the rule to include a always-multiline section with the rest of the function docs, showing:

-Promise.then(x => x
-  .replace('asdasdsdsda', '123213213')
-  .replace('cxvcxvcxvcx', '546546546')
-  .replace('ewrewrewrew', '877876876'),
-)
+Promise.then(x => (
+  x.replace('asdasdsdsda', '123213213')
+    .replace('cxvcxvcxvcx', '546546546')
+    .replace('ewrewrewrew', '877876876')
+))

Raised this as an issue instead of a PR as I guess it’s a conflict between two rules in the airbnb config, but it might not belong on that page

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
not-an-aardvarkcommented, Jan 20, 2017

Would a notice about it being es2017 around the functions section make it clearer?

I agree, this seems like it would help a lot. Would you like to make a PR?

Also, keep in mind that the parser configuration (e.g. ecmaVersion: 2016 and the rule configuration (e.g. functions: always-multiline) are independent from each other. The default functions configuration is ignore (i.e. no errors are reported for trailing function commas), but if you’re using a shareable config such as eslint-config-airbnb, it’s possible the config is explicitly enabling functions: always-multiline. To override this, you can use something like

rules: {
  'comma-dangle': ['error', 'always-multiline']
}
0reactions
not-an-aardvarkcommented, Apr 22, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

comma-dangle - 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 >
Why you should enforce Dangling Commas for Multiline ...
Fortunately ESLint has the comma-dangle rule which allows you to enforce dangling commas for multiline statements. comma-dangle: “always-multiline”. With ...
Read more >
eslint-plugin-flowtype - npm
If it is 'always-multiline' then a problem is raised when there is no trailing comma on a multi-line definition, or there is a...
Read more >
eslint-plugin-flowtype - npm Package Health Analysis - Snyk
This rule has a string option and an object one. String options are: "always" (default) requires parens around arguments in all cases. "as-needed ......
Read more >
client/node_modules/eslint-plugin-flowtype - GitLab
If it is 'always-multiline' then a problem is raised when there is no trailing comma on a multi-line definition, or there is a...
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