Enable no-restricted-globals in JS files
This commit is contained in:
parent
72770e609d
commit
bce890820f
42 changed files with 55 additions and 53 deletions
|
@ -71,7 +71,5 @@ rules:
|
|||
body: 1
|
||||
## Destructuring: https://eslint.org/docs/rules/prefer-destructuring
|
||||
prefer-destructuring: off
|
||||
## no-restricted-globals: https://eslint.org/docs/rules/no-restricted-globals
|
||||
no-restricted-globals: off
|
||||
## no-multi-assign: https://eslint.org/docs/rules/no-multi-assign
|
||||
no-multi-assign: off
|
||||
|
|
|
@ -70,7 +70,7 @@ export default class BlobViewer {
|
|||
const initialViewer = this.$fileHolder[0].querySelector('.blob-viewer:not(.hidden)');
|
||||
let initialViewerName = initialViewer.getAttribute('data-type');
|
||||
|
||||
if (this.switcher && location.hash.indexOf('#L') === 0) {
|
||||
if (this.switcher && window.location.hash.indexOf('#L') === 0) {
|
||||
initialViewerName = 'simple';
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ gl.issueBoards.BoardDelete = Vue.extend({
|
|||
deleteBoard () {
|
||||
$(this.$el).tooltip('hide');
|
||||
|
||||
if (confirm('Are you sure you want to delete this list?')) {
|
||||
if (window.confirm('Are you sure you want to delete this list?')) {
|
||||
this.list.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,6 @@ gl.issueBoards.BoardsStore = {
|
|||
return filteredList[0];
|
||||
},
|
||||
updateFiltersUrl () {
|
||||
history.pushState(null, null, `?${this.filter.path}`);
|
||||
window.history.pushState(null, null, `?${this.filter.path}`);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -45,7 +45,7 @@ export default class CommitsList {
|
|||
this.content.fadeTo('fast', 1.0);
|
||||
|
||||
// Change url so if user reload a page - search results are saved
|
||||
history.replaceState({
|
||||
window.history.replaceState({
|
||||
page: commitsUrl,
|
||||
}, document.title, commitsUrl);
|
||||
})
|
||||
|
|
|
@ -98,7 +98,7 @@ export default {
|
|||
},
|
||||
disableKey(deployKey, callback) {
|
||||
// eslint-disable-next-line no-alert
|
||||
if (confirm(s__('DeployKeys|You are going to remove this deploy key. Are you sure?'))) {
|
||||
if (window.confirm(s__('DeployKeys|You are going to remove this deploy key. Are you sure?'))) {
|
||||
this.service
|
||||
.disableKey(deployKey.id)
|
||||
.then(this.fetchKeys)
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
methods: {
|
||||
onClick() {
|
||||
// eslint-disable-next-line no-alert
|
||||
if (confirm('Are you sure you want to stop this environment?')) {
|
||||
if (window.confirm('Are you sure you want to stop this environment?')) {
|
||||
this.isLoading = true;
|
||||
|
||||
$(this.$el).tooltip('dispose');
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { computeDiff } from './diff';
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
self.addEventListener('message', (e) => {
|
||||
const data = e.data;
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
self.postMessage({
|
||||
path: data.path,
|
||||
changes: computeDiff(data.originalContent, data.newContent),
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { viewerInformationForPath } from '~/vue_shared/components/content_viewer/lib/viewer_utils';
|
||||
import { decorateData, sortTree } from '../utils';
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
self.addEventListener('message', e => {
|
||||
const { data, projectId, branchId, tempFile = false, content = '', base64 = false } = e.data;
|
||||
|
||||
|
@ -89,6 +90,7 @@ self.addEventListener('message', e => {
|
|||
return acc;
|
||||
}, {});
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
self.postMessage({
|
||||
entries,
|
||||
treeList: sortTree(treeList),
|
||||
|
|
|
@ -226,7 +226,7 @@
|
|||
.then(res => res.data)
|
||||
.then(data => this.checkForSpam(data))
|
||||
.then((data) => {
|
||||
if (location.pathname !== data.web_url) {
|
||||
if (window.location.pathname !== data.web_url) {
|
||||
visitUrl(data.web_url);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
},
|
||||
deleteIssuable() {
|
||||
// eslint-disable-next-line no-alert
|
||||
if (confirm('Issue will be removed! Are you sure?')) {
|
||||
if (window.confirm('Issue will be removed! Are you sure?')) {
|
||||
this.deleteLoading = true;
|
||||
|
||||
eventHub.$emit('delete.issuable');
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
export default {
|
||||
computed: {
|
||||
currentPath() {
|
||||
return location.pathname;
|
||||
return window.location.pathname;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -44,8 +44,8 @@ export default class LazyLoader {
|
|||
requestAnimationFrame(() => this.checkElementsInView());
|
||||
}
|
||||
checkElementsInView() {
|
||||
const scrollTop = pageYOffset;
|
||||
const visHeight = scrollTop + innerHeight + SCROLL_THRESHOLD;
|
||||
const scrollTop = window.pageYOffset;
|
||||
const visHeight = scrollTop + window.innerHeight + SCROLL_THRESHOLD;
|
||||
|
||||
// Loading Images which are in the current viewport or close to them
|
||||
this.lazyImages = this.lazyImages.filter((selectedImage) => {
|
||||
|
|
|
@ -93,7 +93,7 @@ export default class LinkedTabs {
|
|||
|
||||
const newState = `${copySource}${this.currentLocation.search}${this.currentLocation.hash}`;
|
||||
|
||||
history.replaceState({
|
||||
window.history.replaceState({
|
||||
url: newState,
|
||||
}, document.title, newState);
|
||||
return newState;
|
||||
|
|
|
@ -12,7 +12,7 @@ export function formatRelevantDigits(number) {
|
|||
let digitsLeft = '';
|
||||
let relevantDigits = 0;
|
||||
let formattedNumber = '';
|
||||
if (!isNaN(Number(number))) {
|
||||
if (!Number.isNaN(Number(number))) {
|
||||
digitsLeft = number.toString().split('.')[0];
|
||||
switch (digitsLeft.length) {
|
||||
case 1:
|
||||
|
|
|
@ -35,7 +35,7 @@ const LineHighlighter = function(options = {}) {
|
|||
options.highlightLineClass = options.highlightLineClass || 'hll';
|
||||
options.fileHolderSelector = options.fileHolderSelector || '.file-holder';
|
||||
options.scrollFileHolder = options.scrollFileHolder || false;
|
||||
options.hash = options.hash || location.hash;
|
||||
options.hash = options.hash || window.location.hash;
|
||||
|
||||
this.options = options;
|
||||
this._hash = options.hash;
|
||||
|
@ -170,7 +170,7 @@ LineHighlighter.prototype.setHash = function(firstLineNumber, lastLineNumber) {
|
|||
//
|
||||
// This method is stubbed in tests.
|
||||
LineHighlighter.prototype.__setLocationHash__ = function(value) {
|
||||
return history.pushState({
|
||||
return window.history.pushState({
|
||||
url: value
|
||||
// We're using pushState instead of assigning location.hash directly to
|
||||
// prevent the page from scrolling on the hashchange event
|
||||
|
|
|
@ -18,13 +18,13 @@ export default class Milestone {
|
|||
return $('a[data-toggle="tab"]').on('show.bs.tab', (e) => {
|
||||
const $target = $(e.target);
|
||||
|
||||
location.hash = $target.attr('href');
|
||||
window.location.hash = $target.attr('href');
|
||||
this.loadTab($target);
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
loadInitialTab() {
|
||||
const $target = $(`.js-milestone-tabs a[href="${location.hash}"]`);
|
||||
const $target = $(`.js-milestone-tabs a[href="${window.location.hash}"]`);
|
||||
|
||||
if ($target.length) {
|
||||
$target.tab('show');
|
||||
|
|
|
@ -97,7 +97,7 @@ export default {
|
|||
? this.deploymentFlagData.seriesIndex
|
||||
: indexFromCoordinates;
|
||||
const value = series.values[index] && series.values[index].value;
|
||||
if (isNaN(value)) {
|
||||
if (Number.isNaN(value)) {
|
||||
return '-';
|
||||
}
|
||||
return `${formatRelevantDigits(value)}${this.unitOfDisplay}`;
|
||||
|
|
|
@ -73,7 +73,7 @@ function queryTimeSeries(query, graphWidth, graphHeight, graphHeightOffset, xDom
|
|||
timeSeriesScaleX.ticks(d3.timeMinute, 60);
|
||||
timeSeriesScaleY.domain(yDom);
|
||||
|
||||
const defined = d => !isNaN(d.value) && d.value != null;
|
||||
const defined = d => !Number.isNaN(d.value) && d.value != null;
|
||||
|
||||
const lineFunction = d3
|
||||
.line()
|
||||
|
|
|
@ -315,7 +315,7 @@ export default class Notes {
|
|||
if (discussionNoteForm.length) {
|
||||
if ($textarea.val() !== '') {
|
||||
if (
|
||||
!confirm('Are you sure you want to cancel creating this comment?')
|
||||
!window.confirm('Are you sure you want to cancel creating this comment?')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ export default class Notes {
|
|||
newText = $textarea.val();
|
||||
if (originalText !== newText) {
|
||||
if (
|
||||
!confirm('Are you sure you want to cancel editing this comment?')
|
||||
!window.confirm('Are you sure you want to cancel editing this comment?')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ export default {
|
|||
const msg = 'Are you sure you want to cancel creating this comment?';
|
||||
|
||||
// eslint-disable-next-line no-alert
|
||||
if (!confirm(msg)) {
|
||||
if (!window.confirm(msg)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ export default {
|
|||
},
|
||||
deleteHandler() {
|
||||
// eslint-disable-next-line no-alert
|
||||
if (confirm('Are you sure you want to delete this comment?')) {
|
||||
if (window.confirm('Are you sure you want to delete this comment?')) {
|
||||
this.isDeleting = true;
|
||||
|
||||
this.deleteNote(this.note)
|
||||
|
@ -129,7 +129,7 @@ export default {
|
|||
formCancelHandler(shouldConfirm, isDirty) {
|
||||
if (shouldConfirm && isDirty) {
|
||||
// eslint-disable-next-line no-alert
|
||||
if (!confirm('Are you sure you want to cancel editing this comment?'))
|
||||
if (!window.confirm('Are you sure you want to cancel editing this comment?'))
|
||||
return;
|
||||
}
|
||||
this.$refs.noteBody.resetAutoSave();
|
||||
|
|
|
@ -187,7 +187,7 @@ export default class UserTabs {
|
|||
let newState = source;
|
||||
newState = newState.replace(/\/+$/, '');
|
||||
newState += this.windowLocation.search + this.windowLocation.hash;
|
||||
history.replaceState(
|
||||
window.history.replaceState(
|
||||
{
|
||||
url: newState,
|
||||
},
|
||||
|
|
|
@ -150,7 +150,7 @@ export default class ProjectFindFile {
|
|||
}
|
||||
|
||||
goToTree() {
|
||||
return location.href = this.options.treeUrl;
|
||||
return window.location.href = this.options.treeUrl;
|
||||
}
|
||||
|
||||
goToBlob() {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { visitUrl } from './lib/utils/url_utility';
|
|||
|
||||
export default function projectImport() {
|
||||
setTimeout(() => {
|
||||
visitUrl(location.href);
|
||||
visitUrl(window.location.href);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
|
|
|
@ -438,7 +438,7 @@ export default class SearchAutocomplete {
|
|||
}
|
||||
|
||||
onClick(item, $el, e) {
|
||||
if (location.pathname.indexOf(item.url) !== -1) {
|
||||
if (window.location.pathname.indexOf(item.url) !== -1) {
|
||||
if (!e.metaKey) e.preventDefault();
|
||||
if (!this.badgePresent) {
|
||||
if (item.category === 'Projects') {
|
||||
|
|
|
@ -42,8 +42,8 @@ export default function initSettingsPanels() {
|
|||
}
|
||||
});
|
||||
|
||||
if (location.hash) {
|
||||
const $target = $(location.hash);
|
||||
if (window.location.hash) {
|
||||
const $target = $(window.location.hash);
|
||||
if ($target.length && $target.hasClass('settings')) {
|
||||
expandSection($target);
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ export default class ShortcutsFindFile extends ShortcutsNavigation {
|
|||
element === this.projectFindFile.inputElement[0] &&
|
||||
(combo === 'up' || combo === 'down' || combo === 'esc' || combo === 'enter')
|
||||
) {
|
||||
// when press up/down key in textbox, cusor prevent to move to home/end
|
||||
event.preventDefault();
|
||||
// when press up/down key in textbox, cursor prevent to move to home/end
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ export default {
|
|||
updateConfidentialAttribute(confidential) {
|
||||
this.service
|
||||
.update('issue', { confidential })
|
||||
.then(() => location.reload())
|
||||
.then(() => window.location.reload())
|
||||
.catch(() => {
|
||||
Flash(
|
||||
__(
|
||||
|
|
|
@ -76,7 +76,7 @@ export default {
|
|||
.update(this.issuableType, {
|
||||
discussion_locked: locked,
|
||||
})
|
||||
.then(() => location.reload())
|
||||
.then(() => window.location.reload())
|
||||
.catch(() =>
|
||||
Flash(
|
||||
this.__(
|
||||
|
|
|
@ -80,7 +80,7 @@ export default class SidebarMediator {
|
|||
return this.service.moveIssue(this.store.moveToProjectId)
|
||||
.then(response => response.json())
|
||||
.then((data) => {
|
||||
if (location.pathname !== data.web_url) {
|
||||
if (window.location.pathname !== data.web_url) {
|
||||
visitUrl(data.web_url);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export default () => {
|
||||
const { protocol, host, pathname } = location;
|
||||
const { protocol, host, pathname } = window.location;
|
||||
const shareBtn = document.querySelector('.js-share-btn');
|
||||
const embedBtn = document.querySelector('.js-embed-btn');
|
||||
const snippetUrlArea = document.querySelector('.js-snippet-url-area');
|
||||
|
|
|
@ -32,7 +32,7 @@ describe('Blob viewer', () => {
|
|||
|
||||
afterEach(() => {
|
||||
mock.restore();
|
||||
location.hash = '';
|
||||
window.location.hash = '';
|
||||
});
|
||||
|
||||
it('loads source file after switching views', (done) => {
|
||||
|
@ -49,7 +49,7 @@ describe('Blob viewer', () => {
|
|||
});
|
||||
|
||||
it('loads source file when line number is in hash', (done) => {
|
||||
location.hash = '#L1';
|
||||
window.location.hash = '#L1';
|
||||
|
||||
new BlobViewer();
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import LinkedTabs from '~/lib/utils/bootstrap_linked_tabs';
|
|||
|
||||
describe('on click', () => {
|
||||
it('should change the url according to the clicked tab', () => {
|
||||
const historySpy = spyOn(history, 'replaceState').and.callFake(() => {});
|
||||
const historySpy = spyOn(window.history, 'replaceState').and.callFake(() => {});
|
||||
|
||||
const linkedTabs = new LinkedTabs({
|
||||
action: 'show',
|
||||
|
|
|
@ -56,7 +56,7 @@ describe('Commits List', () => {
|
|||
beforeEach(() => {
|
||||
commitsList.searchField.val('');
|
||||
|
||||
spyOn(history, 'replaceState').and.stub();
|
||||
spyOn(window.history, 'replaceState').and.stub();
|
||||
mock = new MockAdapter(axios);
|
||||
|
||||
mock.onGet('/h5bp/html5-boilerplate/commits/master').reply(200, {
|
||||
|
|
|
@ -220,7 +220,7 @@ describe('Environment', () => {
|
|||
);
|
||||
|
||||
component = mountComponent(EnvironmentsComponent, mockData);
|
||||
spyOn(history, 'pushState').and.stub();
|
||||
spyOn(window.history, 'pushState').and.stub();
|
||||
});
|
||||
|
||||
describe('updateContent', () => {
|
||||
|
|
|
@ -177,7 +177,7 @@ describe('Environments Folder View', () => {
|
|||
});
|
||||
|
||||
component = mountComponent(Component, mockData);
|
||||
spyOn(history, 'pushState').and.stub();
|
||||
spyOn(window.history, 'pushState').and.stub();
|
||||
});
|
||||
|
||||
describe('updateContent', () => {
|
||||
|
|
|
@ -166,12 +166,12 @@ describe('IDE store file actions', () => {
|
|||
});
|
||||
|
||||
it('resets location.hash for line highlighting', done => {
|
||||
location.hash = 'test';
|
||||
window.location.hash = 'test';
|
||||
|
||||
store
|
||||
.dispatch('setFileActive', localFile.path)
|
||||
.then(() => {
|
||||
expect(location.hash).not.toBe('test');
|
||||
expect(window.location.hash).not.toBe('test');
|
||||
|
||||
done();
|
||||
})
|
||||
|
|
|
@ -145,7 +145,7 @@ describe('Issuable output', () => {
|
|||
resolve({
|
||||
data: {
|
||||
confidential: false,
|
||||
web_url: location.pathname,
|
||||
web_url: window.location.pathname,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
@ -177,7 +177,7 @@ describe('Issuable output', () => {
|
|||
spyOn(vm.service, 'updateIssuable').and.callFake(() => new Promise((resolve) => {
|
||||
resolve({
|
||||
data: {
|
||||
web_url: location.pathname,
|
||||
web_url: window.location.pathname,
|
||||
confidential: vm.isConfidential,
|
||||
},
|
||||
});
|
||||
|
|
|
@ -40,13 +40,13 @@ describe('common_utils', () => {
|
|||
});
|
||||
|
||||
it('should decode params', () => {
|
||||
history.pushState('', '', '?label_name%5B%5D=test');
|
||||
window.history.pushState('', '', '?label_name%5B%5D=test');
|
||||
|
||||
expect(
|
||||
commonUtils.getUrlParamsArray()[0],
|
||||
).toBe('label_name[]=test');
|
||||
|
||||
history.pushState('', '', '?');
|
||||
window.history.pushState('', '', '?');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -427,7 +427,7 @@ describe('Pipelines', () => {
|
|||
|
||||
describe('methods', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(history, 'pushState').and.stub();
|
||||
spyOn(window.history, 'pushState').and.stub();
|
||||
});
|
||||
|
||||
describe('updateContent', () => {
|
||||
|
|
|
@ -9,11 +9,11 @@ describe('Settings Panels', () => {
|
|||
|
||||
describe('initSettingsPane', () => {
|
||||
afterEach(() => {
|
||||
location.hash = '';
|
||||
window.location.hash = '';
|
||||
});
|
||||
|
||||
it('should expand linked hash fragment panel', () => {
|
||||
location.hash = '#autodevops-settings';
|
||||
window.location.hash = '#autodevops-settings';
|
||||
|
||||
const pipelineSettingsPanel = document.querySelector('#autodevops-settings');
|
||||
// Our test environment automatically expands everything so we need to clear that out first
|
||||
|
|
Loading…
Reference in a new issue