Coding style #2813
Replies: 9 comments 3 replies
-
IMO option 2 for both: // Encourages "one-level", no nested if-else-if-if-if-if-else
if (!something) return;
const x = y;
doSomething(); AND if (something) doSomething(); I wonder if we can adapt the linter or prettier rules to enforce on what we decide for? |
Beta Was this translation helpful? Give feedback.
-
My preference: if (!something) return;
const x = y;
doSomething(); and if (something) doSomething(); |
Beta Was this translation helpful? Give feedback.
-
Hi, depending on the situation I use both
and
in certain cases negating 'something' makes it harder to understand, then I use option 1. In most cases, I use option 2. Imo, having both styles doesn't make code harder to understand. What is the purpose of standardizing? Can it be enforced automatically? (via prettier/linter as @mokimo mentioned above) In this case, it wouldn't require more effort from developers. |
Beta Was this translation helpful? Give feedback.
-
I don't like the following syntax as it makes it harder to debug w.r.t breakpoints.
The more verbose version gives more air to the code between logical blocks :)
I would support keeping both versions. However, I agree that we should standardize our coding style. We should also enhance our linter to catch these minor violations before committing, to avoid wasting time on PR reviews for such issues. |
Beta Was this translation helpful? Give feedback.
-
1
One less line (although a couple more characters due to the 2
Same arguments, two lines less, no additional indenting, code is easier to read. As @narcis-radu mentioned, Chrome doesn't have an issue with this and you can easily access the function itself. |
Beta Was this translation helpful? Give feedback.
-
As for the linting rule, this is what we search for https://eslint.org/docs/latest/rules/curly - given what we've discussed so far. Particularly this example ... this does introduce a lot of issues, hence I'd suggest we put it as 'warn' rather than 'error' |
Beta Was this translation helpful? Give feedback.
-
Thanks for this post. I value the consensus and hopefully we can make it easier with the linter. |
Beta Was this translation helpful? Give feedback.
-
Looks like there's consensus on the styles (which I agree with). The other big issue is that we have too much code that is currently breaking the linting. Until that is resolved it makes it much harder to enforce rules. Also once resolved we should have the linter run during an |
Beta Was this translation helpful? Give feedback.
-
Thank you all! I have created a follow-up JIRA story to address this - https://jira.corp.adobe.com/browse/MWPW-158751 |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I wanted to get the community preference on coding style and make sure we use the patterns consistently in Milo. Here are some patterns I wanted to discuss, right now all options are used in random scripts.
Beta Was this translation helpful? Give feedback.
All reactions