diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-28 18:09:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-28 18:09:13 +0300 |
commit | 736d36d8597d0d1ec1b47644e6d091c3f4a78f45 (patch) | |
tree | a38f6fef2b7147416b31f8294a9389b3bb472c87 /doc/development/fe_guide | |
parent | 5426ca9908085087d465fa52800335f408eb965a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/fe_guide')
-rw-r--r-- | doc/development/fe_guide/style/javascript.md | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/development/fe_guide/style/javascript.md b/doc/development/fe_guide/style/javascript.md index f40e8c7b5df..7951c702601 100644 --- a/doc/development/fe_guide/style/javascript.md +++ b/doc/development/fe_guide/style/javascript.md @@ -175,6 +175,21 @@ are loaded dynamically with webpack. Do not use `innerHTML`, `append()` or `html()` to set content. It opens up too many vulnerabilities. +## Avoid single-line conditional statements + +Indentation is important when scanning code as it gives a quick indication of the existence of branches, loops, and return points. +This can help to quickly understand the control flow. + +```javascript +// bad +if (isThingNull) return ''; + +// good +if (isThingNull) { + return ''; +} +``` + ## ESLint ESLint behaviour can be found in our [tooling guide](../tooling.md). |