Commit 5ebea3a4 authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 31 files - 11 of 73

Part of our prettier migration; changing the arrow-parens style.
parent 02fad0bc
......@@ -162,39 +162,6 @@ app/assets/javascripts/ci_variable_list/ci_variable_list.js
app/assets/javascripts/ci_variable_list/components/ci_environments_dropdown.vue
app/assets/javascripts/ci_variable_list/components/ci_variable_table.vue
## loving-feistel
app/assets/javascripts/design_management/components/toolbar/design_navigation.vue
app/assets/javascripts/design_management/components/toolbar/index.vue
app/assets/javascripts/design_management/components/upload/design_version_dropdown.vue
app/assets/javascripts/design_management/graphql.js
app/assets/javascripts/design_management/mixins/all_designs.js
app/assets/javascripts/design_management/mixins/all_versions.js
app/assets/javascripts/design_management/pages/design/index.vue
app/assets/javascripts/design_management/pages/index.vue
app/assets/javascripts/design_management/utils/cache_update.js
app/assets/javascripts/design_management/utils/design_management_utils.js
app/assets/javascripts/design_management/utils/error_messages.js
app/assets/javascripts/diff.js
app/assets/javascripts/diffs/components/app.vue
app/assets/javascripts/diffs/components/compare_dropdown_layout.vue
app/assets/javascripts/diffs/components/diff_content.vue
app/assets/javascripts/diffs/components/diff_expansion_cell.vue
app/assets/javascripts/diffs/components/diff_file.vue
app/assets/javascripts/diffs/components/diff_gutter_avatars.vue
app/assets/javascripts/diffs/components/diff_line_note_form.vue
app/assets/javascripts/diffs/components/diff_row_utils.js
app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
app/assets/javascripts/diffs/components/tree_list.vue
app/assets/javascripts/diffs/index.js
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/getters_versions_dropdowns.js
app/assets/javascripts/diffs/store/mutations.js
app/assets/javascripts/diffs/store/utils.js
app/assets/javascripts/diffs/utils/diff_file.js
app/assets/javascripts/diffs/workers/tree_worker.js
app/assets/javascripts/dirty_submit/dirty_submit_collection.js
app/assets/javascripts/dirty_submit/dirty_submit_form.js
## distracted-nash
app/assets/javascripts/droplab/drop_down.js
app/assets/javascripts/droplab/drop_lab.js
......
......@@ -26,7 +26,7 @@ export default {
return this.designs.length;
},
currentIndex() {
return this.designs.findIndex(design => design.filename === this.id);
return this.designs.findIndex((design) => design.filename === this.id);
},
paginationText() {
return sprintf(s__('DesignManagement|%{current_design} of %{designs_count}'), {
......
......@@ -75,7 +75,7 @@ export default {
iid: this.issueIid,
};
},
update: data => data.project.issue.userPermissions,
update: (data) => data.project.issue.userPermissions,
},
},
computed: {
......
......@@ -19,7 +19,7 @@ export default {
if (!this.queryVersion) return 0;
const idx = this.allVersions.findIndex(
version => this.findVersionId(version.id) === this.queryVersion,
(version) => this.findVersionId(version.id) === this.queryVersion,
);
// if the currentVersionId isn't a valid version (i.e. not in allVersions)
......
......@@ -19,7 +19,7 @@ const resolvers = {
updateActiveDiscussion: (_, { id = null, source }, { cache }) => {
const sourceData = cache.readQuery({ query: activeDiscussionQuery });
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.activeDiscussion = {
__typename: 'ActiveDiscussion',
......@@ -74,7 +74,7 @@ const defaultClient = createDefaultClient(
// Should be removed as soon as https://gitlab.com/gitlab-org/gitlab/issues/13495 is resolved
{
cacheConfig: {
dataIdFromObject: object => {
dataIdFromObject: (object) => {
// eslint-disable-next-line no-underscore-dangle, @gitlab/require-i18n-strings
if (object.__typename === 'Design') {
return object.id && object.image ? `${object.id}-${object.image}` : uniqueId();
......
......@@ -17,7 +17,7 @@ export default {
atVersion: this.designsVersion,
};
},
update: data => {
update: (data) => {
const designNodes = propertyOf(data)([
'project',
'issue',
......
......@@ -12,7 +12,7 @@ export default {
atVersion: null,
};
},
update: data => data.project.issue.designCollection.versions.nodes,
update: (data) => data.project.issue.designCollection.versions.nodes,
},
},
inject: {
......@@ -28,7 +28,7 @@ export default {
return (
this.$route.query.version &&
this.allVersions &&
this.allVersions.some(version => version.id.endsWith(this.$route.query.version))
this.allVersions.some((version) => version.id.endsWith(this.$route.query.version))
);
},
designsVersion() {
......
......@@ -81,7 +81,7 @@ export default {
variables() {
return this.designVariables;
},
update: data => extractDesign(data),
update: (data) => extractDesign(data),
result(res) {
this.onDesignQueryResult(res);
},
......@@ -139,7 +139,7 @@ export default {
return Boolean(this.annotationCoordinates);
},
resolvedDiscussions() {
return this.discussions.filter(discussion => discussion.resolved);
return this.discussions.filter((discussion) => discussion.resolved);
},
},
watch: {
......@@ -203,7 +203,7 @@ export default {
update: this.updateImageDiffNoteInStore,
};
return this.$apollo.mutate(mutationPayload).catch(e => this.onUpdateImageDiffNoteError(e));
return this.$apollo.mutate(mutationPayload).catch((e) => this.onUpdateImageDiffNoteError(e));
},
onDesignQueryResult({ data, loading }) {
// On the initial load with cache-and-network policy data is undefined while loading is true
......
......@@ -69,7 +69,7 @@ export default {
iid: this.issueIid,
};
},
update: data => data.project.issue.userPermissions,
update: (data) => data.project.issue.userPermissions,
},
},
data() {
......@@ -184,7 +184,7 @@ export default {
return this.$apollo
.mutate(mutationPayload)
.then(res => this.onUploadDesignDone(res))
.then((res) => this.onUploadDesignDone(res))
.catch(() => this.onUploadDesignError());
},
afterUploadDesign(store, { data: { designManagementUpload } }) {
......@@ -208,7 +208,7 @@ export default {
this.trackUploadDesign(res);
},
trackUploadDesign(res) {
(res?.data?.designManagementUpload?.designs || []).forEach(design => {
(res?.data?.designManagementUpload?.designs || []).forEach((design) => {
if (design.event === 'CREATION') {
trackDesignCreate();
} else if (design.event === 'MODIFICATION') {
......@@ -222,7 +222,7 @@ export default {
},
changeSelectedDesigns(filename) {
if (this.isDesignSelected(filename)) {
this.selectedDesigns = this.selectedDesigns.filter(design => design !== filename);
this.selectedDesigns = this.selectedDesigns.filter((design) => design !== filename);
} else {
this.selectedDesigns.push(filename);
}
......@@ -231,14 +231,14 @@ export default {
if (this.hasSelectedDesigns) {
this.selectedDesigns = [];
} else {
this.selectedDesigns = this.designs.map(design => design.filename);
this.selectedDesigns = this.designs.map((design) => design.filename);
}
},
isDesignSelected(filename) {
return this.selectedDesigns.includes(filename);
},
isDesignToBeSaved(filename) {
return this.filesToBeSaved.some(file => file.name === filename);
return this.filesToBeSaved.some((file) => file.name === filename);
},
canSelectDesign(filename) {
return this.isLatestVersion && this.canCreateDesign && !this.isDesignToBeSaved(filename);
......
......@@ -11,14 +11,14 @@ import {
designDeletionError,
} from './error_messages';
const designsOf = data => data.project.issue.designCollection.designs;
const designsOf = (data) => data.project.issue.designCollection.designs;
const deleteDesignsFromStore = (store, query, selectedDesigns) => {
const sourceData = store.readQuery(query);
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
const changedDesigns = designsOf(sourceData).nodes.filter(
design => !selectedDesigns.includes(design.filename),
(design) => !selectedDesigns.includes(design.filename),
);
designsOf(draftData).nodes = [...changedDesigns];
});
......@@ -40,7 +40,7 @@ const addNewVersionToStore = (store, query, version) => {
if (!version) return;
const sourceData = store.readQuery(query);
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.issue.designCollection.versions.nodes = [
version,
......@@ -74,14 +74,14 @@ const addImageDiffNoteToStore = (store, createImageDiffNote, query, variables) =
},
};
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
const design = extractDesign(draftData);
design.notesCount += 1;
design.discussions.nodes = [...design.discussions.nodes, newDiscussion];
if (
!design.issue.participants.nodes.some(
participant => participant.username === createImageDiffNote.note.author.username,
(participant) => participant.username === createImageDiffNote.note.author.username,
)
) {
design.issue.participants.nodes = [
......@@ -107,7 +107,7 @@ const updateImageDiffNoteInStore = (store, repositionImageDiffNote, query, varia
variables,
});
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
const design = extractDesign(draftData);
const discussion = extractCurrentDiscussion(
design.discussions,
......@@ -130,18 +130,18 @@ const updateImageDiffNoteInStore = (store, repositionImageDiffNote, query, varia
const addNewDesignToStore = (store, designManagementUpload, query) => {
const sourceData = store.readQuery(query);
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
const currentDesigns = extractDesigns(draftData);
const difference = differenceBy(designManagementUpload.designs, currentDesigns, 'filename');
const newDesigns = currentDesigns
.map(design => {
return designManagementUpload.designs.find(d => d.filename === design.filename) || design;
.map((design) => {
return designManagementUpload.designs.find((d) => d.filename === design.filename) || design;
})
.concat(difference);
let newVersionNode;
const findNewVersions = designManagementUpload.designs.find(design => design.versions);
const findNewVersions = designManagementUpload.designs.find((design) => design.versions);
if (findNewVersions) {
const findNewVersionsNodes = findNewVersions.versions.nodes;
......@@ -181,7 +181,7 @@ const addNewDesignToStore = (store, designManagementUpload, query) => {
const moveDesignInStore = (store, designManagementMove, query) => {
const sourceData = store.readQuery(query);
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.issue.designCollection.designs =
designManagementMove.designCollection.designs;
......@@ -199,7 +199,7 @@ export const addPendingTodoToStore = (store, pendingTodo, query, queryVariables)
variables: queryVariables,
});
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
const design = extractDesign(draftData);
const existingTodos = design.currentUserTodos?.nodes || [];
const newTodoNodes = [...existingTodos, { ...pendingTodo, __typename: 'Todo' }];
......@@ -226,7 +226,7 @@ export const deletePendingTodoFromStore = (store, todoMarkDone, query, queryVari
const {
todo: { id: todoId },
} = todoMarkDone;
const data = produce(sourceData, draftData => {
const data = produce(sourceData, (draftData) => {
const design = extractDesign(draftData);
const existingTodos = design.currentUserTodos?.nodes || [];
......
......@@ -10,7 +10,7 @@ export const isValidDesignFile = ({ type }) =>
* @param {Array} discussions
*/
export const extractDiscussions = discussions =>
export const extractDiscussions = (discussions) =>
discussions.nodes.map((discussion, index) => ({
...discussion,
index: index + 1,
......@@ -24,27 +24,27 @@ export const extractDiscussions = discussions =>
*/
export const extractCurrentDiscussion = (discussions, id) =>
discussions.nodes.find(discussion => discussion.id === id);
discussions.nodes.find((discussion) => discussion.id === id);
export const findVersionId = id => (id.match('::Version/(.+$)') || [])[1];
export const findVersionId = (id) => (id.match('::Version/(.+$)') || [])[1];
export const findNoteId = id => (id.match('DiffNote/(.+$)') || [])[1];
export const findNoteId = (id) => (id.match('DiffNote/(.+$)') || [])[1];
export const findIssueId = id => (id.match('Issue/(.+$)') || [])[1];
export const findIssueId = (id) => (id.match('Issue/(.+$)') || [])[1];
export const findDesignId = id => (id.match('Design/(.+$)') || [])[1];
export const findDesignId = (id) => (id.match('Design/(.+$)') || [])[1];
export const extractDesigns = data => data.project.issue.designCollection.designs.nodes;
export const extractDesigns = (data) => data.project.issue.designCollection.designs.nodes;
export const extractDesign = data => (extractDesigns(data) || [])[0];
export const extractDesign = (data) => (extractDesigns(data) || [])[0];
export const toDiffNoteGid = noteId => `gid://gitlab/DiffNote/${noteId}`;
export const toDiffNoteGid = (noteId) => `gid://gitlab/DiffNote/${noteId}`;
/**
* Return the note ID from a URL hash parameter
* @param {String} urlHash URL hash, including `#` prefix
*/
export const extractDesignNoteId = urlHash => {
export const extractDesignNoteId = (urlHash) => {
const [, noteId] = urlHash.match('#note_([0-9]+$)') || [];
return noteId || null;
};
......@@ -53,8 +53,8 @@ export const extractDesignNoteId = urlHash => {
* Generates optimistic response for a design upload mutation
* @param {Array<File>} files
*/
export const designUploadOptimisticResponse = files => {
const designs = files.map(file => ({
export const designUploadOptimisticResponse = (files) => {
const designs = files.map((file) => ({
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
// eslint-disable-next-line @gitlab/require-i18n-strings
__typename: 'Design',
......@@ -128,7 +128,7 @@ export const repositionImageDiffNoteOptimisticResponse = (note, { position }) =>
* Generates optimistic response for a design upload mutation
* @param {Array} designs
*/
export const moveDesignOptimisticResponse = designs => ({
export const moveDesignOptimisticResponse = (designs) => ({
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
// eslint-disable-next-line @gitlab/require-i18n-strings
__typename: 'Mutation',
......@@ -145,13 +145,13 @@ export const moveDesignOptimisticResponse = designs => ({
},
});
const normalizeAuthor = author => ({
const normalizeAuthor = (author) => ({
...author,
web_url: author.webUrl,
avatar_url: author.avatarUrl,
});
export const extractParticipants = users => users.map(node => normalizeAuthor(node));
export const extractParticipants = (users) => users.map((node) => normalizeAuthor(node));
export const getPageLayoutElement = () => document.querySelector('.layout-page');
......@@ -160,14 +160,14 @@ export const getPageLayoutElement = () => document.querySelector('.layout-page')
* Example of todoDeletePath: /delete/1234
* @param {String} todoDeletePath delete_path from REST API response
*/
export const extractTodoIdFromDeletePath = todoDeletePath =>
export const extractTodoIdFromDeletePath = (todoDeletePath) =>
(todoDeletePath.match('todos/([0-9]+$)') || [])[1];
const createTodoGid = todoId => {
const createTodoGid = (todoId) => {
return `gid://gitlab/Todo/${todoId}`;
};
export const createPendingTodo = todoId => {
export const createPendingTodo = (todoId) => {
return {
__typename: 'Todo', // eslint-disable-line @gitlab/require-i18n-strings
id: createTodoGid(todoId),
......
......@@ -54,7 +54,7 @@ export const TOGGLE_TODO_ERROR = __('Failed to toggle To-Do for the design.');
const MAX_SKIPPED_FILES_LISTINGS = 5;
const oneDesignSkippedMessage = filename =>
const oneDesignSkippedMessage = (filename) =>
`${DESIGN_UPLOAD_SKIPPED_MESSAGE} ${sprintf(s__('DesignManagement|%{filename} did not change.'), {
filename,
})}`;
......@@ -64,7 +64,7 @@ const oneDesignSkippedMessage = filename =>
* files were skipped.
* @param {Array<{ filename }>} skippedFiles
*/
const someDesignsSkippedMessage = skippedFiles => {
const someDesignsSkippedMessage = (skippedFiles) => {
const designsSkippedMessage = `${DESIGN_UPLOAD_SKIPPED_MESSAGE} ${s__(
'Some of the designs you tried uploading did not change:',
)}`;
......
......@@ -117,7 +117,7 @@ export default class Diff {
table.removeClass('left-side-selected right-side-selected');
const lineClass = ['left-side', 'right-side'].filter(name => line.hasClass(name))[0];
const lineClass = ['left-side', 'right-side'].filter((name) => line.hasClass(name))[0];
if (lineClass) {
table.addClass(`${lineClass}-selected`);
}
......@@ -132,7 +132,7 @@ export default class Diff {
if (children.length !== 2) {
return [0, 0];
}
return children.map(elm => parseInt($(elm).data('linenumber'), 10) || 0);
return children.map((elm) => parseInt($(elm).data('linenumber'), 10) || 0);
}
// eslint-disable-next-line class-methods-use-this
highlightSelectedLine() {
......
......@@ -141,19 +141,19 @@ export default {
},
computed: {
...mapState({
isLoading: state => state.diffs.isLoading,
isBatchLoading: state => state.diffs.isBatchLoading,
diffFiles: state => state.diffs.diffFiles,
diffViewType: state => state.diffs.diffViewType,
mergeRequestDiffs: state => state.diffs.mergeRequestDiffs,
mergeRequestDiff: state => state.diffs.mergeRequestDiff,
commit: state => state.diffs.commit,
renderOverflowWarning: state => state.diffs.renderOverflowWarning,
numTotalFiles: state => state.diffs.realSize,
numVisibleFiles: state => state.diffs.size,
plainDiffPath: state => state.diffs.plainDiffPath,
emailPatchPath: state => state.diffs.emailPatchPath,
retrievingBatches: state => state.diffs.retrievingBatches,
isLoading: (state) => state.diffs.isLoading,
isBatchLoading: (state) => state.diffs.isBatchLoading,
diffFiles: (state) => state.diffs.diffFiles,
diffViewType: (state) => state.diffs.diffViewType,
mergeRequestDiffs: (state) => state.diffs.mergeRequestDiffs,
mergeRequestDiff: (state) => state.diffs.mergeRequestDiff,
commit: (state) => state.diffs.commit,
renderOverflowWarning: (state) => state.diffs.renderOverflowWarning,
numTotalFiles: (state) => state.diffs.realSize,
numVisibleFiles: (state) => state.diffs.size,
plainDiffPath: (state) => state.diffs.plainDiffPath,
emailPatchPath: (state) => state.diffs.emailPatchPath,
retrievingBatches: (state) => state.diffs.retrievingBatches,
}),
...mapState('diffs', [
'showTreeList',
......
......@@ -16,7 +16,7 @@ export default {
},
computed: {
selectedVersionName() {
return this.versions.find(x => x.selected)?.versionName || '';
return this.versions.find((x) => x.selected)?.versionName || '';
},
},
};
......
......@@ -50,7 +50,7 @@ export default {
},
computed: {
...mapState({
projectPath: state => state.diffs.projectPath,
projectPath: (state) => state.diffs.projectPath,
}),
...mapGetters('diffs', [
'isInlineView',
......
......@@ -13,7 +13,7 @@ const EXPAND_DOWN = 2;
const lineNumberByViewType = (viewType, diffLine) => {
const numberGetters = {
[INLINE_DIFF_VIEW_TYPE]: line => line?.new_line,
[INLINE_DIFF_VIEW_TYPE]: (line) => line?.new_line,
};
const numberGetter = numberGetters[viewType];
return numberGetter && numberGetter(diffLine);
......@@ -56,7 +56,7 @@ export default {
},
computed: {
...mapState({
diffFiles: state => state.diffs.diffFiles,
diffFiles: (state) => state.diffs.diffFiles,
}),
canExpandUp() {
return !this.isBottom;
......
......@@ -210,7 +210,7 @@ export default {
await this.$nextTick();
eventsForThisFile.forEach(event => {
eventsForThisFile.forEach((event) => {
eventHub.$emit(event);
});
},
......
......@@ -29,7 +29,7 @@ export default {
return this.discussions.reduce((acc, note) => acc.concat(note.notes), []);
},
notesInGutter() {
return this.allDiscussions.slice(0, COUNT_OF_AVATARS_IN_GUTTER).map(n => ({
return this.allDiscussions.slice(0, COUNT_OF_AVATARS_IN_GUTTER).map((n) => ({
note: n.note,
author: n.author,
}));
......
......@@ -56,8 +56,8 @@ export default {
},
computed: {
...mapState({
noteableData: state => state.notes.noteableData,
diffViewType: state => state.diffs.diffViewType,
noteableData: (state) => state.notes.noteableData,
diffViewType: (state) => state.diffs.diffViewType,
}),
...mapState('diffs', ['showSuggestPopover']),
...mapGetters('diffs', ['getDiffFileByHash', 'diffLines']),
......
......@@ -15,22 +15,22 @@ export const isHighlighted = (state, line, isCommented) => {
return lineCode ? lineCode === state.diffs.highlightedRow : false;
};
export const isContextLine = type => type === CONTEXT_LINE_TYPE;
export const isContextLine = (type) => type === CONTEXT_LINE_TYPE;
export const isMatchLine = type => type === MATCH_LINE_TYPE;
export const isMatchLine = (type) => type === MATCH_LINE_TYPE;
export const isMetaLine = type =>
export const isMetaLine = (type) =>
[OLD_NO_NEW_LINE_TYPE, NEW_NO_NEW_LINE_TYPE, EMPTY_CELL_TYPE].includes(type);
export const shouldRenderCommentButton = (isLoggedIn, isCommentButtonRendered) => {
return isCommentButtonRendered && isLoggedIn;
};
export const hasDiscussions = line => line?.discussions?.length > 0;
export const hasDiscussions = (line) => line?.discussions?.length > 0;
export const lineHref = line => `#${line?.line_code || ''}`;
export const lineHref = (line) => `#${line?.line_code || ''}`;
export const lineCode = line => {
export const lineCode = (line) => {
if (!line) return undefined;
return line.line_code || line.left?.line_code || line.right?.line_code;
};
......@@ -48,7 +48,7 @@ export const classNameMapCell = (line, hll, isLoggedIn, isHover) => {
];
};
export const addCommentTooltip = line => {
export const addCommentTooltip = (line) => {
let tooltip;
if (!line) return tooltip;
......@@ -84,7 +84,7 @@ export const shouldShowCommentButton = (hover, context, meta, discussions) => {
return hover && !context && !meta && !discussions;
};
export const mapParallel = content => line => {
export const mapParallel = (content) => (line) => {
let { left, right } = line;
// Dicussions/Comments
......@@ -137,7 +137,7 @@ export const mapParallel = content => line => {
};
// TODO: Delete this function when unifiedDiffComponents FF is removed
export const mapInline = content => line => {
export const mapInline = (content) => (line) => {
// Discussions/Comments
const renderCommentRow = line.hasForm || (line.discussions?.length && line.discussionsExpanded);
......
......@@ -112,8 +112,8 @@ export default {
mounted() {
this.scrollToLineIfNeededParallel(this.line);
this.unwatchShouldShowCommentButton = this.$watch(
vm => [vm.shouldShowCommentButtonLeft, vm.shouldShowCommentButtonRight].join(),
newVal => {
(vm) => [vm.shouldShowCommentButtonLeft, vm.shouldShowCommentButtonRight].join(),
(newVal) => {
if (newVal) {
this.isCommentButtonRendered = true;
this.unwatchShouldShowCommentButton();
......@@ -150,7 +150,7 @@ export default {
const table = line.closest('table');
table.removeClass('left-side-selected right-side-selected');
const [lineClass] = ['left-side', 'right-side'].filter(name => line.hasClass(name));
const [lineClass] = ['left-side', 'right-side'].filter((name) => line.hasClass(name));
if (lineClass) {
table.addClass(`${lineClass}-selected`);
......
......@@ -35,7 +35,7 @@ export default {
}
return this.allBlobs.reduce((acc, folder) => {
const tree = folder.tree.filter(f => f.path.toLowerCase().indexOf(search) >= 0);
const tree = folder.tree.filter((f) => f.path.toLowerCase().indexOf(search) >= 0);
if (tree.length) {
return acc.concat({
......
......@@ -87,7 +87,7 @@ export default function initDiffsApp(store) {
},
computed: {
...mapState({
activeTab: state => state.page.activeTab,
activeTab: (state) => state.page.activeTab,
}),
},
created() {
......
......@@ -127,7 +127,7 @@ export const fetchDiffFilesBatch = ({ commit, state, dispatch }) => {
// We need to check that the currentDiffFileId points to a file that exists
if (
state.currentDiffFileId &&
!state.diffFiles.some(f => f.file_hash === state.currentDiffFileId) &&
!state.diffFiles.some((f) => f.file_hash === state.currentDiffFileId) &&
!isNoteLink
) {
commit(types.VIEW_DIFF_FILE, state.diffFiles[0].file_hash);
......@@ -135,11 +135,11 @@ export const fetchDiffFilesBatch = ({ commit, state, dispatch }) => {
if (state.diffFiles?.length) {
// eslint-disable-next-line promise/catch-or-return,promise/no-nesting
import('~/code_navigation').then(m =>
import('~/code_navigation').then((m) =>
m.default({
blobs: state.diffFiles
.filter(f => f.code_navigation_path)
.map(f => ({
.filter((f) => f.code_navigation_path)
.map((f) => ({
path: f.new_path,
codeNavigationPath: f.code_navigation_path,
})),
......@@ -161,7 +161,7 @@ export const fetchDiffFilesBatch = ({ commit, state, dispatch }) => {
return pagination.next_page;
})
.then(nextPage => nextPage && getBatch(nextPage))
.then((nextPage) => nextPage && getBatch(nextPage))
.catch(() => commit(types.SET_RETRIEVING_BATCHES, false));
return getBatch()
......@@ -211,7 +211,7 @@ export const fetchDiffFilesMeta = ({ commit, state }) => {
export const fetchCoverageFiles = ({ commit, state }) => {
const coveragePoll = new Poll({
resource: {
getCoverageReports: endpoint => axios.get(endpoint),
getCoverageReports: (endpoint) => axios.get(endpoint),
},
data: state.endpointCoverage,
method: 'getCoverageReports',
......@@ -246,8 +246,8 @@ export const assignDiscussionsToDiff = (
const hash = getLocationHash();
discussions
.filter(discussion => discussion.diff_discussion)
.forEach(discussion => {
.filter((discussion) => discussion.diff_discussion)
.forEach((discussion) => {
commit(types.SET_LINE_DISCUSSIONS_FOR_FILE, {
discussion,
diffPositionByLineCode,
......@@ -274,10 +274,10 @@ export const toggleLineDiscussions = ({ commit }, options) => {
};
export const renderFileForDiscussionId = ({ commit, rootState, state }, discussionId) => {
const discussion = rootState.notes.discussions.find(d => d.id === discussionId);
const discussion = rootState.notes.discussions.find((d) => d.id === discussionId);
if (discussion && discussion.diff_file) {
const file = state.diffFiles.find(f => f.file_hash === discussion.diff_file.file_hash);
const file = state.diffFiles.find((f) => f.file_hash === discussion.diff_file.file_hash);
if (file) {
if (!file.renderIt) {
......@@ -303,9 +303,9 @@ export const renderFileForDiscussionId = ({ commit, rootState, state }, discussi
export const startRenderDiffsQueue = ({ state, commit }) => {
const checkItem = () =>
new Promise(resolve => {
new Promise((resolve) => {
const nextFile = state.diffFiles.find(
file =>
(file) =>
!file.renderIt &&
file.viewer &&
(!isCollapsed(file) || file.viewer.name !== diffViewerModes.text),
......@@ -362,7 +362,7 @@ export const loadMoreLines = ({ commit }, options) => {
params.from_merge_request = true;
return axios.get(endpoint, { params }).then(res => {
return axios.get(endpoint, { params }).then((res) => {
const contextLines = res.data || [];
commit(types.ADD_CONTEXT_LINES, {
......@@ -403,7 +403,7 @@ export const loadCollapsedDiff = ({ commit, getters, state }, file) =>
w: state.showWhitespace ? '0' : '1',
},
})
.then(res => {
.then((res) => {
commit(types.ADD_COLLAPSED_DIFFS, {
file,
data: res.data,
......@@ -426,7 +426,7 @@ export const toggleFileDiscussions = ({ getters, dispatch }, diff) => {
const shouldCloseAll = getters.diffHasAllExpandedDiscussions(diff);
const shouldExpandAll = getters.diffHasAllCollapsedDiscussions(diff);
discussions.forEach(discussion => {
discussions.forEach((discussion) => {
const data = { discussionId: discussion.id };
if (shouldCloseAll) {
......@@ -440,13 +440,13 @@ export const toggleFileDiscussions = ({ getters, dispatch }, diff) => {
export const toggleFileDiscussionWrappers = ({ commit }, diff) => {
const discussionWrappersExpanded = allDiscussionWrappersExpanded(diff);
const lineCodesWithDiscussions = new Set();
const lineHasDiscussion = line => Boolean(line?.discussions.length);
const registerDiscussionLine = line => lineCodesWithDiscussions.add(line.line_code);
const lineHasDiscussion = (line) => Boolean(line?.discussions.length);
const registerDiscussionLine = (line) => lineCodesWithDiscussions.add(line.line_code);
diff[INLINE_DIFF_LINES_KEY].filter(lineHasDiscussion).forEach(registerDiscussionLine);
if (lineCodesWithDiscussions.size) {
Array.from(lineCodesWithDiscussions).forEach(lineCode => {
Array.from(lineCodesWithDiscussions).forEach((lineCode) => {
commit(types.TOGGLE_LINE_DISCUSSIONS, {
fileHash: diff.file_hash,
expanded: !discussionWrappersExpanded,
......@@ -464,8 +464,8 @@ export const saveDiffDiscussion = ({ state, dispatch }, { note, formData }) => {
});
return dispatch('saveNote', postData, { root: true })
.then(result => dispatch('updateDiscussion', result.discussion, { root: true }))
.then(discussion => dispatch('assignDiscussionsToDiff', [discussion]))
.then((result) => dispatch('updateDiscussion', result.discussion, { root: true }))
.then((discussion) => dispatch('assignDiscussionsToDiff', [discussion]))
.then(() => dispatch('updateResolvableDiscussionsCounts', null, { root: true }))
.then(() => dispatch('closeDiffFileCommentForm', formData.diffFile.file_hash))
.catch(() => createFlash(s__('MergeRequests|Saving the comment failed')));
......@@ -565,7 +565,7 @@ export const setExpandedDiffLines = ({ commit }, { file, data }) => {
});
commit(types.TOGGLE_DIFF_FILE_RENDERING_MORE, file.file_path);
const idleCb = t => {
const idleCb = (t) => {
const startIndex = index;
while (
......@@ -613,7 +613,7 @@ export const fetchFullDiff = ({ commit, dispatch }, file) =>
.catch(() => dispatch('receiveFullDiffError', file.file_path));
export const toggleFullDiff = ({ dispatch, commit, getters, state }, filePath) => {
const file = state.diffFiles.find(f => f.file_path === filePath);
const file = state.diffFiles.find((f) => f.file_path === filePath);
commit(types.REQUEST_FULL_DIFF, filePath);
......@@ -724,7 +724,7 @@ export const setCurrentDiffFileIdFromNote = ({ commit, state, rootGetters }, not
const fileHash = rootGetters.getDiscussion(note.discussion_id).diff_file?.file_hash;
if (fileHash && state.diffFiles.some(f => f.file_hash === fileHash)) {
if (fileHash && state.diffFiles.some((f) => f.file_hash === fileHash)) {
commit(types.VIEW_DIFF_FILE, fileHash);
}
};
......
......@@ -2,10 +2,10 @@ import { __, n__, sprintf } from '~/locale';
import { getParameterByName, parseBoolean } from '~/lib/utils/common_utils';
import { DIFF_COMPARE_BASE_VERSION_INDEX, DIFF_COMPARE_HEAD_VERSION_INDEX } from '../constants';
export const selectedTargetIndex = state =>
export const selectedTargetIndex = (state) =>
state.startVersion?.version_index || DIFF_COMPARE_BASE_VERSION_INDEX;
export const selectedSourceIndex = state => state.mergeRequestDiff.version_index;
export const selectedSourceIndex = (state) => state.mergeRequestDiff.version_index;
export const diffCompareDropdownTargetVersions = (state, getters) => {
// startVersion only exists if the user has selected a version other
......@@ -40,7 +40,7 @@ export const diffCompareDropdownTargetVersions = (state, getters) => {
selected: isHeadSelected,
};
// Appended properties here are to make the compare_dropdown_layout easier to reason about
const formatVersion = v => {
const formatVersion = (v) => {
return {
href: v.compare_path,
versionName: sprintf(__(`version %{versionIndex}`), { versionIndex: v.version_index }),
......@@ -53,7 +53,7 @@ export const diffCompareDropdownTargetVersions = (state, getters) => {
...state.mergeRequestDiffs.slice(1).map(formatVersion),
baseVersion,
state.mergeRequestDiff.head_version_path && headVersion,
].filter(a => a);
].filter((a) => a);
};
export const diffCompareDropdownSourceVersions = (state, getters) => {
......
......@@ -105,11 +105,11 @@ export default {
},
[types.TOGGLE_LINE_HAS_FORM](state, { lineCode, fileHash, hasForm }) {
const diffFile = state.diffFiles.find(f => f.file_hash === fileHash);
const diffFile = state.diffFiles.find((f) => f.file_hash === fileHash);
if (!diffFile) return;
diffFile[INLINE_DIFF_LINES_KEY].find(l => l.line_code === lineCode).hasForm = hasForm;
diffFile[INLINE_DIFF_LINES_KEY].find((l) => l.line_code === lineCode).hasForm = hasForm;
},
[types.ADD_CONTEXT_LINES](state, options) {
......@@ -125,7 +125,7 @@ export default {
bottom,
isExpandDown,
nextLineNumbers,
).map(line => {
).map((line) => {
const lineCode =
line.type === 'match'
? `${fileHash}_${line.meta_data.old_pos}_${line.meta_data.new_pos}_match`
......@@ -149,8 +149,8 @@ export default {
[types.ADD_COLLAPSED_DIFFS](state, { file, data }) {
const files = prepareDiffData({ diff: data });
const [newFileData] = files.filter(f => f.file_hash === file.file_hash);
const selectedFile = state.diffFiles.find(f => f.file_hash === file.file_hash);
const [newFileData] = files.filter((f) => f.file_hash === file.file_hash);
const selectedFile = state.diffFiles.find((f) => f.file_hash === file.file_hash);
Object.assign(selectedFile, { ...newFileData });
},
......@@ -159,9 +159,9 @@ export default {
const discussionLineCodes = [discussion.line_code, ...(discussion.line_codes || [])];
const fileHash = discussion.diff_file.file_hash;
const lineCheck = line =>
const lineCheck = (line) =>
discussionLineCodes.some(
discussionLineCode =>
(discussionLineCode) =>
line.line_code === discussionLineCode &&
isDiscussionApplicableToLine({
discussion,
......@@ -179,26 +179,26 @@ export default {
: [],
});
const setDiscussionsExpanded = line => {
const setDiscussionsExpanded = (line) => {
const isLineNoteTargeted =
line.discussions &&
line.discussions.some(
disc => disc.notes && disc.notes.find(note => hash === `note_${note.id}`),
(disc) => disc.notes && disc.notes.find((note) => hash === `note_${note.id}`),
);
return {
...line,
discussionsExpanded:
line.discussions && line.discussions.length
? line.discussions.some(disc => !disc.resolved) || isLineNoteTargeted
? line.discussions.some((disc) => !disc.resolved) || isLineNoteTargeted
: false,
};
};
state.diffFiles.forEach(file => {
state.diffFiles.forEach((file) => {
if (file.file_hash === fileHash) {
if (file[INLINE_DIFF_LINES_KEY].length) {
file[INLINE_DIFF_LINES_KEY].forEach(line => {
file[INLINE_DIFF_LINES_KEY].forEach((line) => {
Object.assign(
line,
setDiscussionsExpanded(lineCheck(line) ? mapDiscussions(line) : line),
......@@ -208,7 +208,7 @@ export default {
if (!file[INLINE_DIFF_LINES_KEY].length) {
const newDiscussions = (file.discussions || [])
.filter(d => d.id !== discussion.id)
.filter((d) => d.id !== discussion.id)
.concat(discussion);
Object.assign(file, {
......@@ -220,26 +220,26 @@ export default {
},
[types.REMOVE_LINE_DISCUSSIONS_FOR_FILE](state, { fileHash, lineCode }) {
const selectedFile = state.diffFiles.find(f => f.file_hash === fileHash);
const selectedFile = state.diffFiles.find((f) => f.file_hash === fileHash);
if (selectedFile) {
updateLineInFile(selectedFile, lineCode, line =>
updateLineInFile(selectedFile, lineCode, (line) =>
Object.assign(line, {
discussions: line.discussions.filter(discussion => discussion.notes.length),
discussions: line.discussions.filter((discussion) => discussion.notes.length),
}),
);
if (selectedFile.discussions && selectedFile.discussions.length) {
selectedFile.discussions = selectedFile.discussions.filter(
discussion => discussion.notes.length,
(discussion) => discussion.notes.length,
);
}
}
},
[types.TOGGLE_LINE_DISCUSSIONS](state, { fileHash, lineCode, expanded }) {
const selectedFile = state.diffFiles.find(f => f.file_hash === fileHash);
const selectedFile = state.diffFiles.find((f) => f.file_hash === fileHash);
updateLineInFile(selectedFile, lineCode, line => {
updateLineInFile(selectedFile, lineCode, (line) => {
Object.assign(line, { discussionsExpanded: expanded });
});
},
......@@ -262,7 +262,7 @@ export default {
[types.UPDATE_DIFF_FILE_COMMENT_FORM](state, formData) {
const { fileHash } = formData;
state.commentForms = state.commentForms.map(form => {
state.commentForms = state.commentForms.map((form) => {
if (form.fileHash === fileHash) {
return {
...formData,
......@@ -273,7 +273,7 @@ export default {
});
},
[types.CLOSE_DIFF_FILE_COMMENT_FORM](state, fileHash) {
state.commentForms = state.commentForms.filter(form => form.fileHash !== fileHash);
state.commentForms = state.commentForms.filter((form) => form.fileHash !== fileHash);
},
[types.SET_HIGHLIGHTED_ROW](state, lineCode) {
state.highlightedRow = lineCode;
......@@ -313,7 +313,7 @@ export default {
state,
{ filePath, collapsed, trigger = DIFF_FILE_AUTOMATIC_COLLAPSE },
) {
const file = state.diffFiles.find(f => f.file_path === filePath);
const file = state.diffFiles.find((f) => f.file_path === filePath);
if (file && file.viewer) {
if (trigger === DIFF_FILE_MANUAL_COLLAPSE) {
......@@ -330,17 +330,17 @@ export default {
}
},
[types.SET_CURRENT_VIEW_DIFF_FILE_LINES](state, { filePath, lines }) {
const file = state.diffFiles.find(f => f.file_path === filePath);
const file = state.diffFiles.find((f) => f.file_path === filePath);
file[INLINE_DIFF_LINES_KEY] = lines;
},
[types.ADD_CURRENT_VIEW_DIFF_FILE_LINES](state, { filePath, line }) {
const file = state.diffFiles.find(f => f.file_path === filePath);
const file = state.diffFiles.find((f) => f.file_path === filePath);
file[INLINE_DIFF_LINES_KEY].push(line);
},
[types.TOGGLE_DIFF_FILE_RENDERING_MORE](state, filePath) {
const file = state.diffFiles.find(f => f.file_path === filePath);
const file = state.diffFiles.find((f) => f.file_path === filePath);
file.renderingLines = !file.renderingLines;
},
......
......@@ -23,15 +23,15 @@ import {
} from '../constants';
import { prepareRawDiffFile } from '../utils/diff_file';
export const isAdded = line => ['new', 'new-nonewline'].includes(line.type);
export const isRemoved = line => ['old', 'old-nonewline'].includes(line.type);
export const isUnchanged = line => !line.type;
export const isMeta = line => ['match', 'new-nonewline', 'old-nonewline'].includes(line.type);
export const isConflictMarker = line =>
export const isAdded = (line) => ['new', 'new-nonewline'].includes(line.type);
export const isRemoved = (line) => ['old', 'old-nonewline'].includes(line.type);
export const isUnchanged = (line) => !line.type;
export const isMeta = (line) => ['match', 'new-nonewline', 'old-nonewline'].includes(line.type);
export const isConflictMarker = (line) =>
[CONFLICT_MARKER_OUR, CONFLICT_MARKER_THEIR].includes(line.type);
export const isConflictSeperator = line => line.type === CONFLICT_MARKER;
export const isConflictOur = line => line.type === CONFLICT_OUR;
export const isConflictTheir = line => line.type === CONFLICT_THEIR;
export const isConflictSeperator = (line) => line.type === CONFLICT_MARKER;
export const isConflictOur = (line) => line.type === CONFLICT_OUR;
export const isConflictTheir = (line) => line.type === CONFLICT_THEIR;
/**
* Pass in the inline diff lines array which gets converted
......@@ -117,10 +117,10 @@ export const parallelizeDiffLines = (diffLines, inline) => {
};
export function findDiffFile(files, match, matchKey = 'file_hash') {
return files.find(file => file[matchKey] === match);
return files.find((file) => file[matchKey] === match);
}
export const getReversePosition = linePosition => {
export const getReversePosition = (linePosition) => {
if (linePosition === LINE_POSITION_RIGHT) {
return LINE_POSITION_LEFT;
}
......@@ -197,7 +197,7 @@ export const findIndexInInlineLines = (lines, lineNumbers) => {
const { oldLineNumber, newLineNumber } = lineNumbers;
return lines.findIndex(
line => line.old_line === oldLineNumber && line.new_line === newLineNumber,
(line) => line.old_line === oldLineNumber && line.new_line === newLineNumber,
);
};
......@@ -370,7 +370,7 @@ export function prepareLineForRenamedFile({ line, diffFile, index = 0 }) {
function prepareDiffFileLines(file) {
const inlineLines = file[INLINE_DIFF_LINES_KEY];
inlineLines.forEach(line => prepareLine(line, file)); // WARNING: In-Place Mutations!
inlineLines.forEach((line) => prepareLine(line, file)); // WARNING: In-Place Mutations!
Object.assign(file, {
inlineLinesCount: inlineLines.length,
......@@ -424,7 +424,7 @@ export function getDiffPositionByLineCode(diffFiles) {
let lines = [];
lines = diffFiles.reduce((acc, diffFile) => {
diffFile[INLINE_DIFF_LINES_KEY].forEach(line => {
diffFile[INLINE_DIFF_LINES_KEY].forEach((line) => {
acc.push({ file: diffFile, line });
});
......@@ -471,21 +471,21 @@ export function isDiscussionApplicableToLine({ discussion, diffPosition, latestD
...(discussion.positions || []),
];
const removeLineRange = position => {
const removeLineRange = (position) => {
const { line_range: pNotUsed, ...positionNoLineRange } = position;
return positionNoLineRange;
};
return discussionPositions
.map(removeLineRange)
.some(position => isEqual(position, diffPositionCopy));
.some((position) => isEqual(position, diffPositionCopy));
}
// eslint-disable-next-line
return latestDiff && discussion.active && line_code === discussion.line_code;
}
export const getLowestSingleFolder = folder => {
export const getLowestSingleFolder = (folder) => {
const getFolder = (blob, start = []) =>
blob.tree.reduce(
(acc, file) => {
......@@ -517,8 +517,8 @@ export const getLowestSingleFolder = folder => {
};
};
export const flattenTree = tree => {
const flatten = blobTree =>
export const flattenTree = (tree) => {
const flatten = (blobTree) =>
blobTree.reduce((acc, file) => {
const blob = file;
let treeToFlatten = blob.tree;
......@@ -540,7 +540,7 @@ export const flattenTree = tree => {
return flatten(tree);
};
export const generateTreeList = files => {
export const generateTreeList = (files) => {
const { treeEntries, tree } = files.reduce(
(acc, file) => {
const split = file.new_path.split('/');
......@@ -590,8 +590,8 @@ export const generateTreeList = files => {
return { treeEntries, tree: flattenTree(tree) };
};
export const getDiffMode = diffFile => {
const diffModeKey = Object.keys(diffModes).find(key => diffFile[`${key}_file`]);
export const getDiffMode = (diffFile) => {
const diffModeKey = Object.keys(diffModes).find((key) => diffFile[`${key}_file`]);
return (
diffModes[diffModeKey] ||
(diffFile.viewer &&
......@@ -639,11 +639,11 @@ export const convertExpandLines = ({
return lines;
};
export const idleCallback = cb => requestIdleCallback(cb);
export const idleCallback = (cb) => requestIdleCallback(cb);
function getLinesFromFileByLineCode(file, lineCode) {
const inlineLines = file[INLINE_DIFF_LINES_KEY];
const matchesCode = line => line.line_code === lineCode;
const matchesCode = (line) => line.line_code === lineCode;
return inlineLines.filter(matchesCode);
}
......@@ -652,15 +652,15 @@ export const updateLineInFile = (selectedFile, lineCode, updateFn) => {
getLinesFromFileByLineCode(selectedFile, lineCode).forEach(updateFn);
};
export const allDiscussionWrappersExpanded = diff => {
export const allDiscussionWrappersExpanded = (diff) => {
let discussionsExpanded = true;
const changeExpandedResult = line => {
const changeExpandedResult = (line) => {
if (line && line.discussions.length) {
discussionsExpanded = discussionsExpanded && line.discussionsExpanded;
}
};
diff[INLINE_DIFF_LINES_KEY].forEach(line => {
diff[INLINE_DIFF_LINES_KEY].forEach((line) => {
changeExpandedResult(line);
});
......
......@@ -8,8 +8,8 @@ import { getDerivedMergeRequestInformation } from './merge_request';
import { uuids } from './uuids';
function fileSymlinkInformation(file, fileList) {
const duplicates = fileList.filter(iteratedFile => iteratedFile.file_hash === file.file_hash);
const includesSymlink = duplicates.some(iteratedFile => {
const duplicates = fileList.filter((iteratedFile) => iteratedFile.file_hash === file.file_hash);
const includesSymlink = duplicates.some((iteratedFile) => {
return [iteratedFile.a_mode, iteratedFile.b_mode].includes(DIFF_FILE_SYMLINK_MODE);
});
const brokenSymlinkScenario = duplicates.length > 1 && includesSymlink;
......
......@@ -2,7 +2,7 @@ import { sortTree } from '~/ide/stores/utils';
import { generateTreeList } from '../store/utils';
// eslint-disable-next-line no-restricted-globals
self.addEventListener('message', e => {
self.addEventListener('message', (e) => {
const { data } = e;
if (data === undefined) {
......
......@@ -6,7 +6,7 @@ class DirtySubmitCollection {
this.dirtySubmits = [];
this.forms.forEach(form => this.dirtySubmits.push(new DirtySubmitForm(form)));
this.forms.forEach((form) => this.dirtySubmits.push(new DirtySubmitForm(form)));
}
}
......
......@@ -22,10 +22,10 @@ class DirtySubmitForm {
registerListeners() {
const getThrottledHandlerForInput = memoize(() =>
throttle(event => this.updateDirtyInput(event), DirtySubmitForm.THROTTLE_DURATION),
throttle((event) => this.updateDirtyInput(event), DirtySubmitForm.THROTTLE_DURATION),
);
const throttledUpdateDirtyInput = event => {
const throttledUpdateDirtyInput = (event) => {
const throttledHandler = getThrottledHandlerForInput(event.target.name);
throttledHandler(event);
};
......@@ -33,7 +33,7 @@ class DirtySubmitForm {
this.form.addEventListener('input', throttledUpdateDirtyInput);
this.form.addEventListener('change', throttledUpdateDirtyInput);
$(this.form).on('change.select2', throttledUpdateDirtyInput);
this.form.addEventListener('submit', event => this.formSubmit(event));
this.form.addEventListener('submit', (event) => this.formSubmit(event));
}
updateDirtyInput(event) {
......@@ -58,7 +58,7 @@ class DirtySubmitForm {
toggleSubmission() {
this.isDisabled = this.dirtyInputs.length === 0;
this.submits.forEach(element => {
this.submits.forEach((element) => {
element.disabled = this.isDisabled;
});
}
......
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