-
-
Notifications
You must be signed in to change notification settings - Fork 353
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
Add prefer-array-flat
rule
#1126
Conversation
Half code in this rule just esquery selector. 😄 |
docs/rules/prefer-array-flat.md
Outdated
@@ -0,0 +1,53 @@ | |||
# Prefer `Array#flat()` over legacy techniques to flatten arrays | |||
|
|||
ES2019 introduced a new method [`Array#flat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) that flattens arrays, and there's a [`depth` parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat#parameters), so you can flatten deep nesting arrays with it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the depth
parameter is relevant. People can read about it when they click the MDN link.
index.js
Outdated
@@ -84,6 +84,9 @@ module.exports = { | |||
'unicorn/prefer-add-event-listener': 'error', | |||
'unicorn/prefer-array-find': 'error', | |||
// TODO: Enable this by default when targeting Node.js 12. | |||
// TODO[@fisker]: Set to `off` before merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget this.
Added a |
CI failure should not related, I'll look into it. |
Fixes #975