Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Additional checks for prefer-flat #46

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

Conversation

Copy link
Contributor

@doniyor2109 doniyor2109 commented Feb 25, 2020

prefer-flat is failing in some cases:

  • array.reduce((p, []) => p.concat({}), [])
  • array.reduce((p, n) => p.concat(n), [1])
  • array.reduce((p, n) => p.concat(n, n), [])

@doniyor2109 doniyor2109 changed the title (削除) fix: Additional checks prefer-flat (削除ここまで) (追記) fix: Additional checks for prefer-flat (追記ここまで) Feb 25, 2020
Copy link
Owner

@freaktechnik freaktechnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvement. However I'd like to keep the code consistent in style. I also wonder if some of the conditions couldn't be enforced by the selector.

@@ -1,3 +1,5 @@
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable no-magic-numbers */
Copy link
Owner

@freaktechnik freaktechnik Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, but these rules are there for a reason.

doniyor2109 reacted with thumbs up emoji
Copy link

codecov bot commented Feb 26, 2020
edited
Loading

Codecov Report

Merging #46 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@ Coverage Diff @@
## master #46 +/- ##
=========================================
 Coverage 100.00% 100.00% 
=========================================
 Files 8 8 
 Lines 111 111 
=========================================
 Hits 111 111 

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2133139...d55aab3. Read the comment docs.

Copy link
Owner

@freaktechnik freaktechnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Also, impressed by the quick turnaround time.

doniyor2109 reacted with rocket emoji
if(node.parent.parent.arguments.length > SECOND && node.parent.parent.arguments[SECOND].type === "ArrayExpression" &&
firstElement(node.arguments).name === node.parent.params[SECOND].name &&
node.callee.object.name === firstElement(node.parent.params).name) {
'CallExpression[callee.type="MemberExpression"][callee.property.name="reduce"][arguments.length=2][arguments.1.type=ArrayExpression][arguments.1.elements.length=0] > *:function[params.length=2][params.0.type=Identifier][params.1.type=Identifier] > CallExpression[callee.type="MemberExpression"][callee.property.name="concat"][arguments.length=1][arguments.0.type=Identifier]'(node) {
Copy link
Owner

@freaktechnik freaktechnik Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, I didn't expect this much to be possible within the selector. Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@freaktechnik freaktechnik freaktechnik approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /