Commit 232790a7 authored by Mike Greiling's avatar Mike Greiling

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

Format files with prettier arrowParens [9/15]

See merge request gitlab-org/gitlab!50536
parents 1ce67085 468cb9f0
......@@ -13,7 +13,7 @@ const addScheduleToStore = (store, query, { oncallSchedule: schedule }, variable
variables,
});
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
draftData.project.incidentManagementOncallSchedules.nodes.push(schedule);
});
......@@ -35,7 +35,7 @@ const deleteScheduleFromStore = (store, query, { oncallScheduleDestroy }, variab
variables,
});
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.incidentManagementOncallSchedules.nodes = draftData.project.incidentManagementOncallSchedules.nodes.filter(
({ id }) => id !== schedule.id,
......@@ -60,7 +60,7 @@ const updateScheduleFromStore = (store, query, { oncallScheduleUpdate }, variabl
variables,
});
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.incidentManagementOncallSchedules.nodes = [
...draftData.project.incidentManagementOncallSchedules.nodes,
......
......@@ -11,7 +11,7 @@ import { getDateInFuture } from '~/lib/utils/datetime_utility';
*
* @returns {String}
*/
export const getFormattedTimezone = tz => {
export const getFormattedTimezone = (tz) => {
return sprintf(__('(UTC %{offset}) %{timezone}'), {
offset: tz.formatted_offset,
timezone: `${tz.abbr} ${tz.name}`,
......
......@@ -16,12 +16,12 @@ export default class CiTemplate {
selectable: true,
filterable: true,
allowClear: true,
toggleLabel: item => item.name,
toggleLabel: (item) => item.name,
search: {
fields: ['name'],
},
clicked: clickEvent => this.updateInputValue(clickEvent),
text: item => item.name,
clicked: (clickEvent) => this.updateInputValue(clickEvent),
text: (item) => item.name,
});
this.setDropdownToggle();
......
......@@ -29,7 +29,7 @@ const getDropdownConfig = (placeholder, apiPath, textProp) => ({
},
results(data) {
return {
results: data.map(entity => ({
results: data.map((entity) => ({
id: entity.id,
text: entity[textProp],
})),
......@@ -45,7 +45,7 @@ const $container = $('#js-elasticsearch-settings');
$container
.find('.js-limit-checkbox')
.on('change', e =>
.on('change', (e) =>
onLimitCheckboxChange(
e.currentTarget.checked,
$container.find('.js-limit-namespaces'),
......
......@@ -27,7 +27,7 @@ const getDropdownConfig = (placeholder, url) => ({
},
results(data) {
return {
results: data.map(entity => ({
results: data.map((entity) => ({
id: entity.source_id,
text: entity.path,
})),
......@@ -44,7 +44,7 @@ const $container = $('#js-elasticsearch-settings');
$container
.find('.js-limit-checkbox')
.on('change', e =>
.on('change', (e) =>
onLimitCheckboxChange(
e.currentTarget.checked,
$container.find('.js-limit-namespaces'),
......
......@@ -4,7 +4,7 @@ import { sprintf, __ } from '~/locale';
import { sanitizeItem } from '~/frequent_items/utils';
import { loadCSSFile } from '~/lib/utils/css_utils';
const formatResult = selectedItem => {
const formatResult = (selectedItem) => {
if (selectedItem.path_with_namespace) {
return `<div class='project-result'> <div class='project-name'>${selectedItem.name}</div> <div class='project-path'>${selectedItem.path_with_namespace}</div> </div>`;
} else if (selectedItem.path) {
......@@ -15,7 +15,7 @@ const formatResult = selectedItem => {
)}</div> <div class='group-path'>${__('All groups and projects')}</div> </div>`;
};
const formatSelection = selectedItem => {
const formatSelection = (selectedItem) => {
if (selectedItem.path_with_namespace) {
return sprintf(__('Project: %{name}'), { name: selectedItem.name });
} else if (selectedItem.path) {
......@@ -24,7 +24,7 @@ const formatSelection = selectedItem => {
return __('All groups and projects');
};
const QueryAdmin = query => {
const QueryAdmin = (query) => {
const groupsFetch = Api.groups(query.term, {});
const projectsFetch = Api.projects(query.term, {
order_by: 'id',
......
......@@ -6,4 +6,4 @@ initVueAlerts();
initConfirmModal();
const toasts = document.querySelectorAll('.js-toast-message');
toasts.forEach(toast => showToast(toast.dataset.message));
toasts.forEach((toast) => showToast(toast.dataset.message));
......@@ -15,6 +15,6 @@ const toggleUploadLicenseButton = () => {
uploadLicenseBtn.toggleAttribute('disabled', !acceptEULACheckBox.checked);
};
licenseType.forEach(el => el.addEventListener('change', showLicenseType));
licenseType.forEach((el) => el.addEventListener('change', showLicenseType));
acceptEULACheckBox.addEventListener('change', toggleUploadLicenseButton);
showLicenseType();
......@@ -17,7 +17,7 @@ export default {
resetPipelineMinutes() {
axios
.post(this.resetMinutesPath)
.then(resp => {
.then((resp) => {
if (resp.status === statusCodes.OK) {
this.$toast.show(__('User pipeline minutes were successfully reset.'));
}
......
......@@ -10,7 +10,7 @@ export function fetchPage({ commit, state }, newPage) {
page: newPage || state.pageInfo.page,
per_page: state.pageInfo.perPage,
})
.then(response => {
.then((response) => {
const { headers, data } = response;
const pageInfo = parseIntPagination(normalizeHeaders(headers));
commit(types.RECEIVE_SAML_MEMBERS_SUCCESS, {
......
......@@ -7,7 +7,7 @@ import state from './state';
Vue.use(Vuex);
export default initialState =>
export default (initialState) =>
new Vuex.Store({
actions,
mutations,
......
......@@ -21,7 +21,7 @@ export default () => {
if (isCodequalityTabActive) {
store.dispatch(fetchReportAction);
} else {
const tabClickHandler = e => {
const tabClickHandler = (e) => {
if (e.target.className === 'codequality-tab') {
store.dispatch(fetchReportAction);
tabsElement.removeEventListener('click', tabClickHandler);
......@@ -38,7 +38,7 @@ export default () => {
CodequalityReportApp,
},
store,
render: createElement => createElement('codequality-report-app'),
render: (createElement) => createElement('codequality-report-app'),
});
}
};
......@@ -34,7 +34,7 @@ export default () => {
reportSectionClass: 'split-report-section',
},
on: {
updateBadgeCount: count => {
updateBadgeCount: (count) => {
updateBadgeCount('.js-licenses-counter', count);
},
},
......
......@@ -27,7 +27,7 @@ if (el?.dataset?.apiUrl) {
});
}
toasts.forEach(toast => showToast(toast.dataset.message));
toasts.forEach((toast) => showToast(toast.dataset.message));
// eslint-disable-next-line no-new
new ProtectedEnvironmentCreate();
......
......@@ -37,7 +37,7 @@ export default class EEMirrorRepos extends MirrorRepos {
}
hideForm() {
return new Promise(resolve => {
return new Promise((resolve) => {
if (!this.$insertionPoint.html()) return resolve();
this.$insertionPoint.one('hidden.bs.collapse', () => {
......@@ -48,7 +48,7 @@ export default class EEMirrorRepos extends MirrorRepos {
}
showForm() {
return new Promise(resolve => {
return new Promise((resolve) => {
this.$insertionPoint.one('shown.bs.collapse', () => {
resolve();
});
......
......@@ -4,7 +4,7 @@ import { __ } from '~/locale';
import axios from '~/lib/utils/axios_utils';
export default function initPathLocks(url, path) {
$('a.path-lock').on('click', e => {
$('a.path-lock').on('click', (e) => {
e.preventDefault();
axios
......
......@@ -2,7 +2,7 @@ import Vue from 'vue';
import BlockingMrInput from 'ee/projects/merge_requests/blocking_mr_input_root.vue';
import { n__ } from '~/locale';
export default el => {
export default (el) => {
if (!el) {
return null;
}
......
......@@ -59,7 +59,7 @@ export default class ProtectedEnvironmentCreate {
.get(gon.search_unprotected_environments_url, { params: { query: term } })
.then(({ data }) => {
const environments = [].concat(data);
const results = environments.map(environment => ({
const results = environments.map((environment) => ({
id: environment,
text: environment,
title: environment,
......@@ -80,12 +80,12 @@ export default class ProtectedEnvironmentCreate {
},
};
Object.keys(ACCESS_LEVELS).forEach(level => {
Object.keys(ACCESS_LEVELS).forEach((level) => {
const accessLevel = ACCESS_LEVELS[level];
const selectedItems = this[`${accessLevel}_dropdown`].getSelectedItems();
const levelAttributes = [];
selectedItems.forEach(item => {
selectedItems.forEach((item) => {
if (item.type === LEVEL_TYPES.USER) {
levelAttributes.push({
user_id: item.user_id,
......
......@@ -60,7 +60,7 @@ export default class ProtectedEnvironmentEdit {
.then(({ data }) => {
this.hasChanges = false;
Object.keys(ACCESS_LEVELS).forEach(level => {
Object.keys(ACCESS_LEVELS).forEach((level) => {
const accessLevelName = ACCESS_LEVELS[level];
// The data coming from server will be the new persisted *state* for each dropdown
......@@ -75,7 +75,7 @@ export default class ProtectedEnvironmentEdit {
}
setSelectedItemsToDropdown(items = [], dropdownName) {
const itemsToAdd = items.map(currentItem => {
const itemsToAdd = items.map((currentItem) => {
if (currentItem.user_id) {
// Do this only for users for now
// get the current data for selected items
......
......@@ -64,12 +64,12 @@ export default class ProtectedTagCreate {
},
};
Object.keys(ACCESS_LEVELS).forEach(level => {
Object.keys(ACCESS_LEVELS).forEach((level) => {
const accessLevel = ACCESS_LEVELS[level];
const selectedItems = this[`${ACCESS_LEVELS.CREATE}_dropdown`].getSelectedItems();
const levelAttributes = [];
selectedItems.forEach(item => {
selectedItems.forEach((item) => {
if (item.type === LEVEL_TYPES.USER) {
levelAttributes.push({
user_id: item.user_id,
......
......@@ -60,7 +60,7 @@ export default class ProtectedTagEdit {
.then(({ data }) => {
this.hasChanges = false;
Object.keys(ACCESS_LEVELS).forEach(level => {
Object.keys(ACCESS_LEVELS).forEach((level) => {
const accessLevelName = ACCESS_LEVELS[level];
// The data coming from server will be the new persisted *state* for each dropdown
......@@ -74,7 +74,7 @@ export default class ProtectedTagEdit {
}
setSelectedItemsToDropdown(items = [], dropdownName) {
const itemsToAdd = items.map(currentItem => {
const itemsToAdd = items.map((currentItem) => {
if (currentItem.user_id) {
// Do this only for users for now
// get the current data for selected items
......
......@@ -32,7 +32,7 @@ function toggleTrialForm(trial) {
}
form.classList.toggle('hidden', !trial);
fields.forEach(f => {
fields.forEach((f) => {
f.disabled = !trial; // eslint-disable-line no-param-reassign
});
......@@ -54,7 +54,7 @@ function mountTrialToggle() {
return createElement(RegistrationTrialToggle, {
props: { active },
on: {
changed: event => toggleTrialForm(event.trial),
changed: (event) => toggleTrialForm(event.trial),
},
});
},
......
......@@ -117,7 +117,7 @@ export default {
'fetchProjects',
]),
getRawRefs(value) {
return value.split(/\s+/).filter(ref => ref.trim().length > 0);
return value.split(/\s+/).filter((ref) => ref.trim().length > 0);
},
handlePendingItemRemove(index) {
this.removePendingReference(index);
......
......@@ -69,6 +69,6 @@ export default () => {
methods: {
...Vuex.mapActions(['setInitialParentItem', 'setInitialConfig']),
},
render: createElement => createElement('related-items-tree-app'),
render: (createElement) => createElement('related-items-tree-app'),
});
};
......@@ -269,7 +269,7 @@ export const setItemInputValue = ({ commit }, data) => commit(types.SET_ITEM_INP
export const requestAddItem = ({ commit }) => commit(types.REQUEST_ADD_ITEM);
export const receiveAddItemSuccess = ({ dispatch, commit, getters }, { rawItems }) => {
const items = rawItems.map(item => {
const items = rawItems.map((item) => {
// This is needed since Rails API to add Epic/Issue
// doesn't return global ID string.
// We can remove this change once add epic/issue
......@@ -300,7 +300,7 @@ export const receiveAddItemSuccess = ({ dispatch, commit, getters }, { rawItems
items,
});
items.forEach(item => {
items.forEach((item) => {
dispatch('updateChildrenCount', { item });
});
......@@ -332,7 +332,7 @@ export const addItem = ({ state, dispatch, getters }) => {
rawItems: data.issuables.slice(0, state.pendingReferences.length),
});
})
.catch(data => {
.catch((data) => {
const { response } = data;
if (response.status === httpStatusCodes.NOT_FOUND) {
dispatch('receiveAddItemFailure', { itemAddFailureType: itemAddFailureTypesMap.NOT_FOUND });
......@@ -557,7 +557,7 @@ export const createNewIssue = ({ state, dispatch }, { issuesEndpoint, title }) =
parentItem,
});
})
.catch(e => {
.catch((e) => {
dispatch('receiveCreateIssueFailure');
throw e;
});
......
......@@ -3,10 +3,10 @@ import { processIssueTypeIssueSources } from '../utils/epic_utils';
export const autoCompleteSources = () => gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources;
export const directChildren = state => state.children[state.parentItem.reference] || [];
export const directChildren = (state) => state.children[state.parentItem.reference] || [];
export const anyParentHasChildren = (state, getters) =>
getters.directChildren.some(item => item.hasChildren || item.hasIssues);
getters.directChildren.some((item) => item.hasChildren || item.hasIssues);
export const itemAutoCompleteSources = (state, getters) => {
if (getters.isEpic) {
......@@ -26,4 +26,4 @@ export const itemAutoCompleteSources = (state, getters) => {
export const itemPathIdSeparator = (state, getters) =>
getters.isEpic ? PathIdSeparator.Epic : PathIdSeparator.Issue;
export const isEpic = state => state.issuableType === issuableTypesMap.EPIC;
export const isEpic = (state) => state.issuableType === issuableTypesMap.EPIC;
......@@ -42,14 +42,14 @@ export const sortByState = (a, b) => stateOrder.indexOf(a.state) - stateOrder.in
*
* @param {Array} items
*/
export const applySorts = array => array.sort(sortChildren).sort(sortByState);
export const applySorts = (array) => array.sort(sortChildren).sort(sortByState);
/**
* Returns formatted child item to include additional
* flags and properties to use while rendering tree.
* @param {Object} item
*/
export const formatChildItem = item => ({ ...item, pathIdSeparator: PathIdSeparator[item.type] });
export const formatChildItem = (item) => ({ ...item, pathIdSeparator: PathIdSeparator[item.type] });
/**
* Returns formatted array of Epics that doesn't contain
......@@ -57,7 +57,7 @@ export const formatChildItem = item => ({ ...item, pathIdSeparator: PathIdSepara
*
* @param {Array} children
*/
export const extractChildEpics = children =>
export const extractChildEpics = (children) =>
children.edges.map(({ node, epicNode = node }) =>
formatChildItem({
...epicNode,
......@@ -72,8 +72,8 @@ export const extractChildEpics = children =>
*
* @param {Array} assignees
*/
export const extractIssueAssignees = assignees =>
assignees.edges.map(assigneeNode => ({
export const extractIssueAssignees = (assignees) =>
assignees.edges.map((assigneeNode) => ({
...assigneeNode.node,
}));
......@@ -83,7 +83,7 @@ export const extractIssueAssignees = assignees =>
*
* @param {Array} issues
*/
export const extractChildIssues = issues =>
export const extractChildIssues = (issues) =>
issues.edges.map(({ node, issueNode = node }) =>
formatChildItem({
...issueNode,
......
......@@ -11,7 +11,7 @@ export default () => {
if (!toggleBtn) return;
toggleBtn.addEventListener('click', e => {
toggleBtn.addEventListener('click', (e) => {
e.preventDefault();
toggleBtn.setAttribute('disabled', 'disabled');
......
import { normalizeData as normalizeDataFOSS } from '~/repository/utils/commit';
export function normalizeData(data, path) {
return normalizeDataFOSS(data, path, d => ({
return normalizeDataFOSS(data, path, (d) => ({
lockLabel: d.lock_label || false,
}));
}
......@@ -23,7 +23,7 @@ export default {
requirement: {
type: Object,
required: true,
validator: value =>
validator: (value) =>
[
'iid',
'state',
......@@ -33,7 +33,7 @@ export default {
'updatedAt',
'author',
'testReports',
].every(prop => value[prop]),
].every((prop) => value[prop]),
},
stateChangeRequestActive: {
type: Boolean,
......
......@@ -74,8 +74,8 @@ export default {
initialRequirementsCount: {
type: Object,
required: true,
validator: value =>
['OPENED', 'ARCHIVED', 'ALL'].every(prop => typeof value[prop] === 'number'),
validator: (value) =>
['OPENED', 'ARCHIVED', 'ALL'].every((prop) => typeof value[prop] === 'number'),
},
page: {
type: Number,
......@@ -150,7 +150,7 @@ export default {
update(data) {
const requirementsRoot = data.project?.requirements;
const list = requirementsRoot?.nodes.map(node => {
const list = requirementsRoot?.nodes.map((node) => {
return {
...node,
satisfied: node.lastTestReportState === TestReportStatus.Passed,
......@@ -278,7 +278,7 @@ export default {
];
},
getFilteredSearchValue() {
const value = this.authorUsernames.map(author => ({
const value = this.authorUsernames.map((author) => ({
type: 'author_username',
value: { data: author },
}));
......@@ -378,7 +378,7 @@ export default {
updateRequirementInput,
},
})
.catch(e => {
.catch((e) => {
createFlash({
message: errorFlashMessage,
parent: flashMessageContainer,
......@@ -399,7 +399,7 @@ export default {
.then(({ data }) => {
createFlash({ message: data?.message, type: FLASH_TYPES.NOTICE });
})
.catch(err => {
.catch((err) => {
const { data: { message = __('Something went wrong') } = {} } = err.response;
createFlash({ message });
});
......@@ -445,7 +445,7 @@ export default {
},
},
})
.then(res => {
.then((res) => {
const createReqMutation = res?.data?.createRequirement || {};
if (createReqMutation.errors?.length === 0) {
......@@ -461,7 +461,7 @@ export default {
throw new Error(`Error creating a requirement ${res.message}`);
}
})
.catch(e => {
.catch((e) => {
createFlash({
message: __('Something went wrong while creating a requirement.'),
parent: this.$el,
......@@ -485,7 +485,7 @@ export default {
errorFlashMessage: __('Something went wrong while updating a requirement.'),
flashMessageContainer: this.$el,
})
.then(res => {
.then((res) => {
const updateReqMutation = res?.data?.updateRequirement || {};
if (updateReqMutation.errors?.length === 0) {
......@@ -512,7 +512,7 @@ export default {
? __('Something went wrong while reopening a requirement.')
: __('Something went wrong while archiving a requirement.'),
})
.then(res => {
.then((res) => {
const updateReqMutation = res?.data?.updateRequirement || {};
if (updateReqMutation.errors?.length === 0) {
......@@ -546,7 +546,7 @@ export default {
const authors = [];
let textSearch = '';
filters.forEach(filter => {
filters.forEach((filter) => {
if (typeof filter === 'string') {
textSearch = filter;
} else if (filter.value.data !== DEFAULT_LABEL_ANY.value) {
......
......@@ -24,7 +24,7 @@ export default () => {
{},
{
cacheConfig: {
dataIdFromObject: object =>
dataIdFromObject: (object) =>
// eslint-disable-next-line no-underscore-dangle, @gitlab/require-i18n-strings
object.__typename === 'Requirement' ? object.iid : defaultDataIdFromObject(object),
},
......
......@@ -68,7 +68,7 @@ export default {
},
epicsWithAssociatedParents() {
return this.epics.filter(
epic => !epic.hasParent || (epic.hasParent && this.epicIds.indexOf(epic.parent.id) < 0),
(epic) => !epic.hasParent || (epic.hasParent && this.epicIds.indexOf(epic.parent.id) < 0),
);
},
displayedEpics() {
......
......@@ -125,7 +125,7 @@ export default {
// b) Milestones Public API supports including child projects' milestones.
if (search) {
return {
data: data.filter(m => m.title.toLowerCase().includes(search.toLowerCase())),
data: data.filter((m) => m.title.toLowerCase().includes(search.toLowerCase())),
};
}
return { data };
......@@ -154,7 +154,7 @@ export default {
if (labelName?.length) {
filteredSearchValue.push(
...labelName.map(label => ({
...labelName.map((label) => ({
type: 'label_name',
value: { data: label },
})),
......@@ -217,7 +217,7 @@ export default {
const filterParams = filters.length ? {} : null;
const labels = [];
filters.forEach(filter => {
filters.forEach((filter) => {
if (typeof filter === 'object') {
switch (filter.type) {
case 'author_username':
......
......@@ -34,7 +34,7 @@ export default () => {
// This event handler is to be removed in 11.1 once
// we allow user to save selected preset in db
if (presetButtonsContainer) {
presetButtonsContainer.addEventListener('click', e => {
presetButtonsContainer.addEventListener('click', (e) => {
const presetType = e.target.querySelector('input[name="presetType"]').value;
visitUrl(mergeUrlParams({ layout: presetType }, window.location.href));
......
......@@ -155,7 +155,7 @@ export const fetchEpics = ({ state, commit, dispatch }) => {
commit(types.REQUEST_EPICS);
fetchGroupEpics(state)
.then(rawEpics => {
.then((rawEpics) => {
dispatch('receiveEpicsSuccess', { rawEpics });
})
.catch(() => dispatch('receiveEpicsFailure'));
......@@ -165,7 +165,7 @@ export const fetchEpicsForTimeframe = ({ state, commit, dispatch }, { timeframe
commit(types.REQUEST_EPICS_FOR_TIMEFRAME);
return fetchGroupEpics(state, timeframe)
.then(rawEpics => {
.then((rawEpics) => {
dispatch('receiveEpicsSuccess', {
rawEpics,
newEpic: true,
......@@ -210,7 +210,7 @@ export const toggleEpic = ({ state, dispatch }, { parentItem }) => {
if (!state.childrenEpics[parentItemId]) {
dispatch('requestChildrenEpics', { parentItemId });
fetchChildrenEpics(state, { parentItem })
.then(rawChildren => {
.then((rawChildren) => {
dispatch('receiveChildrenSuccess', {
parentItemId,
rawChildren,
......@@ -234,10 +234,10 @@ export const toggleEpic = ({ state, dispatch }, { parentItem }) => {
* so that the epic bars get longer to appear infinitely scrolling.
*/
export const refreshEpicDates = ({ commit, state, getters }) => {
const epics = state.epics.map(epic => {
const epics = state.epics.map((epic) => {
// Update child epic dates too
if (epic.children?.edges?.length > 0) {
epic.children.edges.map(childEpic =>
epic.children.edges.map((childEpic) =>
roadmapItemUtils.processRoadmapItemDates(
childEpic,
getters.timeframeStartDate,
......@@ -291,7 +291,7 @@ export const fetchMilestones = ({ state, dispatch }) => {
dispatch('requestMilestones');
return fetchGroupMilestones(state)
.then(rawMilestones => {
.then((rawMilestones) => {
dispatch('receiveMilestonesSuccess', { rawMilestones });
})
.catch(() => dispatch('receiveMilestonesFailure'));
......@@ -333,7 +333,7 @@ export const receiveMilestonesFailure = ({ commit }) => {
};
export const refreshMilestoneDates = ({ commit, state, getters }) => {
const milestones = state.milestones.map(milestone =>
const milestones = state.milestones.map((milestone) =>
roadmapItemUtils.processRoadmapItemDates(
milestone,
getters.timeframeStartDate,
......
......@@ -7,14 +7,14 @@ import { PRESET_TYPES, DAYS_IN_WEEK } from '../constants';
*
* @param {Object} state
*/
export const lastTimeframeIndex = state => state.timeframe.length - 1;
export const lastTimeframeIndex = (state) => state.timeframe.length - 1;
/**
* Returns first item of the timeframe array from state
*
* @param {Object} state
*/
export const timeframeStartDate = state => {
export const timeframeStartDate = (state) => {
if (state.presetType === PRESET_TYPES.QUARTERS) {
return state.timeframe[0].range[0];
}
......
......@@ -2,7 +2,7 @@ import Vue from 'vue';
import * as types from './mutation_types';
const resetEpics = state => {
const resetEpics = (state) => {
state.epics = [];
state.childrenFlags = {};
state.epicIds = [];
......@@ -44,7 +44,7 @@ export default {
state.epicsFetchInProgress = false;
state.epicsFetchForTimeframeInProgress = false;
state.epicsFetchFailure = true;
Object.keys(state.childrenEpics).forEach(id => {
Object.keys(state.childrenEpics).forEach((id) => {
Vue.set(state.childrenFlags, id, {
itemChildrenFetchInProgress: false,
});
......@@ -60,7 +60,7 @@ export default {
},
[types.INIT_EPIC_CHILDREN_FLAGS](state, { epics }) {
epics.forEach(item => {
epics.forEach((item) => {
Vue.set(state.childrenFlags, item.id, {
itemExpanded: false,
itemChildrenFetchInProgress: false,
......
......@@ -22,8 +22,8 @@ export const flattenGroupProperty = ({ node: epicNode }) => ({
*
* @param {Object} edges
*/
export const extractGroupEpics = edges => edges.map(flattenGroupProperty);
export const extractGroupEpics = (edges) => edges.map(flattenGroupProperty);
export const addIsChildEpicTrueProperty = obj => ({ ...obj, isChildEpic: true });
export const addIsChildEpicTrueProperty = (obj) => ({ ...obj, isChildEpic: true });
export const generateKey = epic => `${epic.isChildEpic ? 'child-epic-' : 'epic-'}${epic.id}`;
export const generateKey = (epic) => `${epic.isChildEpic ? 'child-epic-' : 'epic-'}${epic.id}`;
......@@ -105,7 +105,7 @@ export const formatRoadmapItemDetails = (rawRoadmapItem, timeframeStartDate, tim
*
* @param {Object} group
*/
export const extractGroupMilestones = edges =>
export const extractGroupMilestones = (edges) =>
edges.map(({ node, milestoneNode = node }) => ({
...milestoneNode,
}));
......@@ -5,19 +5,19 @@ export default class DirtyFormChecker {
this.isDirty = false;
this.editableInputs = Array.from(this.form.querySelectorAll('input[name]')).filter(
el =>
(el) =>
(el.type !== 'submit' && el.type !== 'hidden') ||
el.classList.contains('js-project-feature-toggle-input'),
);
this.startingStates = {};
this.editableInputs.forEach(input => {
this.editableInputs.forEach((input) => {
this.startingStates[input.name] = input.value;
});
}
init() {
this.form.addEventListener('input', event => {
this.form.addEventListener('input', (event) => {
if (event.target.matches('input[name]')) {
this.recalculate();
}
......@@ -26,7 +26,7 @@ export default class DirtyFormChecker {
recalculate() {
const wasDirty = this.isDirty;
this.isDirty = this.editableInputs.some(input => {
this.isDirty = this.editableInputs.some((input) => {
const currentValue = input.value;
const startValue = this.startingStates[input.name];
......
......@@ -45,8 +45,8 @@ export default class SamlSettingsForm {
dependsOn: 'enforced-group-managed-accounts',
},
]
.filter(s => s.el)
.map(setting => ({
.filter((s) => s.el)
.map((setting) => ({
...setting,
toggle: getToggle(setting.el),
helperText: getHelperText(setting.el),
......@@ -60,7 +60,7 @@ export default class SamlSettingsForm {
}
findSetting(name) {
return this.settings.find(s => s.name === name);
return this.settings.find((s) => s.name === name);
}
getValueWithDeps(name) {
......@@ -92,7 +92,7 @@ export default class SamlSettingsForm {
}
updateSAMLSettings() {
this.settings = this.settings.map(setting => ({
this.settings = this.settings.map((setting) => ({
...setting,
value: parseBoolean(setting.el.querySelector('input').value),
}));
......@@ -112,8 +112,8 @@ export default class SamlSettingsForm {
updateToggles() {
this.settings
.filter(setting => setting.dependsOn)
.forEach(setting => {
.filter((setting) => setting.dependsOn)
.forEach((setting) => {
const { helperText, callout, toggle } = setting;
const isRelatedToggleOn = this.getValueWithDeps(setting.dependsOn);
if (helperText) {
......
......@@ -68,10 +68,10 @@ export default class SCIMTokenToggleArea {
this.toggleLoading();
return this.fetchNewToken()
.then(response => {
.then((response) => {
this.setTokenAndToggleSCIMForm(response.data);
})
.catch(error => {
.catch((error) => {
createFlash(error);
this.toggleLoading();
this.toggleFormVisibility(container);
......
......@@ -9,7 +9,7 @@ export default () => {
setHighlightClass();
// Supports Advanced (backed by Elasticsearch) Search highlighting
blobs.forEach(blob => {
blobs.forEach((blob) => {
const lines = blob.querySelectorAll('.line');
const dataHighlightLine = blob.querySelector('[data-highlight-line]');
if (dataHighlightLine) {
......
......@@ -49,7 +49,7 @@ export default {
// In this first iteration, the auto-fix settings is toggled for all features at once via a
// single checkbox. The line below is a temporary workaround to initialize the setting's state
// until we have distinct checkboxes for each auto-fixable feature.
const autoFixEnabled = Object.values(this.autoFixEnabled).some(enabled => enabled);
const autoFixEnabled = Object.values(this.autoFixEnabled).some((enabled) => enabled);
return {
autoFixEnabledLocal: autoFixEnabled,
isChecked: autoFixEnabled,
......@@ -75,7 +75,7 @@ export default {
this.autoFixEnabledLocal = enabled;
this.isChecked = enabled;
})
.catch(e => {
.catch((e) => {
Sentry.captureException(e);
createFlash(
__('Something went wrong while toggling auto-fix settings, please try again later.'),
......
......@@ -55,7 +55,7 @@ export default {
redirectTo(filePath);
})
.catch(error => {
.catch((error) => {
this.isCreatingMergeRequest = false;
createFlash(
s__('SecurityConfiguration|An error occurred while creating the merge request.'),
......
......@@ -141,7 +141,7 @@ export default {
variables: { after: pageInfo.endCursor },
updateQuery: cacheUtils.appendToPreviousResult(profileType),
})
.catch(error => {
.catch((error) => {
this.handleError({
profileType,
exception: error,
......@@ -199,7 +199,7 @@ export default {
},
optimisticResponse: deletion.optimisticResponse,
})
.catch(error => {
.catch((error) => {
this.handleError({
profileType,
exception: error,
......
......@@ -88,7 +88,7 @@ export default {
},
tableFields() {
const defaultClasses = ['gl-word-break-all'];
const dataFields = this.fields.map(key => ({ key, class: defaultClasses }));
const dataFields = this.fields.map((key) => ({ key, class: defaultClasses }));
const staticFields = [{ key: 'actions' }];
return [...dataFields, ...staticFields];
......
......@@ -9,7 +9,7 @@ import dastSiteProfilesQuery from 'ee/security_configuration/dast_profiles/graph
* @param {*} profileType
* @returns {function(*, {fetchMoreResult: *}): *}
*/
export const appendToPreviousResult = profileType => (previousResult, { fetchMoreResult }) => {
export const appendToPreviousResult = (profileType) => (previousResult, { fetchMoreResult }) => {
const newResult = { ...fetchMoreResult };
const previousEdges = previousResult.project[profileType].edges;
const newEdges = newResult.project[profileType].edges;
......@@ -30,7 +30,7 @@ export const appendToPreviousResult = profileType => (previousResult, { fetchMor
export const removeProfile = ({ profileId, profileType, store, queryBody }) => {
const sourceData = store.readQuery(queryBody);
const data = produce(sourceData, draftState => {
const data = produce(sourceData, (draftState) => {
// eslint-disable-next-line no-param-reassign
draftState.project[profileType].edges = draftState.project[profileType].edges.filter(
({ node }) => {
......
......@@ -201,7 +201,7 @@ export default {
}
},
)
.catch(e => {
.catch((e) => {
Sentry.captureException(e);
this.showErrors();
this.loading = false;
......
......@@ -157,7 +157,7 @@ export default {
}
},
)
.catch(exception => {
.catch((exception) => {
this.showErrors({ message: errorMessage });
this.captureException(exception);
this.isLoading = false;
......
......@@ -12,11 +12,11 @@ export const fetchSecurityConfiguration = ({ commit, state }) => {
method: 'GET',
url: state.securityConfigurationPath,
})
.then(response => {
.then((response) => {
const { data } = response;
commit(types.RECEIVE_SECURITY_CONFIGURATION_SUCCESS, data);
})
.catch(error => {
.catch((error) => {
Sentry.captureException(error);
commit(types.RECEIVE_SECURITY_CONFIGURATION_ERROR);
});
......
......@@ -87,7 +87,7 @@ export default {
redirectTo(successPath);
})
.catch(error => {
.catch((error) => {
this.isSubmitting = false;
this.hasSubmissionError = true;
Sentry.captureException(error);
......@@ -101,7 +101,7 @@ export default {
};
},
onAnalyzerChange(name, updatedAnalyzer) {
const index = this.analyzersConfiguration.findIndex(analyzer => analyzer.name === name);
const index = this.analyzersConfiguration.findIndex((analyzer) => analyzer.name === name);
if (index === -1) {
return;
}
......
......@@ -16,7 +16,7 @@ export default {
entities: {
type: Array,
required: true,
validator: value => value.every(isValidConfigurationEntity),
validator: (value) => value.every(isValidConfigurationEntity),
},
disabled: {
type: Boolean,
......
......@@ -35,7 +35,7 @@ export default {
type: String,
required: false,
default: LARGE,
validator: size => Object.keys(SCHEMA_TO_PROP_SIZE_MAP).includes(size),
validator: (size) => Object.keys(SCHEMA_TO_PROP_SIZE_MAP).includes(size),
},
label: {
type: String,
......
const isString = value => typeof value === 'string';
const isBoolean = value => typeof value === 'boolean';
const isString = (value) => typeof value === 'string';
const isBoolean = (value) => typeof value === 'boolean';
export const isValidConfigurationEntity = object => {
export const isValidConfigurationEntity = (object) => {
if (object == null) {
return false;
}
......@@ -18,7 +18,7 @@ export const isValidConfigurationEntity = object => {
);
};
export const isValidAnalyzerEntity = object => {
export const isValidAnalyzerEntity = (object) => {
if (object == null) {
return false;
}
......
......@@ -34,14 +34,14 @@ export default {
},
queryObject() {
// This is the object used to update the querystring.
return { [this.filter.id]: this.selectedOptionsOrAll.map(x => x.id) };
return { [this.filter.id]: this.selectedOptionsOrAll.map((x) => x.id) };
},
filterObject() {
// This is the object used by the GraphQL query.
return { [this.filter.id]: this.selectedOptions.map(x => x.id) };
return { [this.filter.id]: this.selectedOptions.map((x) => x.id) };
},
filteredOptions() {
return this.filter.options.filter(option =>
return this.filter.options.filter((option) =>
option.name.toLowerCase().includes(this.searchTerm.toLowerCase()),
);
},
......@@ -50,7 +50,7 @@ export default {
return Array.isArray(ids) ? ids : [ids];
},
routeQueryOptions() {
const options = this.filter.options.filter(x => this.routeQueryIds.includes(x.id));
const options = this.filter.options.filter((x) => this.routeQueryIds.includes(x.id));
const hasAllId = this.routeQueryIds.includes(this.filter.allOption.id);
if (options.length && !hasAllId) {
......
......@@ -73,7 +73,7 @@ export default {
this.$apollo.queries.vulnerabilities.fetchMore({
variables: { after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => {
const results = produce(fetchMoreResult, draftData => {
const results = produce(fetchMoreResult, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.group.vulnerabilities.nodes = [
...previousResult.group.vulnerabilities.nodes,
......
......@@ -69,7 +69,7 @@ export default {
this.$apollo.queries.vulnerabilities.fetchMore({
variables: { after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => {
const results = produce(fetchMoreResult, draftData => {
const results = produce(fetchMoreResult, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.vulnerabilities.nodes = [
...previousResult.vulnerabilities.nodes,
......
......@@ -60,7 +60,7 @@ export default {
const isProjectSelected = this.selectedProjects.some(({ id }) => id === project.id);
if (isProjectSelected) {
this.selectedProjects = this.selectedProjects.filter(p => p.id !== project.id);
this.selectedProjects = this.selectedProjects.filter((p) => p.id !== project.id);
} else {
this.selectedProjects.push(project);
}
......@@ -68,7 +68,7 @@ export default {
addProjects() {
this.$emit('handleProjectManipulation', true);
const addProjectsPromises = this.selectedProjects.map(project => {
const addProjectsPromises = this.selectedProjects.map((project) => {
return this.$apollo
.mutate({
mutation: addProjectToSecurityDashboard,
......@@ -81,7 +81,7 @@ export default {
const sourceData = store.readQuery({ query: projectsQuery });
const newProject = results.addProjectToSecurityDashboard.project;
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.instanceSecurityDashboard.projects.nodes = [
...draftData.instanceSecurityDashboard.projects.nodes,
......@@ -112,8 +112,8 @@ export default {
});
return Promise.all(addProjectsPromises)
.then(response => {
const invalidProjects = response.filter(value => value.error);
.then((response) => {
const invalidProjects = response.filter((value) => value.error);
this.$emit('handleProjectManipulation', false);
if (invalidProjects.length) {
......@@ -156,10 +156,10 @@ export default {
update(store) {
const sourceData = store.readQuery({ query: projectsQuery });
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.instanceSecurityDashboard.projects.nodes = draftData.instanceSecurityDashboard.projects.nodes.filter(
curr => curr.id !== id,
(curr) => curr.id !== id,
);
});
......@@ -188,7 +188,7 @@ export default {
}
return this.searchProjects(this.searchQuery, this.pageInfo)
.then(payload => {
.then((payload) => {
const {
data: {
projects: { nodes, pageInfo },
......
......@@ -53,7 +53,7 @@ export default {
SEVERITY_LEVELS.high,
SEVERITY_LEVELS.medium,
SEVERITY_LEVELS.low,
].map(l => l.toLowerCase()),
].map((l) => l.toLowerCase()),
apollo: {
vulnerabilitiesHistory: {
query() {
......@@ -87,7 +87,7 @@ export default {
charts() {
const { severityLevels } = this.$options;
return severityLevels.map(severityLevel => {
return severityLevels.map((severityLevel) => {
const history = Object.entries(this.vulnerabilitiesHistory[severityLevel] || {});
const chartData = history.length ? history : this.emptyDataSet;
const [pastCount, currentCount] = firstAndLastY(chartData);
......@@ -135,7 +135,7 @@ export default {
const vulnerabilitiesData = vulnerabilitiesCountByDay.nodes.reduce(
(acc, v) => {
const { date, ...severities } = v;
Object.keys(severities).forEach(severity => {
Object.keys(severities).forEach((severity) => {
acc[severity] = acc[severity] || {};
acc[severity][date] = v[severity];
}, {});
......@@ -150,7 +150,7 @@ export default {
acc[severity] = {};
Object.keys(vulnerabilitiesData[severity])
.sort()
.forEach(day => {
.forEach((day) => {
acc[severity][day] = vulnerabilitiesData[severity][day];
}, {});
......
......@@ -74,7 +74,7 @@ export default {
},
computed: {
severityGroups() {
return SEVERITY_GROUPS.map(group => ({
return SEVERITY_GROUPS.map((group) => ({
...group,
projects: this.findProjectsForGroup(group),
}));
......@@ -86,7 +86,7 @@ export default {
return [];
}
return this.vulnerabilityGrades[group.type].map(project => ({
return this.vulnerabilityGrades[group.type].map((project) => ({
...project,
mostSevereVulnerability: this.findMostSevereVulnerabilityForGroup(project, group),
}));
......@@ -94,7 +94,7 @@ export default {
findMostSevereVulnerabilityForGroup(project, group) {
const mostSevereVulnerability = {};
SEVERITY_LEVELS_ORDERED_BY_SEVERITY.some(level => {
SEVERITY_LEVELS_ORDERED_BY_SEVERITY.some((level) => {
if (!group.severityLevels.includes(level)) {
return false;
}
......
......@@ -27,7 +27,7 @@ export default {
errorCode: {
type: Number,
required: true,
validator: value => Object.values(ERROR_CODES).includes(value),
validator: (value) => Object.values(ERROR_CODES).includes(value),
},
illustrations: {
type: Object,
......
......@@ -90,11 +90,11 @@ export default {
},
}));
this.trendsByDay.forEach(trend => {
this.trendsByDay.forEach((trend) => {
const { date, ...severities } = trend;
SEVERITIES.forEach(({ key }) => {
series.find(s => s.key === key).data.push([date, severities[key]]);
series.find((s) => s.key === key).data.push([date, severities[key]]);
});
});
......
......@@ -51,7 +51,7 @@ export default {
let fulfilledCount = 0;
let rejectedCount = 0;
const promises = this.selectedVulnerabilities.map(vulnerability =>
const promises = this.selectedVulnerabilities.map((vulnerability) =>
this.$apollo
.mutate({
mutation: vulnerabilityDismiss,
......
......@@ -19,7 +19,7 @@ export default {
},
computed: {
buttonContent() {
return days => n__('1 Day', '%d Days', days);
return (days) => n__('1 Day', '%d Days', days);
},
},
methods: {
......
......@@ -12,7 +12,7 @@ export default {
scope: {
type: String,
required: true,
validator: value => Object.values(vulnerabilitiesSeverityCountScopes).includes(value),
validator: (value) => Object.values(vulnerabilitiesSeverityCountScopes).includes(value),
},
fullPath: {
type: String,
......
......@@ -31,7 +31,7 @@ export default {
},
computed: {
counts() {
return SEVERITIES.map(severity => ({
return SEVERITIES.map((severity) => ({
severity,
count: this.vulnerabilitiesCount[severity] || 0,
}));
......
......@@ -97,7 +97,7 @@ export default {
// through the bulk update feature, but no longer matches the filters. For more details:
// https://gitlab.com/gitlab-org/gitlab/-/merge_requests/43468#note_420050017
filteredVulnerabilities() {
return this.vulnerabilities.filter(x =>
return this.vulnerabilities.filter((x) =>
this.filters.state?.length ? this.filters.state.includes(x.state) : true,
);
},
......@@ -106,7 +106,7 @@ export default {
},
hasAnyScannersOtherThanGitLab() {
return this.filteredVulnerabilities.some(
v => v.scanner?.vendor !== 'GitLab' && v.scanner?.vendor !== '',
(v) => v.scanner?.vendor !== 'GitLab' && v.scanner?.vendor !== '',
);
},
notEnabledSecurityScanners() {
......@@ -192,7 +192,7 @@ export default {
}
// Apply gl-bg-white! to every header.
baseFields.forEach(field => {
baseFields.forEach((field) => {
field.thClass = [field.thClass, 'gl-bg-white!']; // eslint-disable-line no-param-reassign
});
......@@ -204,9 +204,9 @@ export default {
this.selectedVulnerabilities = {};
},
filteredVulnerabilities() {
const ids = new Set(this.filteredVulnerabilities.map(v => v.id));
const ids = new Set(this.filteredVulnerabilities.map((v) => v.id));
Object.keys(this.selectedVulnerabilities).forEach(vulnerabilityId => {
Object.keys(this.selectedVulnerabilities).forEach((vulnerabilityId) => {
if (!ids.has(vulnerabilityId)) {
this.$delete(this.selectedVulnerabilities, vulnerabilityId);
}
......
......@@ -5,14 +5,14 @@ import { VULNERABILITY_STATES } from 'ee/vulnerabilities/constants';
import { convertObjectPropsToSnakeCase } from '~/lib/utils/common_utils';
import { s__, __ } from '~/locale';
const parseOptions = obj =>
const parseOptions = (obj) =>
Object.entries(obj).map(([id, name]) => ({ id: id.toUpperCase(), name }));
export const mapProjects = projects =>
projects.map(p => ({ id: p.id.split('/').pop(), name: p.name }));
export const mapProjects = (projects) =>
projects.map((p) => ({ id: p.id.split('/').pop(), name: p.name }));
const stateOptions = parseOptions(VULNERABILITY_STATES);
const defaultStateOptions = stateOptions.filter(x => ['DETECTED', 'CONFIRMED'].includes(x.id));
const defaultStateOptions = stateOptions.filter((x) => ['DETECTED', 'CONFIRMED'].includes(x.id));
export const stateFilter = {
name: s__('SecurityReports|Status'),
......@@ -38,7 +38,7 @@ export const scannerFilter = {
defaultOptions: [],
};
export const getProjectFilter = projects => {
export const getProjectFilter = (projects) => {
return {
name: s__('SecurityReports|Project'),
id: 'projectId',
......@@ -92,7 +92,7 @@ export const getFormattedSummary = (rawSummary = {}) => {
return name ? [name, scanSummary] : null;
});
// Filter out keys that could not be matched with any translation and are thus considered invalid
return formattedEntries.filter(entry => entry !== null);
return formattedEntries.filter((entry) => entry !== null);
};
/**
......@@ -103,7 +103,7 @@ export const getFormattedSummary = (rawSummary = {}) => {
* @param {Object} pageInfo
* @returns {Object}
*/
export const preparePageInfo = pageInfo => {
export const preparePageInfo = (pageInfo) => {
return { ...pageInfo, hasNextPage: Boolean(pageInfo?.endCursor) };
};
......
......@@ -2,7 +2,7 @@ import Vue from 'vue';
import apolloProvider from './graphql/provider';
import InstanceSecurityDashboardSettings from './components/first_class_instance_security_dashboard_settings.vue';
export default el => {
export default (el) => {
if (!el) {
return null;
}
......
......@@ -7,8 +7,8 @@ import { convertObjectPropsToSnakeCase } from '~/lib/utils/common_utils';
export const setFilter = ({ commit }, filter) => {
// Convert the filter key to snake case and the selected option IDs to lower case. The API
// endpoint needs them to be in this format.
const convertedFilter = mapValues(convertObjectPropsToSnakeCase(filter), array =>
array.map(element => element.toLowerCase()),
const convertedFilter = mapValues(convertObjectPropsToSnakeCase(filter), (array) =>
array.map((element) => element.toLowerCase()),
);
commit(SET_FILTER, convertedFilter);
......
......@@ -29,11 +29,11 @@ export const fetchPipelineJobs = ({ commit, state }) => {
}
return requestPromise
.then(response => {
.then((response) => {
const { data } = response;
commit(types.RECEIVE_PIPELINE_JOBS_SUCCESS, data);
})
.catch(error => {
.catch((error) => {
Sentry.captureException(error);
commit(types.RECEIVE_PIPELINE_JOBS_ERROR);
});
......
import { FUZZING_STAGE } from './constants';
export const hasFuzzingArtifacts = state => {
return state.pipelineJobs.some(job => {
export const hasFuzzingArtifacts = (state) => {
return state.pipelineJobs.some((job) => {
return job.stage === FUZZING_STAGE && job.artifacts.length > 0;
});
};
export const fuzzingJobsWithArtifact = state => {
return state.pipelineJobs.filter(job => {
export const fuzzingJobsWithArtifact = (state) => {
return state.pipelineJobs.filter((job) => {
return job.stage === FUZZING_STAGE && job.artifacts.length > 0;
});
};
......@@ -37,9 +37,9 @@ export const addProjects = ({ state, dispatch }) => {
return axios
.post(state.projectEndpoints.add, {
project_ids: state.selectedProjects.map(p => p.id),
project_ids: state.selectedProjects.map((p) => p.id),
})
.then(response => dispatch('receiveAddProjectsSuccess', response.data))
.then((response) => dispatch('receiveAddProjectsSuccess', response.data))
.catch(() => dispatch('receiveAddProjectsError'))
.finally(() => dispatch('clearSearchResults'));
};
......@@ -55,8 +55,8 @@ export const receiveAddProjectsSuccess = ({ commit, dispatch, state }, data) =>
if (invalid.length) {
const [firstProject, secondProject, ...rest] = state.selectedProjects
.filter(project => invalid.includes(project.id))
.map(project => project.name);
.filter((project) => invalid.includes(project.id))
.map((project) => project.name);
const translationValues = {
firstProject,
secondProject,
......@@ -154,7 +154,7 @@ export const fetchSearchResults = ({ state, dispatch, commit }) => {
}
return searchProjects(searchQuery)
.then(payload => commit(types.RECEIVE_SEARCH_RESULTS_SUCCESS, payload))
.then((payload) => commit(types.RECEIVE_SEARCH_RESULTS_SUCCESS, payload))
.catch(() => dispatch('receiveSearchResultsError'));
};
......
......@@ -9,12 +9,12 @@ export default {
state.searchQuery = query;
},
[types.SELECT_PROJECT](state, project) {
if (!state.selectedProjects.some(p => p.id === project.id)) {
if (!state.selectedProjects.some((p) => p.id === project.id)) {
state.selectedProjects.push(project);
}
},
[types.DESELECT_PROJECT](state, project) {
state.selectedProjects = state.selectedProjects.filter(p => p.id !== project.id);
state.selectedProjects = state.selectedProjects.filter((p) => p.id !== project.id);
},
[types.REQUEST_ADD_PROJECTS](state) {
state.isAddingProjects = true;
......
......@@ -18,7 +18,7 @@ const groupPageInfo = ({ page, nextPage, total, totalPages }) => ({
* @param {{headers}} res
* @returns {*}
*/
const getHeaders = res => res.headers;
const getHeaders = (res) => res.headers;
/**
* Takes an XHR-response object and returns an object containing pagination related
......@@ -36,6 +36,6 @@ const pageInfo = flow(getHeaders, normalizeHeaders, parseIntPagination, groupPag
* @param {Object} res
* @return {Object}
*/
const addPageInfo = res => (res?.headers ? { ...res, ...pageInfo(res) } : res);
const addPageInfo = (res) => (res?.headers ? { ...res, ...pageInfo(res) } : res);
export default addPageInfo;
......@@ -35,7 +35,7 @@ export const fetchProjects = ({ state, dispatch }) => {
dispatch('requestProjects');
getAllProjects(state.projectsEndpoint)
.then(projects => {
.then((projects) => {
dispatch('receiveProjectsSuccess', { projects });
})
.catch(() => {
......
......@@ -14,7 +14,7 @@ export const fetchUnscannedProjects = ({ dispatch }, endpoint) => {
return axios
.get(endpoint)
.then(({ data }) => data.map(convertObjectPropsToCamelCase))
.then(data => {
.then((data) => {
dispatch('receiveUnscannedProjectsSuccess', data);
})
.catch(() => {
......
......@@ -9,7 +9,7 @@ export const untestedProjectsCount = (state, getters) => getters.untestedProject
export const outdatedProjects = ({ projects }) =>
groupByDateRanges({
ranges: UNSCANNED_PROJECTS_DATE_RANGES,
dateFn: x => x.securityTestsLastSuccessfulRun,
dateFn: (x) => x.securityTestsLastSuccessfulRun,
projects,
});
......
......@@ -6,7 +6,7 @@ import { getDayDifference, isValidDate } from '~/lib/utils/datetime_utility';
* @param daysInPast {number}
* @returns {function({fromDay: Number, toDay: Number}): boolean}
*/
const isWithinDateRange = daysInPast => ({ fromDay, toDay }) =>
const isWithinDateRange = (daysInPast) => ({ fromDay, toDay }) =>
daysInPast >= fromDay && daysInPast < toDay;
/**
......@@ -15,7 +15,7 @@ const isWithinDateRange = daysInPast => ({ fromDay, toDay }) =>
* @param ranges {*}[]
* @returns {{projects: []}}[]
*/
const withEmptyProjectsArray = ranges => ranges.map(range => ({ ...range, projects: [] }));
const withEmptyProjectsArray = (ranges) => ranges.map((range) => ({ ...range, projects: [] }));
/**
* Checks if a given group-object has any projects
......@@ -23,7 +23,7 @@ const withEmptyProjectsArray = ranges => ranges.map(range => ({ ...range, projec
* @param group {{ projects: [] }}
* @returns {boolean}
*/
const hasProjects = group => group.projects.length > 0;
const hasProjects = (group) => group.projects.length > 0;
/**
* Takes an array of objects and groups them based on the given ranges
......
......@@ -47,11 +47,11 @@ export const fetchVulnerabilities = ({ state, dispatch }, params = {}) => {
url: state.vulnerabilitiesEndpoint,
params,
})
.then(response => {
.then((response) => {
const { headers, data } = response;
dispatch('receiveVulnerabilitiesSuccess', { headers, data });
})
.catch(error => {
.catch((error) => {
dispatch('receiveVulnerabilitiesError', error?.response?.status);
});
};
......@@ -65,7 +65,7 @@ export const receiveVulnerabilitiesSuccess = ({ commit }, { headers, data }) =>
const pageInfo = parseIntPagination(normalizedHeaders);
// Vulnerabilities on pipelines don't have IDs.
// We need to add dummy IDs here to avoid rendering issues.
const vulnerabilities = data.map(vulnerability => ({
const vulnerabilities = data.map((vulnerability) => ({
...vulnerability,
id: vulnerability.id || _.uniqueId('client_'),
}));
......@@ -147,7 +147,7 @@ export const dismissSelectedVulnerabilities = ({ dispatch, state }, { comment }
dispatch('requestDismissSelectedVulnerabilities');
const promises = dismissableVulnerabilties.map(vulnerability =>
const promises = dismissableVulnerabilties.map((vulnerability) =>
axios.post(vulnerability.create_vulnerability_feedback_dismissal_path, {
vulnerability_feedback: {
category: vulnerability.report_type,
......
import { LOADING_VULNERABILITIES_ERROR_CODES } from './constants';
export const dashboardError = state =>
export const dashboardError = (state) =>
state.errorLoadingVulnerabilities && state.errorLoadingVulnerabilitiesCount;
export const dashboardListError = state =>
export const dashboardListError = (state) =>
state.errorLoadingVulnerabilities && !state.errorLoadingVulnerabilitiesCount;
export const dashboardCountError = state =>
export const dashboardCountError = (state) =>
!state.errorLoadingVulnerabilities && state.errorLoadingVulnerabilitiesCount;
export const loadingVulnerabilitiesFailedWithRecognizedErrorCode = state =>
export const loadingVulnerabilitiesFailedWithRecognizedErrorCode = (state) =>
state.errorLoadingVulnerabilities &&
Object.values(LOADING_VULNERABILITIES_ERROR_CODES).includes(
state.loadingVulnerabilitiesErrorCode,
);
export const selectedVulnerabilitiesCount = state =>
export const selectedVulnerabilitiesCount = (state) =>
Object.keys(state.selectedVulnerabilities).length;
export const isSelectingVulnerabilities = (state, getters) =>
......
......@@ -76,7 +76,7 @@ export default {
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_DISMISS_VULNERABILITY_SUCCESS](state, payload) {
const vulnerability = state.vulnerabilities.find(vuln =>
const vulnerability = state.vulnerabilities.find((vuln) =>
isSameVulnerability(vuln, payload.vulnerability),
);
vulnerability.dismissal_feedback = payload.data;
......@@ -125,7 +125,7 @@ export default {
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_ADD_DISMISSAL_COMMENT_SUCCESS](state, payload) {
const vulnerability = state.vulnerabilities.find(vuln =>
const vulnerability = state.vulnerabilities.find((vuln) =>
isSameVulnerability(vuln, payload.vulnerability),
);
if (vulnerability) {
......@@ -143,7 +143,7 @@ export default {
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_DELETE_DISMISSAL_COMMENT_SUCCESS](state, payload) {
const vulnerability = state.vulnerabilities.find(vuln => vuln.id === payload.id);
const vulnerability = state.vulnerabilities.find((vuln) => vuln.id === payload.id);
if (vulnerability) {
vulnerability.dismissal_feedback = payload.data;
state.isDismissingVulnerability = false;
......@@ -159,7 +159,7 @@ export default {
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_REVERT_DISMISSAL_SUCCESS](state, payload) {
const vulnerability = state.vulnerabilities.find(vuln =>
const vulnerability = state.vulnerabilities.find((vuln) =>
isSameVulnerability(vuln, payload.vulnerability),
);
vulnerability.dismissal_feedback = null;
......
import { isEqual } from 'lodash';
const isVulnerabilityLike = object =>
const isVulnerabilityLike = (object) =>
Boolean(object && object.location && object.identifiers && object.identifiers[0]);
/**
......
......@@ -15,7 +15,7 @@ export const fetchProjects = ({ dispatch }, endpoint) => {
return axios
.get(endpoint)
.then(({ data }) => data.map(convertObjectPropsToCamelCase))
.then(data => {
.then((data) => {
dispatch('receiveProjectsSuccess', data);
})
.catch(() => {
......
......@@ -8,7 +8,7 @@ export const severityGroups = ({ projects }) => {
);
// return an array of severity groups, each containing an array of projects match the groups criteria
return SEVERITY_GROUPS.map(severityGroup => ({
return SEVERITY_GROUPS.map((severityGroup) => ({
...severityGroup,
projects: projectsForSeverityGroup(projectsWithSeverityInformation, severityGroup),
}));
......
......@@ -16,7 +16,7 @@ export const vulnerabilityCount = (project, severityLevel) =>
* @param project
* @returns {function(*=): boolean}
*/
export const hasVulnerabilityWithSeverityLevel = project => severityLevel =>
export const hasVulnerabilityWithSeverityLevel = (project) => (severityLevel) =>
vulnerabilityCount(project, severityLevel) > 0;
/**
......@@ -45,7 +45,7 @@ export const mostSevereVulnerability = (severityLevelsOrderedBySeverity, project
* @param severityLevelsInOrder
* @returns {function(*=): {mostSevereVulnerability: *}}
*/
export const addMostSevereVulnerabilityInformation = severityLevelsInOrder => project => ({
export const addMostSevereVulnerabilityInformation = (severityLevelsInOrder) => (project) => ({
...project,
mostSevereVulnerability: mostSevereVulnerability(severityLevelsInOrder, project),
});
......
......@@ -2,8 +2,8 @@ import { SET_FILTER, SET_HIDE_DISMISSED } from '../modules/filters/mutation_type
const refreshTypes = [`filters/${SET_FILTER}`, `filters/${SET_HIDE_DISMISSED}`];
export default store => {
const refreshVulnerabilities = payload => {
export default (store) => {
const refreshVulnerabilities = (payload) => {
store.dispatch('vulnerabilities/fetchVulnerabilities', payload);
};
......
......@@ -7,8 +7,8 @@ import { s__, sprintf } from '~/locale';
* @param {Array} invalidProjects all the projects that failed to be added
* @returns {String} the invalid projects formated in a user-friendly way
*/
export const createInvalidProjectMessage = invalidProjects => {
const [firstProject, secondProject, ...rest] = invalidProjects.map(project => project.name);
export const createInvalidProjectMessage = (invalidProjects) => {
const [firstProject, secondProject, ...rest] = invalidProjects.map((project) => project.name);
const translationValues = {
firstProject,
secondProject,
......
......@@ -36,7 +36,7 @@ export default {
return {
isDropdownShowing: false,
selectedStatus: this.status,
statusOptions: Object.keys(healthStatusTextMap).map(key => ({
statusOptions: Object.keys(healthStatusTextMap).map((key) => ({
key,
value: healthStatusTextMap[key],
})),
......
......@@ -46,7 +46,7 @@ export default {
return {
isDropdownShowing: false,
selectedStatus: this.status,
statusOptions: Object.keys(healthStatusTextMap).map(key => ({
statusOptions: Object.keys(healthStatusTextMap).map((key) => ({
key,
value: healthStatusTextMap[key],
})),
......
......@@ -12,7 +12,7 @@ import { store } from '~/notes/stores';
Vue.use(VueApollo);
const mountWeightComponent = mediator => {
const mountWeightComponent = (mediator) => {
const el = document.querySelector('.js-sidebar-weight-entry-point');
if (!el) return false;
......@@ -22,7 +22,7 @@ const mountWeightComponent = mediator => {
components: {
SidebarWeight,
},
render: createElement =>
render: (createElement) =>
createElement('sidebar-weight', {
props: {
mediator,
......@@ -31,7 +31,7 @@ const mountWeightComponent = mediator => {
});
};
const mountStatusComponent = mediator => {
const mountStatusComponent = (mediator) => {
const el = document.querySelector('.js-sidebar-status-entry-point');
if (!el) {
......@@ -44,7 +44,7 @@ const mountStatusComponent = mediator => {
components: {
SidebarStatus,
},
render: createElement =>
render: (createElement) =>
createElement('sidebar-status', {
props: {
mediator,
......@@ -66,7 +66,7 @@ const mountEpicsSelect = () => {
components: {
SidebarItemEpicsSelect,
},
render: createElement =>
render: (createElement) =>
createElement('sidebar-item-epics-select', {
props: {
sidebarStore,
......@@ -97,7 +97,7 @@ function mountIterationSelect() {
components: {
IterationSelect,
},
render: createElement =>
render: (createElement) =>
createElement('iteration-select', {
props: {
groupPath,
......
......@@ -23,7 +23,7 @@ export default class SidebarMediator extends CESidebarMediator {
this.store.setWeight(data.weight);
this.store.setLoadingState('weight', false);
})
.catch(err => {
.catch((err) => {
this.store.setLoadingState('weight', false);
throw err;
});
......@@ -39,7 +39,7 @@ export default class SidebarMediator extends CESidebarMediator {
}
this.store.setStatus(data?.updateIssue?.issue?.healthStatus);
})
.catch(error => {
.catch((error) => {
throw error;
})
.finally(() => this.store.setFetchingState('status', false));
......
......@@ -34,7 +34,7 @@ export const updateStatusPageSettings = ({ state, dispatch, commit }) => {
},
})
.then(() => dispatch('receiveStatusPageSettingsUpdateSuccess'))
.catch(error => dispatch('receiveStatusPageSettingsUpdateError', error))
.catch((error) => dispatch('receiveStatusPageSettingsUpdateError', error))
.finally(() => commit(mutationTypes.LOADING, false));
};
......
......@@ -6,7 +6,7 @@ import mutations from './mutations';
Vue.use(Vuex);
export default initialState =>
export default (initialState) =>
new Vuex.Store({
state: createState(initialState),
actions,
......
......@@ -64,7 +64,7 @@ export default {
<gl-search-box-by-type
:placeholder="__('Search by name')"
:debounce="$options.searchDebounceValue"
@input="input => this.$emit('search', input)"
@input="(input) => this.$emit('search', input)"
/>
</div>
</template>
......
......@@ -84,7 +84,7 @@ export default {
size: uploadsSize,
},
]
.filter(data => data.size !== 0)
.filter((data) => data.size !== 0)
.sort((a, b) => b.size - a.size);
},
},
......
......@@ -5,7 +5,7 @@ import { STORAGE_USAGE_THRESHOLDS } from './constants';
export function usageRatioToThresholdLevel(currentUsageRatio) {
let currentLevel = Object.keys(STORAGE_USAGE_THRESHOLDS)[0];
Object.keys(STORAGE_USAGE_THRESHOLDS).forEach(thresholdLevel => {
Object.keys(STORAGE_USAGE_THRESHOLDS).forEach((thresholdLevel) => {
if (currentUsageRatio >= STORAGE_USAGE_THRESHOLDS[thresholdLevel])
currentLevel = thresholdLevel;
});
......@@ -23,7 +23,7 @@ export function usageRatioToThresholdLevel(currentUsageRatio) {
* @param {Number} size size in bytes
* @returns {String}
*/
export const formatUsageSize = size => {
export const formatUsageSize = (size) => {
const formatDecimalBytes = getFormatter(SUPPORTED_FORMATS.kibibytes);
return formatDecimalBytes(bytesToKiB(size), 1);
};
......@@ -86,7 +86,7 @@ export const parseProjects = ({
additionalPurchasedStorageSize - totalRepositorySizeExcess,
);
return projects.nodes.map(project =>
return projects.nodes.map((project) =>
calculateUsedAndRemStorage(project, purchasedStorageRemaining),
);
};
......@@ -103,7 +103,7 @@ export const parseProjects = ({
* @param {Object} data graphql result
* @returns {Object}
*/
export const parseGetStorageResults = data => {
export const parseGetStorageResults = (data) => {
const {
namespace: {
projects,
......
......@@ -49,7 +49,7 @@ export const fetchCountries = ({ dispatch }) =>
.catch(() => dispatch('fetchCountriesError'));
export const fetchCountriesSuccess = ({ commit }, data = []) => {
const countries = data.map(country => ({ text: country[0], value: country[1] }));
const countries = data.map((country) => ({ text: country[0], value: country[1] }));
commit(types.UPDATE_COUNTRY_OPTIONS, countries);
};
......@@ -71,7 +71,7 @@ export const fetchStates = ({ state, dispatch }) => {
};
export const fetchStatesSuccess = ({ commit }, data = {}) => {
const states = Object.keys(data).map(state => ({ text: state, value: data[state] }));
const states = Object.keys(data).map((state) => ({ text: state, value: data[state] }));
commit(types.UPDATE_STATE_OPTIONS, states);
};
......
import { STEPS, NEW_GROUP } from '../constants';
import { s__ } from '~/locale';
export const currentStep = state => state.currentStep;
export const currentStep = (state) => state.currentStep;
export const stepIndex = () => step => STEPS.findIndex(el => el === step);
export const stepIndex = () => (step) => STEPS.findIndex((el) => el === step);
export const currentStepIndex = (state, getters) => getters.stepIndex(state.currentStep);
......@@ -12,8 +12,8 @@ export const selectedPlanText = (state, getters) => getters.selectedPlanDetails.
export const selectedPlanPrice = (state, getters) =>
getters.selectedPlanDetails.pricePerUserPerYear;
export const selectedPlanDetails = state =>
state.availablePlans.find(plan => plan.value === state.selectedPlan);
export const selectedPlanDetails = (state) =>
state.availablePlans.find((plan) => plan.value === state.selectedPlan);
export const confirmOrderParams = (state, getters) => ({
setup_for_company: state.isSetupForCompany,
......@@ -35,7 +35,7 @@ export const confirmOrderParams = (state, getters) => ({
},
});
export const endDate = state =>
export const endDate = (state) =>
new Date(state.startDate).setFullYear(state.startDate.getFullYear() + 1);
export const totalExVat = (state, getters) => state.numberOfUsers * getters.selectedPlanPrice;
......@@ -56,14 +56,14 @@ export const name = (state, getters) => {
return state.fullName;
};
export const usersPresent = state => state.numberOfUsers > 0;
export const usersPresent = (state) => state.numberOfUsers > 0;
export const isGroupSelected = state =>
export const isGroupSelected = (state) =>
state.selectedGroup !== null && state.selectedGroup !== NEW_GROUP;
export const isSelectedGroupPresent = (state, getters) => {
return (
getters.isGroupSelected && state.groupData.some(group => group.value === state.selectedGroup)
getters.isGroupSelected && state.groupData.some((group) => group.value === state.selectedGroup)
);
};
......@@ -71,7 +71,7 @@ export const selectedGroupUsers = (state, getters) => {
if (!getters.isGroupSelected) {
return 1;
} else if (getters.isSelectedGroupPresent) {
return state.groupData.find(group => group.value === state.selectedGroup).numberOfUsers;
return state.groupData.find((group) => group.value === state.selectedGroup).numberOfUsers;
}
return null;
......@@ -79,7 +79,7 @@ export const selectedGroupUsers = (state, getters) => {
export const selectedGroupName = (state, getters) => {
if (!getters.isGroupSelected) return null;
return state.groupData.find(group => group.value === state.selectedGroup).text;
return state.groupData.find((group) => group.value === state.selectedGroup).text;
};
export const selectedGroupId = (state, getters) =>
......
......@@ -2,22 +2,22 @@ import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
import { parseBoolean } from '~/lib/utils/common_utils';
import { STEPS, TAX_RATE } from '../constants';
const parsePlanData = planData =>
JSON.parse(planData).map(plan => ({
const parsePlanData = (planData) =>
JSON.parse(planData).map((plan) => ({
value: plan.id,
text: capitalizeFirstCharacter(plan.code),
pricePerUserPerYear: plan.price_per_year,
}));
const parseGroupData = groupData =>
JSON.parse(groupData).map(group => ({
const parseGroupData = (groupData) =>
JSON.parse(groupData).map((group) => ({
value: group.id,
text: group.name,
numberOfUsers: group.users,
}));
const determineSelectedPlan = (planId, plans) => {
if (planId && plans.find(plan => plan.value === planId)) {
if (planId && plans.find((plan) => plan.value === planId)) {
return planId;
}
return plans[0] && plans[0].value;
......@@ -28,7 +28,7 @@ const determineNumberOfUsers = (groupId, groups) => {
return 1;
}
const chosenGroup = groups.find(group => group.value === groupId);
const chosenGroup = groups.find((group) => group.value === groupId);
if (chosenGroup?.numberOfUsers > 1) {
return chosenGroup.numberOfUsers;
......
......@@ -37,7 +37,7 @@ export default {
projectPath: this.projectFullPath,
title: issuableTitle,
description: issuableDescription,
labelIds: selectedLabels.map(label => label.id),
labelIds: selectedLabels.map((label) => label.id),
},
},
})
......@@ -48,7 +48,7 @@ export default {
}
redirectTo(this.projectTestCasesPath);
})
.catch(error => {
.catch((error) => {
createFlash({
message: s__('TestCases|Something went wrong while creating a test case.'),
captureError: true,
......
......@@ -24,6 +24,6 @@ export function initTestCaseCreate({ mountPointSelector }) {
provide: {
...mountPointEl.dataset,
},
render: createElement => createElement(TestCaseCreateApp),
render: (createElement) => createElement(TestCaseCreateApp),
});
}
......@@ -252,7 +252,7 @@ export default {
if (labelName?.length) {
filteredSearchValue.push(
...labelName.map(label => ({
...labelName.map((label) => ({
type: 'label_name',
value: { data: label },
})),
......@@ -290,7 +290,7 @@ export default {
const labels = [];
const plainText = [];
filters.forEach(filter => {
filters.forEach((filter) => {
switch (filter.type) {
case 'author_username':
filterParams.authorUsername = filter.value.data;
......
......@@ -52,7 +52,7 @@ const initTestCaseList = ({ mountPointSelector }) => {
initialState,
initialSortBy,
},
render: createElement =>
render: (createElement) =>
createElement(TestCaseListApp, {
props: {
initialFilterParams,
......
......@@ -76,7 +76,7 @@ export default {
return todos.length ? todos[0] : null;
},
selectedLabels() {
return this.testCase.labels.nodes.map(label => ({
return this.testCase.labels.nodes.map((label) => ({
...label,
id: getIdFromGraphQLId(label.id),
}));
......@@ -91,7 +91,7 @@ export default {
},
errorMessage: s__('TestCases|Something went wrong while updating the test case.'),
})
.then(updatedTestCase => {
.then((updatedTestCase) => {
this.testCase = updatedTestCase;
})
.finally(() => {
......@@ -110,7 +110,7 @@ export default {
},
errorMessage: s__('TestCases|Something went wrong while updating the test case.'),
})
.then(updatedTestCase => {
.then((updatedTestCase) => {
this.testCase = updatedTestCase;
this.editTestCaseFormVisible = false;
IssuableEventHub.$emit('update.issuable');
......
......@@ -130,9 +130,9 @@ export default {
// either selected or removed aren't leading to same selection
// as current one, as then we don't want to make network call
// since nothing has changed.
const anyLabelUpdated = labels.some(label => {
const anyLabelUpdated = labels.some((label) => {
// Find this label in existing selection.
const existingLabel = this.selectedLabels.find(l => l.id === label.id);
const existingLabel = this.selectedLabels.find((l) => l.id === label.id);
// Check either of the two following conditions;
// 1. A label that's not currently applied is being applied.
......@@ -146,12 +146,12 @@ export default {
return this.updateTestCase({
variables: {
addLabelIds: labels.filter(label => label.set).map(label => label.id),
removeLabelIds: labels.filter(label => !label.set).map(label => label.id),
addLabelIds: labels.filter((label) => label.set).map((label) => label.id),
removeLabelIds: labels.filter((label) => !label.set).map((label) => label.id),
},
errorMessage: s__('TestCases|Something went wrong while updating the test case labels.'),
})
.then(updatedTestCase => {
.then((updatedTestCase) => {
this.$emit('test-case-updated', updatedTestCase);
})
.finally(() => {
......
......@@ -63,7 +63,7 @@ export default {
}
return data.updateIssue?.issue;
})
.catch(error => {
.catch((error) => {
createFlash({
message: errorMessage,
captureError: true,
......@@ -81,7 +81,7 @@ export default {
.then(() => {
this.$apollo.queries.testCase.refetch();
})
.catch(error => {
.catch((error) => {
createFlash({
message: s__('TestCases|Something went wrong while adding test case to Todo.'),
captureError: true,
......@@ -110,7 +110,7 @@ export default {
}
this.$apollo.queries.testCase.refetch();
})
.catch(error => {
.catch((error) => {
createFlash({
message: s__('TestCases|Something went wrong while marking test case todo as done.'),
captureError: true,
......@@ -143,7 +143,7 @@ export default {
}
visitUrl(data.issueMove?.issue.webUrl);
})
.catch(error => {
.catch((error) => {
this.testCaseMoveInProgress = false;
createFlash({
message: s__('TestCases|Something went wrong while moving test case.'),
......
......@@ -29,6 +29,6 @@ export default function initTestCaseShow({ mountPointSelector }) {
projectsFetchPath: sidebarOptions.projectsAutocompleteEndpoint,
canEditTestCase: parseBoolean(el.dataset.canEditTestCase),
},
render: createElement => createElement(TestCaseShowApp),
render: (createElement) => createElement(TestCaseShowApp),
});
}
......@@ -99,7 +99,7 @@ export default {
this.$apollo.queries.alerts.fetchMore({
variables: { nextPageCursor: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => {
const results = produce(fetchMoreResult, draftData => {
const results = produce(fetchMoreResult, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.alertManagementAlerts.nodes = [
...previousResult.project.alertManagementAlerts.nodes,
......
......@@ -58,7 +58,7 @@ export default {
selectedPolicy() {
if (!this.hasSelectedPolicy) return null;
return this.policiesWithDefaults.find(policy => policy.name === this.selectedPolicyName);
return this.policiesWithDefaults.find((policy) => policy.name === this.selectedPolicyName);
},
hasPolicyChanges() {
if (!this.hasSelectedPolicy) return false;
......@@ -69,7 +69,7 @@ export default {
);
},
hasAutoDevopsPolicy() {
return this.policiesWithDefaults.some(policy => policy.isAutodevops);
return this.policiesWithDefaults.some((policy) => policy.isAutodevops);
},
hasCiliumSelectedPolicy() {
return this.hasSelectedPolicy
......
......@@ -27,7 +27,7 @@ function ruleTypeEndpointFunc(items) {
const labels = items
.reduce(
(acc, { matchLabels }) =>
acc.concat(Object.keys(matchLabels).map(key => `${key}:${matchLabels[key]}`)),
acc.concat(Object.keys(matchLabels).map((key) => `${key}:${matchLabels[key]}`)),
[],
)
.join(' ');
......@@ -125,10 +125,10 @@ export default function fromYaml(manifest) {
const rules = []
.concat(
ingress.map(item => parseRule(item, RuleDirectionInbound)),
egress.map(item => parseRule(item, RuleDirectionOutbound)),
ingress.map((item) => parseRule(item, RuleDirectionInbound)),
egress.map((item) => parseRule(item, RuleDirectionOutbound)),
)
.filter(rule => Boolean(rule));
.filter((rule) => Boolean(rule));
return {
name,
......
......@@ -37,7 +37,7 @@ function humanizeNetworkPolicyRulePorts(rule) {
function humanizeNetworkPolicyRuleEndpoint({ matchLabels }) {
const matchSelector = labelSelector(matchLabels);
const labels = Object.keys(matchSelector)
.map(key => `${key}: ${matchSelector[key]}`)
.map((key) => `${key}: ${matchSelector[key]}`)
.join(', ');
return labels.length === 0
? sprintf(s__('NetworkPolicies|%{strongOpen}all%{strongClose} pods'), strongArgs, false)
......@@ -104,7 +104,7 @@ function humanizeEndpointSelector({ endpointMatchMode, endpointLabels }) {
const selector = labelSelector(endpointLabels);
const pods = Object.keys(selector)
.map(key => `${key}: ${selector[key]}`)
.map((key) => `${key}: ${selector[key]}`)
.join(', ');
return sprintf(
s__('NetworkPolicies|pods %{pods}'),
......@@ -124,7 +124,7 @@ export default function humanizeNetworkPolicy(policy) {
const selector = humanizeEndpointSelector(policy);
const humanizedRules = rules.map(rule => {
const humanizedRules = rules.map((rule) => {
const { direction } = rule;
const template =
direction === RuleDirectionInbound
......
......@@ -67,7 +67,7 @@ function ruleFQDNSpec({ direction, fqdn }) {
if (fqdnList.length === 0) return {};
return {
toFQDNs: fqdnList.map(item => ({ matchName: item })),
toFQDNs: fqdnList.map((item) => ({ matchName: item })),
};
}
......
......@@ -12,7 +12,7 @@ function spec({ rules, isEnabled, endpointMatchMode, endpointLabels }) {
const policySpec = {};
policySpec.endpointSelector = Object.keys(matchLabels).length > 0 ? { matchLabels } : {};
rules.forEach(rule => {
rules.forEach((rule) => {
const { direction } = rule;
if (!policySpec[direction]) policySpec[direction] = [];
......
......@@ -36,5 +36,5 @@ export function portSelectors({ portMatchMode, ports }) {
Expects items in format "0.0.0.0/24 1.1.1.1/32"
*/
export function splitItems(items) {
return items.split(/\s/).filter(item => item.length > 0);
return items.split(/\s/).filter((item) => item.length > 0);
}
......@@ -40,7 +40,7 @@ export default {
const { value } = this;
let entitiesList = [];
if (value.includes(entity)) {
entitiesList = value.filter(e => e !== entity);
entitiesList = value.filter((e) => e !== entity);
} else {
entitiesList = [...value, entity];
}
......@@ -61,7 +61,7 @@ export default {
return value.includes(entity);
},
},
entities: Object.keys(EntityTypes).map(type => ({
entities: Object.keys(EntityTypes).map((type) => ({
value: EntityTypes[type],
text: EntityTypes[type],
})),
......
......@@ -67,7 +67,7 @@ export default {
name: TIME,
type: 'time',
axisLabel: {
formatter: value => dateFormat(value, DATE_FORMATS.defaultDate),
formatter: (value) => dateFormat(value, DATE_FORMATS.defaultDate),
},
min: from,
max: to,
......
......@@ -11,11 +11,11 @@ export default () =>
new Vuex.Store({
modules: {
threatMonitoring: threatMonitoring(),
threatMonitoringWaf: threatMonitoringStatistics(payload => {
threatMonitoringWaf: threatMonitoringStatistics((payload) => {
const { totalTraffic, anomalousTraffic, history } = convertObjectPropsToCamelCase(payload);
return { total: totalTraffic, anomalous: anomalousTraffic, history };
}),
threatMonitoringNetworkPolicy: threatMonitoringStatistics(payload => {
threatMonitoringNetworkPolicy: threatMonitoringStatistics((payload) => {
const {
opsRate,
opsTotal: { total, drops },
......
......@@ -59,7 +59,7 @@ export const createPolicy = ({ state, commit }, { environmentId, policy }) => {
FLASH_TYPES.SUCCESS,
);
})
.catch(error =>
.catch((error) =>
commitPolicyError(commit, types.RECEIVE_CREATE_POLICY_ERROR, error?.response?.data),
);
};
......@@ -89,7 +89,7 @@ export const updatePolicy = ({ state, commit }, { environmentId, policy }) => {
FLASH_TYPES.SUCCESS,
);
})
.catch(error =>
.catch((error) =>
commitPolicyError(commit, types.RECEIVE_UPDATE_POLICY_ERROR, error?.response?.data),
);
};
......@@ -113,7 +113,7 @@ export const deletePolicy = ({ state, commit }, { environmentId, policy }) => {
policy,
});
})
.catch(error =>
.catch((error) =>
commitPolicyError(commit, types.RECEIVE_DELETE_POLICY_ERROR, error?.response?.data),
);
};
......@@ -6,7 +6,7 @@ export const policiesWithDefaults = ({ policies }) => {
// filter out enabled predefined policies and only append the ones
// that are not present in a cluster.
const predefined = PREDEFINED_NETWORK_POLICIES.filter(
({ name }) => !policies.some(policy => name === policy.name),
({ name }) => !policies.some((policy) => name === policy.name),
);
return [...policies, ...predefined];
};
......@@ -2,7 +2,7 @@ import * as types from './mutation_types';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
const setPolicies = (state, policies) => {
state.policies = policies.map(policy => convertObjectPropsToCamelCase(policy));
state.policies = policies.map((policy) => convertObjectPropsToCamelCase(policy));
};
export default {
......@@ -43,7 +43,7 @@ export default {
},
[types.RECEIVE_UPDATE_POLICY_SUCCESS](state, { policy, updatedPolicy }) {
const newPolicy = convertObjectPropsToCamelCase(updatedPolicy);
state.policies = state.policies.map(pol => (pol.name === policy.name ? newPolicy : pol));
state.policies = state.policies.map((pol) => (pol.name === policy.name ? newPolicy : pol));
state.isUpdatingPolicy = false;
state.errorUpdatingPolicy = false;
},
......
......@@ -35,7 +35,7 @@ const getAllEnvironments = (url, page = 1) =>
const nextPage = headers && headers['x-next-page'];
return nextPage
? // eslint-disable-next-line promise/no-nesting
getAllEnvironments(url, nextPage).then(environments => [
getAllEnvironments(url, nextPage).then((environments) => [
...data.environments,
...environments,
])
......@@ -50,7 +50,7 @@ export const fetchEnvironments = ({ state, dispatch }) => {
dispatch('requestEnvironments');
return getAllEnvironments(state.environmentsEndpoint)
.then(environments => dispatch('receiveEnvironmentsSuccess', environments))
.then((environments) => dispatch('receiveEnvironmentsSuccess', environments))
.catch(() => dispatch('receiveEnvironmentsError'));
};
......
......@@ -33,7 +33,7 @@ export const fetchStatistics = ({ state, dispatch, rootState }) => {
},
})
.then(({ data }) => dispatch('receiveStatisticsSuccess', data))
.catch(error => {
.catch((error) => {
// A NOT_FOUND response from the endpoint means that there is no data for
// the given parameters. There are various reasons *why* there could be
// no data, but we can't distinguish between them, yet. So, just render
......
......@@ -3,7 +3,7 @@ import * as getters from './getters';
import mutations from './mutations';
import state from './state';
export default transformFunc => ({
export default (transformFunc) => ({
namespaced: true,
actions,
getters,
......
import * as types from './mutation_types';
import createState from './state';
export default transformFunc => ({
export default (transformFunc) => ({
[types.SET_ENDPOINT](state, endpoint) {
state.statisticsEndpoint = endpoint;
},
......
import { pick } from 'lodash';
import { getTimeWindow, defaultTimeRange } from '~/vue_shared/constants';
export const getTimeWindowConfig = timeWindow => {
export const getTimeWindowConfig = (timeWindow) => {
const timeWindowObj = pick(getTimeWindow(timeWindow) || defaultTimeRange, 'duration', 'interval');
return {
durationInMilliseconds: timeWindowObj.duration.seconds * 1000,
......
import ipaddr from 'ipaddr.js';
export default address => {
export default (address) => {
// Reject IP addresses that are only integers to match Ruby IPAddr
// https://github.com/whitequark/ipaddr.js/issues/7#issuecomment-158545695
if (/^\d+$/.exec(address)) {
......
......@@ -39,7 +39,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) : [];
},
approvalsRequired() {
return (!this.isBasic && this.approvals.approvals_required) || 0;
......@@ -76,7 +76,7 @@ export default {
this.isLoadingRules = true;
return this.service.fetchApprovalSettings().then(settings => {
return this.service.fetchApprovalSettings().then((settings) => {
this.mr.setApprovalRules(settings);
this.isLoadingRules = false;
});
......
......@@ -38,20 +38,20 @@ export default {
{
id: uniqueId(),
title: '',
rules: this.approvalRules.filter(rule => rule.rule_type !== RULE_TYPE_CODE_OWNER),
rules: this.approvalRules.filter((rule) => rule.rule_type !== RULE_TYPE_CODE_OWNER),
},
{
id: uniqueId(),
title: __('Code Owners'),
rules: orderBy(
this.approvalRules
.filter(rule => rule.rule_type === RULE_TYPE_CODE_OWNER)
.map(rule => ({ ...rule, nameClass: 'gl-font-monospace gl-word-break-all' })),
[o => o.section === 'codeowners', 'name', 'section'],
.filter((rule) => rule.rule_type === RULE_TYPE_CODE_OWNER)
.map((rule) => ({ ...rule, nameClass: 'gl-font-monospace gl-word-break-all' })),
[(o) => o.section === 'codeowners', 'name', 'section'],
['desc', 'asc', 'asc'],
),
},
].filter(x => x.rules.length);
].filter((x) => x.rules.length);
},
},
methods: {
......
......@@ -35,7 +35,7 @@ export default {
},
unmergedBlockingMergeRequests() {
return Object.keys(this.visibleMergeRequests)
.filter(state => state !== 'merged')
.filter((state) => state !== 'merged')
.reduce(
(unmergedBlockingMRs, state) =>
state === 'closed'
......
......@@ -77,7 +77,7 @@ export default {
/* eslint-enable no-useless-escape */
},
filteredChanges() {
return this.changes.filter(change => change.path.includes(this.changesSearchTerm));
return this.changes.filter((change) => change.path.includes(this.changesSearchTerm));
},
instructionText() {
return {
......
......@@ -31,13 +31,13 @@ function getApprovalRuleNamesLeft(data) {
return [];
}
const rulesLeft = groupBy(data.approval_rules_left, x => x.rule_type);
const rulesLeft = groupBy(data.approval_rules_left, (x) => x.rule_type);
// Filter out empty names (fallback rule has no name) because the empties would look weird.
const regularRules = (rulesLeft[RULE_TYPE_REGULAR] || []).map(x => x.name).filter(x => x);
const regularRules = (rulesLeft[RULE_TYPE_REGULAR] || []).map((x) => x.name).filter((x) => x);
// Report Approvals
const reportApprovalRules = (rulesLeft[RULE_TYPE_REPORT_APPROVER] || []).map(x => x.name);
const reportApprovalRules = (rulesLeft[RULE_TYPE_REPORT_APPROVER] || []).map((x) => x.name);
// If there are code owners that need to approve, only mention that once.
// As the names of code owner rules are patterns that don't mean much out of context.
......@@ -50,7 +50,7 @@ function getApprovalRuleNamesLeft(data) {
* Map the approval rules response for use by the MR widget
*/
export function mapApprovalRulesResponse(rules, settings) {
return rules.map(x => mapApprovalRule(x, settings));
return rules.map((x) => mapApprovalRule(x, settings));
}
/**
......
......@@ -55,7 +55,7 @@ export default {
},
degradedBrowserPerformanceTotalScore() {
return this.mr?.browserPerformanceMetrics?.degraded.find(
metric => metric.name === __('Total Score'),
(metric) => metric.name === __('Total Score'),
);
},
hasBrowserPerformanceDegradation() {
......@@ -92,7 +92,7 @@ export default {
return (
this.mr.canReadVulnerabilities &&
enabledReports &&
this.$options.securityReportTypes.some(reportType => enabledReports[reportType])
this.$options.securityReportTypes.some((reportType) => enabledReports[reportType])
);
},
......@@ -191,7 +191,7 @@ export default {
this.isLoadingBrowserPerformance = true;
Promise.all([this.service.fetchReport(head_path), this.service.fetchReport(base_path)])
.then(values => {
.then((values) => {
this.mr.compareBrowserPerformanceMetrics(values[0], values[1]);
})
.catch(() => {
......@@ -208,7 +208,7 @@ export default {
this.isLoadingLoadPerformance = true;
Promise.all([this.service.fetchReport(head_path), this.service.fetchReport(base_path)])
.then(values => {
.then((values) => {
this.mr.compareLoadPerformanceMetrics(values[0], values[1]);
})
.catch(() => {
......
......@@ -11,15 +11,15 @@ export default class MRWidgetService extends CEWidgetService {
approveMergeRequestWithAuth(approvalPassword) {
return axios
.post(this.apiApprovePath, { approval_password: approvalPassword })
.then(res => res.data);
.then((res) => res.data);
}
fetchApprovalSettings() {
return axios.get(this.apiApprovalSettingsPath).then(res => res.data);
return axios.get(this.apiApprovalSettingsPath).then((res) => res.data);
}
// eslint-disable-next-line class-methods-use-this
fetchReport(endpoint) {
return axios.get(endpoint).then(res => res.data);
return axios.get(endpoint).then((res) => res.data);
}
}
......@@ -112,9 +112,9 @@ export default class MergeRequestStore extends CEMergeRequestStore {
const degraded = [];
const same = [];
Object.keys(headMetricsIndexed).forEach(subject => {
Object.keys(headMetricsIndexed).forEach((subject) => {
const subjectMetrics = headMetricsIndexed[subject];
Object.keys(subjectMetrics).forEach(metric => {
Object.keys(subjectMetrics).forEach((metric) => {
const headMetricData = subjectMetrics[metric];
if (baseMetricsIndexed[subject] && baseMetricsIndexed[subject][metric]) {
......@@ -168,7 +168,7 @@ export default class MergeRequestStore extends CEMergeRequestStore {
const degraded = [];
const same = [];
Object.keys(headMetricsIndexed).forEach(metric => {
Object.keys(headMetricsIndexed).forEach((metric) => {
const headMetricData = headMetricsIndexed[metric];
if (metric in baseMetricsIndexed) {
const baseMetricData = baseMetricsIndexed[metric];
......@@ -204,7 +204,7 @@ export default class MergeRequestStore extends CEMergeRequestStore {
const { metrics } = loadPerformanceData;
const indexedMetrics = {};
Object.keys(loadPerformanceData.metrics).forEach(metric => {
Object.keys(loadPerformanceData.metrics).forEach((metric) => {
switch (metric) {
case 'http_reqs':
indexedMetrics[s__('ciReport|RPS')] = metrics.http_reqs.rate;
......
......@@ -4,7 +4,7 @@ import { GlSkeletonLoader, GlIcon } from '@gitlab/ui';
import accordionEventBus from './accordion_event_bus';
const accordionItemUniqueId = name => uniqueId(`gl-accordion-item-${name}-`);
const accordionItemUniqueId = (name) => uniqueId(`gl-accordion-item-${name}-`);
export default {
components: {
......
......@@ -16,7 +16,7 @@ export const tributeConfig = {
config: {
trigger: '&',
fillAttr: 'iid',
lookup: value => `${value.iid}${value.title}`,
lookup: (value) => `${value.iid}${value.title}`,
menuItemTemplate: ({ original }) =>
`<small>${original.iid}</small> ${escape(original.title)}`,
},
......
......@@ -24,7 +24,7 @@ export const setSelectedEpicIssueId = ({ commit }, selectedEpicIssueId) =>
export const requestEpics = ({ commit }) => commit(types.REQUEST_EPICS);
export const receiveEpicsSuccess = ({ commit }, data) => {
const epics = data.map(rawEpic =>
const epics = data.map((rawEpic) =>
convertObjectPropsToCamelCase(
{ ...rawEpic, url: rawEpic.web_edit_url },
{
......
......@@ -11,9 +11,9 @@ import { DropdownVariant } from '../constants';
*
* @param {object} state
*/
export const groupEpics = state => {
export const groupEpics = (state) => {
if (state.searchQuery) {
return state.epics.filter(epic => {
return state.epics.filter((epic) => {
const { title, reference, url, iid } = epic;
// In case user has just pasted ID
......@@ -37,11 +37,11 @@ export const groupEpics = state => {
* is `sidebar`
* @param {object} state
*/
export const isDropdownVariantSidebar = state => state.variant === DropdownVariant.Sidebar;
export const isDropdownVariantSidebar = (state) => state.variant === DropdownVariant.Sidebar;
/**
* Returns boolean representing whether dropdown variant
* is `standalone`
* @param {object} state
*/
export const isDropdownVariantStandalone = state => state.variant === DropdownVariant.Standalone;
export const isDropdownVariantStandalone = (state) => state.variant === DropdownVariant.Standalone;
......@@ -40,7 +40,7 @@ export default {
return (
this.downstreamPipelines &&
this.downstreamPipelines.some(
pipeline =>
(pipeline) =>
pipeline.details &&
pipeline.details.status &&
pipeline.details.status.group === STATUS_FAILED,
......
......@@ -27,9 +27,9 @@ export const forceProjectsRequest = () => {
export const addProjectsToDashboard = ({ state, dispatch }) =>
axios
.post(state.projectEndpoints.add, {
project_ids: state.selectedProjects.map(p => p.id),
project_ids: state.selectedProjects.map((p) => p.id),
})
.then(response => dispatch('receiveAddProjectsToDashboardSuccess', response.data))
.then((response) => dispatch('receiveAddProjectsToDashboardSuccess', response.data))
.catch(() => dispatch('receiveAddProjectsToDashboardError'));
export const toggleSelectedProject = ({ commit, state }, project) => {
......@@ -49,8 +49,8 @@ export const receiveAddProjectsToDashboardSuccess = ({ dispatch, state }, data)
if (invalid.length) {
const [firstProject, secondProject, ...rest] = state.selectedProjects
.filter(project => invalid.includes(project.id))
.map(project => project.name);
.filter((project) => invalid.includes(project.id))
.map((project) => project.name);
const translationValues = {
firstProject,
secondProject,
......@@ -105,7 +105,7 @@ export const fetchProjects = ({ state, dispatch, commit }, page) => {
fetchProjects: () => axios.get(state.projectEndpoints.list, { params: { page } }),
},
method: 'fetchProjects',
successCallback: response => {
successCallback: (response) => {
const {
data: { projects },
headers,
......@@ -160,7 +160,7 @@ export const fetchSearchResults = ({ state, dispatch }) => {
dispatch('minimumQueryMessage');
} else {
Api.projects(searchQuery, {})
.then(results => dispatch('receiveSearchResultsSuccess', results))
.then((results) => dispatch('receiveSearchResultsSuccess', results))
.catch(() => dispatch('receiveSearchResultsError'));
}
};
......@@ -170,7 +170,7 @@ export const fetchNextPage = ({ state, dispatch }) => {
return;
}
Api.projects(state.searchQuery, { page: state.pageInfo.nextPage })
.then(results => dispatch('receiveNextPageSuccess', results))
.then((results) => dispatch('receiveNextPageSuccess', results))
.catch(() => dispatch('receiveSearchResultsError'));
};
......
......@@ -26,7 +26,7 @@ export default {
if (AccessorUtilities.isLocalStorageAccessSafe()) {
localStorage.setItem(
state.projectEndpoints.list,
state.projects.map(p => p.id),
state.projects.map((p) => p.id),
);
} else {
createFlash(
......@@ -44,12 +44,12 @@ export default {
},
[types.ADD_SELECTED_PROJECT](state, project) {
if (!state.selectedProjects.some(p => p.id === project.id)) {
if (!state.selectedProjects.some((p) => p.id === project.id)) {
state.selectedProjects.push(project);
}
},
[types.REMOVE_SELECTED_PROJECT](state, project) {
state.selectedProjects = state.selectedProjects.filter(p => p.id !== project.id);
state.selectedProjects = state.selectedProjects.filter((p) => p.id !== project.id);
},
[types.REQUEST_PROJECTS](state) {
......@@ -68,7 +68,7 @@ export default {
if (AccessorUtilities.isLocalStorageAccessSafe()) {
localStorage.setItem(
state.projectEndpoints.list,
state.projects.map(p => p.id),
state.projects.map((p) => p.id),
);
}
......
......@@ -30,14 +30,14 @@ export default {
.select2({
allowClear: true,
placeholder: this.placeholder,
createSearchChoice: term => ({ id: term, text: term }),
createSearchChoice: (term) => ({ id: term, text: term }),
createSearchChoicePosition: 'bottom',
data: this.knownLicenses.map(license => ({
data: this.knownLicenses.map((license) => ({
id: license,
text: license,
})),
})
.on('change', e => {
.on('change', (e) => {
this.$emit('input', e.target.value);
});
})
......
......@@ -38,7 +38,7 @@ export default {
license: {
type: Object,
required: true,
validator: license =>
validator: (license) =>
Boolean(license.name) &&
Object.values(LICENSE_APPROVAL_STATUS).includes(license.approvalStatus),
},
......
......@@ -47,7 +47,7 @@ export const deleteLicense = ({ dispatch, state }) => {
.then(() => {
dispatch('receiveDeleteLicense', licenseId);
})
.catch(error => {
.catch((error) => {
dispatch('receiveDeleteLicenseError', error);
dispatch('removePendingLicense', licenseId);
});
......@@ -72,7 +72,7 @@ export const fetchManagedLicenses = ({ dispatch, state }) => {
.then(({ data }) => {
dispatch('receiveManagedLicensesSuccess', data);
})
.catch(error => {
.catch((error) => {
dispatch('receiveManagedLicensesError', error);
});
};
......@@ -95,7 +95,7 @@ export const fetchParsedLicenseReport = ({ dispatch, state }) => {
const existingLicenses = (data.existing_licenses || []).map(convertToOldReportFormat);
dispatch('receiveParsedLicenseReportSuccess', { newLicenses, existingLicenses });
})
.catch(error => {
.catch((error) => {
dispatch('receiveParsedLicenseReportError', error);
});
};
......@@ -139,13 +139,13 @@ export const fetchLicenseCheckApprovalRule = ({ dispatch, state }) => {
return axios
.get(state.approvalsApiPath)
.then(({ data }) => {
const hasLicenseCheckApprovalRule = data.approval_rules_left.some(rule => {
const hasLicenseCheckApprovalRule = data.approval_rules_left.some((rule) => {
return rule.name === LICENSE_CHECK_NAME;
});
dispatch('receiveLicenseCheckApprovalRuleSuccess', { hasLicenseCheckApprovalRule });
})
.catch(error => {
.catch((error) => {
dispatch('receiveLicenseCheckApprovalRuleError', error);
});
};
......@@ -196,7 +196,7 @@ export const setLicenseApproval = ({ dispatch, state }, payload) => {
.then(() => {
dispatch('receiveSetLicenseApproval', id);
})
.catch(error => {
.catch((error) => {
dispatch('receiveSetLicenseApprovalError', error);
dispatch('removePendingLicense', id);
});
......
......@@ -2,20 +2,20 @@ import { n__, s__, sprintf } from '~/locale';
import { addLicensesMatchingReportGroupStatus, reportGroupHasAtLeastOneLicense } from './utils';
import { LICENSE_APPROVAL_STATUS, REPORT_GROUPS } from '../constants';
export const isLoading = state =>
export const isLoading = (state) =>
state.isLoadingManagedLicenses ||
state.isLoadingLicenseReport ||
state.isLoadingLicenseCheckApprovalRule;
export const isLicenseBeingUpdated = state => (id = null) => state.pendingLicenses.includes(id);
export const isLicenseBeingUpdated = (state) => (id = null) => state.pendingLicenses.includes(id);
export const isAddingNewLicense = (_, getters) => getters.isLicenseBeingUpdated();
export const hasPendingLicenses = state => state.pendingLicenses.length > 0;
export const hasPendingLicenses = (state) => state.pendingLicenses.length > 0;
export const licenseReport = state => state.newLicenses;
export const licenseReport = (state) => state.newLicenses;
export const licenseReportGroups = state =>
export const licenseReportGroups = (state) =>
REPORT_GROUPS.map(addLicensesMatchingReportGroupStatus(state.newLicenses)).filter(
reportGroupHasAtLeastOneLicense,
);
......@@ -24,7 +24,7 @@ export const hasReportItems = (_, getters) => {
return Boolean(getters.licenseReportLength);
};
export const baseReportHasLicenses = state => {
export const baseReportHasLicenses = (state) => {
return Boolean(state.existingLicenses.length);
};
......@@ -118,5 +118,5 @@ export const summaryTextWithoutLicenseCheck = (_, getters) => {
export const reportContainsBlacklistedLicense = (_, getters) =>
(getters.licenseReport || []).some(
license => license.approvalStatus === LICENSE_APPROVAL_STATUS.DENIED,
(license) => license.approvalStatus === LICENSE_APPROVAL_STATUS.DENIED,
);
......@@ -121,6 +121,6 @@ export default {
state.pendingLicenses.push(id);
},
[types.REMOVE_PENDING_LICENSE](state, id) {
state.pendingLicenses = state.pendingLicenses.filter(pendingLicense => pendingLicense !== id);
state.pendingLicenses = state.pendingLicenses.filter((pendingLicense) => pendingLicense !== id);
},
};
......@@ -11,7 +11,7 @@ import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/reports/constan
* @returns {Object}
*
*/
export const normalizeLicense = license => {
export const normalizeLicense = (license) => {
const { approval_status: approvalStatus, ...rest } = license;
return {
...rest,
......@@ -19,7 +19,7 @@ export const normalizeLicense = license => {
};
};
export const getStatusTranslationsFromLicenseStatus = approvalStatus => {
export const getStatusTranslationsFromLicenseStatus = (approvalStatus) => {
if (approvalStatus === LICENSE_APPROVAL_STATUS.ALLOWED) {
return s__('LicenseCompliance|Allowed');
} else if (approvalStatus === LICENSE_APPROVAL_STATUS.DENIED) {
......@@ -28,7 +28,7 @@ export const getStatusTranslationsFromLicenseStatus = approvalStatus => {
return '';
};
export const getIssueStatusFromLicenseStatus = approvalStatus => {
export const getIssueStatusFromLicenseStatus = (approvalStatus) => {
if (approvalStatus === LICENSE_APPROVAL_STATUS.ALLOWED) {
return STATUS_SUCCESS;
} else if (approvalStatus === LICENSE_APPROVAL_STATUS.DENIED) {
......@@ -55,13 +55,13 @@ export const getPackagesString = (packages, truncate, maxPackages) => {
// and truncate is true.
packagesString = packages
.slice(0, maxPackages)
.map(packageItem => packageItem.name)
.map((packageItem) => packageItem.name)
.join(', ');
} else {
// Return all package names separated by comma with proper grammar
packagesString = packages
.slice(0, packages.length - 1)
.map(packageItem => packageItem.name)
.map((packageItem) => packageItem.name)
.join(', ');
lastPackage = packages[packages.length - 1].name;
}
......@@ -83,7 +83,7 @@ export const getPackagesString = (packages, truncate, maxPackages) => {
* @returns {Object} The converted license;
*/
export const convertToOldReportFormat = license => {
export const convertToOldReportFormat = (license) => {
const approvalStatus = license.classification.approval_status;
return {
......@@ -104,10 +104,10 @@ export const convertToOldReportFormat = license => {
* @param {Array} licenses
* @returns {function(*): {licenses: (*|*[])}}
*/
export const addLicensesMatchingReportGroupStatus = licenses => {
export const addLicensesMatchingReportGroupStatus = (licenses) => {
const licensesGroupedByStatus = groupBy(licenses, 'status');
return reportGroup => ({
return (reportGroup) => ({
...reportGroup,
licenses: licensesGroupedByStatus[reportGroup.status] || [],
});
......
import { LOADING, ERROR, SUCCESS } from '../constants';
export const summaryStatus = state => {
export const summaryStatus = (state) => {
if (state.isLoading) {
return LOADING;
}
......@@ -12,8 +12,8 @@ export const summaryStatus = state => {
return SUCCESS;
};
export const metrics = state => [
...state.newMetrics.map(metric => ({ ...metric, isNew: true })),
export const metrics = (state) => [
...state.newMetrics.map((metric) => ({ ...metric, isNew: true })),
...state.existingMetrics,
...state.removedMetrics.map(metric => ({ ...metric, wasRemoved: true })),
...state.removedMetrics.map((metric) => ({ ...metric, wasRemoved: true })),
];
......@@ -17,7 +17,7 @@ export default {
state.removedMetrics = response.removed_metrics || [];
state.numberOfChanges =
state.existingMetrics.filter(metric => metric.previous_value !== undefined).length +
state.existingMetrics.filter((metric) => metric.previous_value !== undefined).length +
state.newMetrics.length +
state.removedMetrics.length;
},
......
......@@ -66,7 +66,7 @@ export default {
},
recordedMessage() {
return this.vulnerability.supporting_messages?.find(
msg => msg.name === SUPPORTING_MESSAGE_TYPES.RECORDED,
(msg) => msg.name === SUPPORTING_MESSAGE_TYPES.RECORDED,
)?.response;
},
constructedRequest() {
......
......@@ -67,7 +67,7 @@ export const fetchContainerScanningDiff = ({ state, dispatch }) => {
dispatch('requestContainerScanningDiff');
return fetchDiffData(state, state.containerScanning.paths.diffEndpoint, 'container_scanning')
.then(data => {
.then((data) => {
dispatch('receiveContainerScanningDiffSuccess', data);
})
.catch(() => {
......@@ -96,7 +96,7 @@ export const fetchDastDiff = ({ state, dispatch }) => {
dispatch('requestDastDiff');
return fetchDiffData(state, state.dast.paths.diffEndpoint, 'dast')
.then(data => {
.then((data) => {
dispatch('receiveDastDiffSuccess', data);
})
.catch(() => {
......@@ -124,7 +124,7 @@ export const fetchDependencyScanningDiff = ({ state, dispatch }) => {
dispatch('requestDependencyScanningDiff');
return fetchDiffData(state, state.dependencyScanning.paths.diffEndpoint, 'dependency_scanning')
.then(data => {
.then((data) => {
dispatch('receiveDependencyScanningDiffSuccess', data);
})
.catch(() => {
......@@ -161,7 +161,7 @@ export const fetchCoverageFuzzingDiff = ({ state, dispatch }) => {
},
}),
])
.then(values => {
.then((values) => {
dispatch('receiveCoverageFuzzingDiffSuccess', {
diff: values[0].data,
enrichData: values[1].data,
......@@ -371,7 +371,7 @@ export const createNewIssue = ({ state, dispatch }) => {
vulnerability_data: state.modal.vulnerability,
},
})
.then(response => {
.then((response) => {
dispatch('receiveCreateIssue');
// redirect the user to the created issue
visitUrl(response.data.issue_url);
......
......@@ -59,13 +59,13 @@ export const dependencyScanningStatusIcon = ({ dependencyScanning }) =>
export const coverageFuzzingStatusIcon = ({ coverageFuzzing }) =>
statusIcon(coverageFuzzing.isLoading, coverageFuzzing.hasError, coverageFuzzing.newIssues.length);
export const isBaseSecurityReportOutOfDate = state =>
state.reportTypes.some(reportType => state[reportType].baseReportOutofDate);
export const isBaseSecurityReportOutOfDate = (state) =>
state.reportTypes.some((reportType) => state[reportType].baseReportOutofDate);
export const canCreateIssue = state => Boolean(state.createVulnerabilityFeedbackIssuePath);
export const canCreateIssue = (state) => Boolean(state.createVulnerabilityFeedbackIssuePath);
export const canCreateMergeRequest = state =>
export const canCreateMergeRequest = (state) =>
Boolean(state.createVulnerabilityFeedbackMergeRequestPath);
export const canDismissVulnerability = state =>
export const canDismissVulnerability = (state) =>
Boolean(state.createVulnerabilityFeedbackDismissalPath);
......@@ -15,7 +15,7 @@ export const fetchDiff = ({ state, rootState, dispatch }) => {
dispatch('requestDiff');
return fetchDiffData(rootState, state.paths.diffEndpoint, 'api_fuzzing')
.then(data => {
.then((data) => {
dispatch('receiveDiffSuccess', data);
})
.catch(() => {
......
import { statusIcon, groupedReportText } from '../../utils';
import messages from '../../messages';
export const groupedApiFuzzingText = state =>
export const groupedApiFuzzingText = (state) =>
groupedReportText(
state,
messages.API_FUZZING,
......
import { statusIcon, groupedReportText } from '../../utils';
import messages from '../../messages';
export const groupedSastText = state =>
export const groupedSastText = (state) =>
groupedReportText(state, messages.SAST, messages.SAST_HAS_ERROR, messages.SAST_IS_LOADING);
export const sastStatusIcon = ({ isLoading, hasError, newIssues }) =>
......
import { statusIcon, groupedReportText } from '../../utils';
import messages from '../../messages';
export const groupedSecretDetectionText = state =>
export const groupedSecretDetectionText = (state) =>
groupedReportText(
state,
messages.SECRET_SCANNING,
......
......@@ -11,7 +11,7 @@ export { groupedTextBuilder, countVulnerabilities };
* @param {Object} issue
*/
export const findIssueIndex = (issues, issue) =>
issues.findIndex(el => el.project_fingerprint === issue.project_fingerprint);
issues.findIndex((el) => el.project_fingerprint === issue.project_fingerprint);
export const statusIcon = (loading = false, failed = false, newIssues = 0, neutralIssues = 0) => {
if (loading) {
......
......@@ -6,7 +6,7 @@ import { humanize } from '~/lib/utils/text_utility';
* @param {string} reportType that is not human-readable
* @returns {string} a human-readable version of the report type
*/
const convertReportType = reportType => {
const convertReportType = (reportType) => {
if (!reportType) return '';
const lowerCaseType = reportType.toLowerCase();
return REPORT_TYPES[lowerCaseType] || humanize(lowerCaseType);
......
......@@ -6,7 +6,7 @@ import { PRIMARY_IDENTIFIER_TYPE } from 'ee/security_dashboard/store/constants';
* @returns {String} the primary identifier's name
*/
const getPrimaryIdentifier = (identifiers = [], property) => {
const identifier = identifiers.find(value => value[property] === PRIMARY_IDENTIFIER_TYPE);
const identifier = identifiers.find((value) => value[property] === PRIMARY_IDENTIFIER_TYPE);
return identifier?.name || identifiers[0]?.name || '';
};
......
......@@ -62,7 +62,7 @@ export default {
},
recordedMessage() {
return this.vulnerability?.supportingMessages?.find(
msg => msg.name === SUPPORTING_MESSAGE_TYPES.RECORDED,
(msg) => msg.name === SUPPORTING_MESSAGE_TYPES.RECORDED,
)?.response;
},
constructedRequest() {
......@@ -85,7 +85,7 @@ export default {
content: this.constructedRequest,
isCode: true,
},
].filter(x => x.content);
].filter((x) => x.content);
},
responseData() {
if (!this.vulnerability.response) {
......@@ -98,7 +98,7 @@ export default {
content: this.constructedResponse,
isCode: true,
},
].filter(x => x.content);
].filter((x) => x.content);
},
recordedResponseData() {
if (!this.recordedMessage) {
......@@ -111,7 +111,7 @@ export default {
content: this.constructedRecordedResponse,
isCode: true,
},
].filter(x => x.content);
].filter((x) => x.content);
},
shouldShowLocation() {
return (
......
......@@ -43,7 +43,7 @@ export default {
},
noteDictionary() {
return this.discussions
.flatMap(x => x.notes)
.flatMap((x) => x.notes)
.reduce((acc, note) => {
acc[note.id] = note;
return acc;
......@@ -156,11 +156,11 @@ export default {
updateNotes(notes) {
let isVulnerabilityStateChanged = false;
notes.forEach(note => {
notes.forEach((note) => {
// If the note exists, update it.
if (this.noteDictionary[note.id]) {
const updatedDiscussion = { ...this.discussionsDictionary[note.discussionId] };
updatedDiscussion.notes = updatedDiscussion.notes.map(curr =>
updatedDiscussion.notes = updatedDiscussion.notes.map((curr) =>
curr.id === note.id ? note : curr,
);
this.discussionsDictionary[note.discussionId] = updatedDiscussion;
......
......@@ -116,7 +116,7 @@ export default {
this.isLoadingUser = true;
UsersCache.retrieveById(id)
.then(userData => {
.then((userData) => {
this.user = userData;
})
.catch(() => {
......@@ -221,7 +221,7 @@ export default {
.then(({ data }) => {
Object.assign(this.vulnerability, data);
})
.catch(e => {
.catch((e) => {
// Don't show an error message if the request was cancelled through the cancel token.
if (!axios.isCancel(e)) {
createFlash(
......
......@@ -21,10 +21,10 @@ export default {
},
computed: {
systemNote() {
return this.notes.find(x => x.system === true);
return this.notes.find((x) => x.system === true);
},
comments() {
return this.notes.filter(x => x !== this.systemNote);
return this.notes.filter((x) => x !== this.systemNote);
},
},
watch: {
......
......@@ -54,7 +54,7 @@ export default {
return this.projectPath.replace(/^\//, ''); // Remove the leading slash, i.e. '/root/test' -> 'root/test'.
},
isIssueAlreadyCreated() {
return Boolean(this.state.relatedIssues.find(i => i.lockIssueRemoval));
return Boolean(this.state.relatedIssues.find((i) => i.lockIssueRemoval));
},
canCreateIssue() {
return !this.isIssueAlreadyCreated && !this.isFetching && Boolean(this.newIssueUrl);
......@@ -102,7 +102,7 @@ export default {
const errors = [];
// The endpoint can only accept one issue, so we need to do a separate call for each pending reference.
const requests = this.state.pendingReferences.map(reference => {
const requests = this.state.pendingReferences.map((reference) => {
return axios
.post(
this.endpoint,
......@@ -132,7 +132,7 @@ export default {
this.isFormVisible = hasErrors;
if (hasErrors) {
const messages = errors.map(error => sprintf(RELATED_ISSUES_ERRORS.LINK_ERROR, error));
const messages = errors.map((error) => sprintf(RELATED_ISSUES_ERRORS.LINK_ERROR, error));
createFlash(messages.join(' '));
}
});
......@@ -157,7 +157,7 @@ export default {
.then(({ data }) => {
const issues = data.map(getFormattedIssue);
this.store.setRelatedIssues(
issues.map(i => {
issues.map((i) => {
const lockIssueRemoval = i.vulnerability_link_type === 'created';
return {
......@@ -185,7 +185,7 @@ export default {
this.store.removePendingRelatedIssue(indexToRemove);
},
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.addPendingReferences({ untouchedRawReferences: rawReferences });
},
},
......
......@@ -41,7 +41,7 @@ export default {
}
},
isAlreadyDismissed() {
return this.alreadyDismissedVulnerabilities().some(id => id === this.vulnerabilityId);
return this.alreadyDismissedVulnerabilities().some((id) => id === this.vulnerabilityId);
},
dismiss() {
const dismissed = this.alreadyDismissedVulnerabilities().concat(this.vulnerabilityId);
......
......@@ -2,7 +2,7 @@ import { isAbsolute, isSafeURL } from '~/lib/utils/url_utility';
import { REGEXES } from './constants';
// Get the issue in the format expected by the descendant components of related_issues_block.vue.
export const getFormattedIssue = issue => ({
export const getFormattedIssue = (issue) => ({
...issue,
reference: `#${issue.iid}`,
path: issue.web_url,
......
......@@ -3,7 +3,7 @@ import App from 'ee/vulnerabilities/components/vulnerability.vue';
import apolloProvider from 'ee/security_dashboard/graphql/provider';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
export default el => {
export default (el) => {
if (!el) {
return null;
}
......@@ -23,7 +23,7 @@ export default el => {
issueTrackingHelpPath: vulnerability.issueTrackingHelpPath,
permissionsHelpPath: vulnerability.permissionsHelpPath,
},
render: h =>
render: (h) =>
h(App, {
props: { vulnerability },
}),
......
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