Commit 4ad3f344 authored by Paul Slaughter's avatar Paul Slaughter

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

Format files with prettier arrowParens [7/15]

See merge request gitlab-org/gitlab!50533
parents ff9a62a2 d46581c1
This diff is collapsed.
......@@ -12,7 +12,7 @@ import { SNIPPET_MARK_BLOBS_CONTENT, SNIPPET_MEASURE_BLOBS_CONTENT } from '~/per
const createLocalId = () => uniqueId('blob_local_');
export const decorateBlob = blob => ({
export const decorateBlob = (blob) => ({
...blob,
id: createLocalId(),
isLoaded: false,
......@@ -54,7 +54,7 @@ const diff = ({ content, path }, origBlob) => {
*/
export const diffAll = (blobs, origBlobs) => {
const deletedEntries = Object.values(origBlobs)
.filter(x => !blobs[x.id])
.filter((x) => !blobs[x.id])
.map(({ path, content }) => ({
action: SNIPPET_BLOB_ACTION_DELETE,
previousPath: path,
......@@ -63,15 +63,15 @@ export const diffAll = (blobs, origBlobs) => {
}));
const newEntries = Object.values(blobs)
.map(blob => diff(blob, origBlobs[blob.id]))
.filter(x => x);
.map((blob) => diff(blob, origBlobs[blob.id]))
.filter((x) => x);
return [...deletedEntries, ...newEntries];
};
export const defaultSnippetVisibilityLevels = arr => {
export const defaultSnippetVisibilityLevels = (arr) => {
if (Array.isArray(arr)) {
return arr.map(l => {
return arr.map((l) => {
const translatedLevel = SNIPPET_LEVELS_MAP[l];
return {
value: translatedLevel,
......
......@@ -8,7 +8,7 @@ import hasSubmittedChangesResolver from './resolvers/has_submitted_changes';
Vue.use(VueApollo);
const createApolloProvider = appData => {
const createApolloProvider = (appData) => {
const defaultClient = createDefaultClient(
{
Project: {
......@@ -26,7 +26,7 @@ const createApolloProvider = appData => {
);
// eslint-disable-next-line @gitlab/require-i18n-strings
const mounts = appData.mounts.map(mount => ({ __typename: 'Mount', ...mount }));
const mounts = appData.mounts.map((mount) => ({ __typename: 'Mount', ...mount }));
defaultClient.cache.writeData({
data: {
......
import loadSourceContent from '../../services/load_source_content';
const fileResolver = ({ fullPath: projectId }, { path: sourcePath }) => {
return loadSourceContent({ projectId, sourcePath }).then(sourceContent => ({
return loadSourceContent({ projectId, sourcePath }).then((sourceContent) => ({
// eslint-disable-next-line @gitlab/require-i18n-strings
__typename: 'File',
...sourceContent,
......
......@@ -4,7 +4,7 @@ import query from '../queries/app_data.query.graphql';
const hasSubmittedChangesResolver = (_, { input: { hasSubmittedChanges } }, { cache }) => {
const oldData = cache.readQuery({ query });
const data = produce(oldData, draftState => {
const data = produce(oldData, (draftState) => {
// punctually modifying draftState as per immer docs upsets our linters
return {
...draftState,
......
......@@ -25,8 +25,8 @@ const submitContentChangesResolver = (
images,
mergeRequestMeta,
formattedMarkdown,
}).then(savedContentMeta => {
const data = produce(savedContentMeta, draftState => {
}).then((savedContentMeta) => {
const data = produce(savedContentMeta, (draftState) => {
return {
savedContentMeta: {
__typename: 'SavedContentMeta',
......
......@@ -4,15 +4,15 @@ import { getBinary } from './services/image_service';
const imageRepository = () => {
const images = new Map();
const flash = message => new Flash(message);
const flash = (message) => new Flash(message);
const add = (file, url) => {
getBinary(file)
.then(content => images.set(url, content))
.then((content) => images.set(url, content))
.catch(() => flash(__('Something went wrong while inserting your image. Please try again.')));
};
const get = path => images.get(path);
const get = (path) => images.get(path);
const getAll = () => images;
......
......@@ -4,7 +4,7 @@ import App from './components/app.vue';
import createRouter from './router';
import createApolloProvider from './graphql';
const initStaticSiteEditor = el => {
const initStaticSiteEditor = (el) => {
const {
isSupportedContent,
path: sourcePath,
......
......@@ -118,7 +118,7 @@ export default {
},
},
})
.catch(e => {
.catch((e) => {
this.submitChangesError = e.message;
})
.finally(() => {
......
......@@ -24,7 +24,7 @@ const nestedLineRegexp = /^\s+/;
* This function attempts to correct this problem before the content is loaded
* by Toast UI.
*/
const correctNestedContentIndenation = source => {
const correctNestedContentIndenation = (source) => {
const lines = source.split('\n');
let topLevelOrderedListDetected = false;
......@@ -40,7 +40,7 @@ const correctNestedContentIndenation = source => {
.join('\n');
};
const removeOrphanedBrTags = source => {
const removeOrphanedBrTags = (source) => {
/* Until the underlying Squire editor of Toast UI Editor resolves duplicate `<br>` tags, this
`replace` solution will clear out orphaned `<br>` tags that it generates. Additionally,
it cleans up orphaned `<br>` tags in the source markdown document that should be new lines.
......@@ -49,7 +49,7 @@ const removeOrphanedBrTags = source => {
return source.replace(/\n^<br>$/gm, '');
};
const format = source => {
const format = (source) => {
return correctNestedContentIndenation(removeOrphanedBrTags(source));
};
......
......@@ -8,7 +8,7 @@ const hasMatter = (firstThreeChars, fourthChar) => {
return isYamlDelimiter && isFourthCharNewline;
};
export const frontMatterify = source => {
export const frontMatterify = (source) => {
let index = 3;
let offset;
const delimiter = source.slice(0, index);
......
export const getBinary = file => {
export const getBinary = (file) => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result.split(',')[1]);
reader.onerror = error => reject(error);
reader.onerror = (error) => reject(error);
});
};
import Api from '~/api';
const extractTitle = content => {
const extractTitle = (content) => {
const matches = content.match(/title: (.+)\n/i);
return matches ? Array.from(matches)[1] : '';
......
import { frontMatterify, stringify } from './front_matterify';
const parseSourceFile = raw => {
const parseSourceFile = (raw) => {
let editable;
const syncContent = (newVal, isBody) => {
......@@ -20,7 +20,7 @@ const parseSourceFile = raw => {
const matter = () => editable.matter;
const syncMatter = settings => {
const syncMatter = (settings) => {
editable.matter = settings;
};
......
......@@ -4,16 +4,16 @@ const canRender = ({ type }) => type === 'image';
let metadata;
const getCachedContent = basePath => metadata.imageRepository.get(basePath);
const getCachedContent = (basePath) => metadata.imageRepository.get(basePath);
const isRelativeToCurrentDirectory = basePath => !basePath.startsWith('/');
const isRelativeToCurrentDirectory = (basePath) => !basePath.startsWith('/');
const extractSourceDirectory = url => {
const extractSourceDirectory = (url) => {
const sourceDir = /^(.+)\/([^/]+)$/.exec(url); // Extracts the base path and fileName from an image path
return sourceDir || [null, null, url]; // If no source directory was extracted it means only a fileName was specified (e.g. url='file.png')
};
const parseCurrentDirectory = basePath => {
const parseCurrentDirectory = (basePath) => {
const baseUrl = decodeURIComponent(metadata.baseUrl);
const sourceDirectory = extractSourceDirectory(baseUrl)[1];
const currentDirectory = sourceDirectory.split(`/-/sse/${metadata.branch}`)[1];
......@@ -23,7 +23,7 @@ const parseCurrentDirectory = basePath => {
// For more context around this logic, please see the following comment:
// https://gitlab.com/gitlab-org/gitlab/-/issues/241166#note_409413500
const generateSourceDirectory = basePath => {
const generateSourceDirectory = (basePath) => {
let sourceDir = '';
let defaultSourceDir = '';
......
......@@ -32,7 +32,7 @@ const createImageActions = (images, markdown) => {
}
images.forEach((imageContent, filePath) => {
const imageExistsInMarkdown = path => new RegExp(`!\\[([^[\\]\\n]*)\\](\\(${path})\\)`); // matches the image markdown syntax: ![<any-string-except-newline>](<path>)
const imageExistsInMarkdown = (path) => new RegExp(`!\\[([^[\\]\\n]*)\\](\\(${path})\\)`); // matches the image markdown syntax: ![<any-string-except-newline>](<path>)
if (imageExistsInMarkdown(filePath).test(markdown)) {
actions.push(
......
......@@ -40,10 +40,10 @@ const mark = (source, groups) => {
const hash = {};
Object.entries(groups).forEach(([groupKey, group]) => {
group.forEach(pattern => {
group.forEach((pattern) => {
const matches = text.match(pattern);
if (matches) {
matches.forEach(match => {
matches.forEach((match) => {
const key = `${markPrefix}-${groupKey}-${id}`;
text = text.replace(match, key);
hash[key] = match;
......@@ -67,12 +67,12 @@ const unmark = (text, hash) => {
return source;
};
const unwrap = source => {
const unwrap = (source) => {
let text = source;
const matches = text.match(reTemplated);
if (matches) {
matches.forEach(match => {
matches.forEach((match) => {
const initial = match.replace(`${wrapPrefix}`, '').replace(`${wrapPostfix}`, '');
text = text.replace(match, initial);
});
......@@ -81,7 +81,7 @@ const unwrap = source => {
return text;
};
const wrap = source => {
const wrap = (source) => {
const { text, hash } = mark(unwrap(source), patternGroups);
return unmark(text, hash);
};
......
......@@ -35,7 +35,7 @@ export default class TaskList {
`${this.taskListContainerSelector} .js-task-list-field[data-value]`,
);
taskListFields.forEach(taskListField => {
taskListFields.forEach((taskListField) => {
// eslint-disable-next-line no-param-reassign
taskListField.value = taskListField.dataset.value;
});
......
......@@ -64,11 +64,11 @@ export default class GLTerminal {
const decoder = new TextDecoder('utf-8');
const encoder = new TextEncoder('utf-8');
this.terminal.on('data', data => {
this.terminal.on('data', (data) => {
this.socket.send(encoder.encode(data));
});
this.socket.addEventListener('message', ev => {
this.socket.addEventListener('message', (ev) => {
this.terminal.write(decoder.decode(ev.data));
});
......@@ -110,7 +110,7 @@ export default class GLTerminal {
this.terminal.dispose();
this.socket.close();
this.onDispose.forEach(fn => fn());
this.onDispose.forEach((fn) => fn());
this.onDispose.length = 0;
}
......
......@@ -15,7 +15,7 @@ export default {
...this.cursor,
};
},
update: data => data,
update: (data) => data,
error() {
this.states = null;
},
......
......@@ -12,7 +12,7 @@ export default function simulateInput(target, text) {
}
if (text.length > 0) {
Array.prototype.forEach.call(text, char => {
Array.prototype.forEach.call(text, (char) => {
input.value += char;
triggerEvents(input);
});
......
......@@ -49,7 +49,7 @@ function onToggleClicked(toggle, input, clickCallback) {
export default function setupToggleButtons(container, clickCallback = () => {}) {
const toggles = container.querySelectorAll('.js-project-feature-toggle');
toggles.forEach(toggle => {
toggles.forEach((toggle) => {
const input = toggle.querySelector('.js-project-feature-toggle-input');
const isOn = parseBoolean(input.value);
......
......@@ -2,7 +2,7 @@
import { GlTooltip, GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui';
import { uniqueId } from 'lodash';
const getTooltipTitle = element => {
const getTooltipTitle = (element) => {
return element.getAttribute('title') || element.dataset.title;
};
......@@ -37,8 +37,8 @@ export default {
};
},
created() {
this.observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
this.observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.removedNodes.forEach(this.dispose);
});
});
......@@ -49,11 +49,11 @@ export default {
methods: {
addTooltips(elements, config) {
const newTooltips = elements
.filter(element => !this.tooltipExists(element))
.map(element => newTooltip(element, config))
.filter(tooltip => tooltip.title);
.filter((element) => !this.tooltipExists(element))
.map((element) => newTooltip(element, config))
.filter((tooltip) => tooltip.title);
newTooltips.forEach(tooltip => this.observe(tooltip));
newTooltips.forEach((tooltip) => this.observe(tooltip));
this.tooltips.push(...newTooltips);
},
......@@ -91,7 +91,7 @@ export default {
return Boolean(this.findTooltipByTarget(element));
},
findTooltipByTarget(element) {
return this.tooltips.find(tooltip => tooltip.target === element);
return this.tooltips.find((tooltip) => tooltip.target === element);
},
},
safeHtmlConfig: {
......
......@@ -81,12 +81,12 @@ const tooltipApiInvoker = ({ glHandler, bsHandler }) => (elements, ...params) =>
export const initTooltips = (config = {}) => {
if (isGlTooltipsEnabled()) {
const triggers = config?.triggers || DEFAULT_TRIGGER;
const events = triggers.split(' ').map(trigger => EVENTS_MAP[trigger]);
const events = triggers.split(' ').map((trigger) => EVENTS_MAP[trigger]);
events.forEach(event => {
events.forEach((event) => {
document.addEventListener(
event,
e => handleTooltipEvent(document, e, config.selector, config),
(e) => handleTooltipEvent(document, e, config.selector, config),
true,
);
});
......@@ -103,28 +103,28 @@ export const add = (elements, config = {}) => {
return invokeBootstrapApi(elements, config);
};
export const dispose = tooltipApiInvoker({
glHandler: element => tooltipsApp().dispose(element),
bsHandler: elements => invokeBootstrapApi(elements, 'dispose'),
glHandler: (element) => tooltipsApp().dispose(element),
bsHandler: (elements) => invokeBootstrapApi(elements, 'dispose'),
});
export const fixTitle = tooltipApiInvoker({
glHandler: element => tooltipsApp().fixTitle(element),
bsHandler: elements => invokeBootstrapApi(elements, '_fixTitle'),
glHandler: (element) => tooltipsApp().fixTitle(element),
bsHandler: (elements) => invokeBootstrapApi(elements, '_fixTitle'),
});
export const enable = tooltipApiInvoker({
glHandler: element => tooltipsApp().triggerEvent(element, 'enable'),
bsHandler: elements => invokeBootstrapApi(elements, 'enable'),
glHandler: (element) => tooltipsApp().triggerEvent(element, 'enable'),
bsHandler: (elements) => invokeBootstrapApi(elements, 'enable'),
});
export const disable = tooltipApiInvoker({
glHandler: element => tooltipsApp().triggerEvent(element, 'disable'),
bsHandler: elements => invokeBootstrapApi(elements, 'disable'),
glHandler: (element) => tooltipsApp().triggerEvent(element, 'disable'),
bsHandler: (elements) => invokeBootstrapApi(elements, 'disable'),
});
export const hide = tooltipApiInvoker({
glHandler: element => tooltipsApp().triggerEvent(element, 'close'),
bsHandler: elements => invokeBootstrapApi(elements, 'hide'),
glHandler: (element) => tooltipsApp().triggerEvent(element, 'close'),
bsHandler: (elements) => invokeBootstrapApi(elements, 'hide'),
});
export const show = tooltipApiInvoker({
glHandler: element => tooltipsApp().triggerEvent(element, 'open'),
bsHandler: elements => invokeBootstrapApi(elements, 'show'),
glHandler: (element) => tooltipsApp().triggerEvent(element, 'open'),
bsHandler: (elements) => invokeBootstrapApi(elements, 'show'),
});
export const destroy = () => {
tooltipsApp().$destroy();
......
......@@ -43,7 +43,7 @@ const eventHandler = (e, func, opts = {}) => {
};
const eventHandlers = (category, func) => {
const handler = opts => e => eventHandler(e, func, { ...{ category }, ...opts });
const handler = (opts) => (e) => eventHandler(e, func, { ...{ category }, ...opts });
const handlers = [];
handlers.push({ name: 'click', func: handler() });
handlers.push({ name: 'show.bs.dropdown', func: handler({ suffix: '_show' }) });
......@@ -79,7 +79,7 @@ export default class Tracking {
parent.trackingBound = true;
const handlers = eventHandlers(category, (...args) => this.event(...args));
handlers.forEach(event => parent.addEventListener(event.name, event.func));
handlers.forEach((event) => parent.addEventListener(event.name, event.func));
return handlers;
}
......@@ -88,7 +88,7 @@ export default class Tracking {
const loadEvents = parent.querySelectorAll('[data-track-event="render"]');
loadEvents.forEach(element => {
loadEvents.forEach((element) => {
const { action, data } = createEventPayload(element);
this.event(category, action, data);
});
......
......@@ -26,7 +26,7 @@ export default class TreeView {
initKeyNav() {
const li = $('tr.tree-item');
let liSelected = null;
return $('body').keydown(e => {
return $('body').keydown((e) => {
let next, path;
if ($('input:focus').length > 0 && (e.which === 38 || e.which === 40)) {
return false;
......
......@@ -10,19 +10,19 @@ export default () => {
{
order_by: 'last_activity_at',
},
data => {
(data) => {
callback(data);
},
);
},
text: project => project.name_with_namespace || project.name,
text: (project) => project.name_with_namespace || project.name,
selectable: true,
fieldName: 'author_id',
filterable: true,
search: {
fields: ['name_with_namespace'],
},
id: data => data.id,
isSelected: data => data.id === 2,
id: (data) => data.id,
isSelected: (data) => data.id === 2,
});
};
......@@ -5,7 +5,7 @@ import { parseBoolean } from './lib/utils/common_utils';
import { __ } from './locale';
export default () => {
$('body').on('click', '.js-usage-consent-action', e => {
$('body').on('click', '.js-usage-consent-action', (e) => {
e.preventDefault();
e.stopImmediatePropagation(); // overwrite rails listener
......
......@@ -15,7 +15,7 @@ export default class UserCallout {
init() {
if (!this.isCalloutDismissed || this.isCalloutDismissed === 'false') {
this.userCalloutBody.find('.js-close-callout').on('click', e => this.dismissCallout(e));
this.userCalloutBody.find('.js-close-callout').on('click', (e) => this.dismissCallout(e));
}
}
......
......@@ -7,7 +7,7 @@ export const fetchUserList = ({ commit, state }) => {
commit(types.REQUEST_USER_LIST);
return Api.fetchFeatureFlagUserList(state.projectId, state.userListIid)
.then(({ data }) => commit(types.RECEIVE_USER_LIST_SUCCESS, data))
.catch(response => commit(types.RECEIVE_USER_LIST_ERROR, getErrorMessages(response)));
.catch((response) => commit(types.RECEIVE_USER_LIST_ERROR, getErrorMessages(response)));
};
export const dismissErrorAlert = ({ commit }) => commit(types.DISMISS_ERROR_ALERT);
......@@ -18,5 +18,5 @@ export const updateUserList = ({ commit, state }, userList) => {
name: userList.name,
})
.then(({ data }) => redirectTo(data.path))
.catch(response => commit(types.RECEIVE_USER_LIST_ERROR, getErrorMessages(response)));
.catch((response) => commit(types.RECEIVE_USER_LIST_ERROR, getErrorMessages(response)));
};
......@@ -3,7 +3,7 @@ import createState from './state';
import * as actions from './actions';
import mutations from './mutations';
export default initialState =>
export default (initialState) =>
new Vuex.Store({
actions,
mutations,
......
......@@ -11,5 +11,5 @@ export const createUserList = ({ commit, state }, userList) => {
...userList,
})
.then(({ data }) => redirectTo(data.path))
.catch(response => commit(types.RECEIVE_CREATE_USER_LIST_ERROR, getErrorMessages(response)));
.catch((response) => commit(types.RECEIVE_CREATE_USER_LIST_ERROR, getErrorMessages(response)));
};
......@@ -3,7 +3,7 @@ import createState from './state';
import * as actions from './actions';
import mutations from './mutations';
export default initialState =>
export default (initialState) =>
new Vuex.Store({
actions,
mutations,
......
......@@ -5,7 +5,7 @@ import * as types from './mutation_types';
export const fetchUserList = ({ commit, state }) => {
commit(types.REQUEST_USER_LIST);
return Api.fetchFeatureFlagUserList(state.projectId, state.userListIid)
.then(response => commit(types.RECEIVE_USER_LIST_SUCCESS, response.data))
.then((response) => commit(types.RECEIVE_USER_LIST_SUCCESS, response.data))
.catch(() => commit(types.RECEIVE_USER_LIST_ERROR));
};
......@@ -27,6 +27,6 @@ export const updateUserList = ({ commit, state }) => {
...state.userList,
user_xids: stringifyUserIds(state.userIds),
})
.then(response => commit(types.RECEIVE_USER_LIST_SUCCESS, response.data))
.then((response) => commit(types.RECEIVE_USER_LIST_SUCCESS, response.data))
.catch(() => commit(types.RECEIVE_USER_LIST_ERROR));
};
......@@ -3,7 +3,7 @@ import createState from './state';
import * as actions from './actions';
import mutations from './mutations';
export default initialState =>
export default (initialState) =>
new Vuex.Store({
actions,
mutations,
......
......@@ -20,10 +20,10 @@ export default {
[types.ADD_USER_IDS](state, ids) {
state.userIds = [
...state.userIds,
...parseUserIds(ids).filter(id => id && !state.userIds.includes(id)),
...parseUserIds(ids).filter((id) => id && !state.userIds.includes(id)),
];
},
[types.REMOVE_USER_ID](state, id) {
state.userIds = state.userIds.filter(uid => uid !== id);
state.userIds = state.userIds.filter((uid) => uid !== id);
},
};
......@@ -5,14 +5,14 @@ import { sanitize } from '~/lib/dompurify';
import UsersCache from './lib/utils/users_cache';
import UserPopover from './vue_shared/components/user_popover/user_popover.vue';
const removeTitle = el => {
const removeTitle = (el) => {
// Removing titles so its not showing tooltips also
el.dataset.originalTitle = '';
el.setAttribute('title', '');
};
const getPreloadedUserInfo = dataset => {
const getPreloadedUserInfo = (dataset) => {
const userId = dataset.user || dataset.userId;
const { username, name, avatarUrl } = dataset;
......@@ -28,7 +28,7 @@ const getPreloadedUserInfo = dataset => {
* Adds a UserPopover component to the body, hands over as much data as the target element has in data attributes.
* loads based on data-user-id more data about a user from the API and sets it on the popover
*/
const populateUserInfo = user => {
const populateUserInfo = (user) => {
const { userId } = user;
return Promise.all([UsersCache.retrieveById(userId), UsersCache.retrieveStatusById(userId)]).then(
......@@ -66,7 +66,7 @@ export default (elements = document.querySelectorAll('.js-user-link')) => {
return userLinks
.filter(({ dataset }) => dataset.user || dataset.userId)
.map(el => {
.map((el) => {
if (initializedPopovers.has(el)) {
return initializedPopovers.get(el);
}
......
......@@ -145,14 +145,14 @@ function UsersSelect(currentUser, els, options = {}) {
};
const getMultiSelectDropdownTitle = function (selectedUser, isSelected) {
const selectedUsers = getSelected().filter(u => u !== 0);
const selectedUsers = getSelected().filter((u) => u !== 0);
const firstUser = getSelectedUserInputs()
.map((index, input) => ({
name: input.dataset.meta,
value: parseInt(input.value, 10),
}))
.filter(u => u.id !== 0)
.filter((u) => u.id !== 0)
.get(0);
if (selectedUsers.length === 0) {
......@@ -160,7 +160,7 @@ function UsersSelect(currentUser, els, options = {}) {
} else if (selectedUsers.length === 1) {
return firstUser.name;
} else if (isSelected) {
const otherSelected = selectedUsers.filter(s => s !== selectedUser.id);
const otherSelected = selectedUsers.filter((s) => s !== selectedUser.id);
return sprintf(s__('UsersSelect|%{name} + %{length} more'), {
name: selectedUser.name,
length: otherSelected.length,
......@@ -172,7 +172,7 @@ function UsersSelect(currentUser, els, options = {}) {
});
};
$assignToMeLink.on('click', e => {
$assignToMeLink.on('click', (e) => {
e.preventDefault();
$(e.currentTarget).hide();
......@@ -196,7 +196,7 @@ function UsersSelect(currentUser, els, options = {}) {
}
});
$block.on('click', '.js-assign-yourself', e => {
$block.on('click', '.js-assign-yourself', (e) => {
e.preventDefault();
return assignTo(userSelect.currentUser.id);
});
......@@ -250,7 +250,7 @@ function UsersSelect(currentUser, els, options = {}) {
return initDeprecatedJQueryDropdown($dropdown, {
showMenuAbove,
data(term, callback) {
return userSelect.users(term, options, users => {
return userSelect.users(term, options, (users) => {
// GitLabDropdownFilter returns this.instance
// GitLabDropdownRemote returns this.options.instance
const deprecatedJQueryDropdown = this.instance || this.options.instance;
......@@ -266,14 +266,14 @@ function UsersSelect(currentUser, els, options = {}) {
// Potential duplicate entries when dealing with issue board
// because issue board is also managed by vue
const selectedUsers = uniqBy(selectedInputs, a => a.value)
.filter(input => {
const selectedUsers = uniqBy(selectedInputs, (a) => a.value)
.filter((input) => {
const userId = parseInt(input.value, 10);
const inUsersArray = users.find(u => u.id === userId);
const inUsersArray = users.find((u) => u.id === userId);
return !inUsersArray && userId !== 0;
})
.map(input => {
.map((input) => {
const userId = parseInt(input.value, 10);
const { avatarUrl, avatar_url, name, username, canMerge } = input.dataset;
return {
......@@ -334,7 +334,7 @@ function UsersSelect(currentUser, els, options = {}) {
}
if ($dropdown.hasClass('js-multiselect')) {
const selected = getSelected().filter(i => i !== 0);
const selected = getSelected().filter((i) => i !== 0);
if (selected.length > 0) {
if ($dropdown.data('dropdownHeader')) {
......@@ -346,12 +346,12 @@ function UsersSelect(currentUser, els, options = {}) {
}
const selectedUsers = users
.filter(u => selected.indexOf(u.id) !== -1)
.filter((u) => selected.indexOf(u.id) !== -1)
.sort((a, b) => a.name > b.name);
users = users.filter(u => selected.indexOf(u.id) === -1);
users = users.filter((u) => selected.indexOf(u.id) === -1);
selectedUsers.forEach(selectedUser => {
selectedUsers.forEach((selectedUser) => {
showDivider += 1;
users.splice(showDivider, 0, selectedUser);
});
......@@ -477,7 +477,7 @@ function UsersSelect(currentUser, els, options = {}) {
}
}
if (getSelected().find(u => u === gon.current_user_id)) {
if (getSelected().find((u) => u === gon.current_user_id)) {
$assignToMeLink.hide();
} else {
$assignToMeLink.show();
......@@ -544,7 +544,7 @@ function UsersSelect(currentUser, els, options = {}) {
}
if (selected.length > 0) {
getSelected().forEach(selectedId => highlightSelected(selectedId));
getSelected().forEach((selectedId) => highlightSelected(selectedId));
} else if ($dropdown.hasClass('js-issue-board-sidebar')) {
highlightSelected(0);
} else {
......@@ -559,7 +559,7 @@ function UsersSelect(currentUser, els, options = {}) {
let selected = false;
if (this.multiSelect) {
selected = getSelected().find(u => user.id === u);
selected = getSelected().find((u) => user.id === u);
const { fieldName } = this;
const field = $dropdown
......@@ -613,7 +613,7 @@ function UsersSelect(currentUser, els, options = {}) {
multiple: $(select).hasClass('multiselect'),
minimumInputLength: 0,
query(query) {
return userSelect.users(query.term, options, users => {
return userSelect.users(query.term, options, (users) => {
let name;
const data = {
results: users,
......
......@@ -2,7 +2,7 @@ import Vue from 'vue';
import { parseBoolean } from '~/lib/utils/common_utils';
import DismissibleAlert from '~/vue_shared/components/dismissible_alert.vue';
const mountVueAlert = el => {
const mountVueAlert = (el) => {
const props = {
html: el.innerHTML,
};
......
......@@ -74,7 +74,7 @@ export default {
return this.mr.approvals || {};
},
approvedBy() {
return this.approvals.approved_by ? this.approvals.approved_by.map(x => x.user) : [];
return this.approvals.approved_by ? this.approvals.approved_by.map((x) => x.user) : [];
},
userHasApproved() {
return Boolean(this.approvals.user_has_approved);
......@@ -136,7 +136,7 @@ export default {
approveWithAuth(data) {
this.updateApproval(
() => this.service.approveMergeRequestWithAuth(data),
error => {
(error) => {
if (error && error.response && error.response.status === 401) {
this.hasApprovalAuthError = true;
return;
......@@ -155,7 +155,7 @@ export default {
this.isApproving = true;
this.clearError();
return serviceFn()
.then(data => {
.then((data) => {
this.mr.setApprovals(data);
eventHub.$emit('MRWidgetUpdateRequested');
this.$emit('updated');
......
......@@ -121,7 +121,7 @@ export default {
this.actionInProgress = actionName;
MRWidgetService.executeInlineAction(endpoint)
.then(resp => {
.then((resp) => {
const redirectUrl = resp?.data?.redirect_url;
if (redirectUrl) {
visitUrl(redirectUrl);
......
......@@ -57,7 +57,7 @@ export default {
return this.deployment.changes && this.deployment.changes.length > 1;
},
filteredChanges() {
return this.deployment?.changes?.filter(change => change.path.includes(this.searchTerm));
return this.deployment?.changes?.filter((change) => change.path.includes(this.searchTerm));
},
},
};
......
......@@ -102,7 +102,7 @@ export default {
loadMetrics() {
backOff((next, stop) => {
MRWidgetService.fetchMetrics(this.metricsUrl)
.then(res => {
.then((res) => {
if (res.status === statusCodes.NO_CONTENT) {
this.backOffRequestCounter += 1;
/* eslint-disable no-unused-expressions */
......@@ -113,14 +113,14 @@ export default {
})
.catch(stop);
})
.then(res => {
.then((res) => {
if (res.status === statusCodes.NO_CONTENT) {
return res;
}
return res.data;
})
.then(data => {
.then((data) => {
this.computeGraphData(data.metrics, data.deployment_time);
return data;
})
......
......@@ -67,11 +67,11 @@ export default {
},
mounted() {
this.fetchCollapsedData(this.$props)
.then(data => {
.then((data) => {
this.collapsedData = data;
this.loadingState = null;
})
.catch(e => {
.catch((e) => {
this.loadingState = LOADING_STATES.collapsedError;
throw e;
});
......@@ -86,11 +86,11 @@ export default {
this.loadingState = LOADING_STATES.expandedLoading;
this.fetchFullData(this.$props)
.then(data => {
.then((data) => {
this.loadingState = null;
this.fullData = data;
})
.catch(e => {
.catch((e) => {
this.loadingState = null;
throw e;
});
......
......@@ -11,7 +11,7 @@ export default {
return h(
'div',
{},
extensions.map(extension =>
extensions.map((extension) =>
h(extension, {
props: extensions[0].props.reduce(
(acc, key) => ({
......
......@@ -3,7 +3,7 @@ import ExtensionBase from './base.vue';
// Holds all the currently registered extensions
export const extensions = [];
export const registerExtension = extension => {
export const registerExtension = (extension) => {
// Pushes into the extenions array a dynamically created Vue component
// that gets exteneded from `base.vue`
extensions.push({
......
......@@ -13,7 +13,7 @@ export default {
type: String,
required: false,
default: DANGER,
validator: value => [WARNING, DANGER].includes(value),
validator: (value) => [WARNING, DANGER].includes(value),
},
helpPath: {
type: String,
......
......@@ -51,8 +51,8 @@ export default {
this.isCancellingAutoMerge = true;
this.service
.cancelAutomaticMerge()
.then(res => res.data)
.then(data => {
.then((res) => res.data)
.then((data) => {
eventHub.$emit('UpdateWidgetData', data);
})
.catch(() => {
......@@ -70,8 +70,8 @@ export default {
this.isRemovingSourceBranch = true;
this.service
.merge(options)
.then(res => res.data)
.then(data => {
.then((res) => res.data)
.then((data) => {
if (AUTO_MERGE_STRATEGIES.includes(data.status)) {
eventHub.$emit('MRWidgetUpdateRequested');
}
......
......@@ -30,7 +30,7 @@ export default {
variables() {
return this.mergeRequestQueryVariables;
},
update: data => data.project.mergeRequest.userPermissions,
update: (data) => data.project.mergeRequest.userPermissions,
},
stateData: {
query: conflictsStateQuery,
......@@ -40,7 +40,7 @@ export default {
variables() {
return this.mergeRequestQueryVariables;
},
update: data => data.project.mergeRequest,
update: (data) => data.project.mergeRequest,
},
},
props: {
......
......@@ -83,8 +83,8 @@ export default {
this.service
.removeSourceBranch()
.then(res => res.data)
.then(data => {
.then((res) => res.data)
.then((data) => {
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
// eslint-disable-next-line @gitlab/require-i18n-strings
if (data.message === 'Branch was deleted') {
......
......@@ -25,7 +25,7 @@ export default {
variables() {
return this.mergeRequestQueryVariables;
},
update: data => data.project.mergeRequest,
update: (data) => data.project.mergeRequest,
},
},
props: {
......
......@@ -65,7 +65,7 @@ export default {
.then(() => {
simplePoll(this.checkRebaseStatus);
})
.catch(error => {
.catch((error) => {
this.isMakingRequest = false;
if (error.response && error.response.data && error.response.data.merge_error) {
......@@ -78,8 +78,8 @@ export default {
checkRebaseStatus(continuePolling, stopPolling) {
this.service
.poll()
.then(res => res.data)
.then(res => {
.then((res) => res.data)
.then((res) => {
if (res.rebase_in_progress) {
continuePolling();
} else {
......
......@@ -188,8 +188,8 @@ export default {
this.isMakingRequest = true;
this.service
.merge(options)
.then(res => res.data)
.then(data => {
.then((res) => res.data)
.then((data) => {
const hasError =
data.status === MERGE_FAILED_STATUS ||
data.status === MERGE_HOOK_VALIDATION_ERROR_STATUS;
......@@ -228,8 +228,8 @@ export default {
handleMergePolling(continuePolling, stopPolling) {
this.service
.poll()
.then(res => res.data)
.then(data => {
.then((res) => res.data)
.then((data) => {
if (data.state === 'merged') {
// If state is merged we should update the widget and stop the polling
eventHub.$emit('MRWidgetUpdateRequested');
......@@ -270,8 +270,8 @@ export default {
handleRemoveBranchPolling(continuePolling, stopPolling) {
this.service
.poll()
.then(res => res.data)
.then(data => {
.then((res) => res.data)
.then((data) => {
// If source branch exists then we should continue polling
// because removing a source branch is a background task and takes time
if (data.source_branch_exists) {
......
......@@ -46,7 +46,7 @@ export default {
name="squash"
class="qa-squash-checkbox js-squash-checkbox gl-mb-0 gl-mr-2"
:title="tooltipTitle"
@change="checked => $emit('input', checked)"
@change="(checked) => $emit('input', checked)"
>
{{ $options.i18n.checkboxLabel }}
</gl-form-checkbox>
......
......@@ -29,7 +29,7 @@ export default {
variables() {
return this.mergeRequestQueryVariables;
},
update: data => data.project.mergeRequest.userPermissions,
update: (data) => data.project.mergeRequest.userPermissions,
},
},
props: {
......@@ -86,7 +86,7 @@ export default {
variables: mergeRequestQueryVariables,
});
const data = produce(sourceData, draftState => {
const data = produce(sourceData, (draftState) => {
// eslint-disable-next-line no-param-reassign
draftState.project.mergeRequest.workInProgress = workInProgress;
// eslint-disable-next-line no-param-reassign
......@@ -137,8 +137,8 @@ export default {
this.isMakingRequest = true;
this.service
.removeWIP()
.then(res => res.data)
.then(data => {
.then((res) => res.data)
.then((data) => {
eventHub.$emit('UpdateWidgetData', data);
MergeRequest.toggleDraftStatus(this.mr.title, true);
})
......
......@@ -40,7 +40,7 @@ export default {
);
},
numberOfInvalidPlans() {
return Object.values(this.plansObject).filter(plan => plan.tf_report_error).length;
return Object.values(this.plansObject).filter((plan) => plan.tf_report_error).length;
},
numberOfPlans() {
return Object.keys(this.plansObject).length;
......
......@@ -38,7 +38,7 @@ export default {
.query({ query: issuesQuery, variables: { projectPath: targetProjectFullPath } })
.then(({ data }) => {
// Return some transformed data to be rendered in the expanded state
return data.project.issues.nodes.map(issue => ({
return data.project.issues.nodes.map((issue) => ({
id: issue.id, // Required: The ID of the object
text: issue.title, // Required: The text to get used on each row
// Icon to get rendered on the side of each row
......
......@@ -11,7 +11,7 @@ export default {
}
},
refreshApprovals() {
return this.service.fetchApprovals().then(data => {
return this.service.fetchApprovals().then((data) => {
this.mr.setApprovals(data);
});
},
......
......@@ -358,7 +358,7 @@ export default {
fetchActionsContent() {
this.service
.fetchMergeActionsContent()
.then(res => {
.then((res) => {
if (res.data) {
const el = document.createElement('div');
el.innerHTML = res.data;
......@@ -388,26 +388,26 @@ export default {
this.pollingInterval.stopTimer();
},
bindEventHubListeners() {
eventHub.$on('MRWidgetUpdateRequested', cb => {
eventHub.$on('MRWidgetUpdateRequested', (cb) => {
this.checkStatus(cb);
});
eventHub.$on('MRWidgetRebaseSuccess', cb => {
eventHub.$on('MRWidgetRebaseSuccess', (cb) => {
this.checkStatus(cb, true);
});
// `params` should be an Array contains a Boolean, like `[true]`
// Passing parameter as Boolean didn't work.
eventHub.$on('SetBranchRemoveFlag', params => {
eventHub.$on('SetBranchRemoveFlag', (params) => {
[this.mr.isRemovingSourceBranch] = params;
});
eventHub.$on('FailedToMerge', mergeError => {
eventHub.$on('FailedToMerge', (mergeError) => {
this.mr.state = 'failedToMerge';
this.mr.mergeError = mergeError;
});
eventHub.$on('UpdateWidgetData', data => {
eventHub.$on('UpdateWidgetData', (data) => {
this.mr.setData(data);
});
......
......@@ -60,15 +60,15 @@ export default class MRWidgetService {
}
fetchApprovals() {
return axios.get(this.apiApprovalsPath).then(res => res.data);
return axios.get(this.apiApprovalsPath).then((res) => res.data);
}
approveMergeRequest() {
return axios.post(this.apiApprovePath).then(res => res.data);
return axios.post(this.apiApprovePath).then((res) => res.data);
}
unapproveMergeRequest() {
return axios.post(this.apiUnapprovePath).then(res => res.data);
return axios.post(this.apiUnapprovePath).then((res) => res.data);
}
static executeInlineAction(url) {
......
import { s__, n__ } from '~/locale';
export const title = state => {
export const title = (state) => {
if (state.isLoading) {
return s__('BuildArtifacts|Loading artifacts');
}
......
......@@ -43,7 +43,7 @@ export default {
return this.actions.length > 1;
},
selectedAction() {
return this.actions.find(x => x.key === this.selectedKey) || this.actions[0];
return this.actions.find((x) => x.key === this.selectedKey) || this.actions[0];
},
},
methods: {
......
......@@ -48,7 +48,7 @@ export default {
groupedAwards() {
const { thumbsup, thumbsdown, ...rest } = {
...this.groupedDefaultAwards,
...groupBy(this.awards, x => x.name),
...groupBy(this.awards, (x) => x.name),
};
return [
......@@ -73,7 +73,7 @@ export default {
return false;
}
return awardList.some(award => award.user.id === this.currentUserId);
return awardList.some((award) => award.user.id === this.currentUserId);
},
createAwardList(name, list) {
return {
......@@ -95,11 +95,11 @@ export default {
// Filter myself from list if I am awarded.
if (hasReactionByCurrentUser) {
awardList = awardList.filter(award => award.user.id !== this.currentUserId);
awardList = awardList.filter((award) => award.user.id !== this.currentUserId);
}
// Get only 9-10 usernames to show in tooltip text.
const namesToShow = awardList.slice(0, TOOLTIP_NAME_COUNT).map(award => award.user.name);
const namesToShow = awardList.slice(0, TOOLTIP_NAME_COUNT).map((award) => award.user.name);
// Get the remaining list to use in `and x more` text.
const remainingAwardList = awardList.slice(TOOLTIP_NAME_COUNT, awardList.length);
......
......@@ -54,7 +54,7 @@ export default {
type: Object,
required: false,
default: undefined,
validator: ref =>
validator: (ref) =>
ref === undefined || (Number.isFinite(ref.iid) && isString(ref.path) && !isEmpty(ref.path)),
},
......
......@@ -30,8 +30,8 @@ export default {
};
},
mounted() {
document.querySelectorAll(this.selector).forEach(button => {
button.addEventListener('click', e => {
document.querySelectorAll(this.selector).forEach((button) => {
button.addEventListener('click', (e) => {
e.preventDefault();
this.path = button.dataset.path;
......
......@@ -202,7 +202,7 @@ export default {
<template>
<tooltip-on-truncate
:title="timeWindowText"
:truncate-target="elem => elem.querySelector('.gl-dropdown-toggle-text')"
:truncate-target="(elem) => elem.querySelector('.gl-dropdown-toggle-text')"
placement="top"
class="d-inline-block"
>
......
......@@ -20,12 +20,12 @@ export default {
state: {
default: null,
required: true,
validator: prop => typeof prop === 'boolean' || prop === null,
validator: (prop) => typeof prop === 'boolean' || prop === null,
},
value: {
default: null,
required: false,
validator: prop => typeof prop === 'string' || prop === null,
validator: (prop) => typeof prop === 'string' || prop === null,
},
label: {
type: String,
......
......@@ -25,7 +25,7 @@ export const defaultTimeRanges = [
},
];
export const defaultTimeRange = defaultTimeRanges.find(tr => tr.default);
export const defaultTimeRange = defaultTimeRanges.find((tr) => tr.default);
export const dateFormats = {
/**
......@@ -49,7 +49,7 @@ export const dateFormats = {
* @param {string} value - Value as typed by the user
* @returns true if the value can be parsed as a valid date, false otherwise
*/
export const isValidInputString = value => {
export const isValidInputString = (value) => {
try {
// dateformat throws error that can be caught.
// This is better than using `new Date()`
......
......@@ -21,7 +21,7 @@ export default {
type: String,
required: false,
default: 'md',
validator: value => sizeVariants.includes(value),
validator: (value) => sizeVariants.includes(value),
},
headerTitleText: {
type: String,
......@@ -32,7 +32,7 @@ export default {
type: String,
required: false,
default: 'primary',
validator: value => buttonVariants.includes(value),
validator: (value) => buttonVariants.includes(value),
},
footerPrimaryButtonText: {
type: String,
......
......@@ -22,7 +22,7 @@ export default {
.post(this.path, {
feature_name: this.featureId,
})
.catch(e => {
.catch((e) => {
// eslint-disable-next-line @gitlab/require-i18n-strings, no-console
console.error('Failed to dismiss message.', e);
});
......
......@@ -128,7 +128,7 @@ export default {
this.focusedIndex = 0;
}
Mousetrap.bind(['t', 'mod+p'], e => {
Mousetrap.bind(['t', 'mod+p'], (e) => {
if (e.preventDefault) {
e.preventDefault();
}
......
......@@ -59,7 +59,7 @@ export default {
type: String,
required: false,
default: '',
validator: value => value === '' || /(_desc)|(_asc)/g.test(value),
validator: (value) => value === '' || /(_desc)|(_asc)/g.test(value),
},
showCheckbox: {
type: Boolean,
......@@ -89,7 +89,7 @@ export default {
if (this.initialSortBy) {
selectedSortOption = this.sortOptions
.filter(
sortBy =>
(sortBy) =>
sortBy.sortDirection.ascending === this.initialSortBy ||
sortBy.sortDirection.descending === this.initialSortBy,
)
......@@ -204,12 +204,12 @@ export default {
this.recentSearchesStore = new RecentSearchesStore({
isLocalStorageAvailable: RecentSearchesService.isAvailable(),
allowedKeys: this.tokens.map(token => token.type),
allowedKeys: this.tokens.map((token) => token.type),
});
this.recentSearchesPromise = this.recentSearchesService
.fetch()
.catch(error => {
.catch((error) => {
if (error.name === 'RecentSearchesServiceError') return undefined;
createFlash(__('An error occurred while parsing recent searches'));
......@@ -217,7 +217,7 @@ export default {
// Gracefully fail to empty array
return [];
})
.then(searches => {
.then((searches) => {
if (!searches) return;
// Put any searches that may have come in before
......@@ -250,7 +250,7 @@ export default {
* spaces.
*/
removeQuotesEnclosure(filters = []) {
return filters.map(filter => {
return filters.map((filter) => {
if (typeof filter === 'object') {
const valueString = filter.value.data;
return {
......@@ -305,8 +305,8 @@ export default {
},
historyTokenOptionTitle(historyToken) {
const tokenOption = this.tokens
.find(token => token.type === historyToken.type)
?.options?.find(option => option.value === historyToken.value.data);
.find((token) => token.type === historyToken.type)
?.options?.find((option) => option.value === historyToken.value.data);
if (!tokenOption?.title) {
return historyToken.value.data;
......
......@@ -8,7 +8,7 @@ import { queryToObject } from '~/lib/utils/url_utility';
*
* @returns {String} String without any enclosure
*/
export const stripQuotes = value => value.replace(/^('|")(.*)('|")$/, '$2');
export const stripQuotes = (value) => value.replace(/^('|")(.*)('|")$/, '$2');
/**
* This method removes duplicate tokens from tokens array.
......@@ -17,7 +17,7 @@ export const stripQuotes = value => value.replace(/^('|")(.*)('|")$/, '$2');
*
* @returns {Array} Unique array of tokens
*/
export const uniqueTokens = tokens => {
export const uniqueTokens = (tokens) => {
const knownTokens = [];
return tokens.reduce((uniques, token) => {
if (typeof token === 'object' && token.type !== 'filtered-search-term') {
......@@ -61,7 +61,7 @@ export function prepareTokens(filters = {}) {
return memo;
}
if (Array.isArray(value)) {
return [...memo, ...value.map(filterValue => createToken(key, filterValue))];
return [...memo, ...value.map((filterValue) => createToken(key, filterValue))];
}
return [...memo, createToken(key, value)];
......@@ -99,8 +99,8 @@ export function filterToQueryObject(filters = {}) {
let selected;
let unselected;
if (Array.isArray(filter)) {
selected = filter.filter(item => item.operator === '=').map(item => item.value);
unselected = filter.filter(item => item.operator === '!=').map(item => item.value);
selected = filter.filter((item) => item.operator === '=').map((item) => item.value);
unselected = filter.filter((item) => item.operator === '!=').map((item) => item.value);
} else {
selected = filter?.operator === '=' ? filter.value : null;
unselected = filter?.operator === '!=' ? filter.value : null;
......@@ -155,7 +155,7 @@ export function urlQueryToFilter(query = '') {
previousValues = memo[filterName];
}
if (Array.isArray(value)) {
const newAdditions = value.filter(Boolean).map(item => ({ value: item, operator }));
const newAdditions = value.filter(Boolean).map((item) => ({ value: item, operator }));
return { ...memo, [filterName]: [...previousValues, ...newAdditions] };
}
......
......@@ -17,7 +17,7 @@ export function fetchBranches({ commit, state }, search = '') {
commit(types.REQUEST_BRANCHES);
return Api.branches(projectEndpoint, search)
.then(response => {
.then((response) => {
commit(types.RECEIVE_BRANCHES_SUCCESS, response.data);
return response;
})
......@@ -34,7 +34,7 @@ export const fetchMilestones = ({ commit, state }, search_title = '') => {
return axios
.get(milestonesEndpoint, { params: { search_title } })
.then(response => {
.then((response) => {
commit(types.RECEIVE_MILESTONES_SUCCESS, response.data);
return response;
})
......@@ -50,7 +50,7 @@ export const fetchLabels = ({ commit, state }, search = '') => {
return axios
.get(state.labelsEndpoint, { params: { search } })
.then(response => {
.then((response) => {
commit(types.RECEIVE_LABELS_SUCCESS, response.data);
return response;
})
......@@ -67,13 +67,13 @@ function fetchUser(options = {}) {
let fetchUserPromise;
if (projectEndpoint) {
fetchUserPromise = Api.projectUsers(projectEndpoint, query).then(data => ({ data }));
fetchUserPromise = Api.projectUsers(projectEndpoint, query).then((data) => ({ data }));
} else {
fetchUserPromise = Api.groupMembers(groupEndpoint, { query });
}
return fetchUserPromise
.then(response => {
.then((response) => {
commit(`RECEIVE_${action}_SUCCESS`, response.data);
return response;
})
......
......@@ -43,7 +43,7 @@ export default {
return this.value.data.toLowerCase();
},
activeAuthor() {
return this.authors.find(author => author.username.toLowerCase() === this.currentValue);
return this.authors.find((author) => author.username.toLowerCase() === this.currentValue);
},
},
watch: {
......@@ -63,7 +63,7 @@ export default {
: this.config.fetchAuthors(searchTerm);
fetchPromise
.then(res => {
.then((res) => {
// We'd want to avoid doing this check but
// users.json and /groups/:id/members & /projects/:id/users
// return response differently.
......
......@@ -43,7 +43,7 @@ export default {
return this.value.data.toLowerCase();
},
activeBranch() {
return this.branches.find(branch => branch.name.toLowerCase() === this.currentValue);
return this.branches.find((branch) => branch.name.toLowerCase() === this.currentValue);
},
},
watch: {
......
......@@ -47,7 +47,7 @@ export default {
},
activeLabel() {
return this.labels.find(
label => label.title.toLowerCase() === stripQuotes(this.currentValue),
(label) => label.title.toLowerCase() === stripQuotes(this.currentValue),
);
},
containerStyle() {
......@@ -74,7 +74,7 @@ export default {
this.loading = true;
this.config
.fetchLabels(searchTerm)
.then(res => {
.then((res) => {
// We'd want to avoid doing this check but
// labels.json and /groups/:id/labels & /projects/:id/labels
// return response differently.
......
......@@ -43,7 +43,7 @@ export default {
},
activeMilestone() {
return this.milestones.find(
milestone => milestone.title.toLowerCase() === stripQuotes(this.currentValue),
(milestone) => milestone.title.toLowerCase() === stripQuotes(this.currentValue),
);
},
},
......
......@@ -28,7 +28,7 @@ export default {
},
computed: {
config() {
return this.autocompleteTypes.map(type => ({
return this.autocompleteTypes.map((type) => ({
...tributeConfig[type].config,
loadingItemTemplate: `<span class="gl-spinner gl-vertical-align-text-bottom gl-ml-3 gl-mr-2"></span>${__(
'Loading',
......@@ -56,7 +56,7 @@ export default {
if (!this.assignees || !isAssigneesLengthSame) {
this.assignees =
SidebarMediator.singleton?.store?.assignees?.map(assignee => assignee.username) || [];
SidebarMediator.singleton?.store?.assignees?.map((assignee) => assignee.username) || [];
}
},
filterValues(type) {
......@@ -88,7 +88,7 @@ export default {
} else if (this.dataSources[type]) {
axios
.get(this.dataSources[type])
.then(response => {
.then((response) => {
this.cache[type] = response.data;
processValues(this.filterValues(type));
})
......
......@@ -27,7 +27,7 @@ export const tributeConfig = {
[GfmAutocompleteType.Emojis]: {
config: {
trigger: ':',
lookup: value => value,
lookup: (value) => value,
menuItemTemplate: ({ original }) => `${original} ${Emoji.glEmojiTag(original)}`,
selectTemplate: ({ original }) => `:${original}:`,
},
......@@ -36,7 +36,7 @@ export const tributeConfig = {
[GfmAutocompleteType.Issues]: {
config: {
trigger: '#',
lookup: value => `${value.iid}${value.title}`,
lookup: (value) => `${value.iid}${value.title}`,
menuItemTemplate: ({ original }) =>
`<small>${original.reference || original.iid}</small> ${escape(original.title)}`,
selectTemplate: ({ original }) => original.reference || `#${original.iid}`,
......@@ -57,11 +57,11 @@ export const tributeConfig = {
},
filterValues({ collection, fullText, selectionStart }) {
if (doesCurrentLineStartWith('/label', fullText, selectionStart)) {
return collection.filter(label => !label.set);
return collection.filter((label) => !label.set);
}
if (doesCurrentLineStartWith('/unlabel', fullText, selectionStart)) {
return collection.filter(label => label.set);
return collection.filter((label) => label.set);
}
return collection;
......@@ -72,7 +72,7 @@ export const tributeConfig = {
config: {
trigger: '@',
fillAttr: 'username',
lookup: value =>
lookup: (value) =>
value.type === groupType ? last(value.name.split(' / ')) : `${value.name}${value.username}`,
menuItemTemplate: ({ original }) => {
const commonClasses = 'gl-avatar gl-avatar-s24 gl-flex-shrink-0';
......@@ -113,11 +113,11 @@ export const tributeConfig = {
},
filterValues({ assignees, collection, fullText, selectionStart }) {
if (doesCurrentLineStartWith('/assign', fullText, selectionStart)) {
return collection.filter(member => !assignees.includes(member.username));
return collection.filter((member) => !assignees.includes(member.username));
}
if (doesCurrentLineStartWith('/unassign', fullText, selectionStart)) {
return collection.filter(member => assignees.includes(member.username));
return collection.filter((member) => assignees.includes(member.username));
}
return collection;
......@@ -127,7 +127,7 @@ export const tributeConfig = {
[GfmAutocompleteType.MergeRequests]: {
config: {
trigger: '!',
lookup: value => `${value.iid}${value.title}`,
lookup: (value) => `${value.iid}${value.title}`,
menuItemTemplate: ({ original }) =>
`<small>${original.reference || original.iid}</small> ${escape(original.title)}`,
selectTemplate: ({ original }) => original.reference || `!${original.iid}`,
......@@ -147,7 +147,7 @@ export const tributeConfig = {
config: {
trigger: '/',
fillAttr: 'name',
lookup: value => `${value.name}${value.aliases.join()}`,
lookup: (value) => `${value.name}${value.aliases.join()}`,
menuItemTemplate: ({ original }) => {
const aliases = original.aliases.length
? `<small>(or /${original.aliases.join(', /')})</small>`
......@@ -175,7 +175,7 @@ export const tributeConfig = {
config: {
trigger: '$',
fillAttr: 'id',
lookup: value => `${value.id}${value.title}`,
lookup: (value) => `${value.id}${value.title}`,
menuItemTemplate: ({ original }) => `<small>${original.id}</small> ${escape(original.title)}`,
},
},
......
......@@ -15,5 +15,5 @@ function cleanSuggestionLine(line = {}) {
}
export function selectDiffLines(lines) {
return lines.filter(line => line.type !== 'match').map(line => cleanSuggestionLine(line));
return lines.filter((line) => line.type !== 'match').map((line) => cleanSuggestionLine(line));
}
......@@ -158,7 +158,7 @@ export default {
const mediaInPreview = this.$refs['markdown-preview'].querySelectorAll('video, audio');
if (mediaInPreview) {
mediaInPreview.forEach(media => {
mediaInPreview.forEach((media) => {
media.pause();
});
}
......@@ -199,7 +199,7 @@ export default {
this.markdownPreview = __('Loading…');
axios
.post(this.markdownPreviewPath, { text: this.textareaValue })
.then(response => this.renderMarkdown(response.data))
.then((response) => this.renderMarkdown(response.data))
.catch(() => new Flash(__('Error loading markdown preview')));
} else {
this.renderMarkdown();
......
......@@ -110,7 +110,7 @@ export default {
const area = this.$el.parentNode.querySelector('textarea');
CopyAsGFM.nodeToGFM(transformed)
.then(gfm => {
.then((gfm) => {
CopyAsGFM.insertPastedText(area, documentFragment.textContent, CopyAsGFM.quoted(gfm));
})
.catch(() => {});
......
......@@ -98,11 +98,11 @@ export default {
this.$emit('applyBatch', { flashContainer: this.$el });
});
suggestionDiff.$on('addToBatch', suggestionId => {
suggestionDiff.$on('addToBatch', (suggestionId) => {
this.$emit('addToBatch', suggestionId);
});
suggestionDiff.$on('removeFromBatch', suggestionId => {
suggestionDiff.$on('removeFromBatch', (suggestionId) => {
this.$emit('removeFromBatch', suggestionId);
});
......
......@@ -70,14 +70,14 @@ export default {
document.body,
});
this.clipboard
.on('success', e => {
.on('success', (e) => {
this.$root.$emit('bv::hide::tooltip', this.id);
this.$emit('success', e);
// Clear the selection and blur the trigger so it loses its border
e.clearSelection();
e.trigger.blur();
})
.on('error', e => this.$emit('error', e));
.on('error', (e) => this.$emit('error', e));
});
},
destroyed() {
......
......@@ -4,7 +4,7 @@ export default {
render(h, context) {
const { slotKeys } = context.props;
const slots = context.slots();
const children = slotKeys.map(key => slots[key]).filter(x => x);
const children = slotKeys.map((key) => slots[key]).filter((x) => x);
return children;
},
......
......@@ -203,7 +203,7 @@ export default {
this.resetPagination();
const filterParams = { authorUsername: '', assigneeUsername: '', search: '' };
filters.forEach(filter => {
filters.forEach((filter) => {
if (typeof filter === 'object') {
switch (filter.type) {
case 'author_username':
......
......@@ -6,6 +6,6 @@ import { __ } from '~/locale';
* @param {String} value
* @returns {String}
*/
export const isAny = value => {
export const isAny = (value) => {
return value === __('Any') ? '' : value;
};
......@@ -13,7 +13,7 @@ export default {
project: {
type: Object,
required: true,
validator: p =>
validator: (p) =>
(Number.isFinite(p.id) || isString(p.id)) &&
isString(p.name) &&
(isString(p.name_with_namespace) || isString(p.nameWithNamespace)),
......
......@@ -39,7 +39,7 @@ export default {
},
},
mounted() {
this.detailsSlots = Object.keys(this.$slots).filter(k => k.startsWith('details-'));
this.detailsSlots = Object.keys(this.$slots).filter((k) => k.startsWith('details-'));
},
methods: {
toggleDetails() {
......
......@@ -38,11 +38,11 @@ export default {
},
async mounted() {
const METADATA_PREFIX = 'metadata-';
this.metadataSlots = Object.keys(this.$slots).filter(k => k.startsWith(METADATA_PREFIX));
this.metadataSlots = Object.keys(this.$slots).filter((k) => k.startsWith(METADATA_PREFIX));
// we need to wait for next tick to ensure that dynamic names slots are picked up
await this.$nextTick();
this.metadataSlots = Object.keys(this.$slots).filter(k => k.startsWith(METADATA_PREFIX));
this.metadataSlots = Object.keys(this.$slots).filter((k) => k.startsWith(METADATA_PREFIX));
},
};
</script>
......
......@@ -20,7 +20,7 @@ export default {
components: {
ToastEditor: () =>
import(/* webpackChunkName: 'toast_editor' */ '@toast-ui/vue-editor').then(
toast => toast.Editor,
(toast) => toast.Editor,
),
AddImageModal,
InsertVideoModal,
......
......@@ -17,12 +17,12 @@ const listItemRenderers = [renderListItem];
const softbreakRenderers = [renderSoftbreak];
const executeRenderer = (renderers, node, context) => {
const availableRenderer = renderers.find(renderer => renderer.canRender(node, context));
const availableRenderer = renderers.find((renderer) => renderer.canRender(node, context));
return availableRenderer ? availableRenderer.render(node, context) : context.origin();
};
const buildCustomHTMLRenderer = customRenderers => {
const buildCustomHTMLRenderer = (customRenderers) => {
const renderersByType = {
...customRenderers,
htmlBlock: union(htmlBlockRenderers, customRenderers?.htmlBlock),
......@@ -34,7 +34,7 @@ const buildCustomHTMLRenderer = customRenderers => {
softbreak: union(softbreakRenderers, customRenderers?.softbreak),
};
return mapValues(renderersByType, renderers => {
return mapValues(renderersByType, (renderers) => {
return (node, context) => executeRenderer(renderers, node, context);
});
};
......
......@@ -9,7 +9,7 @@ const DEFAULTS = {
emphasis: '_',
};
const countIndentSpaces = text => {
const countIndentSpaces = (text) => {
const matches = text.match(/^\s+/m);
return matches ? matches[0].length : 0;
......@@ -52,7 +52,7 @@ const buildHTMLToMarkdownRender = (baseRenderer, formattingPreferences = {}) =>
const firstLevelIndentSpacesCount = countIndentSpaces(baseResult) || 1;
const reindentedList = baseResult
.split('\n')
.map(line => {
.map((line) => {
const itemIndentSpacesCount = countIndentSpaces(line);
const nestingLevel = Math.ceil(itemIndentSpacesCount / firstLevelIndentSpacesCount);
const indentSpaces = repeat(' ', subListIndentSpaces * nestingLevel);
......
......@@ -6,7 +6,7 @@ import buildCustomHTMLRenderer from './build_custom_renderer';
import { TOOLBAR_ITEM_CONFIGS, VIDEO_ATTRIBUTES } from '../constants';
import sanitizeHTML from './sanitize_html';
const buildWrapper = propsData => {
const buildWrapper = (propsData) => {
const instance = new Vue({
render(createElement) {
return createElement(ToolbarItem, propsData);
......@@ -17,7 +17,7 @@ const buildWrapper = propsData => {
return instance.$el;
};
const buildVideoIframe = src => {
const buildVideoIframe = (src) => {
const wrapper = document.createElement('figure');
const iframe = document.createElement('iframe');
const videoAttributes = { ...VIDEO_ATTRIBUTES, src };
......@@ -48,7 +48,7 @@ const buildImg = (alt, originalSrc, file) => {
return img;
};
export const generateToolbarItem = config => {
export const generateToolbarItem = (config) => {
const { icon, classes, event, command, tooltip, isDivider } = config;
if (isDivider) {
......@@ -92,14 +92,14 @@ export const insertVideo = ({ editor }, url) => {
}
};
export const getMarkdown = editorInstance => editorInstance.invoke('getMarkdown');
export const getMarkdown = (editorInstance) => editorInstance.invoke('getMarkdown');
/**
* This function allow us to extend Toast UI HTML to Markdown renderer. It is
* a temporary measure because Toast UI does not provide an API
* to achieve this goal.
*/
export const registerHTMLToMarkdownRenderer = editorApi => {
export const registerHTMLToMarkdownRenderer = (editorApi) => {
const { renderer } = editorApi.toMarkOptions;
Object.assign(editorApi.toMarkOptions, {
......@@ -107,10 +107,10 @@ export const registerHTMLToMarkdownRenderer = editorApi => {
});
};
export const getEditorOptions = externalOptions => {
export const getEditorOptions = (externalOptions) => {
return defaults({
customHTMLRenderer: buildCustomHTMLRenderer(externalOptions?.customRenderers),
toolbarItems: TOOLBAR_ITEM_CONFIGS.map(toolbarItem => generateToolbarItem(toolbarItem)),
customHTMLSanitizer: html => sanitizeHTML(html),
toolbarItems: TOOLBAR_ITEM_CONFIGS.map((toolbarItem) => generateToolbarItem(toolbarItem)),
customHTMLSanitizer: (html) => sanitizeHTML(html),
});
};
......@@ -32,20 +32,20 @@ export const buildUneditableCloseTokens = (token, tagType = TAG_TYPES.block) =>
// Complete helpers (open plus close)
export const buildTextToken = content => buildToken('text', null, { content });
export const buildTextToken = (content) => buildToken('text', null, { content });
export const buildUneditableBlockTokens = token => {
export const buildUneditableBlockTokens = (token) => {
return [...buildUneditableOpenTokens(token), buildUneditableCloseToken()];
};
export const buildUneditableInlineTokens = token => {
export const buildUneditableInlineTokens = (token) => {
return [
...buildUneditableOpenTokens(token, TAG_TYPES.inline),
buildUneditableCloseToken(TAG_TYPES.inline),
];
};
export const buildUneditableHtmlAsTextTokens = node => {
export const buildUneditableHtmlAsTextTokens = (node) => {
/*
Toast UI internally appends ' data-tomark-pass ' attribute flags so it can target certain
nested nodes for internal use during Markdown <=> WYSIWYG conversions. In our case, we want
......
......@@ -2,7 +2,7 @@ import { buildUneditableHtmlAsTextTokens } from './build_uneditable_token';
import { ALLOWED_VIDEO_ORIGINS } from '../../constants';
import { getURLOrigin } from '~/lib/utils/url_utility';
const isVideoFrame = html => {
const isVideoFrame = (html) => {
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const {
......@@ -18,6 +18,6 @@ const canRender = ({ type, literal }) => {
return type === 'htmlBlock' && !isVideoFrame(literal);
};
const render = node => buildUneditableHtmlAsTextTokens(node);
const render = (node) => buildUneditableHtmlAsTextTokens(node);
export default { canRender, render };
......@@ -17,7 +17,7 @@ Regexp notes:
*/
const identifierInstanceRegex = /((?:\[.+?\]){1}(?:\[\]|\[.+?\])?(?!:))/g;
const isIdentifierInstance = literal => {
const isIdentifierInstance = (literal) => {
// Reset lastIndex as global flag in regexp are stateful (https://stackoverflow.com/a/11477448)
identifierInstanceRegex.lastIndex = 0;
return identifierInstanceRegex.test(literal);
......@@ -25,9 +25,9 @@ const isIdentifierInstance = literal => {
const canRender = ({ literal }) => isIdentifierInstance(literal);
const tokenize = text => {
const tokenize = (text) => {
const matches = text.split(identifierInstanceRegex);
const tokens = matches.map(match => {
const tokens = matches.map((match) => {
const token = buildTextToken(match);
return isIdentifierInstance(match) ? buildUneditableInlineTokens(token) : token;
});
......
const identifierRegex = /(^\[.+\]: .+)/;
const isIdentifier = text => {
const isIdentifier = (text) => {
return identifierRegex.test(text);
};
......
const canRender = node => ['emph', 'strong'].includes(node.parent?.type);
const canRender = (node) => ['emph', 'strong'].includes(node.parent?.type);
const render = () => ({
type: 'text',
content: ' ',
......
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