Commit 9aa1f620 authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 32 files - 26 of 73

Part of our prettier migration; changing the arrow-parens style.
parent 66da0984
......@@ -22,7 +22,7 @@ export default function initReadMore(triggerSelector = '.js-read-more-trigger')
if (!triggerEls) return;
triggerEls.forEach(triggerEl => {
triggerEls.forEach((triggerEl) => {
const targetEl = triggerEl.previousElementSibling;
if (!targetEl) {
......@@ -31,7 +31,7 @@ export default function initReadMore(triggerSelector = '.js-read-more-trigger')
triggerEl.addEventListener(
'click',
e => {
(e) => {
targetEl.classList.add('is-expanded');
e.target.remove();
},
......
......@@ -39,7 +39,7 @@ export default {
items: {
type: Array,
required: true,
validator: items => Array.isArray(items) && items.every(item => item.name),
validator: (items) => Array.isArray(items) && items.every((item) => item.name),
},
/**
......
......@@ -50,9 +50,9 @@ export default {
},
computed: {
...mapState({
matches: state => state.matches,
lastQuery: state => state.query,
selectedRef: state => state.selectedRef,
matches: (state) => state.matches,
lastQuery: (state) => state.query,
selectedRef: (state) => state.selectedRef,
}),
...mapGetters(['isLoading', 'isQueryPossiblyASha']),
i18n() {
......
......@@ -18,10 +18,10 @@ export const searchBranches = ({ commit, state }) => {
commit(types.REQUEST_START);
Api.branches(state.projectId, state.query)
.then(response => {
.then((response) => {
commit(types.RECEIVE_BRANCHES_SUCCESS, response);
})
.catch(error => {
.catch((error) => {
commit(types.RECEIVE_BRANCHES_ERROR, error);
})
.finally(() => {
......@@ -33,10 +33,10 @@ export const searchTags = ({ commit, state }) => {
commit(types.REQUEST_START);
Api.tags(state.projectId, state.query)
.then(response => {
.then((response) => {
commit(types.RECEIVE_TAGS_SUCCESS, response);
})
.catch(error => {
.catch((error) => {
commit(types.RECEIVE_TAGS_ERROR, error);
})
.finally(() => {
......@@ -50,10 +50,10 @@ export const searchCommits = ({ commit, state, getters }) => {
commit(types.REQUEST_START);
Api.commit(state.projectId, state.query)
.then(response => {
.then((response) => {
commit(types.RECEIVE_COMMITS_SUCCESS, response);
})
.catch(error => {
.catch((error) => {
commit(types.RECEIVE_COMMITS_ERROR, error);
})
.finally(() => {
......
......@@ -23,7 +23,7 @@ export default {
[types.RECEIVE_BRANCHES_SUCCESS](state, response) {
state.matches.branches = {
list: convertObjectPropsToCamelCase(response.data).map(b => ({
list: convertObjectPropsToCamelCase(response.data).map((b) => ({
name: b.name,
default: b.default,
})),
......@@ -41,7 +41,7 @@ export default {
[types.RECEIVE_TAGS_SUCCESS](state, response) {
state.matches.tags = {
list: convertObjectPropsToCamelCase(response.data).map(b => ({
list: convertObjectPropsToCamelCase(response.data).map((b) => ({
name: b.name,
})),
totalCount: parseInt(response.headers[X_TOTAL_HEADER], 10),
......
......@@ -31,7 +31,7 @@ class RefSelectDropdown {
const $fieldInput = $(`input[name="${$dropdownButton.data('fieldName')}"]`, $dropdownContainer);
const $filterInput = $('input[type="search"]', $dropdownContainer);
$filterInput.on('keyup', e => {
$filterInput.on('keyup', (e) => {
const keyCode = e.keyCode || e.which;
if (keyCode !== 13) return;
......
......@@ -31,10 +31,10 @@ export default {
},
computed: {
hasSelectedItems() {
return this.tags.some(tag => this.selectedItems[tag.name]);
return this.tags.some((tag) => this.selectedItems[tag.name]);
},
showMultiDeleteButton() {
return this.tags.some(tag => tag.canDelete) && !this.isMobile;
return this.tags.some((tag) => tag.canDelete) && !this.isMobile;
},
},
methods: {
......
......@@ -14,10 +14,10 @@ export default {
},
computed: {
parsedCrumbs() {
return this.crumbs.map(c => ({ ...c, innerHTML: sanitize(c.innerHTML) }));
return this.crumbs.map((c) => ({ ...c, innerHTML: sanitize(c.innerHTML) }));
},
rootRoute() {
return this.$router.options.routes.find(r => r.meta.root);
return this.$router.options.routes.find((r) => r.meta.root);
},
isRootRoute() {
return this.$route.name === this.rootRoute.name;
......
......@@ -97,7 +97,7 @@ export default {
},
methods: {
deleteTags(toBeDeleted) {
this.itemsToBeDeleted = this.tags.filter(tag => toBeDeleted[tag.name]);
this.itemsToBeDeleted = this.tags.filter((tag) => toBeDeleted[tag.name]);
this.track('click_button');
this.$refs.deleteModal.show();
},
......@@ -111,7 +111,7 @@ export default {
mutation: deleteContainerRepositoryTagsMutation,
variables: {
id: this.queryVariables.id,
tagNames: itemsToBeDeleted.map(i => i.name),
tagNames: itemsToBeDeleted.map((i) => i.name),
},
awaitRefetchQueries: true,
refetchQueries: [
......
......@@ -33,7 +33,7 @@ export default {
projectPath: this.projectPath,
};
},
update: data => data.project?.containerExpirationPolicy,
update: (data) => data.project?.containerExpirationPolicy,
result({ data }) {
this.workingCopy = { ...get(data, 'project.containerExpirationPolicy', {}) };
},
......
......@@ -96,7 +96,7 @@ export default {
return this.isLoading || this.mutationLoading;
},
fieldsAreValid() {
return Object.values(this.localErrors).every(error => error);
return Object.values(this.localErrors).every((error) => error);
},
isSubmitButtonDisabled() {
return !this.fieldsAreValid || this.showLoadingIcon;
......@@ -121,7 +121,7 @@ export default {
},
methods: {
findDefaultOption(option) {
return this.value[option] || this.$options.formOptions[option].find(f => f.default)?.key;
return this.value[option] || this.$options.formOptions[option].find((f) => f.default)?.key;
},
reset() {
this.track('reset_form');
......@@ -131,7 +131,7 @@ export default {
},
setApiErrors(response) {
this.apiErrors = response.graphQLErrors.reduce((acc, curr) => {
curr.extensions.problems.forEach(item => {
curr.extensions.problems.forEach((item) => {
acc[item.path[0]] = item.message;
});
return acc;
......@@ -163,7 +163,7 @@ export default {
this.$toast.show(UPDATE_SETTINGS_SUCCESS_MESSAGE, { type: 'success' });
}
})
.catch(error => {
.catch((error) => {
this.setApiErrors(error);
this.$toast.show(UPDATE_SETTINGS_ERROR_MESSAGE, { type: 'error' });
})
......
import { produce } from 'immer';
import expirationPolicyQuery from '../queries/get_expiration_policy.query.graphql';
export const updateContainerExpirationPolicy = projectPath => (client, { data: updatedData }) => {
export const updateContainerExpirationPolicy = (projectPath) => (client, { data: updatedData }) => {
const queryAndParams = {
query: expirationPolicyQuery,
variables: { projectPath },
};
const sourceData = client.readQuery(queryAndParams);
const data = produce(sourceData, draftState => {
const data = produce(sourceData, (draftState) => {
// eslint-disable-next-line no-param-reassign
draftState.project.containerExpirationPolicy = {
...updatedData.updateContainerExpirationPolicy.containerExpirationPolicy,
......
import { n__ } from '~/locale';
import { KEEP_N_OPTIONS, CADENCE_OPTIONS, OLDER_THAN_OPTIONS } from './constants';
export const findDefaultOption = options => {
const item = options.find(o => o.default);
export const findDefaultOption = (options) => {
const item = options.find((o) => o.default);
return item ? item.key : null;
};
export const olderThanTranslationGenerator = variable => n__('%d day', '%d days', variable);
export const olderThanTranslationGenerator = (variable) => n__('%d day', '%d days', variable);
export const keepNTranslationGenerator = variable =>
export const keepNTranslationGenerator = (variable) =>
n__('%d tag per image name', '%d tags per image name', variable);
export const optionLabelGenerator = (collection, translationFn) =>
collection.map(option => ({
collection.map((option) => ({
...option,
label: translationFn(option.variable),
}));
......
......@@ -118,7 +118,7 @@ export default {
let position = 0;
const untouchedRawRefs = rawRefs
.filter(ref => {
.filter((ref) => {
let isTouched = false;
if (caretPos >= position && caretPos <= position + ref.length) {
......@@ -130,7 +130,7 @@ export default {
return !isTouched;
})
.filter(ref => ref.trim().length > 0);
.filter((ref) => ref.trim().length > 0);
this.$emit('addIssuableFormInput', {
newValue: value,
......@@ -208,7 +208,7 @@ export default {
:path-id-separator="pathIdSeparator"
event-namespace="pendingIssuable"
@pendingIssuableRemoveRequest="
params => {
(params) => {
$emit('pendingIssuableRemoveRequest', params);
}
"
......
......@@ -90,11 +90,11 @@ export default {
categorisedIssues() {
if (this.showCategorizedIssues) {
return Object.values(linkedIssueTypesMap)
.map(linkType => ({
.map((linkType) => ({
linkType,
issues: this.relatedIssues.filter(issue => issue.linkType === linkType),
issues: this.relatedIssues.filter((issue) => issue.linkType === linkType),
}))
.filter(obj => obj.issues.length > 0);
.filter((obj) => obj.issues.length > 0);
}
return [{ issues: this.relatedIssues }];
......
......@@ -110,7 +110,7 @@ export default {
},
methods: {
findRelatedIssueById(id) {
return this.state.relatedIssues.find(issue => issue.id === id);
return this.state.relatedIssues.find((issue) => issue.id === id);
},
onRelatedIssueRemoveRequest(idToRemove) {
const issueToRemove = this.findRelatedIssueById(idToRemove);
......@@ -120,7 +120,7 @@ export default {
.then(({ data }) => {
this.store.setRelatedIssues(data.issuables);
})
.catch(res => {
.catch((res) => {
if (res && res.status !== 404) {
Flash(relatedIssuesRemoveErrorMap[this.issuableType]);
}
......@@ -219,7 +219,7 @@ export default {
this.processAllReferences(newValue);
},
processAllReferences(value = '') {
const rawReferences = value.split(/\s+/).filter(reference => reference.trim().length > 0);
const rawReferences = value.split(/\s+/).filter((reference) => reference.trim().length > 0);
this.store.addPendingReferences(rawReferences);
this.inputValue = '';
......
......@@ -11,7 +11,7 @@ export default function initRelatedIssues() {
components: {
relatedIssuesRoot: RelatedIssuesRoot,
},
render: createElement =>
render: (createElement) =>
createElement('related-issues-root', {
props: {
endpoint: relatedIssuesRootElement.dataset.endpoint,
......
......@@ -19,7 +19,7 @@ class RelatedIssuesStore {
}
removeRelatedIssue(issue) {
this.state.relatedIssues = this.state.relatedIssues.filter(x => x.id !== issue.id);
this.state.relatedIssues = this.state.relatedIssues.filter((x) => x.id !== issue.id);
}
updateIssueOrder(oldIndex, newIndex) {
......
......@@ -15,7 +15,7 @@ export default function initRelatedMergeRequests() {
RelatedMergeRequests,
},
store: createStore(),
render: createElement =>
render: (createElement) =>
createElement('related-merge-requests', {
props: { endpoint, projectNamespace, projectPath },
}),
......
......@@ -21,7 +21,7 @@ export const fetchMergeRequests = ({ state, dispatch }) => {
return axios
.get(`${state.apiEndpoint}?per_page=${REQUEST_PAGE_COUNT}`)
.then(res => {
.then((res) => {
const { headers, data } = res;
const total = Number(normalizeHeaders(headers)['X-TOTAL']) || 0;
......
......@@ -47,7 +47,7 @@ export default {
sections() {
return [
{
links: get(this.assets, 'sources', []).map(s => ({
links: get(this.assets, 'sources', []).map((s) => ({
url: s.url,
name: sprintf(__('Source code (%{fileExtension})'), { fileExtension: s.format }),
})),
......@@ -73,7 +73,7 @@ export default {
links: this.otherLinks,
iconName: 'link',
},
].filter(section => section.links.length > 0);
].filter((section) => section.links.length > 0);
},
},
methods: {
......@@ -81,7 +81,7 @@ export default {
this.isAssetsExpanded = !this.isAssetsExpanded;
},
linksForType(type) {
return this.assets.links.filter(l => l.linkType === type);
return this.assets.links.filter((l) => l.linkType === type);
},
},
externalLinkTooltipText: __('This link points to external content'),
......
......@@ -64,7 +64,7 @@ export default {
},
issueCounts() {
return this.milestones
.map(m => m.issueStats || {})
.map((m) => m.issueStats || {})
.reduce(
(acc, current) => {
acc.total += current.total || 0;
......@@ -79,11 +79,11 @@ export default {
);
},
showMergeRequestStats() {
return this.milestones.some(m => m.mrStats);
return this.milestones.some((m) => m.mrStats);
},
mergeRequestCounts() {
return this.milestones
.map(m => m.mrStats || {})
.map((m) => m.mrStats || {})
.reduce(
(acc, current) => {
acc.total += current.total || 0;
......
......@@ -11,14 +11,14 @@ export default {
},
computed: {
...mapState('list', {
orderBy: state => state.sorting.orderBy,
sort: state => state.sorting.sort,
orderBy: (state) => state.sorting.orderBy,
sort: (state) => state.sorting.sort,
}),
sortOptions() {
return SORT_OPTIONS;
},
sortText() {
const option = this.sortOptions.find(s => s.orderBy === this.orderBy);
const option = this.sortOptions.find((s) => s.orderBy === this.orderBy);
return option.label;
},
isSortAscending() {
......
......@@ -18,6 +18,6 @@ export default () => {
return new Vue({
el,
store,
render: h => h(ReleaseEditNewApp),
render: (h) => h(ReleaseEditNewApp),
});
};
......@@ -21,6 +21,6 @@ export default () => {
graphqlMilestoneStats: Boolean(gon.features?.graphqlMilestoneStats),
},
}),
render: h => h(ReleaseListApp),
render: (h) => h(ReleaseListApp),
});
};
......@@ -18,6 +18,6 @@ export default () => {
return new Vue({
el,
store,
render: h => h(ReleaseEditNewApp),
render: (h) => h(ReleaseEditNewApp),
});
};
......@@ -21,6 +21,6 @@ export default () => {
return new Vue({
el,
store,
render: h => h(ReleaseShowApp),
render: (h) => h(ReleaseShowApp),
});
};
......@@ -2,7 +2,7 @@
* @returns {Boolean} `true` if all the feature flags
* required to enable the GraphQL endpoint are enabled
*/
export const useGraphQLEndpoint = rootState => {
export const useGraphQLEndpoint = (rootState) => {
return Boolean(
rootState.featureFlags.graphqlReleaseData &&
rootState.featureFlags.graphqlReleasesPage &&
......
......@@ -36,12 +36,12 @@ export const fetchRelease = ({ commit, state, rootState }) => {
tagName: state.tagName,
},
})
.then(response => {
.then((response) => {
const { data: release } = convertOneReleaseGraphQLResponse(response);
commit(types.RECEIVE_RELEASE_SUCCESS, release);
})
.catch(error => {
.catch((error) => {
commit(types.RECEIVE_RELEASE_ERROR, error);
createFlash(s__('Release|Something went wrong while getting the release details'));
});
......@@ -52,7 +52,7 @@ export const fetchRelease = ({ commit, state, rootState }) => {
.then(({ data }) => {
commit(types.RECEIVE_RELEASE_SUCCESS, apiJsonToRelease(data));
})
.catch(error => {
.catch((error) => {
commit(types.RECEIVE_RELEASE_ERROR, error);
createFlash(s__('Release|Something went wrong while getting the release details'));
});
......@@ -121,7 +121,7 @@ export const createRelease = ({ commit, dispatch, state, getters }) => {
.then(({ data }) => {
dispatch('receiveSaveReleaseSuccess', apiJsonToRelease(data));
})
.catch(error => {
.catch((error) => {
commit(types.RECEIVE_SAVE_RELEASE_ERROR, error);
createFlash(s__('Release|Something went wrong while creating a new release'));
});
......@@ -163,7 +163,7 @@ export const updateRelease = ({ commit, dispatch, state, getters }) => {
// Delete all links currently associated with this Release
return Promise.all(
getters.releaseLinksToDelete.map(l =>
getters.releaseLinksToDelete.map((l) =>
api.deleteReleaseLink(state.projectId, state.release.tagName, l.id),
),
);
......@@ -171,7 +171,7 @@ export const updateRelease = ({ commit, dispatch, state, getters }) => {
.then(() => {
// Create a new link for each link in the form
return Promise.all(
apiJson.assets.links.map(l =>
apiJson.assets.links.map((l) =>
api.createReleaseLink(state.projectId, state.release.tagName, l),
),
);
......@@ -179,7 +179,7 @@ export const updateRelease = ({ commit, dispatch, state, getters }) => {
.then(() => {
dispatch('receiveSaveReleaseSuccess', apiJsonToRelease(updatedRelease));
})
.catch(error => {
.catch((error) => {
commit(types.RECEIVE_SAVE_RELEASE_ERROR, error);
createFlash(s__('Release|Something went wrong while saving the release details'));
})
......
......@@ -5,7 +5,7 @@ import { hasContent } from '~/lib/utils/text_utility';
* @returns {Boolean} `true` if the app is editing an existing release.
* `false` if the app is creating a new release.
*/
export const isExistingRelease = state => {
export const isExistingRelease = (state) => {
return Boolean(state.tagName);
};
......@@ -15,19 +15,19 @@ export const isExistingRelease = state => {
* empty (or whitespace-only) values for both `url` and `name`.
* Otherwise, `false`.
*/
const isEmptyReleaseLink = link => !hasContent(link.url) && !hasContent(link.name);
const isEmptyReleaseLink = (link) => !hasContent(link.url) && !hasContent(link.name);
/** Returns all release links that aren't empty */
export const releaseLinksToCreate = state => {
export const releaseLinksToCreate = (state) => {
if (!state.release) {
return [];
}
return state.release.assets.links.filter(l => !isEmptyReleaseLink(l));
return state.release.assets.links.filter((l) => !isEmptyReleaseLink(l));
};
/** Returns all release links that should be deleted */
export const releaseLinksToDelete = state => {
export const releaseLinksToDelete = (state) => {
if (!state.originalRelease) {
return [];
}
......@@ -36,7 +36,7 @@ export const releaseLinksToDelete = state => {
};
/** Returns all validation errors on the release object */
export const validationErrors = state => {
export const validationErrors = (state) => {
const errors = {
assets: {
links: {},
......@@ -56,7 +56,7 @@ export const validationErrors = state => {
// This is used for detecting duplicate URLs.
const urlToLinksMap = new Map();
state.release.assets.links.forEach(link => {
state.release.assets.links.forEach((link) => {
errors.assets.links[link.id] = {};
// Only validate non-empty URLs
......@@ -81,7 +81,7 @@ export const validationErrors = state => {
// add a validation error for each link that shares this URL
const duplicates = urlToLinksMap.get(normalizedUrl);
duplicates.push(link);
duplicates.forEach(duplicateLink => {
duplicates.forEach((duplicateLink) => {
errors.assets.links[duplicateLink.id].isDuplicate = true;
});
} else {
......
......@@ -3,7 +3,7 @@ import * as getters from './getters';
import mutations from './mutations';
import createState from './state';
export default initialState => ({
export default (initialState) => ({
namespaced: true,
actions,
getters,
......
......@@ -3,7 +3,7 @@ import * as types from './mutation_types';
import { DEFAULT_ASSET_LINK_TYPE } from '../../../constants';
const findReleaseLink = (release, id) => {
return release.assets.links.find(l => l.id === id);
return release.assets.links.find((l) => l.id === id);
};
export default {
......@@ -93,6 +93,6 @@ export default {
},
[types.REMOVE_ASSET_LINK](state, linkIdToRemove) {
state.release.assets.links = state.release.assets.links.filter(l => l.id !== linkIdToRemove);
state.release.assets.links = state.release.assets.links.filter((l) => l.id !== linkIdToRemove);
},
};
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