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
Apply property shorthand syntax following ECMAScript 6 format #3471
Conversation
Yeah, agreed mixed usage of the shorthand and non-shorthand in the same object literal might be very off-setting. One thing we can do to reduce that is to either:
this.changeObservable_.fire({
relayoutAll,
velocity,
top: scrollTop,
left: scrollLeft,
width: size.width,
height: size.height,
}); |
I like option 2. |
8feec99
to
d5df69c
Compare
Lets pick the one option our linter can already enforce. |
I found a lint rule here. However it seems to be enforcing every instance no matter whether it mixes with non-shorthand properties or not.
I don't have a strong opinion here. But enforcing the shorthand property syntax could be a pain for readability and also I am having some compiling errors from the closure compiler(looking into it). I wonder what do you guys think? |
I have little opinion. But not something worth spending more than a couple On Mon, Jun 6, 2016 at 5:28 PM, Yuxi Chen notifications@github.com wrote:
|
yep @cramforce , pointed @muxin to eslint rules |
@muxin can you send me a screenshot of the errors for closure compiler? thanks |
@erwinmombay This is the link to the failed travis build |
I'm currently working on upgrading our compiler version to the latest. Lets On Mon, Jun 6, 2016 at 5:32 PM, erwin mombay notifications@github.com
|
The closure compiler complains when I am changing export const Util = {
filter: filter,
guid: guid,
log: log,
make: make,
set: set,
}; to export const Util = {filter, guid, log, make, set}; I don't know why that happens but if I revert the changes, the closure compiler would work fine. |
FYI. I made the changes in this pull request by searching |
9802010
to
ff841a0
Compare
@@ -61,6 +61,7 @@ | |||
"objectsInObjects": false, | |||
"arraysInObjects": false | |||
}], | |||
"object-shorthand": [2, "properties"], |
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.
This rule will make the linter complain every time we use a non-shorthand syntax. Shall I make the lint level error
or warning
? Do I have to separate this change to another PR?
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.
@erwinmombay What do you think about the error level? I found that travis would still fail if it sees lint warnings. So we might make it error
level? Do you think I should make the lint rule a separate PR?
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.
last conversation i think we had in channel, lets go with error. better for consistency. you can leave the change here just make sure to pull i the latest and run the linter again
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.
OK sure, thanks for the confirmation.
ff841a0
to
c8514ad
Compare
@@ -382,8 +382,8 @@ describe('Slides functional', () => { | |||
pos: 0.6, | |||
min: 0, | |||
max: 0, | |||
prevTr: prevTr, | |||
nextTr: nextTr, | |||
prevTr, |
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.
so we're ok with the shorthand being anywhere? i thought from the conversation here that they should always be on top
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'll add another commit to rearrange the orders.
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.
just want to clarify you are doing the work in this PR or another PR?
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.
In the same PR, commit coming
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.
On second thought, I think leaving the order as it is might be better. Sometimes we have similar objects of the same set of properties but different values like the following:
object1 {
x: x,
y: bla,
z: z,
}
object2 {
x: x,
y: bla,
z: null,
}
I think converting it to
object1 {
x,
y: bla,
z,
}
object2 {
x,
y: bla,
z: null,
}
makes more sense because object1 and object2 looks better if they have the same pattern.
@jridgewell @mkhatib @erwinmombay What do you think?
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.
honestly i don't have any strong opinion on this. since we can't enforce it right now anyways i do think we should just leave it as is
@muxin LGTM, please make sure to fetch the latest from master and run the linter again before merging this |
c8514ad
to
ef5c45e
Compare
👍 |
ef5c45e
to
fd52bff
Compare
#3504
From previous PR
It might be better to apply property shorthand syntax according to ES6 format throughout the code base for consistency.
For example, converting
to
However, if that's the convention we want, I find it not that intuitive when it comes to cases like the following:
if I change the above block to
I think it introduced un-intuitiveness here.
What do you think about it? @cramforce @dvoytenko @mkhatib