Commit 06329078 authored by Lukas 'Eipi' Eipert's avatar Lukas 'Eipi' Eipert

Merge branch 'master' into 'leipert-prettier-arrow-parens-8'

# Conflicts:
#   .prettierignore
parents cfb36828 0e800cbb
......@@ -9,6 +9,7 @@ Set the title to: `Description of the original issue`
## Prior to starting the security release work
- [ ] Read the [security process for developers] if you are not familiar with it.
- Verify if the issue you're working on `gitlab-org/gitlab` is confidential, if it's public fix should be placed on GitLab canonical and no backports are required.
- [ ] Mark this [issue as related] to the Security Release Tracking Issue. You can find it on the topic of the `#releases` Slack channel.
- Fill out the [Links section](#links):
- [ ] Next to **Issue on GitLab**, add a link to the `gitlab-org/gitlab` issue that describes the security vulnerability.
......
This diff is collapsed.
import Vue from 'vue';
import ExpiresAtField from './components/expires_at_field.vue';
const getInputAttrs = el => {
const getInputAttrs = (el) => {
const input = el.querySelector('input');
return {
......
......@@ -9,9 +9,9 @@ export default class Activities {
constructor(container = '') {
this.container = container;
Pager.init(20, true, false, data => data, this.updateTooltips, this.container);
Pager.init(20, true, false, (data) => data, this.updateTooltips, this.container);
$('.event-filter-link').on('click', e => {
$('.event-filter-link').on('click', (e) => {
e.preventDefault();
this.toggleFilter(e.currentTarget);
this.reloadActivities();
......@@ -24,7 +24,7 @@ export default class Activities {
reloadActivities() {
$('.content_list').html('');
Pager.init(20, true, false, data => data, this.updateTooltips, this.container);
Pager.init(20, true, false, (data) => data, this.updateTooltips, this.container);
}
toggleFilter(sender) {
......
......@@ -61,14 +61,14 @@ export default {
},
},
selectedCommitsCount() {
return this.selectedCommits.filter(selectedCommit => selectedCommit.isSelected).length;
return this.selectedCommits.filter((selectedCommit) => selectedCommit.isSelected).length;
},
shouldPurge() {
return this.selectedCommitsCount !== this.selectedCommits.length;
},
uniqueCommits() {
return this.selectedCommits.filter(
selectedCommit =>
(selectedCommit) =>
selectedCommit.isSelected &&
findCommitIndex(this.contextCommits, selectedCommit.short_id) === -1,
);
......@@ -126,7 +126,7 @@ export default {
this.focusSearch();
if (this.shouldPurge) {
this.setSelectedCommits(
[...this.commits, ...this.selectedCommits].filter(commit => commit.isSelected),
[...this.commits, ...this.selectedCommits].filter((commit) => commit.isSelected),
);
}
}
......@@ -178,7 +178,7 @@ export default {
this.setCommits({ commits: tempCommits });
this.setSelectedCommits([
...tempSelectedCommits,
...tempCommits.filter(commit => commit.isSelected),
...tempCommits.filter((commit) => commit.isSelected),
]);
},
handleCreateContextCommits() {
......@@ -186,7 +186,7 @@ export default {
return Promise.all([
this.createContextCommits({ commits: this.uniqueCommits }),
this.removeContextCommits(),
]).then(values => {
]).then((values) => {
if (values[0] || values[1]) {
window.location.reload();
}
......
......@@ -27,10 +27,10 @@ export const searchCommits = ({ dispatch, commit, state }, searchText) => {
return axios
.get(state.contextCommitsPath, params)
.then(({ data }) => {
let commits = data.map(o => ({ ...o, isSelected: false }));
commits = commits.map(c => {
let commits = data.map((o) => ({ ...o, isSelected: false }));
commits = commits.map((c) => {
const isPresent = state.selectedCommits.find(
selectedCommit => selectedCommit.short_id === c.short_id && selectedCommit.isSelected,
(selectedCommit) => selectedCommit.short_id === c.short_id && selectedCommit.isSelected,
);
if (isPresent) {
return { ...c, isSelected: true };
......@@ -50,7 +50,7 @@ export const searchCommits = ({ dispatch, commit, state }, searchText) => {
export const setCommits = ({ commit }, { commits: data, silentAddition = false }) => {
let commits = _.uniqBy(data, 'short_id');
commits = _.orderBy(data, c => new Date(c.committed_date), ['desc']);
commits = _.orderBy(data, (c) => new Date(c.committed_date), ['desc']);
if (silentAddition) {
commit(types.SET_COMMITS_SILENT, commits);
} else {
......@@ -60,7 +60,7 @@ export const setCommits = ({ commit }, { commits: data, silentAddition = false }
export const createContextCommits = ({ state }, { commits, forceReload = false }) =>
Api.createContextCommits(state.projectId, state.mergeRequestIid, {
commits: commits.map(commit => commit.short_id),
commits: commits.map((commit) => commit.short_id),
})
.then(() => {
if (forceReload) {
......@@ -81,7 +81,7 @@ export const fetchContextCommits = ({ dispatch, commit, state }) => {
commit(types.FETCH_CONTEXT_COMMITS);
return Api.allContextCommits(state.projectId, state.mergeRequestIid)
.then(({ data }) => {
const contextCommits = data.map(o => ({ ...o, isSelected: true }));
const contextCommits = data.map((o) => ({ ...o, isSelected: true }));
dispatch('setContextCommits', contextCommits);
dispatch('setCommits', {
commits: [...state.commits, ...contextCommits],
......@@ -121,7 +121,7 @@ export const setSelectedCommits = ({ commit }, selected) => {
let selectedCommits = _.uniqBy(selected, 'short_id');
selectedCommits = _.orderBy(
selectedCommits,
selectedCommit => new Date(selectedCommit.committed_date),
(selectedCommit) => new Date(selectedCommit.committed_date),
['desc'],
);
commit(types.SET_SELECTED_COMMITS, selectedCommits);
......
export const findCommitIndex = (commits, commitShortId) => {
return commits.findIndex(commit => commit.short_id === commitShortId);
return commits.findIndex((commit) => commit.short_id === commitShortId);
};
export const setCommitStatus = (commits, commitIndex, selected) => {
......
import PayloadPreviewer from '~/pages/admin/application_settings/payload_previewer';
export default () => {
Array.from(document.querySelectorAll('.js-payload-preview-trigger')).forEach(trigger => {
Array.from(document.querySelectorAll('.js-payload-preview-trigger')).forEach((trigger) => {
new PayloadPreviewer(trigger).init();
});
};
......@@ -13,7 +13,7 @@ export const fetchStatistics = ({ dispatch }) => {
.then(({ data }) => {
dispatch('receiveStatisticsSuccess', convertObjectPropsToCamelCase(data, { deep: true }));
})
.catch(error => dispatch('receiveStatisticsError', error));
.catch((error) => dispatch('receiveStatisticsError', error));
};
export const receiveStatisticsSuccess = ({ commit }, statistics) =>
......
......@@ -3,8 +3,8 @@
* and returns an array of the following form:
* [{ key: "forks", label: "Forks", value: 50 }]
*/
export const getStatistics = state => labels =>
Object.keys(labels).map(key => {
export const getStatistics = (state) => (labels) =>
Object.keys(labels).map((key) => {
const result = {
key,
label: labels[key],
......
......@@ -4,7 +4,7 @@ import { __ } from '~/locale';
const DEFAULT_TH_CLASSES =
'gl-bg-transparent! gl-border-b-solid! gl-border-b-gray-100! gl-p-5! gl-border-b-1!';
const thWidthClass = width => `gl-w-${width}p ${DEFAULT_TH_CLASSES}`;
const thWidthClass = (width) => `gl-w-${width}p ${DEFAULT_TH_CLASSES}`;
export default {
components: {
......
......@@ -11,7 +11,7 @@ export default function (el = document.querySelector('#js-admin-users-app')) {
return new Vue({
el,
render: createElement =>
render: (createElement) =>
createElement(AdminUsersApp, {
props: {
users: convertObjectPropsToCamelCase(JSON.parse(users), { deep: true }),
......
......@@ -8,9 +8,9 @@ export default function initAlertHandler() {
const DISMISS_LABEL = '[aria-label="Dismiss"]';
const DISMISS_CLASS = '.gl-alert-dismiss';
DISMISSIBLE_SELECTORS.forEach(selector => {
DISMISSIBLE_SELECTORS.forEach((selector) => {
const elements = document.querySelectorAll(selector);
elements.forEach(element => {
elements.forEach((element) => {
const button = element.querySelector(DISMISS_LABEL) || element.querySelector(DISMISS_CLASS);
if (!button) {
return;
......
......@@ -140,7 +140,7 @@ export default {
},
currentTabIndex: {
get() {
return this.$options.tabsConfig.findIndex(tab => tab.id === this.activeTab);
return this.$options.tabsConfig.findIndex((tab) => tab.id === this.activeTab);
},
set(tabIdx) {
const tabId = this.$options.tabsConfig[tabIdx].id;
......@@ -208,7 +208,7 @@ export default {
}
},
)
.catch(error => {
.catch((error) => {
this.createIncidentError = error;
this.incidentCreationInProgress = false;
});
......
......@@ -138,7 +138,7 @@ export default {
data.project || {};
const now = new Date();
const listWithData = list.map(alert => {
const listWithData = list.map((alert) => {
const then = new Date(alert.startedAt);
const diff = now - then;
......
......@@ -33,7 +33,7 @@ export default {
});
this.metricEmbedComponent = MetricEmbed;
})
.catch(e => Sentry.captureException(e));
.catch((e) => Sentry.captureException(e));
}
},
};
......
......@@ -57,7 +57,7 @@ export default {
projectPath: this.projectPath,
},
})
.then(resp => {
.then((resp) => {
this.trackStatusUpdate(status);
const errors = resp.data?.updateAlertStatus?.errors || [];
......
......@@ -92,7 +92,7 @@ export default {
},
sortedUsers() {
return this.users
.map(user => ({ ...user, active: this.isActive(user.username) }))
.map((user) => ({ ...user, active: this.isActive(user.username) }))
.sort((a, b) => (a.active === b.active ? 0 : a.active ? -1 : 1)); // eslint-disable-line no-nested-ternary
},
dropdownClass() {
......
......@@ -115,7 +115,7 @@ export default {
variables: this.getAlertQueryVariables,
});
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.alertManagementAlerts.nodes[0].todos.nodes = [];
});
......
......@@ -9,7 +9,7 @@ import createRouter from './router';
Vue.use(VueApollo);
export default selector => {
export default (selector) => {
const domEl = document.querySelector(selector);
const { alertId, projectPath, projectIssuesPath, projectId } = domEl.dataset;
const router = createRouter();
......@@ -18,7 +18,7 @@ export default selector => {
Mutation: {
toggleSidebarStatus: (_, __, { cache }) => {
const sourceData = cache.readQuery({ query: sidebarStatusQuery });
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.sidebarStatus = !draftData.sidebarStatus;
});
......@@ -30,7 +30,7 @@ export default selector => {
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(resolvers, {
cacheConfig: {
dataIdFromObject: object => {
dataIdFromObject: (object) => {
// eslint-disable-next-line no-underscore-dangle
if (object.__typename === 'AlertManagementAlert') {
return object.iid;
......
......@@ -30,7 +30,7 @@ export default () => {
{},
{
cacheConfig: {
dataIdFromObject: object => {
dataIdFromObject: (object) => {
// eslint-disable-next-line no-underscore-dangle
if (object.__typename === 'AlertManagementAlert') {
return object.iid;
......
......@@ -98,7 +98,7 @@ export default {
},
methods: {
updateIcon() {
return document.querySelectorAll('.js-service-active-status').forEach(icon => {
return document.querySelectorAll('.js-service-active-status').forEach((icon) => {
if (icon.dataset.value === this.activated.toString()) {
icon.classList.remove('d-none');
} else {
......@@ -109,7 +109,7 @@ export default {
resetKey() {
return axios
.put(this.formPath, { service: { token: '' } })
.then(res => {
.then((res) => {
this.authorizationKey = res.data.token;
})
.catch(() => {
......
......@@ -2,7 +2,7 @@ import Vue from 'vue';
import { parseBoolean } from '~/lib/utils/common_utils';
import AlertsServiceForm from './components/alerts_service_form.vue';
export default el => {
export default (el) => {
if (!el) {
return null;
}
......
......@@ -64,9 +64,9 @@ export default {
},
computed: {
mappingData() {
return this.gitlabFields.map(gitlabField => {
return this.gitlabFields.map((gitlabField) => {
const mappingFields = this.payloadFields.filter(({ type }) =>
type.some(t => gitlabField.compatibleTypes.includes(t)),
type.some((t) => gitlabField.compatibleTypes.includes(t)),
);
const foundMapping = this.mapping.find(
......@@ -88,26 +88,26 @@ export default {
},
methods: {
setMapping(gitlabKey, mappingKey, valueKey) {
const fieldIndex = this.gitlabFields.findIndex(field => field.name === gitlabKey);
const fieldIndex = this.gitlabFields.findIndex((field) => field.name === gitlabKey);
const updatedField = { ...this.gitlabFields[fieldIndex], ...{ [valueKey]: mappingKey } };
Vue.set(this.gitlabFields, fieldIndex, updatedField);
},
setSearchTerm(search = '', searchFieldKey, gitlabKey) {
const fieldIndex = this.gitlabFields.findIndex(field => field.name === gitlabKey);
const fieldIndex = this.gitlabFields.findIndex((field) => field.name === gitlabKey);
const updatedField = { ...this.gitlabFields[fieldIndex], ...{ [searchFieldKey]: search } };
Vue.set(this.gitlabFields, fieldIndex, updatedField);
},
filterFields(searchTerm = '', fields) {
const search = searchTerm.toLowerCase();
return fields.filter(field => field.label.toLowerCase().includes(search));
return fields.filter((field) => field.label.toLowerCase().includes(search));
},
isSelected(fieldValue, mapping) {
return fieldValue === mapping;
},
selectedValue(name) {
return (
this.payloadFields.find(item => item.name === name)?.label ||
this.payloadFields.find((item) => item.name === name)?.label ||
this.$options.i18n.makeSelection
);
},
......
......@@ -97,8 +97,8 @@ export default {
};
},
mounted() {
const callback = entries => {
const isVisible = entries.some(entry => entry.isIntersecting);
const callback = (entries) => {
const isVisible = entries.some((entry) => entry.isIntersecting);
if (isVisible) {
this.trackPageViews();
......
......@@ -197,7 +197,7 @@ export default {
return options;
},
options() {
return integrationTypesNew.map(el => ({
return integrationTypesNew.map((el) => ({
...el,
disabled: this.disabledIntegrations.includes(el.value),
}));
......@@ -390,10 +390,10 @@ export default {
// TODO: replace with real BE mutation when ready;
this.parsingPayload = true;
return new Promise(resolve => {
return new Promise((resolve) => {
setTimeout(() => resolve(mockedCustomMapping), 1000);
})
.then(res => {
.then((res) => {
const mapping = { ...res };
delete mapping.storedMapping;
this.customMapping = res;
......@@ -408,7 +408,7 @@ export default {
},
getIntegrationMapping() {
// TODO: replace with real BE mutation when ready;
return Promise.resolve(mockedCustomMapping).then(res => {
return Promise.resolve(mockedCustomMapping).then((res) => {
this.customMapping = res;
this.integrationTestPayload.json = res?.samplePayload.body;
});
......
......@@ -14,7 +14,7 @@ const resolvers = {
{ cache },
) => {
const sourceData = cache.readQuery({ query: getCurrentIntegrationQuery });
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
if (id === null) {
// eslint-disable-next-line no-param-reassign
draftData.currentIntegration = null;
......
......@@ -11,7 +11,7 @@ apolloProvider.clients.defaultClient.cache.writeData({
});
Vue.use(GlToast);
export default el => {
export default (el) => {
if (!el) {
return null;
}
......
......@@ -14,7 +14,7 @@ const deleteIntegrationFromStore = (store, query, { httpIntegrationDestroy }, va
variables,
});
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.alertManagementIntegrations.nodes = draftData.project.alertManagementIntegrations.nodes.filter(
({ id }) => id !== integration.id,
......@@ -45,7 +45,7 @@ const addIntegrationToStore = (
variables,
});
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.alertManagementIntegrations.nodes = [
integration,
......
......@@ -60,13 +60,13 @@ export default {
return Object.values(this.errors);
},
isLoading() {
return some(this.$apollo.queries, query => query?.loading);
return some(this.$apollo.queries, (query) => query?.loading);
},
allQueriesFailed() {
return every(this.errorMessages, message => message.length);
return every(this.errorMessages, (message) => message.length);
},
hasLoadingErrors() {
return some(this.errorMessages, message => message.length);
return some(this.errorMessages, (message) => message.length);
},
errorMessage() {
// show the generic loading message if all requests fail
......@@ -179,7 +179,7 @@ export default {
};
},
})
.catch(error => this.handleError({ identifier, error, message: errorMessage }));
.catch((error) => this.handleError({ identifier, error, message: errorMessage }));
},
},
};
......
......@@ -11,7 +11,7 @@ import latestGroupsQuery from '../graphql/queries/groups.query.graphql';
import latestProjectsQuery from '../graphql/queries/projects.query.graphql';
import { getAverageByMonth } from '../utils';
const sortByDate = data => sortBy(data, item => new Date(item[0]).getTime());
const sortByDate = (data) => sortBy(data, (item) => new Date(item[0]).getTime());
const averageAndSortData = (data = [], maxDataPoints) => {
const averaged = getAverageByMonth(
......@@ -148,7 +148,7 @@ export default {
name: this.$options.i18n.xAxisTitle,
type: 'category',
axisLabel: {
formatter: value => {
formatter: (value) => {
return formatDateAsMonth(value);
},
},
......@@ -189,7 +189,7 @@ export default {
.fetchMore({
variables: { first: this.totalDataPoints, after: pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => {
const results = produce(fetchMoreResult, newData => {
const results = produce(fetchMoreResult, (newData) => {
// eslint-disable-next-line no-param-reassign
newData[dataKey].nodes = [
...previousResult[dataKey].nodes,
......@@ -199,7 +199,7 @@ export default {
return results;
},
})
.catch(error => {
.catch((error) => {
this.handleError({ error, message: errorMessage, dataKey });
});
}
......
......@@ -10,7 +10,7 @@ import { formatDateAsMonth } from '~/lib/utils/datetime_utility';
import usersQuery from '../graphql/queries/users.query.graphql';
import { getAverageByMonth } from '../utils';
const sortByDate = data => sortBy(data, item => new Date(item[0]).getTime());
const sortByDate = (data) => sortBy(data, (item) => new Date(item[0]).getTime());
export default {
name: 'UsersChart',
......@@ -106,7 +106,7 @@ export default {
.fetchMore({
variables: { first: this.totalDataPoints, after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => {
return produce(fetchMoreResult, newUsers => {
return produce(fetchMoreResult, (newUsers) => {
// eslint-disable-next-line no-param-reassign
newUsers.users.nodes = [...previousResult.users.nodes, ...newUsers.users.nodes];
});
......
......@@ -29,7 +29,7 @@ export function getAverageByMonth(items = [], options = {}) {
return { ...memo, [month]: { sum: count, recordCount: 1 } };
}, {});
return Object.keys(itemsMap).map(month => {
return Object.keys(itemsMap).map((month) => {
const { sum, recordCount } = itemsMap[month];
const avg = sum / recordCount;
if (shouldRound) {
......
......@@ -8,7 +8,7 @@ export default () => {
return false;
}
return containers.forEach(container => {
return containers.forEach((container) => {
const { chartData } = container.dataset;
const formattedData = JSON.parse(chartData);
......
......@@ -374,8 +374,8 @@ const Api = {
.post(url, {
label: data,
})
.then(res => callback(res.data))
.catch(e => callback(e.response.data));
.then((res) => callback(res.data))
.catch((e) => callback(e.response.data));
},
// Return group projects list. Filtered by query
......@@ -431,7 +431,7 @@ const Api = {
commitPipelines(projectId, sha) {
const encodedProjectId = projectId
.split('/')
.map(fragment => encodeURIComponent(fragment))
.map((fragment) => encodeURIComponent(fragment))
.join('/');
const url = Api.buildUrl(Api.commitPipelinesPath)
......@@ -455,7 +455,7 @@ const Api = {
.replace(':type', type)
.replace(':key', encodeURIComponent(key));
return axios.get(url, { params: options }).then(res => {
return axios.get(url, { params: options }).then((res) => {
if (callback) callback(res.data);
return res;
......@@ -467,7 +467,7 @@ const Api = {
.replace(':id', encodeURIComponent(id))
.replace(':type', type);
return axios.get(url, { params }).then(res => {
return axios.get(url, { params }).then((res) => {
if (callback) callback(res.data);
return res;
......
......@@ -37,7 +37,7 @@ export default class U2FAuthenticate {
// Note: The server library fixes this behaviour in (unreleased) version 1.0.0.
// This can be removed once we upgrade.
// https://github.com/castle/ruby-u2f/commit/103f428071a81cd3d5f80c2e77d522d5029946a4
this.signRequests = u2fParams.sign_requests.map(request => omit(request, 'challenge'));
this.signRequests = u2fParams.sign_requests.map((request) => omit(request, 'challenge'));
this.templates = {
inProgress: '#js-authenticate-token-2fa-in-progress',
......@@ -48,7 +48,7 @@ export default class U2FAuthenticate {
start() {
return importU2FLibrary()
.then(utils => {
.then((utils) => {
this.u2fUtils = utils;
this.renderInProgress();
})
......@@ -60,7 +60,7 @@ export default class U2FAuthenticate {
this.appId,
this.challenge,
this.signRequests,
response => {
(response) => {
if (response.errorCode) {
const error = new U2FError(response.errorCode, 'authenticate');
return this.renderError(error);
......
......@@ -34,7 +34,7 @@ export default class U2FRegister {
start() {
return importU2FLibrary()
.then(utils => {
.then((utils) => {
this.u2fUtils = utils;
this.renderSetup();
})
......@@ -46,7 +46,7 @@ export default class U2FRegister {
this.appId,
this.registerRequests,
this.signRequests,
response => {
(response) => {
if (response.errorCode) {
const error = new U2FError(response.errorCode, 'register');
return this.renderError(error);
......
......@@ -39,11 +39,11 @@ export default class WebAuthnAuthenticate {
authenticate() {
navigator.credentials
.get({ publicKey: this.webauthnParams })
.then(resp => {
.then((resp) => {
const convertedResponse = convertGetResponse(resp);
this.renderAuthenticated(JSON.stringify(convertedResponse));
})
.catch(err => {
.catch((err) => {
this.flow.renderError(new WebAuthnError(err, 'authenticate'));
});
}
......
......@@ -39,8 +39,8 @@ export default class WebAuthnRegister {
.create({
publicKey: this.webauthnOptions,
})
.then(cred => this.renderRegistered(JSON.stringify(convertCreateResponse(cred))))
.catch(err => this.flow.renderError(new WebAuthnError(err, 'register')));
.then((cred) => this.renderRegistered(JSON.stringify(convertCreateResponse(cred))))
.catch((err) => this.flow.renderError(new WebAuthnError(err, 'register')));
}
renderSetup() {
......
......@@ -56,13 +56,13 @@ export class AwardsHandler {
}
},
);
this.registerEventListener('on', $parentEl, 'click', this.toggleButtonSelector, e => {
this.registerEventListener('on', $parentEl, 'click', this.toggleButtonSelector, (e) => {
e.stopPropagation();
e.preventDefault();
this.showEmojiMenu($(e.currentTarget));
});
this.registerEventListener('on', $('html'), 'click', e => {
this.registerEventListener('on', $('html'), 'click', (e) => {
const $target = $(e.target);
if (!$target.closest(`.${this.menuClass}`).length) {
$('.js-awards-block.current').removeClass('current');
......@@ -74,7 +74,7 @@ export class AwardsHandler {
});
const emojiButtonSelector = `.js-awards-block .js-emoji-btn, .${this.menuClass} .js-emoji-btn`;
this.registerEventListener('on', $parentEl, 'click', emojiButtonSelector, e => {
this.registerEventListener('on', $parentEl, 'click', emojiButtonSelector, (e) => {
e.preventDefault();
const $target = $(e.currentTarget);
const $glEmojiElement = $target.find('gl-emoji');
......@@ -190,7 +190,7 @@ export class AwardsHandler {
(promiseChain, categoryNameKey) =>
promiseChain.then(
() =>
new Promise(resolve => {
new Promise((resolve) => {
const emojisInCategory = categoryMap[categoryNameKey];
const categoryMarkup = this.renderCategory(
categoryLabelMap[categoryNameKey],
......@@ -213,7 +213,7 @@ export class AwardsHandler {
menu.dispatchEvent(new CustomEvent('build-emoji-menu-finish'));
}
})
.catch(err => {
.catch((err) => {
emojiContentElement.insertAdjacentHTML(
'beforeend',
'<p>We encountered an error while adding the remaining categories</p>',
......@@ -230,7 +230,7 @@ export class AwardsHandler {
<ul class="clearfix emoji-menu-list ${opts.menuListClass || ''}">
${emojiList
.map(
emojiName => `
(emojiName) => `
<li class="emoji-menu-list-item">
<button class="emoji-menu-btn text-center js-emoji-btn" type="button">
${this.emoji.glEmojiTag(emojiName, {
......@@ -463,7 +463,7 @@ export class AwardsHandler {
const className = 'pulse animated once short';
$emoji.addClass(className);
this.registerEventListener('on', $emoji, animationEndEventString, e => {
this.registerEventListener('on', $emoji, animationEndEventString, (e) => {
$(e.currentTarget).removeClass(className);
});
}
......@@ -515,7 +515,7 @@ export class AwardsHandler {
this.frequentlyUsedEmojis ||
(() => {
const frequentlyUsedEmojis = uniq((Cookies.get('frequently_used_emojis') || '').split(','));
this.frequentlyUsedEmojis = frequentlyUsedEmojis.filter(inputName =>
this.frequentlyUsedEmojis = frequentlyUsedEmojis.filter((inputName) =>
this.emoji.isEmojiNameValid(inputName),
);
......@@ -527,13 +527,13 @@ export class AwardsHandler {
setupSearch() {
const $search = $('.js-emoji-menu-search');
this.registerEventListener('on', $search, 'input', e => {
this.registerEventListener('on', $search, 'input', (e) => {
const term = $(e.target).val().trim();
this.searchEmojis(term);
});
const $menu = $(`.${this.menuClass}`);
this.registerEventListener('on', $menu, transitionEndEventString, e => {
this.registerEventListener('on', $menu, transitionEndEventString, (e) => {
if (e.target === e.currentTarget) {
// Clear the search
this.searchEmojis('');
......@@ -583,7 +583,7 @@ export class AwardsHandler {
}
hideMenuElement($emojiMenu) {
$emojiMenu.on(transitionEndEventString, e => {
$emojiMenu.on(transitionEndEventString, (e) => {
if (e.currentTarget === e.target) {
// eslint-disable-next-line @gitlab/no-global-event-off
$emojiMenu.removeClass(IS_RENDERED).off(transitionEndEventString);
......@@ -594,7 +594,7 @@ export class AwardsHandler {
}
destroy() {
this.eventListeners.forEach(entry => {
this.eventListeners.forEach((entry) => {
entry.element.off.call(entry.element, ...entry.args);
});
$(`.${this.menuClass}`).remove();
......
......@@ -48,7 +48,7 @@ export default {
},
helpText() {
const placeholders = ['project_path', 'project_id', 'default_branch', 'commit_sha']
.map(placeholder => `<code>%{${placeholder}}</code>`)
.map((placeholder) => `<code>%{${placeholder}}</code>`)
.join(', ');
return sprintf(
s__('Badges|Supported %{docsLinkStart}variables%{docsLinkEnd}: %{placeholders}'),
......@@ -137,7 +137,7 @@ export default {
createFlash(s__('Badges|Badge saved.'), 'notice');
this.wasValidated = false;
})
.catch(error => {
.catch((error) => {
createFlash(
s__('Badges|Saving the badge failed, please check the entered URLs and try again.'),
);
......@@ -150,7 +150,7 @@ export default {
createFlash(s__('Badges|New badge added.'), 'notice');
this.wasValidated = false;
})
.catch(error => {
.catch((error) => {
createFlash(
s__('Badges|Adding the badge failed, please check the entered URLs and try again.'),
);
......
......@@ -42,7 +42,7 @@ export default {
.then(() => {
createFlash(s__('Badges|The badge was deleted.'), 'notice');
})
.catch(error => {
.catch((error) => {
createFlash(s__('Badges|Deleting the badge failed, please try again.'));
throw error;
});
......
......@@ -2,7 +2,7 @@ import axios from '~/lib/utils/axios_utils';
import types from './mutation_types';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
export const transformBackendBadge = badge => ({
export const transformBackendBadge = (badge) => ({
...convertObjectPropsToCamelCase(badge, true),
isDeleting: false,
});
......@@ -27,11 +27,11 @@ export default {
image_url: newBadge.imageUrl,
link_url: newBadge.linkUrl,
})
.catch(error => {
.catch((error) => {
dispatch('receiveNewBadgeError');
throw error;
})
.then(res => {
.then((res) => {
dispatch('receiveNewBadge', transformBackendBadge(res.data));
});
},
......@@ -50,7 +50,7 @@ export default {
const endpoint = `${state.apiEndpointUrl}/${badgeId}`;
return axios
.delete(endpoint)
.catch(error => {
.catch((error) => {
dispatch('receiveDeleteBadgeError', badgeId);
throw error;
})
......@@ -78,11 +78,11 @@ export default {
const endpoint = state.apiEndpointUrl;
return axios
.get(endpoint)
.catch(error => {
.catch((error) => {
dispatch('receiveLoadBadgesError');
throw error;
})
.then(res => {
.then((res) => {
dispatch('receiveLoadBadges', res.data.map(transformBackendBadge));
});
},
......@@ -113,11 +113,11 @@ export default {
const renderEndpoint = `${state.apiEndpointUrl}/render?${parameters}`;
return axios
.get(renderEndpoint)
.catch(error => {
.catch((error) => {
dispatch('receiveRenderedBadgeError');
throw error;
})
.then(res => {
.then((res) => {
dispatch('receiveRenderedBadge', transformBackendBadge(res.data));
});
},
......@@ -142,11 +142,11 @@ export default {
image_url: badge.imageUrl,
link_url: badge.linkUrl,
})
.catch(error => {
.catch((error) => {
dispatch('receiveUpdatedBadgeError');
throw error;
})
.then(res => {
.then((res) => {
dispatch('receiveUpdatedBadge', transformBackendBadge(res.data));
});
},
......
import types from './mutation_types';
import { PROJECT_BADGE } from '../constants';
const reorderBadges = badges =>
const reorderBadges = (badges) =>
badges.sort((a, b) => {
if (a.kind !== b.kind) {
return a.kind === PROJECT_BADGE ? 1 : -1;
......@@ -31,7 +31,7 @@ export default {
},
[types.RECEIVE_UPDATED_BADGE](state, updatedBadge) {
const badges = state.badges.map(badge => {
const badges = state.badges.map((badge) => {
if (badge.id === updatedBadge.id) {
return updatedBadge;
}
......@@ -77,13 +77,13 @@ export default {
},
[types.RECEIVE_DELETE_BADGE](state, badgeId) {
const badges = state.badges.filter(badge => badge.id !== badgeId);
const badges = state.badges.filter((badge) => badge.id !== badgeId);
Object.assign(state, {
badges,
});
},
[types.RECEIVE_DELETE_BADGE_ERROR](state, badgeId) {
const badges = state.badges.map(badge => {
const badges = state.badges.map((badge) => {
if (badge.id === badgeId) {
return {
...badge,
......@@ -98,7 +98,7 @@ export default {
});
},
[types.REQUEST_DELETE_BADGE](state, badgeId) {
const badges = state.badges.map(badge => {
const badges = state.badges.map((badge) => {
if (badge.id === badgeId) {
return {
...badge,
......
......@@ -47,7 +47,7 @@ export default {
}
return sprintf(__("%{authorsName}'s thread"), {
authorsName: this.discussion.notes.find(note => !note.system).author.name,
authorsName: this.discussion.notes.find((note) => !note.system).author.name,
});
},
linePosition() {
......
......@@ -11,8 +11,8 @@ export const saveDraft = ({ dispatch }, draft) =>
export const addDraftToDiscussion = ({ commit }, { endpoint, data }) =>
service
.addDraftToDiscussion(endpoint, data)
.then(res => res.data)
.then(res => {
.then((res) => res.data)
.then((res) => {
commit(types.ADD_NEW_DRAFT, res);
return res;
})
......@@ -23,8 +23,8 @@ export const addDraftToDiscussion = ({ commit }, { endpoint, data }) =>
export const createNewDraft = ({ commit }, { endpoint, data }) =>
service
.createNewDraft(endpoint, data)
.then(res => res.data)
.then(res => {
.then((res) => res.data)
.then((res) => {
commit(types.ADD_NEW_DRAFT, res);
return res;
})
......@@ -43,8 +43,8 @@ export const deleteDraft = ({ commit, getters }, draft) =>
export const fetchDrafts = ({ commit, getters }) =>
service
.fetchDrafts(getters.getNotesData.draftsPath)
.then(res => res.data)
.then(data => commit(types.SET_BATCH_COMMENTS_DRAFTS, data))
.then((res) => res.data)
.then((data) => commit(types.SET_BATCH_COMMENTS_DRAFTS, data))
.catch(() => flash(__('An error occurred while fetching pending comments')));
export const publishSingleDraft = ({ commit, dispatch, getters }, draftId) => {
......@@ -86,8 +86,8 @@ export const updateDraft = (
resolveDiscussion,
position: JSON.stringify(position),
})
.then(res => res.data)
.then(data => commit(types.RECEIVE_DRAFT_UPDATE_SUCCESS, data))
.then((res) => res.data)
.then((data) => commit(types.RECEIVE_DRAFT_UPDATE_SUCCESS, data))
.then(callback)
.catch(() => flash(__('An error occurred while updating the comment')));
......@@ -116,8 +116,8 @@ export const scrollToDraft = ({ dispatch, rootGetters }, draft) => {
export const expandAllDiscussions = ({ dispatch, state }) =>
state.drafts
.filter(draft => draft.discussion_id)
.forEach(draft => {
.filter((draft) => draft.discussion_id)
.forEach((draft) => {
dispatch('expandDiscussion', { discussionId: draft.discussion_id }, { root: true });
});
......
import { parallelLineKey, showDraftOnSide } from '../../../utils';
export const draftsCount = state => state.drafts.length;
export const draftsCount = (state) => state.drafts.length;
export const getNotesData = (state, getters, rootState, rootGetters) => rootGetters.getNotesData;
export const hasDrafts = state => state.drafts.length > 0;
export const hasDrafts = (state) => state.drafts.length > 0;
export const draftsPerDiscussionId = state =>
export const draftsPerDiscussionId = (state) =>
state.drafts.reduce((acc, draft) => {
if (draft.discussion_id) {
acc[draft.discussion_id] = draft;
......@@ -15,7 +15,7 @@ export const draftsPerDiscussionId = state =>
return acc;
}, {});
export const draftsPerFileHashAndLine = state =>
export const draftsPerFileHashAndLine = (state) =>
state.drafts.reduce((acc, draft) => {
if (draft.file_hash) {
if (!acc[draft.file_hash]) {
......@@ -55,10 +55,10 @@ export const hasParallelDraftRight = (state, getters) => (diffFileSha, line) =>
return draftsForFile ? Boolean(draftsForFile[rkey]) : false;
};
export const shouldRenderDraftRowInDiscussion = (state, getters) => discussionId =>
export const shouldRenderDraftRowInDiscussion = (state, getters) => (discussionId) =>
typeof getters.draftsPerDiscussionId[discussionId] !== 'undefined';
export const draftForDiscussion = (state, getters) => discussionId =>
export const draftForDiscussion = (state, getters) => (discussionId) =>
getters.draftsPerDiscussionId[discussionId] || {};
export const draftForLine = (state, getters) => (diffFileSha, line, side = null) => {
......@@ -75,10 +75,10 @@ export const draftForLine = (state, getters) => (diffFileSha, line, side = null)
return {};
};
export const draftsForFile = state => diffFileSha =>
state.drafts.filter(draft => draft.file_hash === diffFileSha);
export const draftsForFile = (state) => (diffFileSha) =>
state.drafts.filter((draft) => draft.file_hash === diffFileSha);
export const isPublishingDraft = state => draftId =>
export const isPublishingDraft = (state) => (draftId) =>
state.currentlyPublishingDrafts.indexOf(draftId) !== -1;
export const sortedDrafts = state => [...state.drafts].sort((a, b) => a.id > b.id);
export const sortedDrafts = (state) => [...state.drafts].sort((a, b) => a.id > b.id);
import * as types from './mutation_types';
const processDraft = draft => ({
const processDraft = (draft) => ({
...draft,
isDraft: true,
});
......@@ -11,7 +11,7 @@ export default {
},
[types.DELETE_DRAFT](state, draftId) {
state.drafts = state.drafts.filter(draft => draft.id !== draftId);
state.drafts = state.drafts.filter((draft) => draft.id !== draftId);
},
[types.SET_BATCH_COMMENTS_DRAFTS](state, drafts) {
......@@ -23,13 +23,13 @@ export default {
},
[types.RECEIVE_PUBLISH_DRAFT_SUCCESS](state, draftId) {
state.currentlyPublishingDrafts = state.currentlyPublishingDrafts.filter(
publishingDraftId => publishingDraftId !== draftId,
(publishingDraftId) => publishingDraftId !== draftId,
);
state.drafts = state.drafts.filter(d => d.id !== draftId);
state.drafts = state.drafts.filter((d) => d.id !== draftId);
},
[types.RECEIVE_PUBLISH_DRAFT_ERROR](state, draftId) {
state.currentlyPublishingDrafts = state.currentlyPublishingDrafts.filter(
publishingDraftId => publishingDraftId !== draftId,
(publishingDraftId) => publishingDraftId !== draftId,
);
},
......@@ -44,14 +44,14 @@ export default {
state.isPublishing = false;
},
[types.RECEIVE_DRAFT_UPDATE_SUCCESS](state, data) {
const index = state.drafts.findIndex(draft => draft.id === data.id);
const index = state.drafts.findIndex((draft) => draft.id === data.id);
if (index >= 0) {
state.drafts.splice(index, 1, processDraft(data));
}
},
[types.TOGGLE_RESOLVE_DISCUSSION](state, draftId) {
state.drafts = state.drafts.map(draft => {
state.drafts = state.drafts.map((draft) => {
if (draft.id === draftId) {
return {
...draft,
......
import { getFormData } from '~/diffs/store/utils';
export const getDraftReplyFormData = data => ({
export const getDraftReplyFormData = (data) => ({
endpoint: data.notesData.draftsPath,
data,
});
export const getDraftFormData = params => ({
export const getDraftFormData = (params) => ({
endpoint: params.notesData.draftsPath,
data: getFormData(params),
});
......
......@@ -8,6 +8,6 @@ document.addEventListener('DOMContentLoaded', () => {
Autosize(autosizeEls);
Autosize.update(autosizeEls);
autosizeEls.forEach(el => el.classList.add('js-autosize-initialized'));
autosizeEls.forEach((el) => el.classList.add('js-autosize-initialized'));
});
});
......@@ -30,7 +30,7 @@ class BindInOut {
static initAll() {
const ins = document.querySelectorAll('*[data-bind-in]');
return [].map.call(ins, anIn => BindInOut.init(anIn));
return [].map.call(ins, (anIn) => BindInOut.init(anIn));
}
static init(anIn, anOut) {
......
......@@ -58,7 +58,7 @@ export default function initCopyToClipboard() {
* the last minute to deconstruct this JSON hash and set the `text/plain` and `text/x-gfm` copy
* data types to the intended values.
*/
$(document).on('copy', 'body > textarea[readonly]', e => {
$(document).on('copy', 'body > textarea[readonly]', (e) => {
const { clipboardData } = e.originalEvent;
if (!clipboardData) return;
......
......@@ -32,7 +32,7 @@ class GlEmoji extends HTMLElement {
const isEmojiUnicode =
this.childNodes &&
Array.prototype.every.call(this.childNodes, childNode => childNode.nodeType === 3);
Array.prototype.every.call(this.childNodes, (childNode) => childNode.nodeType === 3);
if (
emojiUnicode &&
......
......@@ -8,7 +8,7 @@ export const loadStartupCSS = () => {
() => {
document
.querySelectorAll('link[media=print]')
.forEach(x => x.dispatchEvent(new Event('load')));
.forEach((x) => x.dispatchEvent(new Event('load')));
},
{ once: true },
);
......
......@@ -10,10 +10,10 @@ export class CopyAsGFM {
const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
if (isIOS) return;
$(document).on('copy', '.md', e => {
$(document).on('copy', '.md', (e) => {
CopyAsGFM.copyAsGFM(e, CopyAsGFM.transformGFMSelection);
});
$(document).on('copy', 'pre.code.highlight, table.code td.line_content', e => {
$(document).on('copy', 'pre.code.highlight, table.code td.line_content', (e) => {
CopyAsGFM.copyAsGFM(e, CopyAsGFM.transformCodeSelection);
});
$(document).on('paste', '.js-gfm-input', CopyAsGFM.pasteGFM);
......@@ -42,7 +42,7 @@ export class CopyAsGFM {
clipboardData.setData('text/x-gfm-html', html);
CopyAsGFM.nodeToGFM(el)
.then(res => {
.then((res) => {
clipboardData.setData('text/x-gfm', res);
})
.catch(() => {
......@@ -71,7 +71,7 @@ export class CopyAsGFM {
const div = document.createElement('div');
div.innerHTML = gfmHtml;
CopyAsGFM.nodeToGFM(div)
.then(transformedGfm => {
.then((transformedGfm) => {
CopyAsGFM.insertPastedText(e.target, text, transformedGfm);
})
.catch(() => {});
......@@ -79,7 +79,7 @@ export class CopyAsGFM {
}
static insertPastedText(target, text, gfm) {
insertText(target, textBefore => {
insertText(target, (textBefore) => {
// If the text before the cursor contains an odd number of backticks,
// we are either inside an inline code span that starts with 1 backtick
// or a code block that starts with 3 backticks.
......@@ -125,7 +125,7 @@ export class CopyAsGFM {
let lineSelector = '.line';
if (target) {
const lineClass = ['left-side', 'right-side'].filter(name =>
const lineClass = ['left-side', 'right-side'].filter((name) =>
target.classList.contains(name),
)[0];
if (lineClass) {
......
......@@ -9,7 +9,7 @@ export default function highlightCurrentUser(elements) {
return;
}
elements.forEach(element => {
elements.forEach((element) => {
if (parseInt(element.dataset.user, 10) === currentUserId) {
element.classList.add('current-user');
}
......
......@@ -19,7 +19,7 @@ export default class InlineDiff extends Mark {
{ tag: 'span.idiff.addition', attrs: { addition: true } },
{ tag: 'span.idiff.deletion', attrs: { addition: false } },
],
toDOM: node => [
toDOM: (node) => [
'span',
{ class: `idiff left right ${node.attrs.addition ? 'addition' : 'deletion'}` },
0,
......
......@@ -19,14 +19,14 @@ export default class InlineHTML extends Mark {
parseDOM: [
{
tag: 'sup, sub, kbd, q, samp, var',
getAttrs: el => ({ tag: el.nodeName.toLowerCase() }),
getAttrs: (el) => ({ tag: el.nodeName.toLowerCase() }),
},
{
tag: 'abbr',
getAttrs: el => ({ tag: 'abbr', title: el.getAttribute('title') }),
getAttrs: (el) => ({ tag: 'abbr', title: el.getAttribute('title') }),
},
],
toDOM: node => [node.attrs.tag, { title: node.attrs.title }, 0],
toDOM: (node) => [node.attrs.tag, { title: node.attrs.title }, 0],
};
}
......
......@@ -25,7 +25,7 @@ export default class CodeBlock extends BaseCodeBlock {
{
tag: 'pre.code.highlight',
preserveWhitespace: 'full',
getAttrs: el => {
getAttrs: (el) => {
const lang = el.getAttribute('lang');
if (!lang || lang === '') return {};
......@@ -62,13 +62,13 @@ export default class CodeBlock extends BaseCodeBlock {
tag: '.md-suggestion-diff',
preserveWhitespace: 'full',
getContent: (el, schema) =>
[...el.querySelectorAll('.line_content.new span')].map(span =>
[...el.querySelectorAll('.line_content.new span')].map((span) =>
schema.text(span.innerText),
),
attrs: { lang: 'suggestion' },
},
],
toDOM: node => ['pre', { class: 'code highlight', lang: node.attrs.lang }, ['code', 0]],
toDOM: (node) => ['pre', { class: 'code highlight', lang: node.attrs.lang }, ['code', 0]],
};
}
......
......@@ -20,14 +20,14 @@ export default class Emoji extends Node {
parseDOM: [
{
tag: 'gl-emoji',
getAttrs: el => ({
getAttrs: (el) => ({
name: el.dataset.name,
title: el.getAttribute('title'),
moji: el.textContent,
}),
},
],
toDOM: node => [
toDOM: (node) => [
'gl-emoji',
{ 'data-name': node.attrs.name, title: node.attrs.title },
node.attrs.moji,
......
......@@ -30,7 +30,7 @@ export default class Image extends BaseImage {
// Matches HTML generated by Banzai::Filter::ImageLazyLoadFilter
{
tag: 'img[src]',
getAttrs: el => {
getAttrs: (el) => {
const imageSrc = el.src;
const imageUrl =
imageSrc && imageSrc !== placeholderImage ? imageSrc : el.dataset.src || '';
......@@ -43,7 +43,7 @@ export default class Image extends BaseImage {
},
},
],
toDOM: node => ['img', node.attrs],
toDOM: (node) => ['img', node.attrs],
};
}
......
......@@ -42,11 +42,11 @@ export default class Playable extends Node {
},
{
tag: `${this.mediaType}[src]`,
getAttrs: el => ({ src: el.src, alt: el.dataset.title }),
getAttrs: (el) => ({ src: el.src, alt: el.dataset.title }),
},
];
const toDOM = node => [
const toDOM = (node) => [
this.mediaType,
{
src: node.attrs.src,
......
......@@ -25,7 +25,7 @@ export default class Reference extends Node {
{
tag: 'a.gfm:not([data-link=true])',
priority: HIGHER_PARSE_RULE_PRIORITY,
getAttrs: el => ({
getAttrs: (el) => ({
className: el.className,
referenceType: el.dataset.referenceType,
originalText: el.dataset.original,
......@@ -34,7 +34,7 @@ export default class Reference extends Node {
}),
},
],
toDOM: node => [
toDOM: (node) => [
'a',
{
class: node.attrs.className,
......
......@@ -19,13 +19,13 @@ export default class TableCell extends Node {
parseDOM: [
{
tag: 'td, th',
getAttrs: el => ({
getAttrs: (el) => ({
header: el.tagName === 'TH',
align: el.getAttribute('align') || el.style.textAlign,
}),
},
],
toDOM: node => [node.attrs.header ? 'th' : 'td', { align: node.attrs.align }, 0],
toDOM: (node) => [node.attrs.header ? 'th' : 'td', { align: node.attrs.align }, 0],
};
}
......
......@@ -23,7 +23,7 @@ export default class TaskListItem extends Node {
{
priority: HIGHER_PARSE_RULE_PRIORITY,
tag: 'li.task-list-item',
getAttrs: el => {
getAttrs: (el) => {
const checkbox = el.querySelector('input[type=checkbox].task-list-item-checkbox');
return { done: checkbox && checkbox.checked };
},
......
......@@ -35,7 +35,7 @@ const RENDER_FLASH_MSG = sprintf(
// Wait for the browser to reflow the layout. Reflowing SVG takes time.
// This has to wrap the inner function, otherwise IE/Edge throw "invalid calling object".
const waitForReflow = fn => {
const waitForReflow = (fn) => {
window.requestAnimationFrame(fn);
};
......@@ -122,7 +122,7 @@ class SafeMathRenderer {
render() {
// Replace math blocks with a placeholder so they aren't rendered twice
this.elements.forEach(el => {
this.elements.forEach((el) => {
const placeholder = document.createElement('span');
placeholder.style.display = 'none';
placeholder.setAttribute('data-math-style', el.getAttribute('data-math-style'));
......
......@@ -29,7 +29,7 @@ let mermaidModule = {};
function importMermaidModule() {
return import(/* webpackChunkName: 'mermaid' */ 'mermaid')
.then(mermaid => {
.then((mermaid) => {
let theme = 'neutral';
const ideDarkThemes = ['dark', 'solarized-dark', 'monokai'];
......@@ -59,7 +59,7 @@ function importMermaidModule() {
return mermaid;
})
.catch(err => {
.catch((err) => {
flash(sprintf(__("Can't load mermaid module: %{err}"), { err }));
// eslint-disable-next-line no-console
console.error(err);
......@@ -77,7 +77,7 @@ function fixElementSource(el) {
}
function renderMermaidEl(el) {
mermaidModule.init(undefined, el, id => {
mermaidModule.init(undefined, el, (id) => {
const source = el.textContent;
const svg = document.getElementById(id);
......@@ -170,7 +170,7 @@ function renderMermaids($els) {
elsProcessingMap.set(el, requestId);
});
})
.catch(err => {
.catch((err) => {
flash(sprintf(__('Encountered an error while rendering: %{err}'), { err }));
// eslint-disable-next-line no-console
console.error(err);
......
......@@ -9,7 +9,7 @@ export default function renderMetrics(elements) {
const wrapperList = [];
elements.forEach(element => {
elements.forEach((element) => {
let wrapper;
const { previousElementSibling } = element;
const isFirstElementInGroup = !previousElementSibling?.urls;
......@@ -33,7 +33,7 @@ export default function renderMetrics(elements) {
).then(({ default: EmbedGroup }) => {
const EmbedGroupComponent = Vue.extend(EmbedGroup);
wrapperList.forEach(wrapper => {
wrapperList.forEach((wrapper) => {
// eslint-disable-next-line no-new
new EmbedGroupComponent({
el: wrapper,
......
......@@ -2,7 +2,7 @@ import { Schema } from 'prosemirror-model';
import editorExtensions from './editor_extensions';
const nodes = editorExtensions
.filter(extension => extension.type === 'node')
.filter((extension) => extension.type === 'node')
.reduce(
(ns, { name, schema }) => ({
...ns,
......@@ -12,7 +12,7 @@ const nodes = editorExtensions
);
const marks = editorExtensions
.filter(extension => extension.type === 'mark')
.filter((extension) => extension.type === 'mark')
.reduce(
(ms, { name, schema }) => ({
...ms,
......
......@@ -2,7 +2,7 @@ import { MarkdownSerializer } from 'prosemirror-markdown';
import editorExtensions from './editor_extensions';
const nodes = editorExtensions
.filter(extension => extension.type === 'node')
.filter((extension) => extension.type === 'node')
.reduce(
(ns, { name, toMarkdown }) => ({
...ns,
......@@ -12,7 +12,7 @@ const nodes = editorExtensions
);
const marks = editorExtensions
.filter(extension => extension.type === 'mark')
.filter((extension) => extension.type === 'mark')
.reduce(
(ms, { name, toMarkdown }) => ({
...ms,
......
......@@ -41,7 +41,7 @@ MarkdownPreview.prototype.showPreview = function ($form) {
this.hideReferencedUsers($form);
} else {
preview.addClass('md-preview-loading').text(__('Loading...'));
this.fetchMarkdownPreview(mdText, url, response => {
this.fetchMarkdownPreview(mdText, url, (response) => {
let body;
if (response.body.length > 0) {
({ body } = response);
......
......@@ -30,7 +30,7 @@ function keyCodeIs(e, keyCode) {
return e.keyCode === keyCode;
}
$(document).on('keydown.quick_submit', '.js-quick-submit', e => {
$(document).on('keydown.quick_submit', '.js-quick-submit', (e) => {
// Enter
if (!keyCodeIs(e, 13)) {
return;
......
......@@ -23,7 +23,7 @@ $.fn.requiresInput = function requiresInput() {
function requireInput() {
// Collect the input values of *all* required fields
const values = Array.from($(fieldSelector, $form)).map(field => field.value);
const values = Array.from($(fieldSelector, $form)).map((field) => field.value);
// Disable the button if any required fields are empty
if (values.length && values.some(isEmpty)) {
......
......@@ -30,12 +30,12 @@ export default class SecretValues {
updateDom(isRevealed) {
const values = this.container.querySelectorAll(this.valueSelector);
values.forEach(value => {
values.forEach((value) => {
value.classList.toggle('hide', !isRevealed);
});
const placeholders = this.container.querySelectorAll(this.placeholderSelector);
placeholders.forEach(placeholder => {
placeholders.forEach((placeholder) => {
placeholder.classList.toggle('hide', isRevealed);
});
......
......@@ -49,10 +49,10 @@ export const keybindingGroups = [
// For each keybinding object, add a `customKeys` property populated with the
// user's custom keybindings (if the command has been customized).
// `customKeys` will be `undefined` if the command hasn't been customized.
.map(group => {
.map((group) => {
return {
...group,
keybindings: group.keybindings.map(binding => ({
keybindings: group.keybindings.map((binding) => ({
...binding,
customKeys: customizations[binding.command],
})),
......@@ -66,7 +66,7 @@ export const keybindingGroups = [
* @example
* { "globalShortcuts.togglePerformanceBar": ["p e r f"] }
*/
const commandToKeys = flatten(keybindingGroups.map(group => group.keybindings)).reduce(
const commandToKeys = flatten(keybindingGroups.map((group) => group.keybindings)).reduce(
(acc, binding) => {
acc[binding.command] = binding.customKeys || binding.defaultKeys;
return acc;
......@@ -87,7 +87,7 @@ const commandToKeys = flatten(keybindingGroups.map(group => group.keybindings)).
*
* Mousetrap.bind(keysFor(TOGGLE_PERFORMANCE_BAR), handler);
*/
export const keysFor = command => {
export const keysFor = (command) => {
if (shouldDisableShortcuts()) {
return [];
}
......
......@@ -197,7 +197,7 @@ export default class Shortcuts {
$textarea.data(LOCAL_MOUSETRAP_DATA_KEY, localMousetrap);
toolbarBtnToShortcutsMap.forEach((keyboardShortcuts, $toolbarBtn) => {
localMousetrap.bind(keyboardShortcuts, e => {
localMousetrap.bind(keyboardShortcuts, (e) => {
e.preventDefault();
handler($toolbarBtn);
......@@ -231,7 +231,7 @@ export default class Shortcuts {
const localMousetrap = $textarea.data(LOCAL_MOUSETRAP_DATA_KEY);
if (localMousetrap) {
getToolbarBtnToShortcutsMap($textarea).forEach(keyboardShortcuts => {
getToolbarBtnToShortcutsMap($textarea).forEach((keyboardShortcuts) => {
localMousetrap.unbind(keyboardShortcuts);
});
}
......
......@@ -53,7 +53,7 @@ export default class ShortcutsBlob extends Shortcuts {
shortcircuitPermalinkButton() {
const button = this.options.fileBlobPermalinkUrlElement;
const handleButton = e => {
const handleButton = (e) => {
if (!eventHasModifierKeys(e)) {
e.preventDefault();
this.moveToFilePermalink();
......
......@@ -39,7 +39,7 @@ export default class ShortcutsIssuable extends Shortcuts {
// ... Or come from a message
if (!foundMessage) {
if (documentFragment.originalNodes) {
documentFragment.originalNodes.forEach(e => {
documentFragment.originalNodes.forEach((e) => {
let node = e;
do {
// Text nodes don't define the `matches` method
......@@ -62,7 +62,7 @@ export default class ShortcutsIssuable extends Shortcuts {
const blockquoteEl = document.createElement('blockquote');
blockquoteEl.appendChild(el);
CopyAsGFM.nodeToGFM(blockquoteEl)
.then(text => {
.then((text) => {
if (text.trim() === '') {
return false;
}
......
......@@ -68,7 +68,7 @@ export default class Renderer {
}
loadFile() {
this.loader.load(this.container.dataset.endpoint, geo => {
this.loader.load(this.container.dataset.endpoint, (geo) => {
const obj = new MeshObject(geo);
this.objects.push(obj);
......@@ -99,7 +99,7 @@ export default class Renderer {
}
changeObjectMaterials(type) {
this.objects.forEach(obj => {
this.objects.forEach((obj) => {
obj.changeMaterial(type);
});
}
......
......@@ -28,7 +28,7 @@ class BalsamiqViewer {
.then(({ data }) => {
this.renderFile(data);
})
.catch(e => {
.catch((e) => {
throw new Error(e);
});
}
......@@ -39,7 +39,7 @@ class BalsamiqViewer {
this.initDatabase(fileBuffer);
const previews = this.getPreviews();
previews.forEach(preview => {
previews.forEach((preview) => {
const renderedPreview = this.renderPreview(preview);
container.appendChild(renderedPreview);
......
......@@ -80,7 +80,7 @@ export default class BlobFileDropzone {
},
});
submitButton.on('click', e => {
submitButton.on('click', (e) => {
e.preventDefault();
e.stopPropagation();
if (dropzone[0].dropzone.getQueuedFiles().length === 0) {
......
......@@ -2,12 +2,12 @@ import { getLocationHash } from '../lib/utils/url_utility';
const lineNumberRe = /^L[0-9]+/;
const updateLineNumbersOnBlobPermalinks = linksToUpdate => {
const updateLineNumbersOnBlobPermalinks = (linksToUpdate) => {
const hash = getLocationHash();
if (hash && lineNumberRe.test(hash)) {
const hashUrlString = `#${hash}`;
[].concat(Array.prototype.slice.call(linksToUpdate)).forEach(permalinkButton => {
[].concat(Array.prototype.slice.call(linksToUpdate)).forEach((permalinkButton) => {
const baseHref =
permalinkButton.getAttribute('data-original-href') ||
(() => {
......@@ -28,7 +28,7 @@ function BlobLinePermalinkUpdater(blobContentHolder, lineNumberSelector, element
}, 0);
};
blobContentHolder.addEventListener('click', e => {
blobContentHolder.addEventListener('click', (e) => {
if (e.target.matches(lineNumberSelector)) {
updateBlameAndBlobPermalinkCb();
}
......
......@@ -25,7 +25,7 @@ export default {
},
renderErrorReason() {
const defaultReasonPath = Object.keys(BLOB_RENDER_ERRORS.REASONS).find(
reason => BLOB_RENDER_ERRORS.REASONS[reason].id === this.viewerError,
(reason) => BLOB_RENDER_ERRORS.REASONS[reason].id === this.viewerError,
);
const defaultReason = BLOB_RENDER_ERRORS.REASONS[defaultReasonPath].text;
return this.notStoredExternally
......
......@@ -38,14 +38,14 @@ export default class FileTemplateMediator {
MetricsDashboardSelector,
DockerfileSelector,
LicenseSelector,
].map(TemplateSelectorClass => new TemplateSelectorClass({ mediator: this }));
].map((TemplateSelectorClass) => new TemplateSelectorClass({ mediator: this }));
}
initTemplateTypeSelector() {
this.typeSelector = new FileTemplateTypeSelector({
mediator: this,
dropdownData: this.templateSelectors
.map(templateSelector => {
.map((templateSelector) => {
const cfg = templateSelector.config;
return {
......@@ -55,7 +55,7 @@ export default class FileTemplateMediator {
};
})
.reduce(
(acc, current) => (acc.find(item => item.id === current.id) ? acc : [...acc, current]),
(acc, current) => (acc.find((item) => item.id === current.id) ? acc : [...acc, current]),
[],
),
});
......@@ -99,7 +99,7 @@ export default class FileTemplateMediator {
}
listenForPreviewMode() {
this.$navLinks.on('click', 'a', e => {
this.$navLinks.on('click', 'a', (e) => {
const urlPieces = e.target.href.split('#');
const hash = urlPieces[1];
if (hash === 'preview') {
......@@ -115,7 +115,7 @@ export default class FileTemplateMediator {
e.preventDefault();
}
this.templateSelectors.forEach(selector => {
this.templateSelectors.forEach((selector) => {
if (selector.config.key === item.key) {
selector.show();
} else {
......@@ -138,7 +138,7 @@ export default class FileTemplateMediator {
selector.renderLoading();
this.fetchFileTemplate(selector.config.type, query, data)
.then(file => {
.then((file) => {
this.setEditorContent(file);
this.setFilename(name);
selector.renderLoaded();
......@@ -157,12 +157,12 @@ export default class FileTemplateMediator {
initPopover(suggestCommitChanges);
}
})
.catch(err => new Flash(`An error occurred while fetching the template: ${err}`));
.catch((err) => new Flash(`An error occurred while fetching the template: ${err}`));
}
displayMatchedTemplateSelector() {
const currentInput = this.getFilename();
this.templateSelectors.forEach(selector => {
this.templateSelectors.forEach((selector) => {
const match = selector.config.pattern.test(currentInput);
if (match) {
......@@ -174,8 +174,8 @@ export default class FileTemplateMediator {
}
fetchFileTemplate(type, query, data = {}) {
return new Promise(resolve => {
const resolveFile = file => resolve(file);
return new Promise((resolve) => {
const resolveFile = (file) => resolve(file);
Api.projectTemplate(this.projectId, type, query, data, resolveFile);
});
......@@ -194,7 +194,7 @@ export default class FileTemplateMediator {
}
findTemplateSelectorByKey(key) {
return this.templateSelectors.find(selector => selector.config.key === key);
return this.templateSelectors.find((selector) => selector.config.key === key);
}
hideTemplateSelectorMenu() {
......@@ -250,6 +250,6 @@ export default class FileTemplateMediator {
}
getSelected() {
return this.templateSelectors.find(selector => selector.selected);
return this.templateSelectors.find((selector) => selector.selected);
}
}
......@@ -45,12 +45,12 @@ export default {
loadFile() {
axios
.get(this.endpoint)
.then(res => res.data)
.then(data => {
.then((res) => res.data)
.then((data) => {
this.json = data;
this.loading = false;
})
.catch(e => {
.catch((e) => {
if (e.status !== 200) {
this.loadError = true;
}
......
......@@ -12,7 +12,7 @@ export default () => {
dom_id: '#js-openapi-viewer',
});
})
.catch(error => {
.catch((error) => {
flash(__('Something went wrong while initializing the OpenAPI viewer'));
throw error;
});
......
......@@ -12,9 +12,9 @@ export default class SketchLoader {
load() {
return this.getZipFile()
.then(data => JSZip.loadAsync(data))
.then(asyncResult => asyncResult.files['previews/preview.png'].async('uint8array'))
.then(content => {
.then((data) => JSZip.loadAsync(data))
.then((asyncResult) => asyncResult.files['previews/preview.png'].async('uint8array'))
.then((content) => {
const url = window.URL || window.webkitURL;
const blob = new Blob([new Uint8Array(content)], {
type: 'image/png',
......
......@@ -3,8 +3,8 @@ import Renderer from './3d_viewer';
export default () => {
const viewer = new Renderer(document.getElementById('js-stl-viewer'));
[].slice.call(document.querySelectorAll('.js-material-changer')).forEach(el => {
el.addEventListener('click', e => {
[].slice.call(document.querySelectorAll('.js-material-changer')).forEach((el) => {
el.addEventListener('click', (e) => {
const { target } = e;
e.preventDefault();
......
import Vue from 'vue';
import Popover from './components/popover.vue';
export default el =>
export default (el) =>
new Vue({
el,
render(createElement) {
......
......@@ -26,12 +26,12 @@ export default class TemplateSelector {
data,
filterable: true,
selectable: true,
toggleLabel: item => item.name,
toggleLabel: (item) => item.name,
search: {
fields: ['name'],
},
clicked: options => this.onDropdownClicked(options),
text: item => item.name,
clicked: (options) => this.onDropdownClicked(options),
text: (item) => item.name,
});
}
......@@ -46,7 +46,7 @@ export default class TemplateSelector {
}
listenForFilenameInput() {
return this.$filenameInput.on('keyup blur', e => this.renderMatchedDropdown(e));
return this.$filenameInput.on('keyup blur', (e) => this.renderMatchedDropdown(e));
}
renderMatchedDropdown() {
......
......@@ -22,8 +22,8 @@ export default class BlobCiSyntaxYamlSelector extends FileTemplateSelector {
search: {
fields: ['name'],
},
clicked: options => this.reportSelectionName(options),
text: item => item.name,
clicked: (options) => this.reportSelectionName(options),
text: (item) => item.name,
});
}
}
......@@ -23,8 +23,8 @@ export default class BlobCiYamlSelector extends FileTemplateSelector {
search: {
fields: ['name'],
},
clicked: options => this.reportSelectionName(options),
text: item => item.name,
clicked: (options) => this.reportSelectionName(options),
text: (item) => item.name,
});
}
}
......@@ -24,8 +24,8 @@ export default class DockerfileSelector extends FileTemplateSelector {
search: {
fields: ['name'],
},
clicked: options => this.reportSelectionName(options),
text: item => item.name,
clicked: (options) => this.reportSelectionName(options),
text: (item) => item.name,
});
}
}
......@@ -22,8 +22,8 @@ export default class BlobGitignoreSelector extends FileTemplateSelector {
search: {
fields: ['name'],
},
clicked: options => this.reportSelectionName(options),
text: item => item.name,
clicked: (options) => this.reportSelectionName(options),
text: (item) => item.name,
});
}
}
......@@ -22,7 +22,7 @@ export default class BlobLicenseSelector extends FileTemplateSelector {
search: {
fields: ['name'],
},
clicked: options => {
clicked: (options) => {
const { e } = options;
const el = options.$el;
const query = options.selectedObj;
......@@ -39,7 +39,7 @@ export default class BlobLicenseSelector extends FileTemplateSelector {
data,
});
},
text: item => item.name,
text: (item) => item.name,
});
}
}
......@@ -22,8 +22,8 @@ export default class MetricsDashboardSelector extends FileTemplateSelector {
search: {
fields: ['name'],
},
clicked: options => this.reportSelectionName(options),
text: item => item.name,
clicked: (options) => this.reportSelectionName(options),
text: (item) => item.name,
});
}
}
......@@ -17,8 +17,8 @@ export default class FileTemplateTypeSelector extends FileTemplateSelector {
data: this.config.dropdownData,
filterable: false,
selectable: true,
clicked: options => this.mediator.selectTemplateTypeOptions(options),
text: item => item.name,
clicked: (options) => this.mediator.selectTemplateTypeOptions(options),
text: (item) => item.name,
});
}
}
......@@ -7,7 +7,7 @@ import eventHub from '../../notes/event_hub';
import { __ } from '~/locale';
import { fixTitle } from '~/tooltips';
const loadRichBlobViewer = type => {
const loadRichBlobViewer = (type) => {
switch (type) {
case 'balsamiq':
return import(/* webpackChunkName: 'balsamiq_viewer' */ '../balsamiq_viewer');
......@@ -30,8 +30,8 @@ export const handleBlobRichViewer = (viewer, type) => {
if (!viewer || !type) return;
loadRichBlobViewer(type)
.then(module => module?.default(viewer))
.catch(error => {
.then((module) => module?.default(viewer))
.catch((error) => {
Flash(__('Error loading file viewer.'));
throw error;
});
......@@ -84,7 +84,7 @@ export default class BlobViewer {
initBindings() {
if (this.switcherBtns.length) {
Array.from(this.switcherBtns).forEach(el => {
Array.from(this.switcherBtns).forEach((el) => {
el.addEventListener('click', this.switchViewHandler.bind(this));
});
}
......@@ -155,7 +155,7 @@ export default class BlobViewer {
this.toggleCopyButtonState();
BlobViewer.loadViewer(newViewer)
.then(viewer => {
.then((viewer) => {
$(viewer).renderGFM();
this.$fileHolder.trigger('highlight:line');
......
......@@ -75,7 +75,7 @@ export default () => {
});
initPopovers();
})
.catch(e => createFlash(e));
.catch((e) => createFlash(e));
cancelLink.on('click', () => {
window.onbeforeunload = null;
......
......@@ -21,7 +21,7 @@ export default class EditBlob {
this.editor.use(new MarkdownExtension());
addEditorMarkdownListeners(this.editor);
})
.catch(e => createFlash(`${BLOB_EDITOR_ERROR}: ${e}`));
.catch((e) => createFlash(`${BLOB_EDITOR_ERROR}: ${e}`));
}
this.initModePanesAndLinks();
......@@ -66,7 +66,7 @@ export default class EditBlob {
initModePanesAndLinks() {
this.$editModePanes = $('.js-edit-mode-pane');
this.$editModeLinks = $('.js-edit-mode a');
this.$editModeLinks.on('click', e => this.editModeLinkClickHandler(e));
this.$editModeLinks.on('click', (e) => this.editModeLinkClickHandler(e));
}
editModeLinkClickHandler(e) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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