summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils/common_utils.js
diff options
context:
space:
mode:
authorgfyoung <gfyoung17@gmail.com>2018-06-16 14:50:13 -0700
committergfyoung <gfyoung17@gmail.com>2018-06-25 11:53:57 -0700
commit23cdae8eee4fb2017399f54ee0373367fd915e63 (patch)
treeaf797d46be6b0a7a3194d3d797e32bacbacc791f /app/assets/javascripts/lib/utils/common_utils.js
parentd38eb9bb2668afe8ddd2976490c669b8de4c507e (diff)
downloadgitlab-ce-23cdae8eee4fb2017399f54ee0373367fd915e63.tar.gz
Enable "prefer-destructuring" in JS files
Partially addresses #47006.
Diffstat (limited to 'app/assets/javascripts/lib/utils/common_utils.js')
-rw-r--r--app/assets/javascripts/lib/utils/common_utils.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js
index 68f92c7f08a..5c249f3068e 100644
--- a/app/assets/javascripts/lib/utils/common_utils.js
+++ b/app/assets/javascripts/lib/utils/common_utils.js
@@ -164,7 +164,7 @@ export const scrollToElement = element => {
if (!(element instanceof $)) {
$el = $(element);
}
- const top = $el.offset().top;
+ const { top } = $el.offset();
return $('body, html').animate(
{
@@ -203,9 +203,7 @@ export const getSelectedFragment = () => {
export const insertText = (target, text) => {
// Firefox doesn't support `document.execCommand('insertText', false, text)` on textareas
- const selectionStart = target.selectionStart;
- const selectionEnd = target.selectionEnd;
- const value = target.value;
+ const { selectionStart, selectionEnd, value } = target;
const textBefore = value.substring(0, selectionStart);
const textAfter = value.substring(selectionEnd, value.length);
@@ -245,7 +243,8 @@ export const nodeMatchesSelector = (node, selector) => {
// IE11 doesn't support `node.matches(selector)`
- let parentNode = node.parentNode;
+ let { parentNode } = node;
+
if (!parentNode) {
parentNode = document.createElement('div');
// eslint-disable-next-line no-param-reassign
@@ -281,6 +280,8 @@ export const normalizeCRLFHeaders = headers => {
headersArray.forEach(header => {
const keyValue = header.split(': ');
+
+ // eslint-disable-next-line prefer-destructuring
headersObject[keyValue[0]] = keyValue[1];
});