Skip to content
Snippets Groups Projects
Commit 23cdae8e authored by gfyoung's avatar gfyoung
Browse files

Enable "prefer-destructuring" in JS files

Partially addresses #47006.
parent d38eb9bb
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Showing
with 22 additions and 24 deletions
Loading
Loading
@@ -69,5 +69,3 @@ rules:
FunctionExpression:
parameters: 1
body: 1
## Destructuring: https://eslint.org/docs/rules/prefer-destructuring
prefer-destructuring: off
Loading
Loading
@@ -26,7 +26,7 @@ export default class AjaxLoadingSpinner {
}
 
static toggleLoadingIcon(iconElement) {
const classList = iconElement.classList;
const { classList } = iconElement;
classList.toggle(iconElement.dataset.icon);
classList.toggle('fa-spinner');
classList.toggle('fa-spin');
Loading
Loading
Loading
Loading
@@ -52,7 +52,7 @@ export default function initCopyToClipboard() {
* data types to the intended values.
*/
$(document).on('copy', 'body > textarea[readonly]', (e) => {
const clipboardData = e.originalEvent.clipboardData;
const { clipboardData } = e.originalEvent;
if (!clipboardData) return;
 
const text = e.target.value;
Loading
Loading
Loading
Loading
@@ -321,7 +321,7 @@ export class CopyAsGFM {
}
 
static copyAsGFM(e, transformer) {
const clipboardData = e.originalEvent.clipboardData;
const { clipboardData } = e.originalEvent;
if (!clipboardData) return;
 
const documentFragment = getSelectedFragment();
Loading
Loading
@@ -338,7 +338,7 @@ export class CopyAsGFM {
}
 
static pasteGFM(e) {
const clipboardData = e.originalEvent.clipboardData;
const { clipboardData } = e.originalEvent;
if (!clipboardData) return;
 
const text = clipboardData.getData('text/plain');
Loading
Loading
Loading
Loading
@@ -84,7 +84,7 @@ class BalsamiqViewer {
renderTemplate(preview) {
const resource = this.getResource(preview.resourceID);
const name = BalsamiqViewer.parseTitle(resource);
const image = preview.image;
const { image } = preview;
 
const template = PREVIEW_TEMPLATE({
name,
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ export default function loadBalsamiqFile() {
 
if (!(viewer instanceof Element)) return;
 
const endpoint = viewer.dataset.endpoint;
const { endpoint } = viewer.dataset;
 
const balsamiqViewer = new BalsamiqViewer(viewer);
balsamiqViewer.loadFile(endpoint).catch(onError);
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ export default () => {
 
[].slice.call(document.querySelectorAll('.js-material-changer')).forEach((el) => {
el.addEventListener('click', (e) => {
const target = e.target;
const { target } = e;
 
e.preventDefault();
 
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@
},
methods: {
removeIssue() {
const issue = this.issue;
const { issue } = this;
const lists = issue.getLists();
const listLabelIds = lists.map(list => list.label.id);
 
Loading
Loading
Loading
Loading
@@ -121,7 +121,7 @@ export default () => {
this.filterManager.updateTokens();
},
updateDetailIssue(newIssue) {
const sidebarInfoEndpoint = newIssue.sidebarInfoEndpoint;
const { sidebarInfoEndpoint } = newIssue;
if (sidebarInfoEndpoint && newIssue.subscribed === undefined) {
newIssue.setFetchingState('subscriptions', true);
BoardService.getIssueInfo(sidebarInfoEndpoint)
Loading
Loading
@@ -144,7 +144,7 @@ export default () => {
Store.detail.issue = {};
},
toggleSubscription(id) {
const issue = Store.detail.issue;
const { issue } = Store.detail;
if (issue.id === id && issue.toggleSubscriptionEndpoint) {
issue.setFetchingState('subscriptions', true);
BoardService.toggleIssueSubscription(issue.toggleSubscriptionEndpoint)
Loading
Loading
Loading
Loading
@@ -26,7 +26,7 @@ class ModalStore {
 
toggleIssue(issueObj) {
const issue = issueObj;
const selected = issue.selected;
const { selected } = issue;
 
issue.selected = !selected;
 
Loading
Loading
Loading
Loading
@@ -81,7 +81,7 @@ export default class Clusters {
}
 
initApplications() {
const store = this.store;
const { store } = this;
const el = document.querySelector('#js-cluster-applications');
 
this.applications = new Vue({
Loading
Loading
Loading
Loading
@@ -122,7 +122,7 @@ export default class ImageFile {
return $('.swipe.view', this.file).each((function(_this) {
return function(index, view) {
var $swipeWrap, $swipeBar, $swipeFrame, wrapPadding, ref;
ref = _this.prepareFrames(view), maxWidth = ref[0], maxHeight = ref[1];
ref = _this.prepareFrames(view), [maxWidth, maxHeight] = ref;
$swipeFrame = $('.swipe-frame', view);
$swipeWrap = $('.swipe-wrap', view);
$swipeBar = $('.swipe-bar', view);
Loading
Loading
@@ -159,7 +159,7 @@ export default class ImageFile {
return $('.onion-skin.view', this.file).each((function(_this) {
return function(index, view) {
var $frame, $track, $dragger, $frameAdded, framePadding, ref, dragging = false;
ref = _this.prepareFrames(view), maxWidth = ref[0], maxHeight = ref[1];
ref = _this.prepareFrames(view), [maxWidth, maxHeight] = ref;
$frame = $('.onion-skin-frame', view);
$frameAdded = $('.frame.added', view);
$track = $('.drag-track', view);
Loading
Loading
Loading
Loading
@@ -281,7 +281,7 @@ export default class CreateMergeRequestDropdown {
 
if (event.target === this.branchInput) {
target = 'branch';
value = this.branchInput.value;
({ value } = this.branchInput);
} else if (event.target === this.refInput) {
target = 'ref';
value =
Loading
Loading
Loading
Loading
@@ -111,7 +111,7 @@ const DiffNoteAvatars = Vue.extend({
});
},
addNoCommentClass() {
const notesCount = this.notesCount;
const { notesCount } = this;
 
$(this.$el).closest('.js-avatar-container')
.toggleClass('no-comment-btn', notesCount > 0)
Loading
Loading
Loading
Loading
@@ -73,7 +73,7 @@ const JumpToDiscussion = Vue.extend({
}).toArray();
};
 
const discussions = this.discussions;
const { discussions } = this;
 
if (activeTab === 'diffs') {
discussionsSelector = '.diffs .notes[data-discussion-id]';
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ import './components/new_issue_for_discussion';
export default () => {
const projectPathHolder =
document.querySelector('.merge-request') || document.querySelector('.commit-box');
const projectPath = projectPathHolder.dataset.projectPath;
const { projectPath } = projectPathHolder.dataset;
const COMPONENT_SELECTOR =
'resolve-btn, resolve-discussion-btn, jump-to-discussion, comment-and-resolve-btn, new-issue-for-discussion-btn';
 
Loading
Loading
Loading
Loading
@@ -47,7 +47,7 @@ export default {
methods: {
...mapActions(['toggleDiscussion']),
getTooltipText(noteData) {
let note = noteData.note;
let { note } = noteData;
 
if (note.length > LENGTH_OF_AVATAR_TOOLTIP) {
note = truncate(note, LENGTH_OF_AVATAR_TOOLTIP);
Loading
Loading
Loading
Loading
@@ -124,7 +124,7 @@ export default {
const newLineNumber = this.metaData.newPos || 0;
const offset = newLineNumber - oldLineNumber;
const bottom = this.isBottom;
const fileHash = this.fileHash;
const { fileHash } = this;
const view = this.diffViewType;
let unfold = true;
let lineNumber = newLineNumber - 1;
Loading
Loading
Loading
Loading
@@ -89,7 +89,7 @@ export default {
return isLeftExpanded || isRightExpanded;
},
getLineCode(line, side) {
const lineCode = side.lineCode;
const { lineCode } = side;
if (lineCode) {
return lineCode;
}
Loading
Loading
Loading
Loading
@@ -292,7 +292,7 @@
if (this.model &&
this.model.last_deployment &&
this.model.last_deployment.deployable) {
const deployable = this.model.last_deployment.deployable;
const { deployable } = this.model.last_deployment;
return `${deployable.name} #${deployable.id}`;
}
return '';
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment