Commit 0a8f575e authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 32 files - 29 of 73

Part of our prettier migration; changing the arrow-parens style.
parent dc6c2412
......@@ -848,40 +848,6 @@ app/assets/javascripts/snippets/components/snippet_blob_view.vue
app/assets/javascripts/snippets/components/snippet_header.vue
app/assets/javascripts/snippets/mixins/snippets.js
## lucid-lalande
app/assets/javascripts/snippets/utils/blob.js
app/assets/javascripts/static_site_editor/graphql/index.js
app/assets/javascripts/static_site_editor/graphql/resolvers/file.js
app/assets/javascripts/static_site_editor/graphql/resolvers/has_submitted_changes.js
app/assets/javascripts/static_site_editor/graphql/resolvers/submit_content_changes.js
app/assets/javascripts/static_site_editor/image_repository.js
app/assets/javascripts/static_site_editor/index.js
app/assets/javascripts/static_site_editor/pages/home.vue
app/assets/javascripts/static_site_editor/services/formatter.js
app/assets/javascripts/static_site_editor/services/front_matterify.js
app/assets/javascripts/static_site_editor/services/image_service.js
app/assets/javascripts/static_site_editor/services/load_source_content.js
app/assets/javascripts/static_site_editor/services/parse_source_file.js
app/assets/javascripts/static_site_editor/services/renderers/render_image.js
app/assets/javascripts/static_site_editor/services/submit_content_changes.js
app/assets/javascripts/static_site_editor/services/templater.js
app/assets/javascripts/task_list.js
app/assets/javascripts/terminal/terminal.js
app/assets/javascripts/terraform/components/terraform_list.vue
app/assets/javascripts/test_utils/simulate_input.js
app/assets/javascripts/toggle_buttons.js
app/assets/javascripts/tooltips/components/tooltips.vue
app/assets/javascripts/tooltips/index.js
app/assets/javascripts/tracking.js
app/assets/javascripts/tree.js
app/assets/javascripts/ui_development_kit.js
app/assets/javascripts/usage_ping_consent.js
app/assets/javascripts/user_callout.js
app/assets/javascripts/user_lists/store/edit/actions.js
app/assets/javascripts/user_lists/store/edit/index.js
app/assets/javascripts/user_lists/store/new/actions.js
app/assets/javascripts/user_lists/store/new/index.js
## nostalgic-morse
app/assets/javascripts/user_lists/store/show/actions.js
app/assets/javascripts/user_lists/store/show/index.js
......
......@@ -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,
......
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