Commit 9e5f8dc8 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch 'ps-enable-eslint-no-global-event-off' into 'master'

Add no-global-event-off error to eslint conifg

See merge request gitlab-org/gitlab!49438
parents 80275713 79ed530a
......@@ -42,6 +42,7 @@ rules:
no-jquery/no-serialize: error
promise/always-return: off
promise/no-callback-in-promise: off
"@gitlab/no-global-event-off": error
overrides:
- files:
- '**/spec/**/*'
......
......@@ -74,6 +74,7 @@ export default class Autosave {
}
dispose() {
// eslint-disable-next-line @gitlab/no-global-event-off
this.field.off('input');
}
}
......@@ -596,6 +596,7 @@ export class AwardsHandler {
hideMenuElement($emojiMenu) {
$emojiMenu.on(transitionEndEventString, e => {
if (e.currentTarget === e.target) {
// eslint-disable-next-line @gitlab/no-global-event-off
$emojiMenu.removeClass(IS_RENDERED).off(transitionEndEventString);
}
});
......
......@@ -97,6 +97,7 @@ export default class Shortcuts {
e.preventDefault();
});
// eslint-disable-next-line @gitlab/no-global-event-off
$('.js-shortcuts-modal-trigger')
.off('click')
.on('click', this.onToggleHelp);
......
......@@ -15,6 +15,7 @@ function shouldCreateListGraphQL(label) {
return store.getters.shouldUseGraphQL && !store.getters.getListByLabelId(fullLabelId(label));
}
// eslint-disable-next-line @gitlab/no-global-event-off
$(document)
.off('created.label')
.on('created.label', (e, label, addNewList) => {
......
......@@ -265,13 +265,21 @@ export default class Clusters {
removeListeners() {
eventHub.$off('installApplication', this.installApplication);
eventHub.$off('updateApplication', this.updateApplication);
// eslint-disable-next-line @gitlab/no-global-event-off
eventHub.$off('saveKnativeDomain');
// eslint-disable-next-line @gitlab/no-global-event-off
eventHub.$off('setKnativeDomain');
// eslint-disable-next-line @gitlab/no-global-event-off
eventHub.$off('setCrossplaneProviderStack');
// eslint-disable-next-line @gitlab/no-global-event-off
eventHub.$off('uninstallApplication');
// eslint-disable-next-line @gitlab/no-global-event-off
eventHub.$off('setIngressModSecurityEnabled');
// eslint-disable-next-line @gitlab/no-global-event-off
eventHub.$off('setIngressModSecurityMode');
// eslint-disable-next-line @gitlab/no-global-event-off
eventHub.$off('resetIngressModSecurityChanges');
// eslint-disable-next-line @gitlab/no-global-event-off
eventHub.$off('setFluentdSettings');
}
......
......@@ -72,12 +72,14 @@ export default class ImageFile {
callback(e, left);
};
// eslint-disable-next-line @gitlab/no-global-event-off
$el
.off('mousedown')
.off('touchstart')
.on('mousedown', dragStart)
.on('touchstart', dragStart);
// eslint-disable-next-line @gitlab/no-global-event-off
$body
.off('mouseup')
.off('mousemove')
......
......@@ -14,6 +14,7 @@ function openConfirmDangerModal($form, $modal, text) {
$submit.disable();
$input.focus();
// eslint-disable-next-line @gitlab/no-global-event-off
$input.off('input').on('input', function handleInput() {
const confirmText = rstrip($(this).val());
if (confirmText === confirmTextMatch) {
......@@ -23,6 +24,7 @@ function openConfirmDangerModal($form, $modal, text) {
}
});
// eslint-disable-next-line @gitlab/no-global-event-off
$('.js-confirm-danger-submit', $modal)
.off('click')
.on('click', () => {
......
......@@ -154,6 +154,7 @@ export default {
});
},
beforeDestroy() {
// eslint-disable-next-line @gitlab/no-global-event-off
$(this.$refs.dropdown).off();
},
methods: {
......
......@@ -29,11 +29,17 @@ export default class CreateLabelDropdown {
}
cleanBinding() {
// eslint-disable-next-line @gitlab/no-global-event-off
this.$colorSuggestions.off('click');
// eslint-disable-next-line @gitlab/no-global-event-off
this.$newLabelField.off('keyup change');
// eslint-disable-next-line @gitlab/no-global-event-off
this.$newColorField.off('keyup change');
// eslint-disable-next-line @gitlab/no-global-event-off
this.$dropdownBack.off('click');
// eslint-disable-next-line @gitlab/no-global-event-off
this.$cancelButton.off('click');
// eslint-disable-next-line @gitlab/no-global-event-off
this.$newLabelCreateButton.off('click');
}
......
......@@ -74,6 +74,7 @@ export default () => {
const $dropdown = $('.js-ca-dropdown');
const $label = $dropdown.find('.dropdown-label');
// eslint-disable-next-line @gitlab/no-global-event-off
$dropdown
.find('li a')
.off('click')
......
......@@ -622,6 +622,7 @@ export class GitLabDropdown {
// eslint-disable-next-line class-methods-use-this
removeArrowKeyEvent() {
// eslint-disable-next-line @gitlab/no-global-event-off
return $('body').off('keydown');
}
......
......@@ -93,7 +93,9 @@ export default {
},
beforeDestroy() {
// eslint-disable-next-line @gitlab/no-global-event-off
eventHub.$off('toggleFolder');
// eslint-disable-next-line @gitlab/no-global-event-off
eventHub.$off('toggleDeployBoard');
},
......
......@@ -78,6 +78,7 @@ class GfmAutoComplete {
this.input.each((i, input) => {
const $input = $(input);
if (!$input.hasClass('js-gfm-input-initialized')) {
// eslint-disable-next-line @gitlab/no-global-event-off
$input.off('focus.setupAtWho').on('focus.setupAtWho', this.setupAtWho.bind(this, $input));
$input.on('change.atwho', () => input.dispatchEvent(new Event('input')));
// This triggers at.js again
......
......@@ -80,6 +80,7 @@ export default class GlFieldError {
// hidden when injected into DOM
errorAnchor.after(this.fieldErrorElement);
// eslint-disable-next-line @gitlab/no-global-event-off
this.inputElement.off('invalid').on('invalid', this.handleInvalidSubmit.bind(this));
this.scopedSiblings = this.safelySelectSiblings();
}
......@@ -117,6 +118,7 @@ export default class GlFieldError {
this.form.focusInvalid.apply(this.form);
// For UX, wait til after first invalid submission to check each keyup
// eslint-disable-next-line @gitlab/no-global-event-off
this.inputElement
.off('keyup.fieldValidator')
.on('keyup.fieldValidator', this.updateValidity.bind(this));
......
......@@ -70,8 +70,10 @@ export default class GLForm {
}
setupAutosize() {
// eslint-disable-next-line @gitlab/no-global-event-off
this.textarea.off('autosize:resized').on('autosize:resized', this.setHeightData.bind(this));
// eslint-disable-next-line @gitlab/no-global-event-off
this.textarea.off('mouseup.autosize').on('mouseup.autosize', this.destroyAutosize.bind(this));
setTimeout(() => {
......@@ -97,7 +99,9 @@ export default class GLForm {
}
clearEventListeners() {
// eslint-disable-next-line @gitlab/no-global-event-off
this.textarea.off('focus');
// eslint-disable-next-line @gitlab/no-global-event-off
this.textarea.off('blur');
removeMarkdownListeners(this.form);
}
......
......@@ -30,6 +30,7 @@ export default {
.on('hide.bs.dropdown', () => this.hideDropdown());
},
removeDropdownListeners() {
// eslint-disable-next-line @gitlab/no-global-event-off
$(this.$refs.dropdown)
.off('show.bs.dropdown')
.off('hide.bs.dropdown');
......
......@@ -15,6 +15,7 @@ export default {
},
bindEvents() {
// eslint-disable-next-line @gitlab/no-global-event-off
return this.form.off('submit').on('submit', this.onFormSubmit.bind(this));
},
......
......@@ -215,6 +215,7 @@ export default {
this.fetchIssuables();
},
beforeDestroy() {
// eslint-disable-next-line @gitlab/no-global-event-off
issueableEventHub.$off('issuables:toggleBulkEdit');
},
methods: {
......
......@@ -339,6 +339,7 @@ export function addMarkdownListeners(form) {
Shortcuts.initMarkdownEditorShortcuts($(this), updateTextForToolbarBtn);
});
// eslint-disable-next-line @gitlab/no-global-event-off
const $allToolbarBtns = $('.js-md', form)
.off('click')
.on('click', function() {
......@@ -351,6 +352,7 @@ export function addMarkdownListeners(form) {
}
export function addEditorMarkdownListeners(editor) {
// eslint-disable-next-line @gitlab/no-global-event-off
$('.js-md')
.off('click')
.on('click', e => {
......@@ -376,5 +378,6 @@ export function removeMarkdownListeners(form) {
Shortcuts.removeMarkdownEditorShortcuts($(this));
});
// eslint-disable-next-line @gitlab/no-global-event-off
return $('.js-md', form).off('click');
}
......@@ -77,6 +77,7 @@ if (process.env.NODE_ENV !== 'production' && gon?.test_env) {
document.addEventListener('beforeunload', () => {
// Unbind scroll events
// eslint-disable-next-line @gitlab/no-global-event-off
$(document).off('scroll');
// Close any open tooltips
tooltips.dispose(document.querySelectorAll('.has-tooltip, [data-toggle="tooltip"]'));
......
......@@ -11,9 +11,11 @@ export default class Members {
}
addListeners() {
// eslint-disable-next-line @gitlab/no-global-event-off
$('.js-member-update-control')
.off('change')
.on('change', this.formSubmit.bind(this));
// eslint-disable-next-line @gitlab/no-global-event-off
$('.js-edit-member-form')
.off('ajax:success')
.on('ajax:success', this.formSuccess.bind(this));
......
......@@ -39,6 +39,7 @@ export default class MirrorRepos {
initMirrorSSH() {
if (this.$password) {
// eslint-disable-next-line @gitlab/no-global-event-off
this.$password.off('input.updateUrl');
}
this.$password = undefined;
......
......@@ -185,10 +185,15 @@ export default class SSHMirror {
}
destroy() {
// eslint-disable-next-line @gitlab/no-global-event-off
this.$repositoryUrl.off('keyup');
// eslint-disable-next-line @gitlab/no-global-event-off
this.$form.find('.js-known-hosts').off('keyup');
// eslint-disable-next-line @gitlab/no-global-event-off
this.$dropdownAuthType.off('change');
// eslint-disable-next-line @gitlab/no-global-event-off
this.$btnDetectHostKeys.off('click');
// eslint-disable-next-line @gitlab/no-global-event-off
this.$btnSSHHostsShowAdvanced.off('click');
}
}
......@@ -367,6 +367,7 @@ export default {
},
);
// eslint-disable-next-line @gitlab/no-global-event-off
eChart.off('datazoom');
eChart.on('datazoom', this.throttledDatazoom);
},
......
......@@ -187,6 +187,7 @@ export default class Notes {
this.$wrapperEl.off('click', '.js-discussion-reply-button');
this.$wrapperEl.off('click', '.js-add-diff-note-button');
this.$wrapperEl.off('click', '.js-add-image-diff-note-button');
// eslint-disable-next-line @gitlab/no-global-event-off
this.$wrapperEl.off('visibilitychange');
this.$wrapperEl.off('keyup input', '.js-note-text');
this.$wrapperEl.off('click', '.js-note-target-reopen');
......
......@@ -72,6 +72,7 @@ export default {
},
initLoadMore() {
// eslint-disable-next-line @gitlab/no-global-event-off
$(document).off('scroll');
$(document).endlessScroll({
bottomPixels: ENDLESS_SCROLL_BOTTOM_PX,
......
......@@ -55,6 +55,7 @@ export default class ProjectFindFile {
}
initEvent() {
// eslint-disable-next-line @gitlab/no-global-event-off
this.inputElement.off('keyup');
this.inputElement.on('keyup', event => {
const target = $(event.target);
......
......@@ -26,12 +26,14 @@ const onProjectPathChange = ($projectNameInput, $projectPathInput, hasExistingPr
};
const setProjectNamePathHandlers = ($projectNameInput, $projectPathInput) => {
// eslint-disable-next-line @gitlab/no-global-event-off
$projectNameInput.off('keyup change').on('keyup change', () => {
onProjectNameChange($projectNameInput, $projectPathInput);
hasUserDefinedProjectName = $projectNameInput.val().trim().length > 0;
hasUserDefinedProjectPath = $projectPathInput.val().trim().length > 0;
});
// eslint-disable-next-line @gitlab/no-global-event-off
$projectPathInput.off('keyup change').on('keyup change', () => {
onProjectPathChange($projectNameInput, $projectPathInput, hasUserDefinedProjectName);
hasUserDefinedProjectPath = $projectPathInput.val().trim().length > 0;
......@@ -137,6 +139,7 @@ const bindEvents = () => {
target.focus();
})
.on('hide.bs.popover', () => {
// eslint-disable-next-line @gitlab/no-global-event-off
$(document).off('click.popover touchstart.popover');
});
}
......
......@@ -97,7 +97,9 @@ export default {
},
beforeDestroy() {
const $input = $(this.$refs.input);
// eslint-disable-next-line @gitlab/no-global-event-off
$input.off('shown-issues.atwho');
// eslint-disable-next-line @gitlab/no-global-event-off
$input.off('hidden-issues.atwho');
$input.off('inserted-issues.atwho', this.onInput);
},
......
......@@ -23,8 +23,11 @@ Sidebar.initialize = function() {
Sidebar.prototype.removeListeners = function() {
this.sidebar.off('click', '.sidebar-collapsed-icon');
// eslint-disable-next-line @gitlab/no-global-event-off
this.sidebar.off('hidden.gl.dropdown');
// eslint-disable-next-line @gitlab/no-global-event-off
$('.dropdown').off('loading.gl.dropdown');
// eslint-disable-next-line @gitlab/no-global-event-off
$('.dropdown').off('loaded.gl.dropdown');
$(document).off('click', '.js-sidebar-toggle');
};
......
......@@ -3,6 +3,7 @@ import { __ } from './locale';
function expandSection($section) {
$section.find('.js-settings-toggle:not(.js-settings-toggle-trigger-only)').text(__('Collapse'));
// eslint-disable-next-line @gitlab/no-global-event-off
$section
.find('.settings-content')
.off('scroll.expandSection')
......
......@@ -95,6 +95,7 @@ export default class SmartInterval {
window.removeEventListener('blur', this.onWindowVisibilityChange);
window.removeEventListener('focus', this.onWindowVisibilityChange);
this.cancel();
// eslint-disable-next-line @gitlab/no-global-event-off
$(document)
.off('visibilitychange')
.off('beforeunload');
......
......@@ -25,6 +25,7 @@ export default class GLTerminal {
this.setSocketUrl();
this.createTerminal();
// eslint-disable-next-line @gitlab/no-global-event-off
$(window)
.off('resize.terminal')
.on('resize.terminal', () => {
......@@ -104,6 +105,7 @@ export default class GLTerminal {
}
dispose() {
// eslint-disable-next-line @gitlab/no-global-event-off
this.terminal.off('data');
this.terminal.dispose();
this.socket.close();
......
export default class VersionCheckImage {
static bindErrorEvent(imageElement) {
// eslint-disable-next-line @gitlab/no-global-event-off
imageElement.off('error').on('error', () => imageElement.hide());
}
}
......@@ -8,9 +8,11 @@ export default class MembersEE extends Members {
addListeners() {
super.addListeners();
// eslint-disable-next-line @gitlab/no-global-event-off
$('.js-ldap-permissions')
.off('click')
.on('click', this.showLDAPPermissionsWarning.bind(this));
// eslint-disable-next-line @gitlab/no-global-event-off
$('.js-ldap-override')
.off('click')
.on('click', this.toggleMemberAccessToggle.bind(this));
......
......@@ -118,7 +118,9 @@ export default {
});
},
beforeDestroy() {
// eslint-disable-next-line @gitlab/no-global-event-off
$(document).off('zen_mode:enter');
// eslint-disable-next-line @gitlab/no-global-event-off
$(document).off('zen_mode:leave');
},
methods: {
......
......@@ -60,6 +60,7 @@ export default {
accordionEventBus.$on(this.closeOtherItemsEvent, this.onCloseOtherAccordionItems);
},
destroyed() {
// eslint-disable-next-line @gitlab/no-global-event-off
accordionEventBus.$off(this.closeOtherItemsEvent);
},
methods: {
......
......@@ -25,3 +25,6 @@ rules:
- 'testAction'
jest/no-test-callback:
- off
"@gitlab/no-global-event-off":
- off
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment