-
-
Notifications
You must be signed in to change notification settings - Fork 681
Fix issue return in computed properties & render to match only corret nodes #131
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
Fix issue return in computed properties & render to match only corret nodes #131
Conversation
b760b10
to
5cf8338
Compare
lib/rules/require-render-return.js
Outdated
@@ -28,7 +28,8 @@ function create (context) { | |||
forbiddenNodes.forEach(el => { | |||
if ( | |||
el.loc.start.line >= node.value.loc.start.line && | |||
el.loc.end.line <= node.value.loc.end.line | |||
el.loc.end.line <= node.value.loc.end.line && | |||
node.value === el |
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 think simple:
el.loc.start.line === node.value.loc.start.line
would be enough, or even just:
node.value === el
wdyt? (I was sceptic but looks like this kind of comparison works just fine for ASTs)
Plus I think that this line should be moved to extecuteOnFunctionsWithoutReturn:
- if (!isValidReturn()) {
+ if (!isValidReturn() && !node.expression) {
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.
@michalsnik thank you for tips 🍡
@@ -28,7 +28,8 @@ function create (context) { | |||
if ( | |||
cp.value && | |||
el.loc.start.line >= cp.value.loc.start.line && | |||
el.loc.end.line <= cp.value.loc.end.line | |||
el.loc.end.line <= cp.value.loc.end.line && | |||
cp.value.parent === el |
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.
Same here
lib/rules/require-render-return.js
Outdated
) | ||
if (!node) return | ||
|
||
forbiddenNodes.forEach(el => { | ||
if ( | ||
el.loc.start.line >= node.value.loc.start.line && | ||
el.loc.end.line <= node.value.loc.end.line | ||
el.loc.end.line <= node.value.loc.end.line && | ||
el.loc.start.line === node.value.loc.start.line |
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 meant we can remove all other conditions and leave only this one. Or even just leave:
node.value === el
:D up to you, we only want to check if the forbidden node is the same as the render
's property value
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.
yup, i need a bit more ☕️
251d12f
to
88c0d75
Compare
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.
Thank you @armano2 ! LGTM 👍
fixes #130