Skip to content

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

Merged
merged 1 commit into from
Aug 5, 2017

Conversation

armano2
Copy link
Contributor

@armano2 armano2 commented Aug 4, 2017

fixes #130

@armano2 armano2 force-pushed the patch-29-render-computed-error branch from b760b10 to 5cf8338 Compare August 4, 2017 16:29
@@ -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
Copy link
Member

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) {

Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

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

Same here

)
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
Copy link
Member

@michalsnik michalsnik Aug 4, 2017

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

Copy link
Contributor Author

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 ☕️

@armano2 armano2 force-pushed the patch-29-render-computed-error branch from 251d12f to 88c0d75 Compare August 4, 2017 23:06
Copy link
Member

@michalsnik michalsnik left a 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 👍

@michalsnik michalsnik merged commit 3db7b13 into vuejs:master Aug 5, 2017
@armano2 armano2 deleted the patch-29-render-computed-error branch August 5, 2017 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue in return-in-computed-property & require-render-return
3 participants