-
Notifications
You must be signed in to change notification settings - Fork 27
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
Handle functions and assignment in prefer-at condition #114
Conversation
eslint-plugin-expensify/prefer-at.js
Outdated
// Skip if the property is a method (like a.map) | ||
if (node.parent && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node) { | ||
return; | ||
} | ||
|
||
// Skip if the node is part of an assignment expression (like a[i] = 2) | ||
if (isAssignmentExpression(node)) { | ||
return; | ||
} |
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.
We want to return early if node
is left-hand side right? If so, I think it'll be better to wrap them in method. I'm not sure if there's a similar method from @typescript-eslint/utils
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.
@ShridharGoel I did some search and found a similar implementation from this project eslint-plugin-unicorn (under MIT license) and there's a isLeftHandSide method. Maybe we can learn some ideas from there to make our implementation more robust.
@ShridharGoel Could you please take a look at @eh2077 comments? |
Updated. |
@eh2077 Could you take a look now? Thanks 😄 |
@ShridharGoel The unit test is failing. Can you please take a look? Seems not related to this change? |
@eh2077 This unit test is already failing on |
|
||
function isLeftHandSide(node) { | ||
return ( | ||
(node.parent.type === 'AssignmentExpression' || node.parent.type === 'AssignmentPattern') |
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.
NAB: We use constants from
const { AST_NODE_TYPES, ESLintUtils } = require('@typescript-eslint/utils');
in prefer-at.js
.
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.
LGTM!
I ran test and lint locally but both of them failed though they're not caused by this change.
@fabioh8010 Can we just ignore them in this PR?
Yes I would ignore them for now |
🚀 Published in 2.0.59 |
Expensify/App#43055
This is a follow-up to include handling of functions like map and assignment like
a[i] = 2
.