Commit 3a71d488 authored by Mike Greiling's avatar Mike Greiling

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

Format files with prettier arrowParens [4/15]

See merge request gitlab-org/gitlab!50529
parents c3691f24 e820c228
...@@ -19,7 +19,7 @@ class RecentSearchesStore { ...@@ -19,7 +19,7 @@ class RecentSearchesStore {
} }
setRecentSearches(searches = []) { setRecentSearches(searches = []) {
const trimmedSearches = searches.map(search => const trimmedSearches = searches.map((search) =>
typeof search === 'string' ? search.trim() : search, typeof search === 'string' ? search.trim() : search,
); );
......
...@@ -40,7 +40,7 @@ export default class VisualTokenValue { ...@@ -40,7 +40,7 @@ export default class VisualTokenValue {
return ( return (
UsersCache.retrieve(username) UsersCache.retrieve(username)
.then(user => { .then((user) => {
if (!user) { if (!user) {
return; return;
} }
...@@ -68,9 +68,9 @@ export default class VisualTokenValue { ...@@ -68,9 +68,9 @@ export default class VisualTokenValue {
); );
return AjaxCache.retrieve(labelsEndpointWithParams) return AjaxCache.retrieve(labelsEndpointWithParams)
.then(labels => { .then((labels) => {
const matchingLabel = (labels || []).find( const matchingLabel = (labels || []).find(
label => `~${DropdownUtils.getEscapedText(label.title)}` === tokenValue, (label) => `~${DropdownUtils.getEscapedText(label.title)}` === tokenValue,
); );
if (!matchingLabel) { if (!matchingLabel) {
...@@ -96,8 +96,8 @@ export default class VisualTokenValue { ...@@ -96,8 +96,8 @@ export default class VisualTokenValue {
); );
return AjaxCache.retrieve(epicsEndpointWithParams) return AjaxCache.retrieve(epicsEndpointWithParams)
.then(epics => { .then((epics) => {
const matchingEpic = (epics || []).find(epic => epic.id === Number(tokenValue)); const matchingEpic = (epics || []).find((epic) => epic.id === Number(tokenValue));
if (!matchingEpic) { if (!matchingEpic) {
return; return;
......
...@@ -34,7 +34,7 @@ const hideFlash = (flashEl, fadeTransition = true) => { ...@@ -34,7 +34,7 @@ const hideFlash = (flashEl, fadeTransition = true) => {
if (!fadeTransition) flashEl.dispatchEvent(new Event('transitionend')); if (!fadeTransition) flashEl.dispatchEvent(new Event('transitionend'));
}; };
const createAction = config => ` const createAction = (config) => `
<a <a
href="${config.href || '#'}" href="${config.href || '#'}"
class="flash-action" class="flash-action"
...@@ -97,7 +97,7 @@ const deprecatedCreateFlash = function deprecatedCreateFlash( ...@@ -97,7 +97,7 @@ const deprecatedCreateFlash = function deprecatedCreateFlash(
if (actionConfig.clickHandler) { if (actionConfig.clickHandler) {
flashEl flashEl
.querySelector('.flash-action') .querySelector('.flash-action')
.addEventListener('click', e => actionConfig.clickHandler(e)); .addEventListener('click', (e) => actionConfig.clickHandler(e));
} }
} }
...@@ -151,7 +151,7 @@ const createFlash = function createFlash({ ...@@ -151,7 +151,7 @@ const createFlash = function createFlash({
if (actionConfig.clickHandler) { if (actionConfig.clickHandler) {
flashEl flashEl
.querySelector('.flash-action') .querySelector('.flash-action')
.addEventListener('click', e => actionConfig.clickHandler(e)); .addEventListener('click', (e) => actionConfig.clickHandler(e));
} }
} }
......
...@@ -12,7 +12,7 @@ let sidebar; ...@@ -12,7 +12,7 @@ let sidebar;
export const mousePos = []; export const mousePos = [];
export const setSidebar = el => { export const setSidebar = (el) => {
sidebar = el; sidebar = el;
}; };
export const getOpenMenu = () => currentOpenMenu; export const getOpenMenu = () => currentOpenMenu;
...@@ -32,7 +32,7 @@ const setHeaderHeight = () => { ...@@ -32,7 +32,7 @@ const setHeaderHeight = () => {
export const isSidebarCollapsed = () => export const isSidebarCollapsed = () =>
sidebar && sidebar.classList.contains(SIDEBAR_COLLAPSED_CLASS); sidebar && sidebar.classList.contains(SIDEBAR_COLLAPSED_CLASS);
export const canShowActiveSubItems = el => { export const canShowActiveSubItems = (el) => {
if (el.classList.contains('active') && !isSidebarCollapsed()) { if (el.classList.contains('active') && !isSidebarCollapsed()) {
return false; return false;
} }
...@@ -71,7 +71,7 @@ export const calculateTop = (boundingRect, outerHeight) => { ...@@ -71,7 +71,7 @@ export const calculateTop = (boundingRect, outerHeight) => {
: boundingRect.top; : boundingRect.top;
}; };
export const hideMenu = el => { export const hideMenu = (el) => {
if (!el) return; if (!el) return;
const parentEl = el.parentNode; const parentEl = el.parentNode;
...@@ -112,7 +112,7 @@ export const moveSubItemsToPosition = (el, subItems) => { ...@@ -112,7 +112,7 @@ export const moveSubItemsToPosition = (el, subItems) => {
} }
}; };
export const showSubLevelItems = el => { export const showSubLevelItems = (el) => {
const subItems = el.querySelector('.sidebar-sub-level-items'); const subItems = el.querySelector('.sidebar-sub-level-items');
const isIconOnly = subItems && subItems.classList.contains('is-fly-out-only'); const isIconOnly = subItems && subItems.classList.contains('is-fly-out-only');
...@@ -139,7 +139,7 @@ export const mouseEnterTopItems = (el, timeout = getHideSubItemsInterval()) => { ...@@ -139,7 +139,7 @@ export const mouseEnterTopItems = (el, timeout = getHideSubItemsInterval()) => {
}, timeout); }, timeout);
}; };
export const mouseLeaveTopItem = el => { export const mouseLeaveTopItem = (el) => {
const subItems = el.querySelector('.sidebar-sub-level-items'); const subItems = el.querySelector('.sidebar-sub-level-items');
if ( if (
...@@ -152,7 +152,7 @@ export const mouseLeaveTopItem = el => { ...@@ -152,7 +152,7 @@ export const mouseLeaveTopItem = el => {
el.classList.remove(IS_OVER_CLASS); el.classList.remove(IS_OVER_CLASS);
}; };
export const documentMouseMove = e => { export const documentMouseMove = (e) => {
mousePos.push({ mousePos.push({
x: e.clientX, x: e.clientX,
y: e.clientY, y: e.clientY,
...@@ -161,7 +161,7 @@ export const documentMouseMove = e => { ...@@ -161,7 +161,7 @@ export const documentMouseMove = e => {
if (mousePos.length > 6) mousePos.shift(); if (mousePos.length > 6) mousePos.shift();
}; };
export const subItemsMouseLeave = relatedTarget => { export const subItemsMouseLeave = (relatedTarget) => {
clearTimeout(timeoutId); clearTimeout(timeoutId);
if (relatedTarget && !relatedTarget.closest(`.${IS_OVER_CLASS}`)) { if (relatedTarget && !relatedTarget.closest(`.${IS_OVER_CLASS}`)) {
...@@ -189,15 +189,15 @@ export default () => { ...@@ -189,15 +189,15 @@ export default () => {
requestIdleCallback(setHeaderHeight); requestIdleCallback(setHeaderHeight);
items.forEach(el => { items.forEach((el) => {
const subItems = el.querySelector('.sidebar-sub-level-items'); const subItems = el.querySelector('.sidebar-sub-level-items');
if (subItems) { if (subItems) {
subItems.addEventListener('mouseleave', e => subItemsMouseLeave(e.relatedTarget)); subItems.addEventListener('mouseleave', (e) => subItemsMouseLeave(e.relatedTarget));
} }
el.addEventListener('mouseenter', e => mouseEnterTopItems(e.currentTarget)); el.addEventListener('mouseenter', (e) => mouseEnterTopItems(e.currentTarget));
el.addEventListener('mouseleave', e => mouseLeaveTopItem(e.currentTarget)); el.addEventListener('mouseleave', (e) => mouseLeaveTopItem(e.currentTarget));
}); });
document.addEventListener('mousemove', documentMouseMove); document.addEventListener('mousemove', documentMouseMove);
......
...@@ -77,7 +77,7 @@ export default { ...@@ -77,7 +77,7 @@ export default {
// Check if item already exists in list // Check if item already exists in list
const itemMatchIndex = storedFrequentItems.findIndex( const itemMatchIndex = storedFrequentItems.findIndex(
frequentItem => frequentItem.id === item.id, (frequentItem) => frequentItem.id === item.id,
); );
if (itemMatchIndex > -1) { if (itemMatchIndex > -1) {
......
...@@ -18,7 +18,7 @@ const frequentItemDropdowns = [ ...@@ -18,7 +18,7 @@ const frequentItemDropdowns = [
]; ];
export default function initFrequentItemDropdowns() { export default function initFrequentItemDropdowns() {
frequentItemDropdowns.forEach(dropdown => { frequentItemDropdowns.forEach((dropdown) => {
const { namespace, key } = dropdown; const { namespace, key } = dropdown;
const el = document.getElementById(`js-${namespace}-dropdown`); const el = document.getElementById(`js-${namespace}-dropdown`);
const navEl = document.getElementById(`nav-${namespace}-dropdown`); const navEl = document.getElementById(`nav-${namespace}-dropdown`);
......
...@@ -59,7 +59,7 @@ export const fetchSearchedItems = ({ state, dispatch }, searchQuery) => { ...@@ -59,7 +59,7 @@ export const fetchSearchedItems = ({ state, dispatch }, searchQuery) => {
} }
return Api[state.namespace](searchQuery, params) return Api[state.namespace](searchQuery, params)
.then(results => { .then((results) => {
dispatch('receiveSearchedItemsSuccess', results); dispatch('receiveSearchedItemsSuccess', results);
}) })
.catch(() => { .catch(() => {
......
export const hasSearchQuery = state => state.searchQuery !== ''; export const hasSearchQuery = (state) => state.searchQuery !== '';
...@@ -50,7 +50,7 @@ export default { ...@@ -50,7 +50,7 @@ export default {
[types.RECEIVE_SEARCHED_ITEMS_SUCCESS](state, results) { [types.RECEIVE_SEARCHED_ITEMS_SUCCESS](state, results) {
const rawItems = results.data ? results.data : results; // Api.groups returns array, Api.projects returns object const rawItems = results.data ? results.data : results; // Api.groups returns array, Api.projects returns object
Object.assign(state, { Object.assign(state, {
items: rawItems.map(rawItem => ({ items: rawItems.map((rawItem) => ({
id: rawItem.id, id: rawItem.id,
name: rawItem.name, name: rawItem.name,
namespace: rawItem.name_with_namespace || rawItem.full_name, namespace: rawItem.name_with_namespace || rawItem.full_name,
......
...@@ -5,7 +5,7 @@ import { FREQUENT_ITEMS, HOUR_IN_MS } from './constants'; ...@@ -5,7 +5,7 @@ import { FREQUENT_ITEMS, HOUR_IN_MS } from './constants';
export const isMobile = () => ['md', 'sm', 'xs'].includes(bp.getBreakpointSize()); export const isMobile = () => ['md', 'sm', 'xs'].includes(bp.getBreakpointSize());
export const getTopFrequentItems = items => { export const getTopFrequentItems = (items) => {
if (!items) { if (!items) {
return []; return [];
} }
...@@ -13,7 +13,7 @@ export const getTopFrequentItems = items => { ...@@ -13,7 +13,7 @@ export const getTopFrequentItems = items => {
? FREQUENT_ITEMS.LIST_COUNT_MOBILE ? FREQUENT_ITEMS.LIST_COUNT_MOBILE
: FREQUENT_ITEMS.LIST_COUNT_DESKTOP; : FREQUENT_ITEMS.LIST_COUNT_DESKTOP;
const frequentItems = items.filter(item => item.frequency >= FREQUENT_ITEMS.ELIGIBLE_FREQUENCY); const frequentItems = items.filter((item) => item.frequency >= FREQUENT_ITEMS.ELIGIBLE_FREQUENCY);
if (!frequentItems || frequentItems.length === 0) { if (!frequentItems || frequentItems.length === 0) {
return []; return [];
...@@ -45,9 +45,9 @@ export const updateExistingFrequentItem = (frequentItem, item) => { ...@@ -45,9 +45,9 @@ export const updateExistingFrequentItem = (frequentItem, item) => {
}; };
}; };
export const sanitizeItem = item => { export const sanitizeItem = (item) => {
// Only sanitize if the key exists on the item // Only sanitize if the key exists on the item
const maybeSanitize = key => { const maybeSanitize = (key) => {
if (!Object.prototype.hasOwnProperty.call(item, key)) { if (!Object.prototype.hasOwnProperty.call(item, key)) {
return {}; return {};
} }
......
...@@ -15,7 +15,7 @@ function sanitize(str) { ...@@ -15,7 +15,7 @@ function sanitize(str) {
} }
export function membersBeforeSave(members) { export function membersBeforeSave(members) {
return members.map(member => { return members.map((member) => {
const GROUP_TYPE = 'Group'; const GROUP_TYPE = 'Group';
let title = ''; let title = '';
...@@ -156,7 +156,7 @@ class GfmAutoComplete { ...@@ -156,7 +156,7 @@ class GfmAutoComplete {
...this.getDefaultCallbacks(), ...this.getDefaultCallbacks(),
beforeSave(commands) { beforeSave(commands) {
if (GfmAutoComplete.isLoading(commands)) return commands; if (GfmAutoComplete.isLoading(commands)) return commands;
return $.map(commands, c => { return $.map(commands, (c) => {
let search = c.name; let search = c.name;
if (c.aliases.length > 0) { if (c.aliases.length > 0) {
search = `${search} ${c.aliases.join(' ')}`; search = `${search} ${c.aliases.join(' ')}`;
...@@ -237,7 +237,7 @@ class GfmAutoComplete { ...@@ -237,7 +237,7 @@ class GfmAutoComplete {
}); });
// return to the form atwho wants // return to the form atwho wants
return results.map(name => ({ name })); return results.map((name) => ({ name }));
}, },
}, },
}); });
...@@ -288,7 +288,7 @@ class GfmAutoComplete { ...@@ -288,7 +288,7 @@ class GfmAutoComplete {
const subtextNodes = subtext.split(/\n+/g).pop().split(GfmAutoComplete.regexSubtext); const subtextNodes = subtext.split(/\n+/g).pop().split(GfmAutoComplete.regexSubtext);
// Check if @ is followed by '/assign', '/reassign', '/unassign' or '/cc' commands. // Check if @ is followed by '/assign', '/reassign', '/unassign' or '/cc' commands.
command = subtextNodes.find(node => { command = subtextNodes.find((node) => {
if (Object.values(MEMBER_COMMAND).includes(node)) { if (Object.values(MEMBER_COMMAND).includes(node)) {
return node; return node;
} }
...@@ -298,7 +298,7 @@ class GfmAutoComplete { ...@@ -298,7 +298,7 @@ class GfmAutoComplete {
// Cache assignees list for easier filtering later // Cache assignees list for easier filtering later
assignees = assignees =
SidebarMediator.singleton?.store?.assignees?.map( SidebarMediator.singleton?.store?.assignees?.map(
assignee => `${assignee.username} ${assignee.name}`, (assignee) => `${assignee.username} ${assignee.name}`,
) || []; ) || [];
const match = GfmAutoComplete.defaultMatcher(flag, subtext, this.app.controllers); const match = GfmAutoComplete.defaultMatcher(flag, subtext, this.app.controllers);
...@@ -316,10 +316,10 @@ class GfmAutoComplete { ...@@ -316,10 +316,10 @@ class GfmAutoComplete {
if (command === MEMBER_COMMAND.ASSIGN) { if (command === MEMBER_COMMAND.ASSIGN) {
// Only include members which are not assigned to Issuable currently // Only include members which are not assigned to Issuable currently
return data.filter(member => !assignees.includes(member.search)); return data.filter((member) => !assignees.includes(member.search));
} else if (command === MEMBER_COMMAND.UNASSIGN) { } else if (command === MEMBER_COMMAND.UNASSIGN) {
// Only include members which are assigned to Issuable currently // Only include members which are assigned to Issuable currently
return data.filter(member => assignees.includes(member.search)); return data.filter((member) => assignees.includes(member.search));
} }
return data; return data;
...@@ -346,7 +346,7 @@ class GfmAutoComplete { ...@@ -346,7 +346,7 @@ class GfmAutoComplete {
callbacks: { callbacks: {
...this.getDefaultCallbacks(), ...this.getDefaultCallbacks(),
beforeSave(issues) { beforeSave(issues) {
return $.map(issues, i => { return $.map(issues, (i) => {
if (i.title == null) { if (i.title == null) {
return i; return i;
} }
...@@ -380,7 +380,7 @@ class GfmAutoComplete { ...@@ -380,7 +380,7 @@ class GfmAutoComplete {
callbacks: { callbacks: {
...this.getDefaultCallbacks(), ...this.getDefaultCallbacks(),
beforeSave(milestones) { beforeSave(milestones) {
return $.map(milestones, m => { return $.map(milestones, (m) => {
if (m.title == null) { if (m.title == null) {
return m; return m;
} }
...@@ -413,7 +413,7 @@ class GfmAutoComplete { ...@@ -413,7 +413,7 @@ class GfmAutoComplete {
callbacks: { callbacks: {
...this.getDefaultCallbacks(), ...this.getDefaultCallbacks(),
beforeSave(merges) { beforeSave(merges) {
return $.map(merges, m => { return $.map(merges, (m) => {
if (m.title == null) { if (m.title == null) {
return m; return m;
} }
...@@ -454,7 +454,7 @@ class GfmAutoComplete { ...@@ -454,7 +454,7 @@ class GfmAutoComplete {
...this.getDefaultCallbacks(), ...this.getDefaultCallbacks(),
beforeSave(merges) { beforeSave(merges) {
if (GfmAutoComplete.isLoading(merges)) return merges; if (GfmAutoComplete.isLoading(merges)) return merges;
return $.map(merges, m => ({ return $.map(merges, (m) => ({
title: sanitize(m.title), title: sanitize(m.title),
color: m.color, color: m.color,
search: m.title, search: m.title,
...@@ -465,7 +465,7 @@ class GfmAutoComplete { ...@@ -465,7 +465,7 @@ class GfmAutoComplete {
const subtextNodes = subtext.split(/\n+/g).pop().split(GfmAutoComplete.regexSubtext); const subtextNodes = subtext.split(/\n+/g).pop().split(GfmAutoComplete.regexSubtext);
// Check if ~ is followed by '/label', '/relabel' or '/unlabel' commands. // Check if ~ is followed by '/label', '/relabel' or '/unlabel' commands.
command = subtextNodes.find(node => { command = subtextNodes.find((node) => {
if ( if (
node === LABEL_COMMAND.LABEL || node === LABEL_COMMAND.LABEL ||
node === LABEL_COMMAND.RELABEL || node === LABEL_COMMAND.RELABEL ||
...@@ -486,7 +486,7 @@ class GfmAutoComplete { ...@@ -486,7 +486,7 @@ class GfmAutoComplete {
return null; return null;
} }
const lastCandidate = subtext.split(flag).pop(); const lastCandidate = subtext.split(flag).pop();
if (labels.find(label => label.title.startsWith(lastCandidate))) { if (labels.find((label) => label.title.startsWith(lastCandidate))) {
return lastCandidate; return lastCandidate;
} }
} else { } else {
...@@ -513,10 +513,10 @@ class GfmAutoComplete { ...@@ -513,10 +513,10 @@ class GfmAutoComplete {
// because we want to return all the labels (unfiltered) for that command. // because we want to return all the labels (unfiltered) for that command.
if (command === LABEL_COMMAND.LABEL) { if (command === LABEL_COMMAND.LABEL) {
// Return labels with set: undefined. // Return labels with set: undefined.
return data.filter(label => !label.set); return data.filter((label) => !label.set);
} else if (command === LABEL_COMMAND.UNLABEL) { } else if (command === LABEL_COMMAND.UNLABEL) {
// Return labels with set: true. // Return labels with set: true.
return data.filter(label => label.set); return data.filter((label) => label.set);
} }
return data; return data;
...@@ -543,7 +543,7 @@ class GfmAutoComplete { ...@@ -543,7 +543,7 @@ class GfmAutoComplete {
callbacks: { callbacks: {
...this.getDefaultCallbacks(), ...this.getDefaultCallbacks(),
beforeSave(snippets) { beforeSave(snippets) {
return $.map(snippets, m => { return $.map(snippets, (m) => {
if (m.title == null) { if (m.title == null) {
return m; return m;
} }
...@@ -648,7 +648,7 @@ class GfmAutoComplete { ...@@ -648,7 +648,7 @@ class GfmAutoComplete {
this.loadEmojiData($input, at).catch(() => {}); this.loadEmojiData($input, at).catch(() => {});
} else if (dataSource) { } else if (dataSource) {
AjaxCache.retrieve(dataSource, true) AjaxCache.retrieve(dataSource, true)
.then(data => { .then((data) => {
this.loadData($input, at, data); this.loadData($input, at, data);
}) })
.catch(() => { .catch(() => {
...@@ -690,11 +690,11 @@ class GfmAutoComplete { ...@@ -690,11 +690,11 @@ class GfmAutoComplete {
} }
lookup[key].push({ kind, emoji }); lookup[key].push({ kind, emoji });
}; };
Object.values(emojis).forEach(emoji => { Object.values(emojis).forEach((emoji) => {
add(emoji.name, 'name', emoji); add(emoji.name, 'name', emoji);
add(emoji.d, 'description', emoji); add(emoji.d, 'description', emoji);
add(emoji.e, 'unicode', emoji); add(emoji.e, 'unicode', emoji);
emoji.aliases.forEach(a => add(a, 'alias', emoji)); emoji.aliases.forEach((a) => add(a, 'alias', emoji));
}); });
this.emojiLookup = lookup; this.emojiLookup = lookup;
...@@ -766,7 +766,7 @@ GfmAutoComplete.atTypeMap = { ...@@ -766,7 +766,7 @@ GfmAutoComplete.atTypeMap = {
}; };
GfmAutoComplete.typesWithBackendFiltering = ['vulnerabilities']; GfmAutoComplete.typesWithBackendFiltering = ['vulnerabilities'];
GfmAutoComplete.isTypeWithBackendFiltering = type => GfmAutoComplete.isTypeWithBackendFiltering = (type) =>
GfmAutoComplete.typesWithBackendFiltering.includes(GfmAutoComplete.atTypeMap[type]); GfmAutoComplete.typesWithBackendFiltering.includes(GfmAutoComplete.atTypeMap[type]);
function findEmoji(name) { function findEmoji(name) {
......
...@@ -16,14 +16,14 @@ export default class GlFieldErrors { ...@@ -16,14 +16,14 @@ export default class GlFieldErrors {
initValidators() { initValidators() {
// register selectors here as needed // register selectors here as needed
const validateSelectors = [':text', ':password', '[type=email]', '[type=url]', '[type=number]'] const validateSelectors = [':text', ':password', '[type=email]', '[type=url]', '[type=number]']
.map(selector => `input${selector}`) .map((selector) => `input${selector}`)
.join(','); .join(',');
this.state.inputs = this.form this.state.inputs = this.form
.find(validateSelectors) .find(validateSelectors)
.toArray() .toArray()
.filter(input => !input.classList.contains(customValidationFlag)) .filter((input) => !input.classList.contains(customValidationFlag))
.map(input => new GlFieldError({ input, formErrors: this })); .map((input) => new GlFieldError({ input, formErrors: this }));
this.form.on('submit', GlFieldErrors.catchInvalidFormSubmit); this.form.on('submit', GlFieldErrors.catchInvalidFormSubmit);
} }
...@@ -45,7 +45,7 @@ export default class GlFieldErrors { ...@@ -45,7 +45,7 @@ export default class GlFieldErrors {
/* Public method for triggering validity updates manually */ /* Public method for triggering validity updates manually */
updateFormValidityState() { updateFormValidityState() {
this.state.inputs.forEach(field => { this.state.inputs.forEach((field) => {
if (field.state.submitted) { if (field.state.submitted) {
field.updateValidity(); field.updateValidity();
} }
......
...@@ -20,7 +20,7 @@ export default class GLForm { ...@@ -20,7 +20,7 @@ export default class GLForm {
// Disable autocomplete for keywords which do not have dataSources available // Disable autocomplete for keywords which do not have dataSources available
const dataSources = (gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources) || {}; const dataSources = (gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources) || {};
Object.keys(this.enableGFM).forEach(item => { Object.keys(this.enableGFM).forEach((item) => {
if (item !== 'emojis' && !dataSources[item]) { if (item !== 'emojis' && !dataSources[item]) {
this.enableGFM[item] = false; this.enableGFM[item] = false;
} }
......
...@@ -28,7 +28,7 @@ export default class GpgBadges { ...@@ -28,7 +28,7 @@ export default class GpgBadges {
return axios return axios
.get(endpoint, { params }) .get(endpoint, { params })
.then(({ data }) => { .then(({ data }) => {
data.signatures.forEach(signature => { data.signatures.forEach((signature) => {
badges.filter(`[data-commit-sha="${signature.commit_sha}"]`).replaceWith(signature.html); badges.filter(`[data-commit-sha="${signature.commit_sha}"]`).replaceWith(signature.html);
}); });
}) })
......
...@@ -24,7 +24,7 @@ export const updateGrafanaIntegration = ({ state, dispatch }) => ...@@ -24,7 +24,7 @@ export const updateGrafanaIntegration = ({ state, dispatch }) =>
}, },
}) })
.then(() => dispatch('receiveGrafanaIntegrationUpdateSuccess')) .then(() => dispatch('receiveGrafanaIntegrationUpdateSuccess'))
.catch(error => dispatch('receiveGrafanaIntegrationUpdateError', error)); .catch((error) => dispatch('receiveGrafanaIntegrationUpdateError', error));
export const receiveGrafanaIntegrationUpdateSuccess = () => { export const receiveGrafanaIntegrationUpdateSuccess = () => {
/** /**
......
...@@ -6,7 +6,7 @@ import mutations from './mutations'; ...@@ -6,7 +6,7 @@ import mutations from './mutations';
Vue.use(Vuex); Vue.use(Vuex);
export const createStore = initialState => export const createStore = (initialState) =>
new Vuex.Store({ new Vuex.Store({
state: createState(initialState), state: createState(initialState),
actions, actions,
......
...@@ -51,4 +51,4 @@ export const convertToGraphQLId = (type, id) => { ...@@ -51,4 +51,4 @@ export const convertToGraphQLId = (type, id) => {
* @param {Array} ids An array of id values * @param {Array} ids An array of id values
* @returns {Array} * @returns {Array}
*/ */
export const convertToGraphQLIds = (type, ids) => ids.map(id => convertToGraphQLId(type, id)); export const convertToGraphQLIds = (type, ids) => ids.map((id) => convertToGraphQLId(type, id));
...@@ -12,7 +12,7 @@ export default class Group { ...@@ -12,7 +12,7 @@ export default class Group {
this.resetHandler = this.reset.bind(this); this.resetHandler = this.reset.bind(this);
this.updateGroupPathSlugHandler = this.updateGroupPathSlug.bind(this); this.updateGroupPathSlugHandler = this.updateGroupPathSlug.bind(this);
this.groupNames.forEach(groupName => { this.groupNames.forEach((groupName) => {
if (groupName.value === '') { if (groupName.value === '') {
groupName.addEventListener('keyup', this.updateHandler); groupName.addEventListener('keyup', this.updateHandler);
...@@ -22,7 +22,7 @@ export default class Group { ...@@ -22,7 +22,7 @@ export default class Group {
} }
}); });
this.groupPaths.forEach(groupPath => { this.groupPaths.forEach((groupPath) => {
groupPath.addEventListener('keydown', this.resetHandler); groupPath.addEventListener('keydown', this.resetHandler);
}); });
} }
...@@ -30,21 +30,21 @@ export default class Group { ...@@ -30,21 +30,21 @@ export default class Group {
update({ currentTarget: { value: updatedValue } }) { update({ currentTarget: { value: updatedValue } }) {
const slug = slugify(updatedValue); const slug = slugify(updatedValue);
this.groupNames.forEach(element => { this.groupNames.forEach((element) => {
element.value = updatedValue; element.value = updatedValue;
}); });
this.groupPaths.forEach(element => { this.groupPaths.forEach((element) => {
element.value = slug; element.value = slug;
}); });
} }
reset() { reset() {
this.groupNames.forEach(groupName => { this.groupNames.forEach((groupName) => {
groupName.removeEventListener('keyup', this.updateHandler); groupName.removeEventListener('keyup', this.updateHandler);
groupName.removeEventListener('blur', this.checkPathHandler); groupName.removeEventListener('blur', this.checkPathHandler);
}); });
this.groupPaths.forEach(groupPath => { this.groupPaths.forEach((groupPath) => {
groupPath.removeEventListener('keydown', this.resetHandler); groupPath.removeEventListener('keydown', this.resetHandler);
}); });
} }
...@@ -59,7 +59,7 @@ export default class Group { ...@@ -59,7 +59,7 @@ export default class Group {
if (exists && suggests.length) { if (exists && suggests.length) {
const [suggestedSlug] = suggests; const [suggestedSlug] = suggests;
this.groupPaths.forEach(element => { this.groupPaths.forEach((element) => {
element.value = suggestedSlug; element.value = suggestedSlug;
}); });
} else if (exists && !suggests.length) { } else if (exists && !suggests.length) {
......
...@@ -82,7 +82,7 @@ export default { ...@@ -82,7 +82,7 @@ export default {
.then(() => { .then(() => {
this.isLoading = false; this.isLoading = false;
}) })
.catch(error => { .catch((error) => {
const message = [ const message = [
error.response?.data?.error || __('An error occurred while updating configuration.'), error.response?.data?.error || __('An error occurred while updating configuration.'),
ERROR_MESSAGE, ERROR_MESSAGE,
......
...@@ -108,7 +108,7 @@ export default { ...@@ -108,7 +108,7 @@ export default {
fetchGroups({ parentId, page, filterGroupsBy, sortBy, archived, updatePagination }) { fetchGroups({ parentId, page, filterGroupsBy, sortBy, archived, updatePagination }) {
return this.service return this.service
.getGroups(parentId, page, filterGroupsBy, sortBy, archived) .getGroups(parentId, page, filterGroupsBy, sortBy, archived)
.then(res => { .then((res) => {
if (updatePagination) { if (updatePagination) {
this.updatePagination(res.headers); this.updatePagination(res.headers);
} }
...@@ -135,7 +135,7 @@ export default { ...@@ -135,7 +135,7 @@ export default {
sortBy, sortBy,
archived, archived,
updatePagination: true, updatePagination: true,
}).then(res => { }).then((res) => {
this.isLoading = false; this.isLoading = false;
this.updateGroups(res, Boolean(filterGroupsBy)); this.updateGroups(res, Boolean(filterGroupsBy));
}); });
...@@ -149,7 +149,7 @@ export default { ...@@ -149,7 +149,7 @@ export default {
sortBy, sortBy,
archived, archived,
updatePagination: true, updatePagination: true,
}).then(res => { }).then((res) => {
this.isLoading = false; this.isLoading = false;
$.scrollTo(0); $.scrollTo(0);
...@@ -173,7 +173,7 @@ export default { ...@@ -173,7 +173,7 @@ export default {
this.fetchGroups({ this.fetchGroups({
parentId: parentGroup.id, parentId: parentGroup.id,
}) })
.then(res => { .then((res) => {
this.store.setGroupChildren(parentGroup, res); this.store.setGroupChildren(parentGroup, res);
}) })
.catch(() => { .catch(() => {
...@@ -194,12 +194,12 @@ export default { ...@@ -194,12 +194,12 @@ export default {
this.targetGroup.isBeingRemoved = true; this.targetGroup.isBeingRemoved = true;
this.service this.service
.leaveGroup(this.targetGroup.leavePath) .leaveGroup(this.targetGroup.leavePath)
.then(res => { .then((res) => {
$.scrollTo(0); $.scrollTo(0);
this.store.removeGroup(this.targetGroup, this.targetParentGroup); this.store.removeGroup(this.targetGroup, this.targetParentGroup);
this.$toast.show(res.data.notice); this.$toast.show(res.data.notice);
}) })
.catch(err => { .catch((err) => {
let message = COMMON_STR.FAILURE; let message = COMMON_STR.FAILURE;
if (err.status === 403) { if (err.status === 403) {
message = COMMON_STR.LEAVE_FORBIDDEN; message = COMMON_STR.LEAVE_FORBIDDEN;
......
...@@ -23,7 +23,7 @@ export default { ...@@ -23,7 +23,7 @@ export default {
}, },
methods: { methods: {
getDefaultOption() { getDefaultOption() {
return this.visibilityLevelOptions.find(option => option.level === this.defaultLevel); return this.visibilityLevelOptions.find((option) => option.level === this.defaultLevel);
}, },
onClick(option) { onClick(option) {
this.selectedOption = option; this.selectedOption = option;
......
...@@ -18,6 +18,6 @@ export default function initInviteMembersBanner() { ...@@ -18,6 +18,6 @@ export default function initInviteMembersBanner() {
isDismissedKey, isDismissedKey,
trackLabel, trackLabel,
}, },
render: createElement => createElement(InviteMembersBanner), render: (createElement) => createElement(InviteMembersBanner),
}); });
} }
...@@ -38,6 +38,6 @@ export const initGroupMembersApp = ( ...@@ -38,6 +38,6 @@ export const initGroupMembersApp = (
el, el,
components: { App }, components: { App },
store, store,
render: createElement => createElement('app'), render: (createElement) => createElement('app'),
}); });
}; };
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
GROUP_LINK_ACCESS_LEVEL_PROPERTY_NAME, GROUP_LINK_ACCESS_LEVEL_PROPERTY_NAME,
} from './constants'; } from './constants';
export const parseDataAttributes = el => { export const parseDataAttributes = (el) => {
const { members, groupId, memberPath, canManageMembers } = el.dataset; const { members, groupId, memberPath, canManageMembers } = el.dataset;
return { return {
......
...@@ -12,15 +12,15 @@ export default class GroupsStore { ...@@ -12,15 +12,15 @@ export default class GroupsStore {
setGroups(rawGroups) { setGroups(rawGroups) {
if (rawGroups && rawGroups.length) { if (rawGroups && rawGroups.length) {
this.state.groups = rawGroups.map(rawGroup => this.formatGroupItem(rawGroup)); this.state.groups = rawGroups.map((rawGroup) => this.formatGroupItem(rawGroup));
} else { } else {
this.state.groups = []; this.state.groups = [];
} }
} }
setSearchedGroups(rawGroups) { setSearchedGroups(rawGroups) {
const formatGroups = groups => const formatGroups = (groups) =>
groups.map(group => { groups.map((group) => {
const formattedGroup = this.formatGroupItem(group); const formattedGroup = this.formatGroupItem(group);
if (formattedGroup.children && formattedGroup.children.length) { if (formattedGroup.children && formattedGroup.children.length) {
formattedGroup.children = formatGroups(formattedGroup.children); formattedGroup.children = formatGroups(formattedGroup.children);
...@@ -37,7 +37,7 @@ export default class GroupsStore { ...@@ -37,7 +37,7 @@ export default class GroupsStore {
setGroupChildren(parentGroup, children) { setGroupChildren(parentGroup, children) {
const updatedParentGroup = parentGroup; const updatedParentGroup = parentGroup;
updatedParentGroup.children = children.map(rawChild => this.formatGroupItem(rawChild)); updatedParentGroup.children = children.map((rawChild) => this.formatGroupItem(rawChild));
updatedParentGroup.isOpen = true; updatedParentGroup.isOpen = true;
updatedParentGroup.isChildrenLoading = false; updatedParentGroup.isChildrenLoading = false;
} }
...@@ -103,9 +103,9 @@ export default class GroupsStore { ...@@ -103,9 +103,9 @@ export default class GroupsStore {
removeGroup(group, parentGroup) { removeGroup(group, parentGroup) {
const updatedParentGroup = parentGroup; const updatedParentGroup = parentGroup;
if (updatedParentGroup.children && updatedParentGroup.children.length) { if (updatedParentGroup.children && updatedParentGroup.children.length) {
updatedParentGroup.children = parentGroup.children.filter(child => group.id !== child.id); updatedParentGroup.children = parentGroup.children.filter((child) => group.id !== child.id);
} else { } else {
this.state.groups = this.state.groups.filter(child => group.id !== child.id); this.state.groups = this.state.groups.filter((child) => group.id !== child.id);
} }
} }
} }
...@@ -20,11 +20,11 @@ export default class TransferDropdown { ...@@ -20,11 +20,11 @@ export default class TransferDropdown {
initDeprecatedJQueryDropdown(this.groupDropdown, { initDeprecatedJQueryDropdown(this.groupDropdown, {
selectable: true, selectable: true,
filterable: true, filterable: true,
toggleLabel: item => item.text, toggleLabel: (item) => item.text,
search: { fields: ['text'] }, search: { fields: ['text'] },
data: extraOptions.concat(this.data), data: extraOptions.concat(this.data),
text: item => item.text, text: (item) => item.text,
clicked: options => { clicked: (options) => {
const { e } = options; const { e } = options;
e.preventDefault(); e.preventDefault();
this.assignSelected(options.selectedObj); this.assignSelected(options.selectedObj);
......
...@@ -6,11 +6,11 @@ import { normalizeHeaders } from './lib/utils/common_utils'; ...@@ -6,11 +6,11 @@ import { normalizeHeaders } from './lib/utils/common_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { loadCSSFile } from './lib/utils/css_utils'; import { loadCSSFile } from './lib/utils/css_utils';
const fetchGroups = params => { const fetchGroups = (params) => {
axios[params.type.toLowerCase()](params.url, { axios[params.type.toLowerCase()](params.url, {
params: params.data, params: params.data,
}) })
.then(res => { .then((res) => {
const results = res.data || []; const results = res.data || [];
const headers = normalizeHeaders(res.headers); const headers = normalizeHeaders(res.headers);
const currentPage = parseInt(headers['X-PAGE'], 10) || 0; const currentPage = parseInt(headers['X-PAGE'], 10) || 0;
...@@ -67,7 +67,7 @@ const groupsSelect = () => { ...@@ -67,7 +67,7 @@ const groupsSelect = () => {
const groups = data.length ? data : data.results || []; const groups = data.length ? data : data.results || [];
const more = data.pagination ? data.pagination.more : false; const more = data.pagination ? data.pagination.more : false;
const results = groups.filter(group => skipGroups.indexOf(group.id) === -1); const results = groups.filter((group) => skipGroups.indexOf(group.id) === -1);
return { return {
results, results,
......
...@@ -45,7 +45,7 @@ class EventHub { ...@@ -45,7 +45,7 @@ class EventHub {
$off(type, handler) { $off(type, handler) {
const handlers = this.$_all.get(type) || []; const handlers = this.$_all.get(type) || [];
const newHandlers = handler ? handlers.filter(x => x !== handler) : []; const newHandlers = handler ? handlers.filter((x) => x !== handler) : [];
if (newHandlers.length) { if (newHandlers.length) {
this.$_all.set(type, newHandlers); this.$_all.set(type, newHandlers);
...@@ -77,7 +77,7 @@ class EventHub { ...@@ -77,7 +77,7 @@ class EventHub {
$emit(type, ...args) { $emit(type, ...args) {
const handlers = this.$_all.get(type) || []; const handlers = this.$_all.get(type) || [];
handlers.forEach(handler => { handlers.forEach((handler) => {
handler(...args); handler(...args);
}); });
} }
......
...@@ -38,7 +38,7 @@ const templatedLabel = (queryLabel, metricAttributes) => { ...@@ -38,7 +38,7 @@ const templatedLabel = (queryLabel, metricAttributes) => {
* @example * @example
* multiMetricLabel('', {__name__: "up", app: "prometheus"}) -> "__name__: up, app: prometheus" * multiMetricLabel('', {__name__: "up", app: "prometheus"}) -> "__name__: up, app: prometheus"
*/ */
const multiMetricLabel = metricAttributes => { const multiMetricLabel = (metricAttributes) => {
return Object.entries(metricAttributes) return Object.entries(metricAttributes)
.map(([templateVar, label]) => `${templateVar}: ${label}`) .map(([templateVar, label]) => `${templateVar}: ${label}`)
.join(', '); .join(', ');
...@@ -64,7 +64,7 @@ export const getSeriesLabel = (queryLabel, metricAttributes) => { ...@@ -64,7 +64,7 @@ export const getSeriesLabel = (queryLabel, metricAttributes) => {
* @returns {Array} The formatted values * @returns {Array} The formatted values
*/ */
export const makeDataSeries = (queryResults, defaultConfig) => export const makeDataSeries = (queryResults, defaultConfig) =>
queryResults.map(result => { queryResults.map((result) => {
return { return {
...defaultConfig, ...defaultConfig,
data: result.values, data: result.values,
......
...@@ -23,13 +23,13 @@ const handleStartupEvents = () => { ...@@ -23,13 +23,13 @@ const handleStartupEvents = () => {
/* For `waitForCSSLoaded` methods, see docs.gitlab.com/ee/development/fe_guide/performance.html#important-considerations */ /* For `waitForCSSLoaded` methods, see docs.gitlab.com/ee/development/fe_guide/performance.html#important-considerations */
export const waitForCSSLoaded = (action = () => {}) => { export const waitForCSSLoaded = (action = () => {}) => {
if (!gon?.features?.startupCss || allLinksLoaded()) { if (!gon?.features?.startupCss || allLinksLoaded()) {
return new Promise(resolve => { return new Promise((resolve) => {
action(); action();
resolve(); resolve();
}); });
} }
return new Promise(resolve => { return new Promise((resolve) => {
document.addEventListener(CSS_LOADED_EVENT, resolve, { once: true }); document.addEventListener(CSS_LOADED_EVENT, resolve, { once: true });
document.addEventListener(STARTUP_LINK_LOADED_EVENT, handleStartupEvents); document.addEventListener(STARTUP_LINK_LOADED_EVENT, handleStartupEvents);
}).then(action); }).then(action);
......
import { commitItemIconMap } from './constants'; import { commitItemIconMap } from './constants';
export default file => { export default (file) => {
if (file.deleted) { if (file.deleted) {
return commitItemIconMap.deleted; return commitItemIconMap.deleted;
} else if (file.tempFile && !file.prevPath) { } else if (file.tempFile && !file.prevPath) {
......
...@@ -63,7 +63,7 @@ export default { ...@@ -63,7 +63,7 @@ export default {
return this.openPendingTab({ return this.openPendingTab({
file: this.file, file: this.file,
keyPrefix: this.keyPrefix, keyPrefix: this.keyPrefix,
}).then(changeViewer => { }).then((changeViewer) => {
if (changeViewer) { if (changeViewer) {
this.updateViewer(viewerTypes.diff); this.updateViewer(viewerTypes.diff);
} }
......
...@@ -29,7 +29,7 @@ export default { ...@@ -29,7 +29,7 @@ export default {
'undoFileTemplate', 'undoFileTemplate',
]), ]),
setInitialType() { setInitialType() {
const initialTemplateType = this.templateTypes.find(t => t.name === this.activeFile.name); const initialTemplateType = this.templateTypes.find((t) => t.name === this.activeFile.name);
if (initialTemplateType) { if (initialTemplateType) {
this.setSelectedTemplateType(initialTemplateType); this.setSelectedTemplateType(initialTemplateType);
......
...@@ -44,7 +44,7 @@ export default { ...@@ -44,7 +44,7 @@ export default {
computed: { computed: {
...mapState('fileTemplates', ['templates', 'isLoading']), ...mapState('fileTemplates', ['templates', 'isLoading']),
outputData() { outputData() {
return (this.isAsyncData ? this.templates : this.data).filter(t => { return (this.isAsyncData ? this.templates : this.data).filter((t) => {
if (!this.searchable) return true; if (!this.searchable) return true;
return t.name.toLowerCase().indexOf(this.search.toLowerCase()) >= 0; return t.name.toLowerCase().indexOf(this.search.toLowerCase()) >= 0;
......
...@@ -73,7 +73,7 @@ export default { ...@@ -73,7 +73,7 @@ export default {
}, },
}, },
mounted() { mounted() {
window.onbeforeunload = e => this.onBeforeUnload(e); window.onbeforeunload = (e) => this.onBeforeUnload(e);
if (this.themeName) if (this.themeName)
document.querySelector('.navbar-gitlab').classList.add(`theme-${this.themeName}`); document.querySelector('.navbar-gitlab').classList.add(`theme-${this.themeName}`);
......
...@@ -37,7 +37,7 @@ export default { ...@@ -37,7 +37,7 @@ export default {
}, },
methods: { methods: {
isActiveTab(tab) { isActiveTab(tab) {
return this.isOpen && tab.views.some(view => view.name === this.currentView); return this.isOpen && tab.views.some((view) => view.name === this.currentView);
}, },
buttonClasses(tab) { buttonClasses(tab) {
return [ return [
......
...@@ -30,7 +30,7 @@ export default { ...@@ -30,7 +30,7 @@ export default {
const rawContent = encodedContent ? atob(encodedContent) : ''; const rawContent = encodedContent ? atob(encodedContent) : '';
const isText = isTextFile({ content: rawContent, mimeType, name }); const isText = isTextFile({ content: rawContent, mimeType, name });
const emitCreateEvent = content => const emitCreateEvent = (content) =>
this.$emit('create', { this.$emit('create', {
name: `${this.path ? `${this.path}/` : ''}${name}`, name: `${this.path ? `${this.path}/` : ''}${name}`,
type: 'blob', type: 'blob',
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
if (isText) { if (isText) {
const reader = new FileReader(); const reader = new FileReader();
reader.addEventListener('load', e => emitCreateEvent(e.target.result), { once: true }); reader.addEventListener('load', (e) => emitCreateEvent(e.target.result), { once: true });
reader.readAsText(file); reader.readAsText(file);
} else { } else {
emitCreateEvent(rawContent); emitCreateEvent(rawContent);
...@@ -51,11 +51,11 @@ export default { ...@@ -51,11 +51,11 @@ export default {
readFile(file) { readFile(file) {
const reader = new FileReader(); const reader = new FileReader();
reader.addEventListener('load', e => this.createFile(e.target, file), { once: true }); reader.addEventListener('load', (e) => this.createFile(e.target, file), { once: true });
reader.readAsDataURL(file); reader.readAsDataURL(file);
}, },
openFile() { openFile() {
Array.from(this.$refs.fileUpload.files).forEach(file => this.readFile(file)); Array.from(this.$refs.fileUpload.files).forEach((file) => this.readFile(file));
}, },
startFileUpload() { startFileUpload() {
this.$refs.fileUpload.click(); this.$refs.fileUpload.click();
......
...@@ -35,13 +35,13 @@ export default { ...@@ -35,13 +35,13 @@ export default {
return `${this.side}Pane`; return `${this.side}Pane`;
}, },
tabs() { tabs() {
return this.extensionTabs.filter(tab => tab.show); return this.extensionTabs.filter((tab) => tab.show);
}, },
tabViews() { tabViews() {
return this.tabs.map(tab => tab.views).flat(); return this.tabs.map((tab) => tab.views).flat();
}, },
aliveTabViews() { aliveTabViews() {
return this.tabViews.filter(view => this.isAliveView(view.name)); return this.tabViews.filter((view) => this.isAliveView(view.name));
}, },
}, },
methods: { methods: {
......
...@@ -108,7 +108,7 @@ export default { ...@@ -108,7 +108,7 @@ export default {
.then(() => { .then(() => {
this.initManager(); this.initManager();
this.listener = listen(e => { this.listener = listen((e) => {
switch (e.type) { switch (e.type) {
case 'done': case 'done':
this.sandpackReady = true; this.sandpackReady = true;
...@@ -139,8 +139,8 @@ export default { ...@@ -139,8 +139,8 @@ export default {
const settings = { const settings = {
fileResolver: { fileResolver: {
isFile: p => Promise.resolve(Boolean(this.entries[createPathWithExt(p)])), isFile: (p) => Promise.resolve(Boolean(this.entries[createPathWithExt(p)])),
readFile: p => this.loadFileContent(createPathWithExt(p)).then(content => content), readFile: (p) => this.loadFileContent(createPathWithExt(p)).then((content) => content),
}, },
...(bundlerURL ? { bundlerURL } : {}), ...(bundlerURL ? { bundlerURL } : {}),
}; };
......
...@@ -31,7 +31,7 @@ export default { ...@@ -31,7 +31,7 @@ export default {
}, },
}, },
mounted() { mounted() {
this.listener = listen(e => { this.listener = listen((e) => {
switch (e.type) { switch (e.type) {
case 'urlchange': case 'urlchange':
this.onUrlChange(e); this.onUrlChange(e);
......
...@@ -41,12 +41,12 @@ export default { ...@@ -41,12 +41,12 @@ export default {
file, file,
keyPrefix: file.staged ? stageKeys.staged : stageKeys.unstaged, keyPrefix: file.staged ? stageKeys.staged : stageKeys.unstaged,
}) })
.then(changeViewer => { .then((changeViewer) => {
if (changeViewer) { if (changeViewer) {
this.updateViewer('diff'); this.updateViewer('diff');
} }
}) })
.catch(e => { .catch((e) => {
throw e; throw e;
}); });
}, },
......
...@@ -219,7 +219,7 @@ export default { ...@@ -219,7 +219,7 @@ export default {
.then(() => { .then(() => {
this.createEditorInstance(); this.createEditorInstance();
}) })
.catch(err => { .catch((err) => {
flash( flash(
__('Error setting up editor. Please try again.'), __('Error setting up editor. Please try again.'),
'alert', 'alert',
...@@ -281,7 +281,7 @@ export default { ...@@ -281,7 +281,7 @@ export default {
this.model.updateOptions(this.rules); this.model.updateOptions(this.rules);
this.model.onChange(model => { this.model.onChange((model) => {
const { file } = model; const { file } = model;
if (!file.active) return; if (!file.active) return;
...@@ -329,7 +329,7 @@ export default { ...@@ -329,7 +329,7 @@ export default {
} }
}, },
fetchEditorconfigRules() { fetchEditorconfigRules() {
return getRulesWithTraversal(this.file.path, path => { return getRulesWithTraversal(this.file.path, (path) => {
const entry = this.entries[path]; const entry = this.entries[path];
if (!entry) return Promise.resolve(null); if (!entry) return Promise.resolve(null);
...@@ -339,7 +339,7 @@ export default { ...@@ -339,7 +339,7 @@ export default {
return this.getFileData({ path: entry.path, makeFileActive: false }).then(() => return this.getFileData({ path: entry.path, makeFileActive: false }).then(() =>
this.getRawFileData({ path: entry.path }), this.getRawFileData({ path: entry.path }),
); );
}).then(rules => { }).then((rules) => {
this.rules = mapRulesToMonaco(rules); this.rules = mapRulesToMonaco(rules);
}); });
}, },
...@@ -353,7 +353,7 @@ export default { ...@@ -353,7 +353,7 @@ export default {
event.preventDefault(); event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
return readFileAsDataURL(file).then(content => { return readFileAsDataURL(file).then((content) => {
const parentPath = getPathParent(this.file.path); const parentPath = getPathParent(this.file.path);
const path = `${parentPath ? `${parentPath}/` : ''}${file.name}`; const path = `${parentPath ? `${parentPath}/` : ''}${file.name}`;
......
...@@ -39,7 +39,7 @@ const EmptyRouterComponent = { ...@@ -39,7 +39,7 @@ const EmptyRouterComponent = {
}, },
}; };
export const createRouter = store => { export const createRouter = (store) => {
const router = new IdeRouter({ const router = new IdeRouter({
mode: 'history', mode: 'history',
base: joinPaths(gon.relative_url_root || '', '/-/ide/'), base: joinPaths(gon.relative_url_root || '', '/-/ide/'),
...@@ -54,11 +54,11 @@ export const createRouter = store => { ...@@ -54,11 +54,11 @@ export const createRouter = store => {
}, },
{ {
path: ':targetmode(edit|tree|blob)/:branchid+/', path: ':targetmode(edit|tree|blob)/:branchid+/',
redirect: to => joinPaths(to.path, '/-/'), redirect: (to) => joinPaths(to.path, '/-/'),
}, },
{ {
path: ':targetmode(edit|tree|blob)', path: ':targetmode(edit|tree|blob)',
redirect: to => joinPaths(to.path, '/master/-/'), redirect: (to) => joinPaths(to.path, '/master/-/'),
}, },
{ {
path: 'merge_requests/:mrid', path: 'merge_requests/:mrid',
...@@ -66,7 +66,7 @@ export const createRouter = store => { ...@@ -66,7 +66,7 @@ export const createRouter = store => {
}, },
{ {
path: '', path: '',
redirect: to => joinPaths(to.path, '/edit/master/-/'), redirect: (to) => joinPaths(to.path, '/edit/master/-/'),
}, },
], ],
}, },
...@@ -110,7 +110,7 @@ export const createRouter = store => { ...@@ -110,7 +110,7 @@ export const createRouter = store => {
}); });
} }
}) })
.catch(e => { .catch((e) => {
flash( flash(
__('Error while loading the project data. Please try again.'), __('Error while loading the project data. Please try again.'),
'alert', 'alert',
......
...@@ -4,11 +4,11 @@ export default class Disposable { ...@@ -4,11 +4,11 @@ export default class Disposable {
} }
add(...disposers) { add(...disposers) {
disposers.forEach(disposer => this.disposers.add(disposer)); disposers.forEach((disposer) => this.disposers.add(disposer));
} }
dispose() { dispose() {
this.disposers.forEach(disposer => disposer.dispose()); this.disposers.forEach((disposer) => disposer.dispose());
this.disposers.clear(); this.disposers.clear();
} }
} }
...@@ -75,7 +75,7 @@ export default class Model { ...@@ -75,7 +75,7 @@ export default class Model {
} }
onChange(cb) { onChange(cb) {
this.events.add(this.disposable.add(this.model.onDidChangeContent(e => cb(this, e)))); this.events.add(this.disposable.add(this.model.onDidChangeContent((e) => cb(this, e))));
} }
onDispose(cb) { onDispose(cb) {
...@@ -121,7 +121,7 @@ export default class Model { ...@@ -121,7 +121,7 @@ export default class Model {
dispose() { dispose() {
if (!this.model.isDisposed()) this.applyCustomOptions(); if (!this.model.isDisposed()) this.applyCustomOptions();
this.events.forEach(cb => { this.events.forEach((cb) => {
if (typeof cb === 'function') cb(); if (typeof cb === 'function') cb();
}); });
......
...@@ -12,13 +12,13 @@ const NEW_LINE = '\n'; ...@@ -12,13 +12,13 @@ const NEW_LINE = '\n';
* *
* - Removes "=======" separator added at the beginning * - Removes "=======" separator added at the beginning
*/ */
const cleanTwoFilesPatch = text => text.replace(/^(=+\s*)/, ''); const cleanTwoFilesPatch = (text) => text.replace(/^(=+\s*)/, '');
const endsWithNewLine = val => !val || val[val.length - 1] === NEW_LINE; const endsWithNewLine = (val) => !val || val[val.length - 1] === NEW_LINE;
const addEndingNewLine = val => (endsWithNewLine(val) ? val : val + NEW_LINE); const addEndingNewLine = (val) => (endsWithNewLine(val) ? val : val + NEW_LINE);
const removeEndingNewLine = val => (endsWithNewLine(val) ? val.substr(0, val.length - 1) : val); const removeEndingNewLine = (val) => (endsWithNewLine(val) ? val.substr(0, val.length - 1) : val);
const diffHead = (prevPath, newPath = '') => const diffHead = (prevPath, newPath = '') =>
`diff --git "a/${prevPath}" "b/${newPath || prevPath}"`; `diff --git "a/${prevPath}" "b/${newPath || prevPath}"`;
...@@ -37,7 +37,7 @@ const createDiffBody = (path, content, isCreate) => { ...@@ -37,7 +37,7 @@ const createDiffBody = (path, content, isCreate) => {
const chunkHead = isCreate ? `@@ -0,0 +1,${lines.length} @@` : `@@ -1,${lines.length} +0,0 @@`; const chunkHead = isCreate ? `@@ -0,0 +1,${lines.length} @@` : `@@ -1,${lines.length} +0,0 @@`;
const chunk = lines const chunk = lines
.map(line => `${prefix}${line}`) .map((line) => `${prefix}${line}`)
.concat(!hasNewLine ? [NO_NEW_LINE] : []) .concat(!hasNewLine ? [NO_NEW_LINE] : [])
.join(NEW_LINE); .join(NEW_LINE);
......
...@@ -11,7 +11,7 @@ export default class DecorationsController { ...@@ -11,7 +11,7 @@ export default class DecorationsController {
const modelDecorations = this.decorations.get(model.url); const modelDecorations = this.decorations.get(model.url);
const decorations = []; const decorations = [];
modelDecorations.forEach(val => decorations.push(...val)); modelDecorations.forEach((val) => decorations.push(...val));
return decorations; return decorations;
} }
......
...@@ -3,7 +3,7 @@ import { throttle } from 'lodash'; ...@@ -3,7 +3,7 @@ import { throttle } from 'lodash';
import DirtyDiffWorker from './diff_worker'; import DirtyDiffWorker from './diff_worker';
import Disposable from '../common/disposable'; import Disposable from '../common/disposable';
export const getDiffChangeType = change => { export const getDiffChangeType = (change) => {
if (change.modified) { if (change.modified) {
return 'modified'; return 'modified';
} else if (change.added) { } else if (change.added) {
...@@ -15,7 +15,7 @@ export const getDiffChangeType = change => { ...@@ -15,7 +15,7 @@ export const getDiffChangeType = change => {
return ''; return '';
}; };
export const getDecorator = change => ({ export const getDecorator = (change) => ({
range: new Range(change.lineNumber, 1, change.endLineNumber, 1), range: new Range(change.lineNumber, 1, change.endLineNumber, 1),
options: { options: {
isWholeLine: true, isWholeLine: true,
...@@ -71,7 +71,7 @@ export default class DirtyDiffController { ...@@ -71,7 +71,7 @@ export default class DirtyDiffController {
} }
decorate({ data }) { decorate({ data }) {
const decorations = data.changes.map(change => getDecorator(change)); const decorations = data.changes.map((change) => getDecorator(change));
const model = this.modelManager.getModel(data.path); const model = this.modelManager.getModel(data.path);
this.decorationsController.addDecorations(model, 'dirtyDiff', decorations); this.decorationsController.addDecorations(model, 'dirtyDiff', decorations);
} }
......
...@@ -11,7 +11,7 @@ export const computeDiff = (originalContent, newContent) => { ...@@ -11,7 +11,7 @@ export const computeDiff = (originalContent, newContent) => {
let lineNumber = 1; let lineNumber = 1;
return changes.reduce((acc, change) => { return changes.reduce((acc, change) => {
const findOnLine = acc.find(c => c.lineNumber === lineNumber); const findOnLine = acc.find((c) => c.lineNumber === lineNumber);
if (findOnLine) { if (findOnLine) {
Object.assign(findOnLine, change, { Object.assign(findOnLine, change, {
......
import { computeDiff } from './diff'; import { computeDiff } from './diff';
// eslint-disable-next-line no-restricted-globals // eslint-disable-next-line no-restricted-globals
self.addEventListener('message', e => { self.addEventListener('message', (e) => {
const { data } = e; const { data } = e;
// eslint-disable-next-line no-restricted-globals // eslint-disable-next-line no-restricted-globals
......
...@@ -12,7 +12,7 @@ import { clearDomElement } from '~/editor/utils'; ...@@ -12,7 +12,7 @@ import { clearDomElement } from '~/editor/utils';
import { registerLanguages } from '../utils'; import { registerLanguages } from '../utils';
function setupThemes() { function setupThemes() {
themes.forEach(theme => { themes.forEach((theme) => {
monacoEditor.defineTheme(theme.name, theme.data); monacoEditor.defineTheme(theme.name, theme.data);
}); });
} }
...@@ -108,7 +108,7 @@ export default class Editor { ...@@ -108,7 +108,7 @@ export default class Editor {
this.instance.updateOptions( this.instance.updateOptions(
editorOptions.reduce((acc, obj) => { editorOptions.reduce((acc, obj) => {
Object.keys(obj).forEach(key => { Object.keys(obj).forEach((key) => {
Object.assign(acc, { Object.assign(acc, {
[key]: obj[key](model), [key]: obj[key](model),
}); });
...@@ -177,7 +177,7 @@ export default class Editor { ...@@ -177,7 +177,7 @@ export default class Editor {
onPositionChange(cb) { onPositionChange(cb) {
if (!this.instance.onDidChangeCursorPosition) return; if (!this.instance.onDidChangeCursorPosition) return;
this.disposable.add(this.instance.onDidChangeCursorPosition(e => cb(this.instance, e))); this.disposable.add(this.instance.onDidChangeCursorPosition((e) => cb(this.instance, e)));
} }
updateDiffView() { updateDiffView() {
...@@ -213,14 +213,14 @@ export default class Editor { ...@@ -213,14 +213,14 @@ export default class Editor {
addCommands() { addCommands() {
const { store } = this; const { store } = this;
const getKeyCode = key => { const getKeyCode = (key) => {
const monacoKeyMod = key.indexOf('KEY_') === 0; const monacoKeyMod = key.indexOf('KEY_') === 0;
return monacoKeyMod ? KeyCode[key] : KeyMod[key]; return monacoKeyMod ? KeyCode[key] : KeyMod[key];
}; };
keymap.forEach(command => { keymap.forEach((command) => {
const keybindings = command.bindings.map(binding => { const keybindings = command.bindings.map((binding) => {
const keys = binding.split('+'); const keys = binding.split('+');
// eslint-disable-next-line no-bitwise // eslint-disable-next-line no-bitwise
......
...@@ -31,7 +31,7 @@ export const defaultModelOptions = { ...@@ -31,7 +31,7 @@ export const defaultModelOptions = {
export const editorOptions = [ export const editorOptions = [
{ {
readOnly: model => Boolean(model.file.file_lock), readOnly: (model) => Boolean(model.file.file_lock),
quickSuggestions: model => !(model.language === 'markdown'), quickSuggestions: (model) => !(model.language === 'markdown'),
}, },
]; ];
...@@ -2,7 +2,7 @@ import { parseString } from 'editorconfig/src/lib/ini'; ...@@ -2,7 +2,7 @@ import { parseString } from 'editorconfig/src/lib/ini';
import minimatch from 'minimatch'; import minimatch from 'minimatch';
import { getPathParents } from '../../utils'; import { getPathParents } from '../../utils';
const dirname = path => path.replace(/\.editorconfig$/, ''); const dirname = (path) => path.replace(/\.editorconfig$/, '');
function isRootConfig(config) { function isRootConfig(config) {
return config.some(([pattern, rules]) => !pattern && rules?.root === 'true'); return config.some(([pattern, rules]) => !pattern && rules?.root === 'true');
...@@ -44,16 +44,16 @@ function getRulesWithConfigs(filePath, configFiles = [], rules = {}) { ...@@ -44,16 +44,16 @@ function getRulesWithConfigs(filePath, configFiles = [], rules = {}) {
export function getRulesWithTraversal(filePath, getFileContent) { export function getRulesWithTraversal(filePath, getFileContent) {
const editorconfigPaths = [ const editorconfigPaths = [
...getPathParents(filePath).map(x => `${x}/.editorconfig`), ...getPathParents(filePath).map((x) => `${x}/.editorconfig`),
'.editorconfig', '.editorconfig',
]; ];
return Promise.all( return Promise.all(
editorconfigPaths.map(path => getFileContent(path).then(content => ({ path, content }))), editorconfigPaths.map((path) => getFileContent(path).then((content) => ({ path, content }))),
).then(results => ).then((results) =>
getRulesWithConfigs( getRulesWithConfigs(
filePath, filePath,
results.filter(x => x.content), results.filter((x) => x.content),
), ),
); );
} }
import { isBoolean, isNumber } from 'lodash'; import { isBoolean, isNumber } from 'lodash';
const map = (key, validValues) => value => const map = (key, validValues) => (value) =>
value in validValues ? { [key]: validValues[value] } : {}; value in validValues ? { [key]: validValues[value] } : {};
const bool = key => value => (isBoolean(value) ? { [key]: value } : {}); const bool = (key) => (value) => (isBoolean(value) ? { [key]: value } : {});
const int = (key, isValid) => value => const int = (key, isValid) => (value) =>
isNumber(value) && isValid(value) ? { [key]: Math.trunc(value) } : {}; isNumber(value) && isValid(value) ? { [key]: Math.trunc(value) } : {};
const rulesMapper = { const rulesMapper = {
indent_style: map('insertSpaces', { tab: false, space: true }), indent_style: map('insertSpaces', { tab: false, space: true }),
indent_size: int('tabSize', n => n > 0), indent_size: int('tabSize', (n) => n > 0),
tab_width: int('tabSize', n => n > 0), tab_width: int('tabSize', (n) => n > 0),
trim_trailing_whitespace: bool('trimTrailingWhitespace'), trim_trailing_whitespace: bool('trimTrailingWhitespace'),
end_of_line: map('endOfLine', { crlf: 1, lf: 0 }), end_of_line: map('endOfLine', { crlf: 1, lf: 0 }),
insert_final_newline: bool('insertFinalNewline'), insert_final_newline: bool('insertFinalNewline'),
}; };
const parseValue = x => { const parseValue = (x) => {
let value = typeof x === 'string' ? x.toLowerCase() : x; let value = typeof x === 'string' ? x.toLowerCase() : x;
if (/^[0-9.-]+$/.test(value)) value = Number(value); if (/^[0-9.-]+$/.test(value)) value = Number(value);
if (value === 'true') value = true; if (value === 'true') value = true;
......
...@@ -6,17 +6,17 @@ const CODEOWNERS_REGEX = /Push.*protected branches.*CODEOWNERS/; ...@@ -6,17 +6,17 @@ const CODEOWNERS_REGEX = /Push.*protected branches.*CODEOWNERS/;
const BRANCH_CHANGED_REGEX = /changed.*since.*start.*edit/; const BRANCH_CHANGED_REGEX = /changed.*since.*start.*edit/;
const BRANCH_ALREADY_EXISTS = /branch.*already.*exists/; const BRANCH_ALREADY_EXISTS = /branch.*already.*exists/;
const createNewBranchAndCommit = store => const createNewBranchAndCommit = (store) =>
store store
.dispatch('commit/updateCommitAction', consts.COMMIT_TO_NEW_BRANCH) .dispatch('commit/updateCommitAction', consts.COMMIT_TO_NEW_BRANCH)
.then(() => store.dispatch('commit/commitChanges')); .then(() => store.dispatch('commit/commitChanges'));
export const createUnexpectedCommitError = message => ({ export const createUnexpectedCommitError = (message) => ({
title: __('Unexpected error'), title: __('Unexpected error'),
messageHTML: escape(message) || __('Could not commit. An unexpected error occurred.'), messageHTML: escape(message) || __('Could not commit. An unexpected error occurred.'),
}); });
export const createCodeownersCommitError = message => ({ export const createCodeownersCommitError = (message) => ({
title: __('CODEOWNERS rule violation'), title: __('CODEOWNERS rule violation'),
messageHTML: escape(message), messageHTML: escape(message),
primaryAction: { primaryAction: {
...@@ -25,7 +25,7 @@ export const createCodeownersCommitError = message => ({ ...@@ -25,7 +25,7 @@ export const createCodeownersCommitError = message => ({
}, },
}); });
export const createBranchChangedCommitError = message => ({ export const createBranchChangedCommitError = (message) => ({
title: __('Branch changed'), title: __('Branch changed'),
messageHTML: `${escape(message)}<br/><br/>${__('Would you like to create a new branch?')}`, messageHTML: `${escape(message)}<br/><br/>${__('Would you like to create a new branch?')}`,
primaryAction: { primaryAction: {
...@@ -34,19 +34,19 @@ export const createBranchChangedCommitError = message => ({ ...@@ -34,19 +34,19 @@ export const createBranchChangedCommitError = message => ({
}, },
}); });
export const branchAlreadyExistsCommitError = message => ({ export const branchAlreadyExistsCommitError = (message) => ({
title: __('Branch already exists'), title: __('Branch already exists'),
messageHTML: `${escape(message)}<br/><br/>${__( messageHTML: `${escape(message)}<br/><br/>${__(
'Would you like to try auto-generating a branch name?', 'Would you like to try auto-generating a branch name?',
)}`, )}`,
primaryAction: { primaryAction: {
text: __('Create new branch'), text: __('Create new branch'),
callback: store => callback: (store) =>
store.dispatch('commit/addSuffixToBranchName').then(() => createNewBranchAndCommit(store)), store.dispatch('commit/addSuffixToBranchName').then(() => createNewBranchAndCommit(store)),
}, },
}); });
export const parseCommitError = e => { export const parseCommitError = (e) => {
const { message } = e?.response?.data || {}; const { message } = e?.response?.data || {};
if (!message) { if (!message) {
......
import { decorateData, sortTree } from '../stores/utils'; import { decorateData, sortTree } from '../stores/utils';
export const splitParent = path => { export const splitParent = (path) => {
const idx = path.lastIndexOf('/'); const idx = path.lastIndexOf('/');
return { return {
...@@ -32,7 +32,7 @@ export const decorateFiles = ({ ...@@ -32,7 +32,7 @@ export const decorateFiles = ({
let file; let file;
let parentPath; let parentPath;
const insertParent = path => { const insertParent = (path) => {
if (!path) { if (!path) {
return null; return null;
} else if (entries[path]) { } else if (entries[path]) {
...@@ -67,7 +67,7 @@ export const decorateFiles = ({ ...@@ -67,7 +67,7 @@ export const decorateFiles = ({
return tree; return tree;
}; };
data.forEach(path => { data.forEach((path) => {
const { parent, name } = splitParent(path); const { parent, name } = splitParent(path);
const fileFolder = parent && insertParent(parent); const fileFolder = parent && insertParent(parent);
......
...@@ -12,23 +12,23 @@ export const MSG_CONNECTION_ERROR = __('Could not connect to Web IDE file mirror ...@@ -12,23 +12,23 @@ export const MSG_CONNECTION_ERROR = __('Could not connect to Web IDE file mirror
const noop = () => {}; const noop = () => {};
export const SERVICE_DELAY = 8000; export const SERVICE_DELAY = 8000;
const cancellableWait = time => { const cancellableWait = (time) => {
let timeoutId = 0; let timeoutId = 0;
const cancel = () => clearTimeout(timeoutId); const cancel = () => clearTimeout(timeoutId);
const promise = new Promise(resolve => { const promise = new Promise((resolve) => {
timeoutId = setTimeout(resolve, time); timeoutId = setTimeout(resolve, time);
}); });
return [promise, cancel]; return [promise, cancel];
}; };
const isErrorResponse = error => error && error.code !== 0; const isErrorResponse = (error) => error && error.code !== 0;
const isErrorPayload = payload => payload && payload.status_code !== 200; const isErrorPayload = (payload) => payload && payload.status_code !== 200;
const getErrorFromResponse = data => { const getErrorFromResponse = (data) => {
if (isErrorResponse(data.error)) { if (isErrorResponse(data.error)) {
return { message: data.error.Message }; return { message: data.error.Message };
} else if (isErrorPayload(data.payload)) { } else if (isErrorPayload(data.payload)) {
...@@ -38,9 +38,9 @@ const getErrorFromResponse = data => { ...@@ -38,9 +38,9 @@ const getErrorFromResponse = data => {
return null; return null;
}; };
const getFullPath = path => mergeUrlParams({ service: SERVICE_NAME }, getWebSocketUrl(path)); const getFullPath = (path) => mergeUrlParams({ service: SERVICE_NAME }, getWebSocketUrl(path));
const createWebSocket = fullPath => const createWebSocket = (fullPath) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
const socket = new WebSocket(fullPath, [PROTOCOL]); const socket = new WebSocket(fullPath, [PROTOCOL]);
const resetCallbacks = () => { const resetCallbacks = () => {
...@@ -59,7 +59,7 @@ const createWebSocket = fullPath => ...@@ -59,7 +59,7 @@ const createWebSocket = fullPath =>
}; };
}); });
export const canConnect = ({ services = [] }) => services.some(name => name === SERVICE_NAME); export const canConnect = ({ services = [] }) => services.some((name) => name === SERVICE_NAME);
export const createMirror = () => { export const createMirror = () => {
let socket = null; let socket = null;
...@@ -71,23 +71,23 @@ export const createMirror = () => { ...@@ -71,23 +71,23 @@ export const createMirror = () => {
cancelHandler = noop; cancelHandler = noop;
}; };
const onCancelConnect = fn => { const onCancelConnect = (fn) => {
cancelHandler = fn; cancelHandler = fn;
}; };
const receiveMessage = ev => { const receiveMessage = (ev) => {
const handle = nextMessageHandler; const handle = nextMessageHandler;
nextMessageHandler = noop; nextMessageHandler = noop;
handle(JSON.parse(ev.data)); handle(JSON.parse(ev.data));
}; };
const onNextMessage = fn => { const onNextMessage = (fn) => {
nextMessageHandler = fn; nextMessageHandler = fn;
}; };
const waitForNextMessage = () => const waitForNextMessage = () =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
onNextMessage(data => { onNextMessage((data) => {
const err = getErrorFromResponse(data); const err = getErrorFromResponse(data);
if (err) { if (err) {
...@@ -133,7 +133,7 @@ export const createMirror = () => { ...@@ -133,7 +133,7 @@ export const createMirror = () => {
return wait return wait
.then(() => createWebSocket(fullPath)) .then(() => createWebSocket(fullPath))
.then(newSocket => { .then((newSocket) => {
socket = newSocket; socket = newSocket;
socket.onmessage = receiveMessage; socket.onmessage = receiveMessage;
}); });
......
...@@ -4,9 +4,9 @@ import Api from '~/api'; ...@@ -4,9 +4,9 @@ import Api from '~/api';
import getUserPermissions from '../queries/getUserPermissions.query.graphql'; import getUserPermissions from '../queries/getUserPermissions.query.graphql';
import { query } from './gql'; import { query } from './gql';
const fetchApiProjectData = projectPath => Api.project(projectPath).then(({ data }) => data); const fetchApiProjectData = (projectPath) => Api.project(projectPath).then(({ data }) => data);
const fetchGqlProjectData = projectPath => const fetchGqlProjectData = (projectPath) =>
query({ query({
query: getUserPermissions, query: getUserPermissions,
variables: { projectPath }, variables: { projectPath },
...@@ -31,7 +31,7 @@ export default { ...@@ -31,7 +31,7 @@ export default {
return axios return axios
.get(file.rawPath, { .get(file.rawPath, {
transformResponse: [f => f], transformResponse: [(f) => f],
...options, ...options,
}) })
.then(({ data }) => data); .then(({ data }) => data);
...@@ -54,7 +54,7 @@ export default { ...@@ -54,7 +54,7 @@ export default {
escapeFileUrl(filePath), escapeFileUrl(filePath),
), ),
{ {
transformResponse: [f => f], transformResponse: [(f) => f],
}, },
) )
.then(({ data }) => data); .then(({ data }) => data);
......
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
export const baseUrl = projectPath => `/${projectPath}/ide_terminals`; export const baseUrl = (projectPath) => `/${projectPath}/ide_terminals`;
export const checkConfig = (projectPath, branch) => export const checkConfig = (projectPath, branch) =>
axios.post(`${baseUrl(projectPath)}/check_config`, { axios.post(`${baseUrl(projectPath)}/check_config`, {
......
...@@ -20,7 +20,7 @@ export const redirectToUrl = (self, url) => visitUrl(url); ...@@ -20,7 +20,7 @@ export const redirectToUrl = (self, url) => visitUrl(url);
export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DATA, data); export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DATA, data);
export const discardAllChanges = ({ state, commit, dispatch }) => { export const discardAllChanges = ({ state, commit, dispatch }) => {
state.changedFiles.forEach(file => dispatch('restoreOriginalFile', file.path)); state.changedFiles.forEach((file) => dispatch('restoreOriginalFile', file.path));
commit(types.REMOVE_ALL_CHANGES_FILES); commit(types.REMOVE_ALL_CHANGES_FILES);
}; };
...@@ -106,7 +106,7 @@ export const stageAllChanges = ({ state, commit, dispatch, getters }) => { ...@@ -106,7 +106,7 @@ export const stageAllChanges = ({ state, commit, dispatch, getters }) => {
commit(types.SET_LAST_COMMIT_MSG, ''); commit(types.SET_LAST_COMMIT_MSG, '');
state.changedFiles.forEach(file => state.changedFiles.forEach((file) =>
commit(types.STAGE_CHANGE, { path: file.path, diffInfo: getters.getDiffInfo(file.path) }), commit(types.STAGE_CHANGE, { path: file.path, diffInfo: getters.getDiffInfo(file.path) }),
); );
...@@ -123,7 +123,7 @@ export const stageAllChanges = ({ state, commit, dispatch, getters }) => { ...@@ -123,7 +123,7 @@ export const stageAllChanges = ({ state, commit, dispatch, getters }) => {
export const unstageAllChanges = ({ state, commit, dispatch, getters }) => { export const unstageAllChanges = ({ state, commit, dispatch, getters }) => {
const openFile = state.openFiles[0]; const openFile = state.openFiles[0];
state.stagedFiles.forEach(file => state.stagedFiles.forEach((file) =>
commit(types.UNSTAGE_CHANGE, { path: file.path, diffInfo: getters.getDiffInfo(file.path) }), commit(types.UNSTAGE_CHANGE, { path: file.path, diffInfo: getters.getDiffInfo(file.path) }),
); );
...@@ -194,7 +194,7 @@ export const deleteEntry = ({ commit, dispatch, state }, path) => { ...@@ -194,7 +194,7 @@ export const deleteEntry = ({ commit, dispatch, state }, path) => {
if (entry.opened) dispatch('closeFile', entry); if (entry.opened) dispatch('closeFile', entry);
if (isTree) { if (isTree) {
entry.tree.forEach(f => dispatch('deleteEntry', f.path)); entry.tree.forEach((f) => dispatch('deleteEntry', f.path));
} }
commit(types.DELETE_ENTRY, path); commit(types.DELETE_ENTRY, path);
...@@ -221,7 +221,7 @@ export const renameEntry = ({ dispatch, commit, state, getters }, { path, name, ...@@ -221,7 +221,7 @@ export const renameEntry = ({ dispatch, commit, state, getters }, { path, name,
commit(types.RENAME_ENTRY, { path, name, parentPath }); commit(types.RENAME_ENTRY, { path, name, parentPath });
if (entry.type === 'tree') { if (entry.type === 'tree') {
state.entries[newPath].tree.forEach(f => { state.entries[newPath].tree.forEach((f) => {
dispatch('renameEntry', { dispatch('renameEntry', {
path: f.path, path: f.path,
name: f.name, name: f.name,
...@@ -280,7 +280,7 @@ export const getBranchData = ({ commit, state }, { projectId, branchId, force = ...@@ -280,7 +280,7 @@ export const getBranchData = ({ commit, state }, { projectId, branchId, force =
commit(types.SET_BRANCH_WORKING_REFERENCE, { projectId, branchId, reference: id }); commit(types.SET_BRANCH_WORKING_REFERENCE, { projectId, branchId, reference: id });
resolve(data); resolve(data);
}) })
.catch(e => { .catch((e) => {
if (e.response.status === 404) { if (e.response.status === 404) {
reject(e); reject(e);
} else { } else {
......
...@@ -14,7 +14,7 @@ import { viewerTypes, stageKeys } from '../../constants'; ...@@ -14,7 +14,7 @@ import { viewerTypes, stageKeys } from '../../constants';
export const closeFile = ({ commit, state, dispatch, getters }, file) => { export const closeFile = ({ commit, state, dispatch, getters }, file) => {
const { path } = file; const { path } = file;
const indexOfClosedFile = state.openFiles.findIndex(f => f.key === file.key); const indexOfClosedFile = state.openFiles.findIndex((f) => f.key === file.key);
const fileWasActive = file.active; const fileWasActive = file.active;
if (file.pending) { if (file.pending) {
...@@ -108,7 +108,7 @@ export const getFileData = ( ...@@ -108,7 +108,7 @@ export const getFileData = (
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading the file.'), text: __('An error occurred while loading the file.'),
action: payload => action: (payload) =>
dispatch('getFileData', payload).then(() => dispatch('setErrorMessage', null)), dispatch('getFileData', payload).then(() => dispatch('setErrorMessage', null)),
actionText: __('Please try again'), actionText: __('Please try again'),
actionPayload: { path, makeFileActive }, actionPayload: { path, makeFileActive },
...@@ -125,13 +125,13 @@ export const setFileMrChange = ({ commit }, { file, mrChange }) => { ...@@ -125,13 +125,13 @@ export const setFileMrChange = ({ commit }, { file, mrChange }) => {
export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) => { export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) => {
const file = state.entries[path]; const file = state.entries[path];
const stagedFile = state.stagedFiles.find(f => f.path === path); const stagedFile = state.stagedFiles.find((f) => f.path === path);
const fileDeletedAndReadded = getters.isFileDeletedAndReadded(path); const fileDeletedAndReadded = getters.isFileDeletedAndReadded(path);
commit(types.TOGGLE_LOADING, { entry: file, forceValue: true }); commit(types.TOGGLE_LOADING, { entry: file, forceValue: true });
return service return service
.getRawFileData(fileDeletedAndReadded ? stagedFile : file) .getRawFileData(fileDeletedAndReadded ? stagedFile : file)
.then(raw => { .then((raw) => {
if (!(file.tempFile && !file.prevPath && !fileDeletedAndReadded)) if (!(file.tempFile && !file.prevPath && !fileDeletedAndReadded))
commit(types.SET_FILE_RAW_DATA, { file, raw, fileDeletedAndReadded }); commit(types.SET_FILE_RAW_DATA, { file, raw, fileDeletedAndReadded });
...@@ -139,7 +139,7 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) = ...@@ -139,7 +139,7 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) =
const baseSha = const baseSha =
(getters.currentMergeRequest && getters.currentMergeRequest.baseCommitSha) || ''; (getters.currentMergeRequest && getters.currentMergeRequest.baseCommitSha) || '';
return service.getBaseRawFileData(file, state.currentProjectId, baseSha).then(baseRaw => { return service.getBaseRawFileData(file, state.currentProjectId, baseSha).then((baseRaw) => {
commit(types.SET_FILE_BASE_RAW_DATA, { commit(types.SET_FILE_BASE_RAW_DATA, {
file, file,
baseRaw, baseRaw,
...@@ -149,10 +149,10 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) = ...@@ -149,10 +149,10 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) =
} }
return raw; return raw;
}) })
.catch(e => { .catch((e) => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading the file content.'), text: __('An error occurred while loading the file content.'),
action: payload => action: (payload) =>
dispatch('getRawFileData', payload).then(() => dispatch('setErrorMessage', null)), dispatch('getRawFileData', payload).then(() => dispatch('setErrorMessage', null)),
actionText: __('Please try again'), actionText: __('Please try again'),
actionPayload: { path }, actionPayload: { path },
...@@ -178,7 +178,7 @@ export const changeFileContent = ({ commit, state, getters }, { path, content }) ...@@ -178,7 +178,7 @@ export const changeFileContent = ({ commit, state, getters }, { path, content })
content, content,
}); });
const indexOfChangedFile = state.changedFiles.findIndex(f => f.path === path); const indexOfChangedFile = state.changedFiles.findIndex((f) => f.path === path);
if (file.changed && indexOfChangedFile === -1) { if (file.changed && indexOfChangedFile === -1) {
commit(types.STAGE_CHANGE, { path, diffInfo: getters.getDiffInfo(path) }); commit(types.STAGE_CHANGE, { path, diffInfo: getters.getDiffInfo(path) });
...@@ -225,7 +225,7 @@ export const discardFileChanges = ({ dispatch, state, commit, getters }, path) = ...@@ -225,7 +225,7 @@ export const discardFileChanges = ({ dispatch, state, commit, getters }, path) =
.then(() => { .then(() => {
dispatch('router/push', getters.getUrlForPath(file.path), { root: true }); dispatch('router/push', getters.getUrlForPath(file.path), { root: true });
}) })
.catch(e => { .catch((e) => {
throw e; throw e;
}); });
} }
...@@ -275,7 +275,7 @@ export const unstageChange = ({ commit, dispatch, getters }, path) => { ...@@ -275,7 +275,7 @@ export const unstageChange = ({ commit, dispatch, getters }, path) => {
export const openPendingTab = ({ commit, dispatch, getters, state }, { file, keyPrefix }) => { export const openPendingTab = ({ commit, dispatch, getters, state }, { file, keyPrefix }) => {
if (getters.activeFile && getters.activeFile.key === `${keyPrefix}-${file.key}`) return false; if (getters.activeFile && getters.activeFile.key === `${keyPrefix}-${file.key}`) return false;
state.openFiles.forEach(f => eventHub.$emit(`editor.update.model.dispose.${f.key}`)); state.openFiles.forEach((f) => eventHub.$emit(`editor.update.model.dispose.${f.key}`));
commit(types.ADD_PENDING_TAB, { file, keyPrefix }); commit(types.ADD_PENDING_TAB, { file, keyPrefix });
......
...@@ -33,7 +33,7 @@ export const getMergeRequestsForBranch = ( ...@@ -33,7 +33,7 @@ export const getMergeRequestsForBranch = (
commit(types.SET_CURRENT_MERGE_REQUEST, `${currentMR.iid}`); commit(types.SET_CURRENT_MERGE_REQUEST, `${currentMR.iid}`);
} }
}) })
.catch(e => { .catch((e) => {
flash( flash(
__(`Error fetching merge requests for ${branchId}`), __(`Error fetching merge requests for ${branchId}`),
'alert', 'alert',
...@@ -66,7 +66,7 @@ export const getMergeRequestData = ( ...@@ -66,7 +66,7 @@ export const getMergeRequestData = (
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading the merge request.'), text: __('An error occurred while loading the merge request.'),
action: payload => action: (payload) =>
dispatch('getMergeRequestData', payload).then(() => dispatch('getMergeRequestData', payload).then(() =>
dispatch('setErrorMessage', null), dispatch('setErrorMessage', null),
), ),
...@@ -99,7 +99,7 @@ export const getMergeRequestChanges = ( ...@@ -99,7 +99,7 @@ export const getMergeRequestChanges = (
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading the merge request changes.'), text: __('An error occurred while loading the merge request changes.'),
action: payload => action: (payload) =>
dispatch('getMergeRequestChanges', payload).then(() => dispatch('getMergeRequestChanges', payload).then(() =>
dispatch('setErrorMessage', null), dispatch('setErrorMessage', null),
), ),
...@@ -121,8 +121,8 @@ export const getMergeRequestVersions = ( ...@@ -121,8 +121,8 @@ export const getMergeRequestVersions = (
if (!state.projects[projectId].mergeRequests[mergeRequestId].versions.length || force) { if (!state.projects[projectId].mergeRequests[mergeRequestId].versions.length || force) {
service service
.getProjectMergeRequestVersions(targetProjectId || projectId, mergeRequestId) .getProjectMergeRequestVersions(targetProjectId || projectId, mergeRequestId)
.then(res => res.data) .then((res) => res.data)
.then(data => { .then((data) => {
commit(types.SET_MERGE_REQUEST_VERSIONS, { commit(types.SET_MERGE_REQUEST_VERSIONS, {
projectPath: projectId, projectPath: projectId,
mergeRequestId, mergeRequestId,
...@@ -133,7 +133,7 @@ export const getMergeRequestVersions = ( ...@@ -133,7 +133,7 @@ export const getMergeRequestVersions = (
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading the merge request version data.'), text: __('An error occurred while loading the merge request version data.'),
action: payload => action: (payload) =>
dispatch('getMergeRequestVersions', payload).then(() => dispatch('getMergeRequestVersions', payload).then(() =>
dispatch('setErrorMessage', null), dispatch('setErrorMessage', null),
), ),
...@@ -156,7 +156,7 @@ export const openMergeRequest = ( ...@@ -156,7 +156,7 @@ export const openMergeRequest = (
targetProjectId, targetProjectId,
mergeRequestId, mergeRequestId,
}) })
.then(mr => { .then((mr) => {
dispatch('setCurrentBranchId', mr.source_branch); dispatch('setCurrentBranchId', mr.source_branch);
return dispatch('getBranchData', { return dispatch('getBranchData', {
...@@ -186,7 +186,7 @@ export const openMergeRequest = ( ...@@ -186,7 +186,7 @@ export const openMergeRequest = (
mergeRequestId, mergeRequestId,
}), }),
) )
.then(mrChanges => { .then((mrChanges) => {
if (mrChanges.changes.length) { if (mrChanges.changes.length) {
dispatch('updateActivityBarView', leftSidebarViews.review.name); dispatch('updateActivityBarView', leftSidebarViews.review.name);
} }
...@@ -210,7 +210,7 @@ export const openMergeRequest = ( ...@@ -210,7 +210,7 @@ export const openMergeRequest = (
} }
}); });
}) })
.catch(e => { .catch((e) => {
flash(__('Error while loading the merge request. Please try again.')); flash(__('Error while loading the merge request. Please try again.'));
throw e; throw e;
}); });
...@@ -11,8 +11,8 @@ export const getProjectData = ({ commit, state }, { namespace, projectId, force ...@@ -11,8 +11,8 @@ export const getProjectData = ({ commit, state }, { namespace, projectId, force
commit(types.TOGGLE_LOADING, { entry: state }); commit(types.TOGGLE_LOADING, { entry: state });
service service
.getProjectData(namespace, projectId) .getProjectData(namespace, projectId)
.then(res => res.data) .then((res) => res.data)
.then(data => { .then((data) => {
commit(types.TOGGLE_LOADING, { entry: state }); commit(types.TOGGLE_LOADING, { entry: state });
commit(types.SET_PROJECT, { projectPath: `${namespace}/${projectId}`, project: data }); commit(types.SET_PROJECT, { projectPath: `${namespace}/${projectId}`, project: data });
commit(types.SET_CURRENT_PROJECT, `${namespace}/${projectId}`); commit(types.SET_CURRENT_PROJECT, `${namespace}/${projectId}`);
...@@ -61,7 +61,7 @@ export const createNewBranchFromDefault = ({ state, dispatch, getters }, branch) ...@@ -61,7 +61,7 @@ export const createNewBranchFromDefault = ({ state, dispatch, getters }, branch)
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred creating the new branch.'), text: __('An error occurred creating the new branch.'),
action: payload => dispatch('createNewBranchFromDefault', payload), action: (payload) => dispatch('createNewBranchFromDefault', payload),
actionText: __('Please try again'), actionText: __('Please try again'),
actionPayload: branch, actionPayload: branch,
}); });
...@@ -76,7 +76,7 @@ export const showBranchNotFoundError = ({ dispatch }, branchId) => { ...@@ -76,7 +76,7 @@ export const showBranchNotFoundError = ({ dispatch }, branchId) => {
}, },
false, false,
), ),
action: payload => dispatch('createNewBranchFromDefault', payload), action: (payload) => dispatch('createNewBranchFromDefault', payload),
actionText: __('Create branch'), actionText: __('Create branch'),
actionPayload: branchId, actionPayload: branchId,
}); });
...@@ -102,7 +102,7 @@ export const loadFile = ({ dispatch, state }, { basePath }) => { ...@@ -102,7 +102,7 @@ export const loadFile = ({ dispatch, state }, { basePath }) => {
if (basePath) { if (basePath) {
const path = basePath.slice(-1) === '/' ? basePath.slice(0, -1) : basePath; const path = basePath.slice(-1) === '/' ? basePath.slice(0, -1) : basePath;
const treeEntryKey = Object.keys(state.entries).find( const treeEntryKey = Object.keys(state.entries).find(
key => key === path && !state.entries[key].pending, (key) => key === path && !state.entries[key].pending,
); );
const treeEntry = state.entries[treeEntryKey]; const treeEntry = state.entries[treeEntryKey];
...@@ -144,7 +144,7 @@ export const loadBranch = ({ dispatch, getters, state }, { projectId, branchId } ...@@ -144,7 +144,7 @@ export const loadBranch = ({ dispatch, getters, state }, { projectId, branchId }
ref: branch.commit.id, ref: branch.commit.id,
}); });
}) })
.catch(err => { .catch((err) => {
dispatch('showBranchNotFoundError', branchId); dispatch('showBranchNotFoundError', branchId);
throw err; throw err;
}); });
......
...@@ -87,10 +87,10 @@ export const getFiles = ({ state, commit, dispatch }, payload = {}) => { ...@@ -87,10 +87,10 @@ export const getFiles = ({ state, commit, dispatch }, payload = {}) => {
resolve(); resolve();
}) })
.catch(e => { .catch((e) => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading all the files.'), text: __('An error occurred while loading all the files.'),
action: actionPayload => action: (actionPayload) =>
dispatch('getFiles', actionPayload).then(() => dispatch('setErrorMessage', null)), dispatch('getFiles', actionPayload).then(() => dispatch('setErrorMessage', null)),
actionText: __('Please try again'), actionText: __('Please try again'),
actionPayload: { projectId, branchId }, actionPayload: { projectId, branchId },
......
...@@ -8,7 +8,7 @@ const plugins = () => [ ...@@ -8,7 +8,7 @@ const plugins = () => [
export default (store, el) => { export default (store, el) => {
// plugins is actually an array of plugin factories, so we have to create first then call // plugins is actually an array of plugin factories, so we have to create first then call
plugins().forEach(plugin => plugin(el)(store)); plugins().forEach((plugin) => plugin(el)(store));
return store; return store;
}; };
...@@ -9,19 +9,19 @@ import { ...@@ -9,19 +9,19 @@ import {
import { addNumericSuffix } from '~/ide/utils'; import { addNumericSuffix } from '~/ide/utils';
import Api from '~/api'; import Api from '~/api';
export const activeFile = state => state.openFiles.find(file => file.active) || null; export const activeFile = (state) => state.openFiles.find((file) => file.active) || null;
export const addedFiles = state => state.changedFiles.filter(f => f.tempFile); export const addedFiles = (state) => state.changedFiles.filter((f) => f.tempFile);
export const modifiedFiles = state => state.changedFiles.filter(f => !f.tempFile); export const modifiedFiles = (state) => state.changedFiles.filter((f) => !f.tempFile);
export const projectsWithTrees = state => export const projectsWithTrees = (state) =>
Object.keys(state.projects).map(projectId => { Object.keys(state.projects).map((projectId) => {
const project = state.projects[projectId]; const project = state.projects[projectId];
return { return {
...project, ...project,
branches: Object.keys(project.branches).map(branchId => { branches: Object.keys(project.branches).map((branchId) => {
const branch = project.branches[branchId]; const branch = project.branches[branchId];
return { return {
...@@ -32,7 +32,7 @@ export const projectsWithTrees = state => ...@@ -32,7 +32,7 @@ export const projectsWithTrees = state =>
}; };
}); });
export const currentMergeRequest = state => { export const currentMergeRequest = (state) => {
if ( if (
state.projects[state.currentProjectId] && state.projects[state.currentProjectId] &&
state.projects[state.currentProjectId].mergeRequests state.projects[state.currentProjectId].mergeRequests
...@@ -42,19 +42,19 @@ export const currentMergeRequest = state => { ...@@ -42,19 +42,19 @@ export const currentMergeRequest = state => {
return null; return null;
}; };
export const findProject = state => projectId => state.projects[projectId]; export const findProject = (state) => (projectId) => state.projects[projectId];
export const currentProject = (state, getters) => getters.findProject(state.currentProjectId); export const currentProject = (state, getters) => getters.findProject(state.currentProjectId);
export const emptyRepo = state => export const emptyRepo = (state) =>
state.projects[state.currentProjectId] && state.projects[state.currentProjectId].empty_repo; state.projects[state.currentProjectId] && state.projects[state.currentProjectId].empty_repo;
export const currentTree = state => export const currentTree = (state) =>
state.trees[`${state.currentProjectId}/${state.currentBranchId}`]; state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
export const hasMergeRequest = state => Boolean(state.currentMergeRequestId); export const hasMergeRequest = (state) => Boolean(state.currentMergeRequestId);
export const allBlobs = state => export const allBlobs = (state) =>
Object.keys(state.entries) Object.keys(state.entries)
.reduce((acc, key) => { .reduce((acc, key) => {
const entry = state.entries[key]; const entry = state.entries[key];
...@@ -67,35 +67,35 @@ export const allBlobs = state => ...@@ -67,35 +67,35 @@ export const allBlobs = state =>
}, []) }, [])
.sort((a, b) => b.lastOpenedAt - a.lastOpenedAt); .sort((a, b) => b.lastOpenedAt - a.lastOpenedAt);
export const getChangedFile = state => path => state.changedFiles.find(f => f.path === path); export const getChangedFile = (state) => (path) => state.changedFiles.find((f) => f.path === path);
export const getStagedFile = state => path => state.stagedFiles.find(f => f.path === path); export const getStagedFile = (state) => (path) => state.stagedFiles.find((f) => f.path === path);
export const getOpenFile = state => path => state.openFiles.find(f => f.path === path); export const getOpenFile = (state) => (path) => state.openFiles.find((f) => f.path === path);
export const lastOpenedFile = state => export const lastOpenedFile = (state) =>
[...state.changedFiles, ...state.stagedFiles].sort((a, b) => b.lastOpenedAt - a.lastOpenedAt)[0]; [...state.changedFiles, ...state.stagedFiles].sort((a, b) => b.lastOpenedAt - a.lastOpenedAt)[0];
export const isEditModeActive = state => state.currentActivityView === leftSidebarViews.edit.name; export const isEditModeActive = (state) => state.currentActivityView === leftSidebarViews.edit.name;
export const isCommitModeActive = state => export const isCommitModeActive = (state) =>
state.currentActivityView === leftSidebarViews.commit.name; state.currentActivityView === leftSidebarViews.commit.name;
export const isReviewModeActive = state => export const isReviewModeActive = (state) =>
state.currentActivityView === leftSidebarViews.review.name; state.currentActivityView === leftSidebarViews.review.name;
export const someUncommittedChanges = state => export const someUncommittedChanges = (state) =>
Boolean(state.changedFiles.length || state.stagedFiles.length); Boolean(state.changedFiles.length || state.stagedFiles.length);
export const getChangesInFolder = state => path => { export const getChangesInFolder = (state) => (path) => {
const changedFilesCount = state.changedFiles.filter(f => filePathMatches(f.path, path)).length; const changedFilesCount = state.changedFiles.filter((f) => filePathMatches(f.path, path)).length;
const stagedFilesCount = state.stagedFiles.filter( const stagedFilesCount = state.stagedFiles.filter(
f => filePathMatches(f.path, path) && !getChangedFile(state)(f.path), (f) => filePathMatches(f.path, path) && !getChangedFile(state)(f.path),
).length; ).length;
return changedFilesCount + stagedFilesCount; return changedFilesCount + stagedFilesCount;
}; };
export const getUnstagedFilesCountForPath = state => path => export const getUnstagedFilesCountForPath = (state) => (path) =>
getChangesCountForFiles(state.changedFiles, path); getChangesCountForFiles(state.changedFiles, path);
export const getStagedFilesCountForPath = state => path => export const getStagedFilesCountForPath = (state) => (path) =>
getChangesCountForFiles(state.stagedFiles, path); getChangesCountForFiles(state.stagedFiles, path);
export const lastCommit = (state, getters) => { export const lastCommit = (state, getters) => {
...@@ -115,7 +115,7 @@ export const currentBranch = (state, getters) => ...@@ -115,7 +115,7 @@ export const currentBranch = (state, getters) =>
export const branchName = (_state, getters) => getters.currentBranch && getters.currentBranch.name; export const branchName = (_state, getters) => getters.currentBranch && getters.currentBranch.name;
export const packageJson = state => state.entries[packageJsonPath]; export const packageJson = (state) => state.entries[packageJsonPath];
export const isOnDefaultBranch = (_state, getters) => export const isOnDefaultBranch = (_state, getters) =>
getters.currentProject && getters.currentProject.default_branch === getters.branchName; getters.currentProject && getters.currentProject.default_branch === getters.branchName;
...@@ -124,14 +124,14 @@ export const canPushToBranch = (_state, getters) => { ...@@ -124,14 +124,14 @@ export const canPushToBranch = (_state, getters) => {
return Boolean(getters.currentBranch ? getters.currentBranch.can_push : getters.canPushCode); return Boolean(getters.currentBranch ? getters.currentBranch.can_push : getters.canPushCode);
}; };
export const isFileDeletedAndReadded = (state, getters) => path => { export const isFileDeletedAndReadded = (state, getters) => (path) => {
const stagedFile = getters.getStagedFile(path); const stagedFile = getters.getStagedFile(path);
const file = state.entries[path]; const file = state.entries[path];
return Boolean(stagedFile && stagedFile.deleted && file.tempFile); return Boolean(stagedFile && stagedFile.deleted && file.tempFile);
}; };
// checks if any diff exists in the staged or unstaged changes for this path // checks if any diff exists in the staged or unstaged changes for this path
export const getDiffInfo = (state, getters) => path => { export const getDiffInfo = (state, getters) => (path) => {
const stagedFile = getters.getStagedFile(path); const stagedFile = getters.getStagedFile(path);
const file = state.entries[path]; const file = state.entries[path];
const renamed = file.prevPath ? file.path !== file.prevPath : false; const renamed = file.prevPath ? file.path !== file.prevPath : false;
...@@ -149,7 +149,7 @@ export const getDiffInfo = (state, getters) => path => { ...@@ -149,7 +149,7 @@ export const getDiffInfo = (state, getters) => path => {
}; };
}; };
export const findProjectPermissions = (state, getters) => projectId => export const findProjectPermissions = (state, getters) => (projectId) =>
getters.findProject(projectId)?.userPermissions || {}; getters.findProject(projectId)?.userPermissions || {};
export const canReadMergeRequests = (state, getters) => export const canReadMergeRequests = (state, getters) =>
...@@ -161,10 +161,10 @@ export const canCreateMergeRequests = (state, getters) => ...@@ -161,10 +161,10 @@ export const canCreateMergeRequests = (state, getters) =>
export const canPushCode = (state, getters) => export const canPushCode = (state, getters) =>
Boolean(getters.findProjectPermissions(state.currentProjectId)[PERMISSION_PUSH_CODE]); Boolean(getters.findProjectPermissions(state.currentProjectId)[PERMISSION_PUSH_CODE]);
export const entryExists = state => path => export const entryExists = (state) => (path) =>
Boolean(state.entries[path] && !state.entries[path].deleted); Boolean(state.entries[path] && !state.entries[path].deleted);
export const getAvailableFileName = (state, getters) => path => { export const getAvailableFileName = (state, getters) => (path) => {
let newPath = path; let newPath = path;
while (getters.entryExists(newPath)) { while (getters.entryExists(newPath)) {
...@@ -174,10 +174,10 @@ export const getAvailableFileName = (state, getters) => path => { ...@@ -174,10 +174,10 @@ export const getAvailableFileName = (state, getters) => path => {
return newPath; return newPath;
}; };
export const getUrlForPath = state => path => export const getUrlForPath = (state) => (path) =>
`/project/${state.currentProjectId}/tree/${state.currentBranchId}/-/${path}/`; `/project/${state.currentProjectId}/tree/${state.currentBranchId}/-/${path}/`;
export const getJsonSchemaForPath = (state, getters) => path => { export const getJsonSchemaForPath = (state, getters) => (path) => {
const [namespace, ...project] = state.currentProjectId.split('/'); const [namespace, ...project] = state.currentProjectId.split('/');
return { return {
uri: uri:
......
...@@ -8,7 +8,7 @@ export const receiveBranchesError = ({ commit, dispatch }, { search }) => { ...@@ -8,7 +8,7 @@ export const receiveBranchesError = ({ commit, dispatch }, { search }) => {
'setErrorMessage', 'setErrorMessage',
{ {
text: __('Error loading branches.'), text: __('Error loading branches.'),
action: payload => action: (payload) =>
dispatch('fetchBranches', payload).then(() => dispatch('fetchBranches', payload).then(() =>
dispatch('setErrorMessage', null, { root: true }), dispatch('setErrorMessage', null, { root: true }),
), ),
......
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
}, },
[types.RECEIVE_BRANCHES_SUCCESS](state, data) { [types.RECEIVE_BRANCHES_SUCCESS](state, data) {
state.isLoading = false; state.isLoading = false;
state.branches = data.map(branch => ({ state.branches = data.map((branch) => ({
name: branch.name, name: branch.name,
committedDate: branch.commit.committed_date, committedDate: branch.commit.committed_date,
})); }));
......
...@@ -78,8 +78,8 @@ export const updateFilesAfterCommit = ({ commit, dispatch, rootState, rootGetter ...@@ -78,8 +78,8 @@ export const updateFilesAfterCommit = ({ commit, dispatch, rootState, rootGetter
{ root: true }, { root: true },
); );
rootState.stagedFiles.forEach(file => { rootState.stagedFiles.forEach((file) => {
const changedFile = rootState.changedFiles.find(f => f.path === file.path); const changedFile = rootState.changedFiles.find((f) => f.path === file.path);
commit( commit(
rootTypes.UPDATE_FILE_AFTER_COMMIT, rootTypes.UPDATE_FILE_AFTER_COMMIT,
...@@ -133,7 +133,7 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo ...@@ -133,7 +133,7 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
return service.commit(rootState.currentProjectId, payload); return service.commit(rootState.currentProjectId, payload);
}) })
.catch(e => { .catch((e) => {
commit(types.UPDATE_LOADING, false); commit(types.UPDATE_LOADING, false);
commit(types.SET_ERROR, parseCommitError(e)); commit(types.SET_ERROR, parseCommitError(e));
...@@ -193,12 +193,12 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo ...@@ -193,12 +193,12 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
}, },
{ root: true }, { root: true },
) )
.then(changeViewer => { .then((changeViewer) => {
if (changeViewer) { if (changeViewer) {
dispatch('updateViewer', 'diff', { root: true }); dispatch('updateViewer', 'diff', { root: true });
} }
}) })
.catch(e => { .catch((e) => {
throw e; throw e;
}); });
} else { } else {
......
...@@ -11,7 +11,7 @@ const createTranslatedTextForFiles = (files, text) => { ...@@ -11,7 +11,7 @@ const createTranslatedTextForFiles = (files, text) => {
}); });
}; };
export const discardDraftButtonDisabled = state => export const discardDraftButtonDisabled = (state) =>
state.commitMessage === '' || state.submitCommitLoading; state.commitMessage === '' || state.submitCommitLoading;
// Note: If changing the structure of the placeholder branch name, please also // Note: If changing the structure of the placeholder branch name, please also
...@@ -37,18 +37,18 @@ export const preBuiltCommitMessage = (state, _, rootState) => { ...@@ -37,18 +37,18 @@ export const preBuiltCommitMessage = (state, _, rootState) => {
if (state.commitMessage) return state.commitMessage; if (state.commitMessage) return state.commitMessage;
const files = rootState.stagedFiles.length ? rootState.stagedFiles : rootState.changedFiles; const files = rootState.stagedFiles.length ? rootState.stagedFiles : rootState.changedFiles;
const modifiedFiles = files.filter(f => !f.deleted); const modifiedFiles = files.filter((f) => !f.deleted);
const deletedFiles = files.filter(f => f.deleted); const deletedFiles = files.filter((f) => f.deleted);
return [ return [
createTranslatedTextForFiles(modifiedFiles, __('Update')), createTranslatedTextForFiles(modifiedFiles, __('Update')),
createTranslatedTextForFiles(deletedFiles, __('Deleted')), createTranslatedTextForFiles(deletedFiles, __('Deleted')),
] ]
.filter(t => t) .filter((t) => t)
.join('\n'); .join('\n');
}; };
export const isCreatingNewBranch = state => state.commitAction === consts.COMMIT_TO_NEW_BRANCH; export const isCreatingNewBranch = (state) => state.commitAction === consts.COMMIT_TO_NEW_BRANCH;
export const shouldHideNewMrOption = (_state, getters, _rootState, rootGetters) => export const shouldHideNewMrOption = (_state, getters, _rootState, rootGetters) =>
!getters.isCreatingNewBranch && !getters.isCreatingNewBranch &&
......
import eventHub from '~/ide/eventhub'; import eventHub from '~/ide/eventhub';
import { commitActionTypes } from '~/ide/constants'; import { commitActionTypes } from '~/ide/constants';
const removeUnusedFileEditors = store => { const removeUnusedFileEditors = (store) => {
Object.keys(store.state.editor.fileEditors) Object.keys(store.state.editor.fileEditors)
.filter(path => !store.state.entries[path]) .filter((path) => !store.state.entries[path])
.forEach(path => store.dispatch('editor/removeFileEditor', path)); .forEach((path) => store.dispatch('editor/removeFileEditor', path));
}; };
export const setupFileEditorsSync = store => { export const setupFileEditorsSync = (store) => {
eventHub.$on('ide.files.change', ({ type, ...payload } = {}) => { eventHub.$on('ide.files.change', ({ type, ...payload } = {}) => {
if (type === commitActionTypes.move) { if (type === commitActionTypes.move) {
store.dispatch('editor/renameFileEditor', payload); store.dispatch('editor/renameFileEditor', payload);
......
...@@ -68,7 +68,7 @@ export const receiveTemplateError = ({ dispatch }, template) => { ...@@ -68,7 +68,7 @@ export const receiveTemplateError = ({ dispatch }, template) => {
'setErrorMessage', 'setErrorMessage',
{ {
text: __('Error loading template.'), text: __('Error loading template.'),
action: payload => action: (payload) =>
dispatch('fetchTemplateTypes', payload).then(() => dispatch('fetchTemplateTypes', payload).then(() =>
dispatch('setErrorMessage', null, { root: true }), dispatch('setErrorMessage', null, { root: true }),
), ),
......
...@@ -24,6 +24,6 @@ export const templateTypes = () => [ ...@@ -24,6 +24,6 @@ export const templateTypes = () => [
}, },
]; ];
export const showFileTemplatesBar = (_, getters, rootState) => name => export const showFileTemplatesBar = (_, getters, rootState) => (name) =>
getters.templateTypes.find(t => t.name === name) && getters.templateTypes.find((t) => t.name === name) &&
rootState.currentActivityView === leftSidebarViews.edit.name; rootState.currentActivityView === leftSidebarViews.edit.name;
...@@ -9,7 +9,7 @@ export const receiveMergeRequestsError = ({ commit, dispatch }, { type, search } ...@@ -9,7 +9,7 @@ export const receiveMergeRequestsError = ({ commit, dispatch }, { type, search }
'setErrorMessage', 'setErrorMessage',
{ {
text: __('Error loading merge requests.'), text: __('Error loading merge requests.'),
action: payload => action: (payload) =>
dispatch('fetchMergeRequests', payload).then(() => dispatch('fetchMergeRequests', payload).then(() =>
dispatch('setErrorMessage', null, { root: true }), dispatch('setErrorMessage', null, { root: true }),
), ),
......
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
}, },
[types.RECEIVE_MERGE_REQUESTS_SUCCESS](state, data) { [types.RECEIVE_MERGE_REQUESTS_SUCCESS](state, data) {
state.isLoading = false; state.isLoading = false;
state.mergeRequests = data.map(mergeRequest => ({ state.mergeRequests = data.map((mergeRequest) => ({
id: mergeRequest.id, id: mergeRequest.id,
iid: mergeRequest.iid, iid: mergeRequest.iid,
title: mergeRequest.title, title: mergeRequest.title,
......
export const isAliveView = state => view => export const isAliveView = (state) => (view) =>
state.keepAliveViews[view] || (state.isOpen && state.currentView === view); state.keepAliveViews[view] || (state.isOpen && state.currentView === view);
...@@ -47,7 +47,7 @@ export const receiveLatestPipelineSuccess = ({ rootGetters, commit }, { pipeline ...@@ -47,7 +47,7 @@ export const receiveLatestPipelineSuccess = ({ rootGetters, commit }, { pipeline
if (pipelines && pipelines.length) { if (pipelines && pipelines.length) {
const lastCommitHash = rootGetters.lastCommit && rootGetters.lastCommit.id; const lastCommitHash = rootGetters.lastCommit && rootGetters.lastCommit.id;
lastCommitPipeline = pipelines.find(pipeline => pipeline.commit.id === lastCommitHash); lastCommitPipeline = pipelines.find((pipeline) => pipeline.commit.id === lastCommitHash);
} }
commit(types.RECEIVE_LASTEST_PIPELINE_SUCCESS, lastCommitPipeline); commit(types.RECEIVE_LASTEST_PIPELINE_SUCCESS, lastCommitPipeline);
...@@ -63,7 +63,7 @@ export const fetchLatestPipeline = ({ dispatch, rootGetters }) => { ...@@ -63,7 +63,7 @@ export const fetchLatestPipeline = ({ dispatch, rootGetters }) => {
method: 'lastCommitPipelines', method: 'lastCommitPipelines',
data: { getters: rootGetters }, data: { getters: rootGetters },
successCallback: ({ data }) => dispatch('receiveLatestPipelineSuccess', data), successCallback: ({ data }) => dispatch('receiveLatestPipelineSuccess', data),
errorCallback: err => dispatch('receiveLatestPipelineError', err), errorCallback: (err) => dispatch('receiveLatestPipelineError', err),
}); });
if (!Visibility.hidden()) { if (!Visibility.hidden()) {
...@@ -85,7 +85,7 @@ export const receiveJobsError = ({ commit, dispatch }, stage) => { ...@@ -85,7 +85,7 @@ export const receiveJobsError = ({ commit, dispatch }, stage) => {
'setErrorMessage', 'setErrorMessage',
{ {
text: __('An error occurred while loading the pipelines jobs.'), text: __('An error occurred while loading the pipelines jobs.'),
action: payload => action: (payload) =>
dispatch('fetchJobs', payload).then(() => dispatch('fetchJobs', payload).then(() =>
dispatch('setErrorMessage', null, { root: true }), dispatch('setErrorMessage', null, { root: true }),
), ),
......
...@@ -23,7 +23,7 @@ export default { ...@@ -23,7 +23,7 @@ export default {
yamlError: pipeline.yaml_errors, yamlError: pipeline.yaml_errors,
}; };
state.stages = pipeline.details.stages.map((stage, i) => { state.stages = pipeline.details.stages.map((stage, i) => {
const foundStage = state.stages.find(s => s.id === i); const foundStage = state.stages.find((s) => s.id === i);
return { return {
id: i, id: i,
dropdownPath: stage.dropdown_path, dropdownPath: stage.dropdown_path,
...@@ -39,26 +39,26 @@ export default { ...@@ -39,26 +39,26 @@ export default {
} }
}, },
[types.REQUEST_JOBS](state, id) { [types.REQUEST_JOBS](state, id) {
state.stages = state.stages.map(stage => ({ state.stages = state.stages.map((stage) => ({
...stage, ...stage,
isLoading: stage.id === id ? true : stage.isLoading, isLoading: stage.id === id ? true : stage.isLoading,
})); }));
}, },
[types.RECEIVE_JOBS_ERROR](state, id) { [types.RECEIVE_JOBS_ERROR](state, id) {
state.stages = state.stages.map(stage => ({ state.stages = state.stages.map((stage) => ({
...stage, ...stage,
isLoading: stage.id === id ? false : stage.isLoading, isLoading: stage.id === id ? false : stage.isLoading,
})); }));
}, },
[types.RECEIVE_JOBS_SUCCESS](state, { id, data }) { [types.RECEIVE_JOBS_SUCCESS](state, { id, data }) {
state.stages = state.stages.map(stage => ({ state.stages = state.stages.map((stage) => ({
...stage, ...stage,
isLoading: stage.id === id ? false : stage.isLoading, isLoading: stage.id === id ? false : stage.isLoading,
jobs: stage.id === id ? data.latest_statuses.map(normalizeJob) : stage.jobs, jobs: stage.id === id ? data.latest_statuses.map(normalizeJob) : stage.jobs,
})); }));
}, },
[types.TOGGLE_STAGE_COLLAPSE](state, id) { [types.TOGGLE_STAGE_COLLAPSE](state, id) {
state.stages = state.stages.map(stage => ({ state.stages = state.stages.map((stage) => ({
...stage, ...stage,
isCollapsed: stage.id === id ? !stage.isCollapsed : stage.isCollapsed, isCollapsed: stage.id === id ? !stage.isCollapsed : stage.isCollapsed,
})); }));
......
export const normalizeJob = job => ({ export const normalizeJob = (job) => ({
id: job.id, id: job.id,
name: job.name, name: job.name,
status: job.status, status: job.status,
......
...@@ -36,7 +36,7 @@ export const fetchConfigCheck = ({ dispatch, rootState, rootGetters }) => { ...@@ -36,7 +36,7 @@ export const fetchConfigCheck = ({ dispatch, rootState, rootGetters }) => {
.then(() => { .then(() => {
dispatch('receiveConfigCheckSuccess'); dispatch('receiveConfigCheckSuccess');
}) })
.catch(e => { .catch((e) => {
dispatch('receiveConfigCheckError', e); dispatch('receiveConfigCheckError', e);
}); });
}; };
...@@ -92,7 +92,7 @@ export const fetchRunnersCheck = ({ dispatch, rootGetters }, options = {}) => { ...@@ -92,7 +92,7 @@ export const fetchRunnersCheck = ({ dispatch, rootGetters }, options = {}) => {
.then(({ data }) => { .then(({ data }) => {
dispatch('receiveRunnersCheckSuccess', data); dispatch('receiveRunnersCheckSuccess', data);
}) })
.catch(e => { .catch((e) => {
dispatch('receiveRunnersCheckError', e); dispatch('receiveRunnersCheckError', e);
}); });
}; };
...@@ -45,7 +45,7 @@ export const startSession = ({ state, dispatch, rootGetters, rootState }) => { ...@@ -45,7 +45,7 @@ export const startSession = ({ state, dispatch, rootGetters, rootState }) => {
.then(({ data }) => { .then(({ data }) => {
dispatch('receiveStartSessionSuccess', data); dispatch('receiveStartSessionSuccess', data);
}) })
.catch(error => { .catch((error) => {
dispatch('receiveStartSessionError', error); dispatch('receiveStartSessionError', error);
}); });
}; };
...@@ -73,7 +73,7 @@ export const stopSession = ({ state, dispatch }) => { ...@@ -73,7 +73,7 @@ export const stopSession = ({ state, dispatch }) => {
.then(() => { .then(() => {
dispatch('receiveStopSessionSuccess'); dispatch('receiveStopSessionSuccess');
}) })
.catch(err => { .catch((err) => {
dispatch('receiveStopSessionError', err); dispatch('receiveStopSessionError', err);
}); });
}; };
...@@ -103,7 +103,7 @@ export const restartSession = ({ state, dispatch, rootState }) => { ...@@ -103,7 +103,7 @@ export const restartSession = ({ state, dispatch, rootState }) => {
.then(({ data }) => { .then(({ data }) => {
dispatch('receiveStartSessionSuccess', data); dispatch('receiveStartSessionSuccess', data);
}) })
.catch(error => { .catch((error) => {
const responseStatus = error.response && error.response.status; const responseStatus = error.response && error.response.status;
// We may have removed the build, in this case we'll just create a new session // We may have removed the build, in this case we'll just create a new session
if ( if (
......
...@@ -58,7 +58,7 @@ export const fetchSessionStatus = ({ dispatch, state }) => { ...@@ -58,7 +58,7 @@ export const fetchSessionStatus = ({ dispatch, state }) => {
.then(({ data }) => { .then(({ data }) => {
dispatch('receiveSessionStatusSuccess', data); dispatch('receiveSessionStatusSuccess', data);
}) })
.catch(error => { .catch((error) => {
dispatch('receiveSessionStatusError', error); dispatch('receiveSessionStatusError', error);
}); });
}; };
export const allCheck = state => { export const allCheck = (state) => {
const checks = Object.values(state.checks); const checks = Object.values(state.checks);
if (checks.some(check => check.isLoading)) { if (checks.some((check) => check.isLoading)) {
return { isLoading: true }; return { isLoading: true };
} }
const invalidCheck = checks.find(check => !check.isValid); const invalidCheck = checks.find((check) => !check.isValid);
const isValid = !invalidCheck; const isValid = !invalidCheck;
const message = !invalidCheck ? '' : invalidCheck.message; const message = !invalidCheck ? '' : invalidCheck.message;
......
...@@ -46,7 +46,7 @@ export const configCheckError = (status, helpUrl) => { ...@@ -46,7 +46,7 @@ export const configCheckError = (status, helpUrl) => {
return UNEXPECTED_ERROR_CONFIG; return UNEXPECTED_ERROR_CONFIG;
}; };
export const runnersCheckEmpty = helpUrl => export const runnersCheckEmpty = (helpUrl) =>
sprintf( sprintf(
EMPTY_RUNNERS, EMPTY_RUNNERS,
{ {
......
import { STARTING, PENDING, RUNNING } from './constants'; import { STARTING, PENDING, RUNNING } from './constants';
export const isStartingStatus = status => status === STARTING || status === PENDING; export const isStartingStatus = (status) => status === STARTING || status === PENDING;
export const isRunningStatus = status => status === RUNNING; export const isRunningStatus = (status) => status === RUNNING;
export const isEndingStatus = status => !isStartingStatus(status) && !isRunningStatus(status); export const isEndingStatus = (status) => !isStartingStatus(status) && !isRunningStatus(status);
...@@ -9,7 +9,7 @@ export const upload = ({ rootState, commit }) => { ...@@ -9,7 +9,7 @@ export const upload = ({ rootState, commit }) => {
.then(() => { .then(() => {
commit(types.SET_SUCCESS); commit(types.SET_SUCCESS);
}) })
.catch(err => { .catch((err) => {
commit(types.SET_ERROR, err); commit(types.SET_ERROR, err);
}); });
}; };
...@@ -34,7 +34,7 @@ export const start = ({ rootState, commit }) => { ...@@ -34,7 +34,7 @@ export const start = ({ rootState, commit }) => {
.then(() => { .then(() => {
commit(types.SET_SUCCESS); commit(types.SET_SUCCESS);
}) })
.catch(err => { .catch((err) => {
commit(types.SET_ERROR, err); commit(types.SET_ERROR, err);
throw err; throw err;
}); });
......
...@@ -61,7 +61,7 @@ export default { ...@@ -61,7 +61,7 @@ export default {
}); });
} else { } else {
const tree = entry.tree.filter( const tree = entry.tree.filter(
f => foundEntry.tree.find(e => e.path === f.path) === undefined, (f) => foundEntry.tree.find((e) => e.path === f.path) === undefined,
); );
Object.assign(foundEntry, { Object.assign(foundEntry, {
tree: sortTree(foundEntry.tree.concat(tree)), tree: sortTree(foundEntry.tree.concat(tree)),
...@@ -72,7 +72,7 @@ export default { ...@@ -72,7 +72,7 @@ export default {
}, []); }, []);
const currentTree = state.trees[`${state.currentProjectId}/${state.currentBranchId}`]; const currentTree = state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
const foundEntry = currentTree.tree.find(e => e.path === data.treeList[0].path); const foundEntry = currentTree.tree.find((e) => e.path === data.treeList[0].path);
if (!foundEntry) { if (!foundEntry) {
Object.assign(currentTree, { Object.assign(currentTree, {
...@@ -125,7 +125,7 @@ export default { ...@@ -125,7 +125,7 @@ export default {
}); });
}, },
[types.UPDATE_FILE_AFTER_COMMIT](state, { file, lastCommit }) { [types.UPDATE_FILE_AFTER_COMMIT](state, { file, lastCommit }) {
const changedFile = state.changedFiles.find(f => f.path === file.path); const changedFile = state.changedFiles.find((f) => f.path === file.path);
const { prevPath } = file; const { prevPath } = file;
Object.assign(state.entries[file.path], { Object.assign(state.entries[file.path], {
...@@ -172,7 +172,7 @@ export default { ...@@ -172,7 +172,7 @@ export default {
entry.deleted = true; entry.deleted = true;
if (parent) { if (parent) {
parent.tree = parent.tree.filter(f => f.path !== entry.path); parent.tree = parent.tree.filter((f) => f.path !== entry.path);
} }
if (entry.type === 'blob') { if (entry.type === 'blob') {
...@@ -181,8 +181,8 @@ export default { ...@@ -181,8 +181,8 @@ export default {
// changed and staged. Otherwise, we'd need to somehow evaluate the difference between // changed and staged. Otherwise, we'd need to somehow evaluate the difference between
// changed and HEAD. // changed and HEAD.
// https://gitlab.com/gitlab-org/create-stage/-/issues/12669 // https://gitlab.com/gitlab-org/create-stage/-/issues/12669
state.changedFiles = state.changedFiles.filter(f => f.path !== path); state.changedFiles = state.changedFiles.filter((f) => f.path !== path);
state.stagedFiles = state.stagedFiles.filter(f => f.path !== path); state.stagedFiles = state.stagedFiles.filter((f) => f.path !== path);
} else { } else {
state.changedFiles = state.changedFiles.concat(entry); state.changedFiles = state.changedFiles.concat(entry);
} }
......
...@@ -12,7 +12,7 @@ export default { ...@@ -12,7 +12,7 @@ export default {
if (active && !state.entries[path].pending) { if (active && !state.entries[path].pending) {
Object.assign(state, { Object.assign(state, {
openFiles: state.openFiles.map(f => openFiles: state.openFiles.map((f) =>
Object.assign(f, { active: f.pending ? false : f.active }), Object.assign(f, { active: f.pending ? false : f.active }),
), ),
}); });
...@@ -28,21 +28,21 @@ export default { ...@@ -28,21 +28,21 @@ export default {
if (entry.opened) { if (entry.opened) {
Object.assign(state, { Object.assign(state, {
openFiles: state.openFiles.filter(f => f.path !== path).concat(state.entries[path]), openFiles: state.openFiles.filter((f) => f.path !== path).concat(state.entries[path]),
}); });
} else { } else {
Object.assign(state, { Object.assign(state, {
openFiles: state.openFiles.filter(f => f.key !== entry.key), openFiles: state.openFiles.filter((f) => f.key !== entry.key),
}); });
} }
}, },
[types.SET_FILE_DATA](state, { data, file }) { [types.SET_FILE_DATA](state, { data, file }) {
const stateEntry = state.entries[file.path]; const stateEntry = state.entries[file.path];
const stagedFile = state.stagedFiles.find(f => f.path === file.path); const stagedFile = state.stagedFiles.find((f) => f.path === file.path);
const openFile = state.openFiles.find(f => f.path === file.path); const openFile = state.openFiles.find((f) => f.path === file.path);
const changedFile = state.changedFiles.find(f => f.path === file.path); const changedFile = state.changedFiles.find((f) => f.path === file.path);
[stateEntry, stagedFile, openFile, changedFile].forEach(f => { [stateEntry, stagedFile, openFile, changedFile].forEach((f) => {
if (f) { if (f) {
Object.assign( Object.assign(
f, f,
...@@ -57,10 +57,10 @@ export default { ...@@ -57,10 +57,10 @@ export default {
}, },
[types.SET_FILE_RAW_DATA](state, { file, raw, fileDeletedAndReadded = false }) { [types.SET_FILE_RAW_DATA](state, { file, raw, fileDeletedAndReadded = false }) {
const openPendingFile = state.openFiles.find( const openPendingFile = state.openFiles.find(
f => (f) =>
f.path === file.path && f.pending && !(f.tempFile && !f.prevPath && !fileDeletedAndReadded), f.path === file.path && f.pending && !(f.tempFile && !f.prevPath && !fileDeletedAndReadded),
); );
const stagedFile = state.stagedFiles.find(f => f.path === file.path); const stagedFile = state.stagedFiles.find((f) => f.path === file.path);
if (file.tempFile && file.content === '' && !fileDeletedAndReadded) { if (file.tempFile && file.content === '' && !fileDeletedAndReadded) {
Object.assign(state.entries[file.path], { content: raw }); Object.assign(state.entries[file.path], { content: raw });
...@@ -86,7 +86,7 @@ export default { ...@@ -86,7 +86,7 @@ export default {
}); });
}, },
[types.UPDATE_FILE_CONTENT](state, { path, content }) { [types.UPDATE_FILE_CONTENT](state, { path, content }) {
const stagedFile = state.stagedFiles.find(f => f.path === path); const stagedFile = state.stagedFiles.find((f) => f.path === path);
const rawContent = stagedFile ? stagedFile.content : state.entries[path].raw; const rawContent = stagedFile ? stagedFile.content : state.entries[path].raw;
const changed = content !== rawContent; const changed = content !== rawContent;
...@@ -112,7 +112,7 @@ export default { ...@@ -112,7 +112,7 @@ export default {
}); });
}, },
[types.DISCARD_FILE_CHANGES](state, path) { [types.DISCARD_FILE_CHANGES](state, path) {
const stagedFile = state.stagedFiles.find(f => f.path === path); const stagedFile = state.stagedFiles.find((f) => f.path === path);
const entry = state.entries[path]; const entry = state.entries[path];
const { deleted } = entry; const { deleted } = entry;
...@@ -137,14 +137,14 @@ export default { ...@@ -137,14 +137,14 @@ export default {
}, },
[types.REMOVE_FILE_FROM_CHANGED](state, path) { [types.REMOVE_FILE_FROM_CHANGED](state, path) {
Object.assign(state, { Object.assign(state, {
changedFiles: state.changedFiles.filter(f => f.path !== path), changedFiles: state.changedFiles.filter((f) => f.path !== path),
}); });
}, },
[types.STAGE_CHANGE](state, { path, diffInfo }) { [types.STAGE_CHANGE](state, { path, diffInfo }) {
const stagedFile = state.stagedFiles.find(f => f.path === path); const stagedFile = state.stagedFiles.find((f) => f.path === path);
Object.assign(state, { Object.assign(state, {
changedFiles: state.changedFiles.filter(f => f.path !== path), changedFiles: state.changedFiles.filter((f) => f.path !== path),
entries: Object.assign(state.entries, { entries: Object.assign(state.entries, {
[path]: Object.assign(state.entries[path], { [path]: Object.assign(state.entries[path], {
staged: diffInfo.exists, staged: diffInfo.exists,
...@@ -162,12 +162,12 @@ export default { ...@@ -162,12 +162,12 @@ export default {
} }
if (!diffInfo.exists) { if (!diffInfo.exists) {
state.stagedFiles = state.stagedFiles.filter(f => f.path !== path); state.stagedFiles = state.stagedFiles.filter((f) => f.path !== path);
} }
}, },
[types.UNSTAGE_CHANGE](state, { path, diffInfo }) { [types.UNSTAGE_CHANGE](state, { path, diffInfo }) {
const changedFile = state.changedFiles.find(f => f.path === path); const changedFile = state.changedFiles.find((f) => f.path === path);
const stagedFile = state.stagedFiles.find(f => f.path === path); const stagedFile = state.stagedFiles.find((f) => f.path === path);
if (!changedFile && stagedFile) { if (!changedFile && stagedFile) {
Object.assign(state.entries[path], { Object.assign(state.entries[path], {
...@@ -182,11 +182,11 @@ export default { ...@@ -182,11 +182,11 @@ export default {
} }
if (!diffInfo.exists) { if (!diffInfo.exists) {
state.changedFiles = state.changedFiles.filter(f => f.path !== path); state.changedFiles = state.changedFiles.filter((f) => f.path !== path);
} }
Object.assign(state, { Object.assign(state, {
stagedFiles: state.stagedFiles.filter(f => f.path !== path), stagedFiles: state.stagedFiles.filter((f) => f.path !== path),
entries: Object.assign(state.entries, { entries: Object.assign(state.entries, {
[path]: Object.assign(state.entries[path], { [path]: Object.assign(state.entries[path], {
staged: false, staged: false,
...@@ -206,7 +206,7 @@ export default { ...@@ -206,7 +206,7 @@ export default {
state.entries[file.path].opened = false; state.entries[file.path].opened = false;
state.entries[file.path].active = false; state.entries[file.path].active = false;
state.entries[file.path].lastOpenedAt = new Date().getTime(); state.entries[file.path].lastOpenedAt = new Date().getTime();
state.openFiles.forEach(f => state.openFiles.forEach((f) =>
Object.assign(f, { Object.assign(f, {
opened: false, opened: false,
active: false, active: false,
...@@ -224,13 +224,13 @@ export default { ...@@ -224,13 +224,13 @@ export default {
}, },
[types.REMOVE_PENDING_TAB](state, file) { [types.REMOVE_PENDING_TAB](state, file) {
Object.assign(state, { Object.assign(state, {
openFiles: state.openFiles.filter(f => f.key !== file.key), openFiles: state.openFiles.filter((f) => f.key !== file.key),
}); });
}, },
[types.REMOVE_FILE_FROM_STAGED_AND_CHANGED](state, file) { [types.REMOVE_FILE_FROM_STAGED_AND_CHANGED](state, file) {
Object.assign(state, { Object.assign(state, {
changedFiles: state.changedFiles.filter(f => f.key !== file.key), changedFiles: state.changedFiles.filter((f) => f.key !== file.key),
stagedFiles: state.stagedFiles.filter(f => f.key !== file.key), stagedFiles: state.stagedFiles.filter((f) => f.key !== file.key),
}); });
Object.assign(state.entries[file.path], { Object.assign(state.entries[file.path], {
......
...@@ -45,7 +45,7 @@ export default { ...@@ -45,7 +45,7 @@ export default {
? state.entries[entry.parentPath] ? state.entries[entry.parentPath]
: state.trees[`${state.currentProjectId}/${state.currentBranchId}`]; : state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
if (!parent.tree.find(f => f.path === path)) { if (!parent.tree.find((f) => f.path === path)) {
parent.tree = sortTree(parent.tree.concat(entry)); parent.tree = sortTree(parent.tree.concat(entry));
} }
}, },
......
...@@ -11,7 +11,7 @@ function getPathsFromData(el) { ...@@ -11,7 +11,7 @@ function getPathsFromData(el) {
} }
export default function createTerminalPlugin(el) { export default function createTerminalPlugin(el) {
return store => { return (store) => {
store.registerModule('terminal', terminalModule()); store.registerModule('terminal', terminalModule());
store.dispatch('terminal/setPaths', getPathsFromData(el)); store.dispatch('terminal/setPaths', getPathsFromData(el));
......
...@@ -12,7 +12,7 @@ const UPLOAD_DEBOUNCE = 200; ...@@ -12,7 +12,7 @@ const UPLOAD_DEBOUNCE = 200;
* - Listens for file change event to control upload. * - Listens for file change event to control upload.
*/ */
export default function createMirrorPlugin() { export default function createMirrorPlugin() {
return store => { return (store) => {
store.registerModule('terminalSync', terminalSyncModule()); store.registerModule('terminalSync', terminalSyncModule());
const upload = debounce(() => { const upload = debounce(() => {
...@@ -36,8 +36,8 @@ export default function createMirrorPlugin() { ...@@ -36,8 +36,8 @@ export default function createMirrorPlugin() {
}; };
store.watch( store.watch(
x => x.terminal && x.terminal.session && x.terminal.session.status, (x) => x.terminal && x.terminal.session && x.terminal.session.status,
val => { (val) => {
if (isRunningStatus(val)) { if (isRunningStatus(val)) {
start(); start();
} else if (isEndingStatus(val)) { } else if (isEndingStatus(val)) {
......
...@@ -34,7 +34,7 @@ export const dataStructure = () => ({ ...@@ -34,7 +34,7 @@ export const dataStructure = () => ({
mimeType: '', mimeType: '',
}); });
export const decorateData = entity => { export const decorateData = (entity) => {
const { const {
id, id,
type, type,
...@@ -69,7 +69,7 @@ export const decorateData = entity => { ...@@ -69,7 +69,7 @@ export const decorateData = entity => {
}); });
}; };
export const setPageTitle = title => { export const setPageTitle = (title) => {
document.title = title; document.title = title;
}; };
...@@ -78,7 +78,7 @@ export const setPageTitleForFile = (state, file) => { ...@@ -78,7 +78,7 @@ export const setPageTitleForFile = (state, file) => {
setPageTitle(title); setPageTitle(title);
}; };
export const commitActionForFile = file => { export const commitActionForFile = (file) => {
if (file.prevPath) { if (file.prevPath) {
return commitActionTypes.move; return commitActionTypes.move;
} else if (file.deleted) { } else if (file.deleted) {
...@@ -90,7 +90,7 @@ export const commitActionForFile = file => { ...@@ -90,7 +90,7 @@ export const commitActionForFile = file => {
return commitActionTypes.update; return commitActionTypes.update;
}; };
export const getCommitFiles = stagedFiles => export const getCommitFiles = (stagedFiles) =>
stagedFiles.reduce((acc, file) => { stagedFiles.reduce((acc, file) => {
if (file.type === 'tree') return acc; if (file.type === 'tree') return acc;
...@@ -109,7 +109,7 @@ export const createCommitPayload = ({ ...@@ -109,7 +109,7 @@ export const createCommitPayload = ({
}) => ({ }) => ({
branch, branch,
commit_message: state.commitMessage || getters.preBuiltCommitMessage, commit_message: state.commitMessage || getters.preBuiltCommitMessage,
actions: getCommitFiles(rootState.stagedFiles).map(f => { actions: getCommitFiles(rootState.stagedFiles).map((f) => {
const isBlob = isBlobUrl(f.rawPath); const isBlob = isBlobUrl(f.rawPath);
const content = isBlob ? btoa(f.content) : f.content; const content = isBlob ? btoa(f.content) : f.content;
...@@ -139,9 +139,9 @@ const sortTreesByTypeAndName = (a, b) => { ...@@ -139,9 +139,9 @@ const sortTreesByTypeAndName = (a, b) => {
return 0; return 0;
}; };
export const sortTree = sortedTree => export const sortTree = (sortedTree) =>
sortedTree sortedTree
.map(entity => .map((entity) =>
Object.assign(entity, { Object.assign(entity, {
tree: entity.tree.length ? sortTree(entity.tree) : [], tree: entity.tree.length ? sortTree(entity.tree) : [],
}), }),
...@@ -151,7 +151,7 @@ export const sortTree = sortedTree => ...@@ -151,7 +151,7 @@ export const sortTree = sortedTree =>
export const filePathMatches = (filePath, path) => filePath.indexOf(`${path}/`) === 0; export const filePathMatches = (filePath, path) => filePath.indexOf(`${path}/`) === 0;
export const getChangesCountForFiles = (files, path) => export const getChangesCountForFiles = (files, path) =>
files.filter(f => filePathMatches(f.path, path)).length; files.filter((f) => filePathMatches(f.path, path)).length;
export const mergeTrees = (fromTree, toTree) => { export const mergeTrees = (fromTree, toTree) => {
if (!fromTree || !fromTree.length) { if (!fromTree || !fromTree.length) {
...@@ -162,7 +162,7 @@ export const mergeTrees = (fromTree, toTree) => { ...@@ -162,7 +162,7 @@ export const mergeTrees = (fromTree, toTree) => {
if (!n) { if (!n) {
return t; return t;
} }
const existingTreeNode = t.find(el => el.path === n.path); const existingTreeNode = t.find((el) => el.path === n.path);
if (existingTreeNode && n.tree.length > 0) { if (existingTreeNode && n.tree.length > 0) {
existingTreeNode.opened = true; existingTreeNode.opened = true;
...@@ -183,7 +183,7 @@ export const mergeTrees = (fromTree, toTree) => { ...@@ -183,7 +183,7 @@ export const mergeTrees = (fromTree, toTree) => {
export const swapInStateArray = (state, arr, key, entryPath) => export const swapInStateArray = (state, arr, key, entryPath) =>
Object.assign(state, { Object.assign(state, {
[arr]: state[arr].map(f => (f.key === key ? state.entries[entryPath] : f)), [arr]: state[arr].map((f) => (f.key === key ? state.entries[entryPath] : f)),
}); });
export const getEntryOrRoot = (state, path) => export const getEntryOrRoot = (state, path) =>
...@@ -216,12 +216,12 @@ export const removeFromParentTree = (state, oldKey, parentPath) => { ...@@ -216,12 +216,12 @@ export const removeFromParentTree = (state, oldKey, parentPath) => {
}; };
export const updateFileCollections = (state, key, entryPath) => { export const updateFileCollections = (state, key, entryPath) => {
['openFiles', 'changedFiles', 'stagedFiles'].forEach(fileCollection => { ['openFiles', 'changedFiles', 'stagedFiles'].forEach((fileCollection) => {
swapInStateArray(state, fileCollection, key, entryPath); swapInStateArray(state, fileCollection, key, entryPath);
}); });
}; };
export const cleanTrailingSlash = path => path.replace(/\/$/, ''); export const cleanTrailingSlash = (path) => path.replace(/\/$/, '');
export const pathsAreEqual = (a, b) => { export const pathsAreEqual = (a, b) => {
const cleanA = a ? cleanTrailingSlash(a) : ''; const cleanA = a ? cleanTrailingSlash(a) : '';
......
...@@ -21,8 +21,8 @@ export const syncRouterAndStore = (router, store) => { ...@@ -21,8 +21,8 @@ export const syncRouterAndStore = (router, store) => {
// sync store to router // sync store to router
disposables.push( disposables.push(
store.watch( store.watch(
state => state.router.fullPath, (state) => state.router.fullPath,
fullPath => { (fullPath) => {
if (currentPath === fullPath) { if (currentPath === fullPath) {
return; return;
} }
...@@ -36,7 +36,7 @@ export const syncRouterAndStore = (router, store) => { ...@@ -36,7 +36,7 @@ export const syncRouterAndStore = (router, store) => {
// sync router to store // sync router to store
disposables.push( disposables.push(
router.afterEach(to => { router.afterEach((to) => {
if (currentPath === to.fullPath) { if (currentPath === to.fullPath) {
return; return;
} }
...@@ -47,7 +47,7 @@ export const syncRouterAndStore = (router, store) => { ...@@ -47,7 +47,7 @@ export const syncRouterAndStore = (router, store) => {
); );
const unsync = () => { const unsync = () => {
disposables.forEach(fn => fn()); disposables.forEach((fn) => fn());
}; };
return unsync; return unsync;
......
...@@ -3,17 +3,17 @@ import { flatten, isString } from 'lodash'; ...@@ -3,17 +3,17 @@ import { flatten, isString } from 'lodash';
import { SIDE_LEFT, SIDE_RIGHT } from './constants'; import { SIDE_LEFT, SIDE_RIGHT } from './constants';
import { performanceMarkAndMeasure } from '~/performance/utils'; import { performanceMarkAndMeasure } from '~/performance/utils';
const toLowerCase = x => x.toLowerCase(); const toLowerCase = (x) => x.toLowerCase();
const monacoLanguages = languages.getLanguages(); const monacoLanguages = languages.getLanguages();
const monacoExtensions = new Set( const monacoExtensions = new Set(
flatten(monacoLanguages.map(lang => lang.extensions?.map(toLowerCase) || [])), flatten(monacoLanguages.map((lang) => lang.extensions?.map(toLowerCase) || [])),
); );
const monacoMimetypes = new Set( const monacoMimetypes = new Set(
flatten(monacoLanguages.map(lang => lang.mimetypes?.map(toLowerCase) || [])), flatten(monacoLanguages.map((lang) => lang.mimetypes?.map(toLowerCase) || [])),
); );
const monacoFilenames = new Set( const monacoFilenames = new Set(
flatten(monacoLanguages.map(lang => lang.filenames?.map(toLowerCase) || [])), flatten(monacoLanguages.map((lang) => lang.filenames?.map(toLowerCase) || [])),
); );
const KNOWN_TYPES = [ const KNOWN_TYPES = [
...@@ -44,7 +44,7 @@ const KNOWN_TYPES = [ ...@@ -44,7 +44,7 @@ const KNOWN_TYPES = [
]; ];
export function isTextFile({ name, raw, content, mimeType = '' }) { export function isTextFile({ name, raw, content, mimeType = '' }) {
const knownType = KNOWN_TYPES.find(type => type.isMatch(mimeType, name)); const knownType = KNOWN_TYPES.find((type) => type.isMatch(mimeType, name));
if (knownType) return knownType.isText; if (knownType) return knownType.isText;
// does the string contain ascii characters only (ranges from space to tilde, tabs and new lines) // does the string contain ascii characters only (ranges from space to tilde, tabs and new lines)
...@@ -56,20 +56,20 @@ export function isTextFile({ name, raw, content, mimeType = '' }) { ...@@ -56,20 +56,20 @@ export function isTextFile({ name, raw, content, mimeType = '' }) {
return isString(fileContents) && (fileContents === '' || asciiRegex.test(fileContents)); return isString(fileContents) && (fileContents === '' || asciiRegex.test(fileContents));
} }
export const createPathWithExt = p => { export const createPathWithExt = (p) => {
const ext = p.lastIndexOf('.') >= 0 ? p.substring(p.lastIndexOf('.') + 1) : ''; const ext = p.lastIndexOf('.') >= 0 ? p.substring(p.lastIndexOf('.') + 1) : '';
return `${p.substring(1, p.lastIndexOf('.') + 1 || p.length)}${ext || '.js'}`; return `${p.substring(1, p.lastIndexOf('.') + 1 || p.length)}${ext || '.js'}`;
}; };
export const trimPathComponents = path => export const trimPathComponents = (path) =>
path path
.split('/') .split('/')
.map(s => s.trim()) .map((s) => s.trim())
.join('/'); .join('/');
export function registerLanguages(def, ...defs) { export function registerLanguages(def, ...defs) {
defs.forEach(lang => registerLanguages(lang)); defs.forEach((lang) => registerLanguages(lang));
const languageId = def.id; const languageId = def.id;
...@@ -80,7 +80,7 @@ export function registerLanguages(def, ...defs) { ...@@ -80,7 +80,7 @@ export function registerLanguages(def, ...defs) {
export function registerSchema(schema) { export function registerSchema(schema) {
const defaults = [languages.json.jsonDefaults, languages.yaml.yamlDefaults]; const defaults = [languages.json.jsonDefaults, languages.yaml.yamlDefaults];
defaults.forEach(d => defaults.forEach((d) =>
d.setDiagnosticsOptions({ d.setDiagnosticsOptions({
validate: true, validate: true,
enableSchemaRequest: true, enableSchemaRequest: true,
...@@ -91,7 +91,7 @@ export function registerSchema(schema) { ...@@ -91,7 +91,7 @@ export function registerSchema(schema) {
); );
} }
export const otherSide = side => (side === SIDE_RIGHT ? SIDE_LEFT : SIDE_RIGHT); export const otherSide = (side) => (side === SIDE_RIGHT ? SIDE_LEFT : SIDE_RIGHT);
export function trimTrailingWhitespace(content) { export function trimTrailingWhitespace(content) {
return content.replace(/[^\S\r\n]+$/gm, ''); return content.replace(/[^\S\r\n]+$/gm, '');
...@@ -125,9 +125,9 @@ export function getPathParent(path) { ...@@ -125,9 +125,9 @@ export function getPathParent(path) {
* @param {File} file * @param {File} file
*/ */
export function readFileAsDataURL(file) { export function readFileAsDataURL(file) {
return new Promise(resolve => { return new Promise((resolve) => {
const reader = new FileReader(); const reader = new FileReader();
reader.addEventListener('load', e => resolve(e.target.result), { once: true }); reader.addEventListener('load', (e) => resolve(e.target.result), { once: true });
reader.readAsDataURL(file); reader.readAsDataURL(file);
}); });
} }
......
...@@ -3,7 +3,7 @@ import { spriteIcon } from '~/lib/utils/common_utils'; ...@@ -3,7 +3,7 @@ import { spriteIcon } from '~/lib/utils/common_utils';
export function createImageBadge(noteId, { x, y }, classNames = []) { export function createImageBadge(noteId, { x, y }, classNames = []) {
const buttonEl = document.createElement('button'); const buttonEl = document.createElement('button');
const classList = classNames.concat(['js-image-badge']); const classList = classNames.concat(['js-image-badge']);
classList.forEach(className => buttonEl.classList.add(className)); classList.forEach((className) => buttonEl.classList.add(className));
buttonEl.setAttribute('type', 'button'); buttonEl.setAttribute('type', 'button');
buttonEl.setAttribute('disabled', true); buttonEl.setAttribute('disabled', true);
buttonEl.dataset.noteId = noteId; buttonEl.dataset.noteId = noteId;
......
...@@ -7,7 +7,7 @@ export default () => { ...@@ -7,7 +7,7 @@ export default () => {
const renderCommentBadge = true; const renderCommentBadge = true;
const diffFileEls = document.querySelectorAll('.timeline-content .diff-file.js-image-file'); const diffFileEls = document.querySelectorAll('.timeline-content .diff-file.js-image-file');
[...diffFileEls].forEach(diffFileEl => [...diffFileEls].forEach((diffFileEl) =>
initImageDiffHelper.initImageDiff(diffFileEl, canCreateNote, renderCommentBadge), initImageDiffHelper.initImageDiff(diffFileEl, canCreateNote, renderCommentBadge),
); );
}; };
...@@ -26,7 +26,7 @@ export default class ReplacedImageDiff extends ImageDiff { ...@@ -26,7 +26,7 @@ export default class ReplacedImageDiff extends ImageDiff {
this.imageEls = {}; this.imageEls = {};
const viewTypeNames = Object.getOwnPropertyNames(viewTypes); const viewTypeNames = Object.getOwnPropertyNames(viewTypes);
viewTypeNames.forEach(viewType => { viewTypeNames.forEach((viewType) => {
this.imageEls[viewType] = this.imageFrameEls[viewType].querySelector('img'); this.imageEls[viewType] = this.imageFrameEls[viewType].querySelector('img');
}); });
} }
...@@ -62,7 +62,7 @@ export default class ReplacedImageDiff extends ImageDiff { ...@@ -62,7 +62,7 @@ export default class ReplacedImageDiff extends ImageDiff {
// Clear existing badges on new view // Clear existing badges on new view
const existingBadges = this.imageFrameEl.querySelectorAll('.badge'); const existingBadges = this.imageFrameEl.querySelectorAll('.badge');
[...existingBadges].map(badge => badge.remove()); [...existingBadges].map((badge) => badge.remove());
// Remove existing references to old view image badges // Remove existing references to old view image badges
this.imageBadges = []; this.imageBadges = [];
......
...@@ -5,5 +5,5 @@ export const viewTypes = { ...@@ -5,5 +5,5 @@ export const viewTypes = {
}; };
export function isValidViewType(validate) { export function isValidViewType(validate) {
return Boolean(Object.getOwnPropertyNames(viewTypes).find(viewType => viewType === validate)); return Boolean(Object.getOwnPropertyNames(viewTypes).find((viewType) => viewType === validate));
} }
...@@ -7,7 +7,7 @@ import setNewNameMutation from '../graphql/mutations/set_new_name.mutation.graph ...@@ -7,7 +7,7 @@ import setNewNameMutation from '../graphql/mutations/set_new_name.mutation.graph
import importGroupMutation from '../graphql/mutations/import_group.mutation.graphql'; import importGroupMutation from '../graphql/mutations/import_group.mutation.graphql';
import ImportTableRow from './import_table_row.vue'; import ImportTableRow from './import_table_row.vue';
const mapApolloMutations = mutations => const mapApolloMutations = (mutations) =>
Object.fromEntries( Object.fromEntries(
Object.entries(mutations).map(([key, mutation]) => [ Object.entries(mutations).map(([key, mutation]) => [
key, key,
......
...@@ -35,7 +35,7 @@ export default { ...@@ -35,7 +35,7 @@ export default {
select2Options() { select2Options() {
return { return {
data: this.availableNamespaces.map(namespace => ({ data: this.availableNamespaces.map((namespace) => ({
id: namespace.full_path, id: namespace.full_path,
text: namespace.full_path, text: namespace.full_path,
})), })),
......
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