Commit e7d50054 authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 31 files - 16 of 73

Part of our prettier migration; changing the arrow-parens style.
parent 00827a74
...@@ -8,7 +8,7 @@ const plugins = () => [ ...@@ -8,7 +8,7 @@ const plugins = () => [
export default (store, el) => { export default (store, el) => {
// plugins is actually an array of plugin factories, so we have to create first then call // plugins is actually an array of plugin factories, so we have to create first then call
plugins().forEach(plugin => plugin(el)(store)); plugins().forEach((plugin) => plugin(el)(store));
return store; return store;
}; };
...@@ -9,19 +9,19 @@ import { ...@@ -9,19 +9,19 @@ import {
import { addNumericSuffix } from '~/ide/utils'; import { addNumericSuffix } from '~/ide/utils';
import Api from '~/api'; import Api from '~/api';
export const activeFile = state => state.openFiles.find(file => file.active) || null; export const activeFile = (state) => state.openFiles.find((file) => file.active) || null;
export const addedFiles = state => state.changedFiles.filter(f => f.tempFile); export const addedFiles = (state) => state.changedFiles.filter((f) => f.tempFile);
export const modifiedFiles = state => state.changedFiles.filter(f => !f.tempFile); export const modifiedFiles = (state) => state.changedFiles.filter((f) => !f.tempFile);
export const projectsWithTrees = state => export const projectsWithTrees = (state) =>
Object.keys(state.projects).map(projectId => { Object.keys(state.projects).map((projectId) => {
const project = state.projects[projectId]; const project = state.projects[projectId];
return { return {
...project, ...project,
branches: Object.keys(project.branches).map(branchId => { branches: Object.keys(project.branches).map((branchId) => {
const branch = project.branches[branchId]; const branch = project.branches[branchId];
return { return {
...@@ -32,7 +32,7 @@ export const projectsWithTrees = state => ...@@ -32,7 +32,7 @@ export const projectsWithTrees = state =>
}; };
}); });
export const currentMergeRequest = state => { export const currentMergeRequest = (state) => {
if ( if (
state.projects[state.currentProjectId] && state.projects[state.currentProjectId] &&
state.projects[state.currentProjectId].mergeRequests state.projects[state.currentProjectId].mergeRequests
...@@ -42,19 +42,19 @@ export const currentMergeRequest = state => { ...@@ -42,19 +42,19 @@ export const currentMergeRequest = state => {
return null; return null;
}; };
export const findProject = state => projectId => state.projects[projectId]; export const findProject = (state) => (projectId) => state.projects[projectId];
export const currentProject = (state, getters) => getters.findProject(state.currentProjectId); export const currentProject = (state, getters) => getters.findProject(state.currentProjectId);
export const emptyRepo = state => export const emptyRepo = (state) =>
state.projects[state.currentProjectId] && state.projects[state.currentProjectId].empty_repo; state.projects[state.currentProjectId] && state.projects[state.currentProjectId].empty_repo;
export const currentTree = state => export const currentTree = (state) =>
state.trees[`${state.currentProjectId}/${state.currentBranchId}`]; state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
export const hasMergeRequest = state => Boolean(state.currentMergeRequestId); export const hasMergeRequest = (state) => Boolean(state.currentMergeRequestId);
export const allBlobs = state => export const allBlobs = (state) =>
Object.keys(state.entries) Object.keys(state.entries)
.reduce((acc, key) => { .reduce((acc, key) => {
const entry = state.entries[key]; const entry = state.entries[key];
...@@ -67,35 +67,35 @@ export const allBlobs = state => ...@@ -67,35 +67,35 @@ export const allBlobs = state =>
}, []) }, [])
.sort((a, b) => b.lastOpenedAt - a.lastOpenedAt); .sort((a, b) => b.lastOpenedAt - a.lastOpenedAt);
export const getChangedFile = state => path => state.changedFiles.find(f => f.path === path); export const getChangedFile = (state) => (path) => state.changedFiles.find((f) => f.path === path);
export const getStagedFile = state => path => state.stagedFiles.find(f => f.path === path); export const getStagedFile = (state) => (path) => state.stagedFiles.find((f) => f.path === path);
export const getOpenFile = state => path => state.openFiles.find(f => f.path === path); export const getOpenFile = (state) => (path) => state.openFiles.find((f) => f.path === path);
export const lastOpenedFile = state => export const lastOpenedFile = (state) =>
[...state.changedFiles, ...state.stagedFiles].sort((a, b) => b.lastOpenedAt - a.lastOpenedAt)[0]; [...state.changedFiles, ...state.stagedFiles].sort((a, b) => b.lastOpenedAt - a.lastOpenedAt)[0];
export const isEditModeActive = state => state.currentActivityView === leftSidebarViews.edit.name; export const isEditModeActive = (state) => state.currentActivityView === leftSidebarViews.edit.name;
export const isCommitModeActive = state => export const isCommitModeActive = (state) =>
state.currentActivityView === leftSidebarViews.commit.name; state.currentActivityView === leftSidebarViews.commit.name;
export const isReviewModeActive = state => export const isReviewModeActive = (state) =>
state.currentActivityView === leftSidebarViews.review.name; state.currentActivityView === leftSidebarViews.review.name;
export const someUncommittedChanges = state => export const someUncommittedChanges = (state) =>
Boolean(state.changedFiles.length || state.stagedFiles.length); Boolean(state.changedFiles.length || state.stagedFiles.length);
export const getChangesInFolder = state => path => { export const getChangesInFolder = (state) => (path) => {
const changedFilesCount = state.changedFiles.filter(f => filePathMatches(f.path, path)).length; const changedFilesCount = state.changedFiles.filter((f) => filePathMatches(f.path, path)).length;
const stagedFilesCount = state.stagedFiles.filter( const stagedFilesCount = state.stagedFiles.filter(
f => filePathMatches(f.path, path) && !getChangedFile(state)(f.path), (f) => filePathMatches(f.path, path) && !getChangedFile(state)(f.path),
).length; ).length;
return changedFilesCount + stagedFilesCount; return changedFilesCount + stagedFilesCount;
}; };
export const getUnstagedFilesCountForPath = state => path => export const getUnstagedFilesCountForPath = (state) => (path) =>
getChangesCountForFiles(state.changedFiles, path); getChangesCountForFiles(state.changedFiles, path);
export const getStagedFilesCountForPath = state => path => export const getStagedFilesCountForPath = (state) => (path) =>
getChangesCountForFiles(state.stagedFiles, path); getChangesCountForFiles(state.stagedFiles, path);
export const lastCommit = (state, getters) => { export const lastCommit = (state, getters) => {
...@@ -115,7 +115,7 @@ export const currentBranch = (state, getters) => ...@@ -115,7 +115,7 @@ export const currentBranch = (state, getters) =>
export const branchName = (_state, getters) => getters.currentBranch && getters.currentBranch.name; export const branchName = (_state, getters) => getters.currentBranch && getters.currentBranch.name;
export const packageJson = state => state.entries[packageJsonPath]; export const packageJson = (state) => state.entries[packageJsonPath];
export const isOnDefaultBranch = (_state, getters) => export const isOnDefaultBranch = (_state, getters) =>
getters.currentProject && getters.currentProject.default_branch === getters.branchName; getters.currentProject && getters.currentProject.default_branch === getters.branchName;
...@@ -124,14 +124,14 @@ export const canPushToBranch = (_state, getters) => { ...@@ -124,14 +124,14 @@ export const canPushToBranch = (_state, getters) => {
return Boolean(getters.currentBranch ? getters.currentBranch.can_push : getters.canPushCode); return Boolean(getters.currentBranch ? getters.currentBranch.can_push : getters.canPushCode);
}; };
export const isFileDeletedAndReadded = (state, getters) => path => { export const isFileDeletedAndReadded = (state, getters) => (path) => {
const stagedFile = getters.getStagedFile(path); const stagedFile = getters.getStagedFile(path);
const file = state.entries[path]; const file = state.entries[path];
return Boolean(stagedFile && stagedFile.deleted && file.tempFile); return Boolean(stagedFile && stagedFile.deleted && file.tempFile);
}; };
// checks if any diff exists in the staged or unstaged changes for this path // checks if any diff exists in the staged or unstaged changes for this path
export const getDiffInfo = (state, getters) => path => { export const getDiffInfo = (state, getters) => (path) => {
const stagedFile = getters.getStagedFile(path); const stagedFile = getters.getStagedFile(path);
const file = state.entries[path]; const file = state.entries[path];
const renamed = file.prevPath ? file.path !== file.prevPath : false; const renamed = file.prevPath ? file.path !== file.prevPath : false;
...@@ -149,7 +149,7 @@ export const getDiffInfo = (state, getters) => path => { ...@@ -149,7 +149,7 @@ export const getDiffInfo = (state, getters) => path => {
}; };
}; };
export const findProjectPermissions = (state, getters) => projectId => export const findProjectPermissions = (state, getters) => (projectId) =>
getters.findProject(projectId)?.userPermissions || {}; getters.findProject(projectId)?.userPermissions || {};
export const canReadMergeRequests = (state, getters) => export const canReadMergeRequests = (state, getters) =>
...@@ -161,10 +161,10 @@ export const canCreateMergeRequests = (state, getters) => ...@@ -161,10 +161,10 @@ export const canCreateMergeRequests = (state, getters) =>
export const canPushCode = (state, getters) => export const canPushCode = (state, getters) =>
Boolean(getters.findProjectPermissions(state.currentProjectId)[PERMISSION_PUSH_CODE]); Boolean(getters.findProjectPermissions(state.currentProjectId)[PERMISSION_PUSH_CODE]);
export const entryExists = state => path => export const entryExists = (state) => (path) =>
Boolean(state.entries[path] && !state.entries[path].deleted); Boolean(state.entries[path] && !state.entries[path].deleted);
export const getAvailableFileName = (state, getters) => path => { export const getAvailableFileName = (state, getters) => (path) => {
let newPath = path; let newPath = path;
while (getters.entryExists(newPath)) { while (getters.entryExists(newPath)) {
...@@ -174,10 +174,10 @@ export const getAvailableFileName = (state, getters) => path => { ...@@ -174,10 +174,10 @@ export const getAvailableFileName = (state, getters) => path => {
return newPath; return newPath;
}; };
export const getUrlForPath = state => path => export const getUrlForPath = (state) => (path) =>
`/project/${state.currentProjectId}/tree/${state.currentBranchId}/-/${path}/`; `/project/${state.currentProjectId}/tree/${state.currentBranchId}/-/${path}/`;
export const getJsonSchemaForPath = (state, getters) => path => { export const getJsonSchemaForPath = (state, getters) => (path) => {
const [namespace, ...project] = state.currentProjectId.split('/'); const [namespace, ...project] = state.currentProjectId.split('/');
return { return {
uri: uri:
......
...@@ -8,7 +8,7 @@ export const receiveBranchesError = ({ commit, dispatch }, { search }) => { ...@@ -8,7 +8,7 @@ export const receiveBranchesError = ({ commit, dispatch }, { search }) => {
'setErrorMessage', 'setErrorMessage',
{ {
text: __('Error loading branches.'), text: __('Error loading branches.'),
action: payload => action: (payload) =>
dispatch('fetchBranches', payload).then(() => dispatch('fetchBranches', payload).then(() =>
dispatch('setErrorMessage', null, { root: true }), dispatch('setErrorMessage', null, { root: true }),
), ),
......
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
}, },
[types.RECEIVE_BRANCHES_SUCCESS](state, data) { [types.RECEIVE_BRANCHES_SUCCESS](state, data) {
state.isLoading = false; state.isLoading = false;
state.branches = data.map(branch => ({ state.branches = data.map((branch) => ({
name: branch.name, name: branch.name,
committedDate: branch.commit.committed_date, committedDate: branch.commit.committed_date,
})); }));
......
...@@ -78,8 +78,8 @@ export const updateFilesAfterCommit = ({ commit, dispatch, rootState, rootGetter ...@@ -78,8 +78,8 @@ export const updateFilesAfterCommit = ({ commit, dispatch, rootState, rootGetter
{ root: true }, { root: true },
); );
rootState.stagedFiles.forEach(file => { rootState.stagedFiles.forEach((file) => {
const changedFile = rootState.changedFiles.find(f => f.path === file.path); const changedFile = rootState.changedFiles.find((f) => f.path === file.path);
commit( commit(
rootTypes.UPDATE_FILE_AFTER_COMMIT, rootTypes.UPDATE_FILE_AFTER_COMMIT,
...@@ -133,7 +133,7 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo ...@@ -133,7 +133,7 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
return service.commit(rootState.currentProjectId, payload); return service.commit(rootState.currentProjectId, payload);
}) })
.catch(e => { .catch((e) => {
commit(types.UPDATE_LOADING, false); commit(types.UPDATE_LOADING, false);
commit(types.SET_ERROR, parseCommitError(e)); commit(types.SET_ERROR, parseCommitError(e));
...@@ -193,12 +193,12 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo ...@@ -193,12 +193,12 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
}, },
{ root: true }, { root: true },
) )
.then(changeViewer => { .then((changeViewer) => {
if (changeViewer) { if (changeViewer) {
dispatch('updateViewer', 'diff', { root: true }); dispatch('updateViewer', 'diff', { root: true });
} }
}) })
.catch(e => { .catch((e) => {
throw e; throw e;
}); });
} else { } else {
......
...@@ -11,7 +11,7 @@ const createTranslatedTextForFiles = (files, text) => { ...@@ -11,7 +11,7 @@ const createTranslatedTextForFiles = (files, text) => {
}); });
}; };
export const discardDraftButtonDisabled = state => export const discardDraftButtonDisabled = (state) =>
state.commitMessage === '' || state.submitCommitLoading; state.commitMessage === '' || state.submitCommitLoading;
// Note: If changing the structure of the placeholder branch name, please also // Note: If changing the structure of the placeholder branch name, please also
...@@ -37,18 +37,18 @@ export const preBuiltCommitMessage = (state, _, rootState) => { ...@@ -37,18 +37,18 @@ export const preBuiltCommitMessage = (state, _, rootState) => {
if (state.commitMessage) return state.commitMessage; if (state.commitMessage) return state.commitMessage;
const files = rootState.stagedFiles.length ? rootState.stagedFiles : rootState.changedFiles; const files = rootState.stagedFiles.length ? rootState.stagedFiles : rootState.changedFiles;
const modifiedFiles = files.filter(f => !f.deleted); const modifiedFiles = files.filter((f) => !f.deleted);
const deletedFiles = files.filter(f => f.deleted); const deletedFiles = files.filter((f) => f.deleted);
return [ return [
createTranslatedTextForFiles(modifiedFiles, __('Update')), createTranslatedTextForFiles(modifiedFiles, __('Update')),
createTranslatedTextForFiles(deletedFiles, __('Deleted')), createTranslatedTextForFiles(deletedFiles, __('Deleted')),
] ]
.filter(t => t) .filter((t) => t)
.join('\n'); .join('\n');
}; };
export const isCreatingNewBranch = state => state.commitAction === consts.COMMIT_TO_NEW_BRANCH; export const isCreatingNewBranch = (state) => state.commitAction === consts.COMMIT_TO_NEW_BRANCH;
export const shouldHideNewMrOption = (_state, getters, _rootState, rootGetters) => export const shouldHideNewMrOption = (_state, getters, _rootState, rootGetters) =>
!getters.isCreatingNewBranch && !getters.isCreatingNewBranch &&
......
import eventHub from '~/ide/eventhub'; import eventHub from '~/ide/eventhub';
import { commitActionTypes } from '~/ide/constants'; import { commitActionTypes } from '~/ide/constants';
const removeUnusedFileEditors = store => { const removeUnusedFileEditors = (store) => {
Object.keys(store.state.editor.fileEditors) Object.keys(store.state.editor.fileEditors)
.filter(path => !store.state.entries[path]) .filter((path) => !store.state.entries[path])
.forEach(path => store.dispatch('editor/removeFileEditor', path)); .forEach((path) => store.dispatch('editor/removeFileEditor', path));
}; };
export const setupFileEditorsSync = store => { export const setupFileEditorsSync = (store) => {
eventHub.$on('ide.files.change', ({ type, ...payload } = {}) => { eventHub.$on('ide.files.change', ({ type, ...payload } = {}) => {
if (type === commitActionTypes.move) { if (type === commitActionTypes.move) {
store.dispatch('editor/renameFileEditor', payload); store.dispatch('editor/renameFileEditor', payload);
......
...@@ -68,7 +68,7 @@ export const receiveTemplateError = ({ dispatch }, template) => { ...@@ -68,7 +68,7 @@ export const receiveTemplateError = ({ dispatch }, template) => {
'setErrorMessage', 'setErrorMessage',
{ {
text: __('Error loading template.'), text: __('Error loading template.'),
action: payload => action: (payload) =>
dispatch('fetchTemplateTypes', payload).then(() => dispatch('fetchTemplateTypes', payload).then(() =>
dispatch('setErrorMessage', null, { root: true }), dispatch('setErrorMessage', null, { root: true }),
), ),
......
...@@ -24,6 +24,6 @@ export const templateTypes = () => [ ...@@ -24,6 +24,6 @@ export const templateTypes = () => [
}, },
]; ];
export const showFileTemplatesBar = (_, getters, rootState) => name => export const showFileTemplatesBar = (_, getters, rootState) => (name) =>
getters.templateTypes.find(t => t.name === name) && getters.templateTypes.find((t) => t.name === name) &&
rootState.currentActivityView === leftSidebarViews.edit.name; rootState.currentActivityView === leftSidebarViews.edit.name;
...@@ -9,7 +9,7 @@ export const receiveMergeRequestsError = ({ commit, dispatch }, { type, search } ...@@ -9,7 +9,7 @@ export const receiveMergeRequestsError = ({ commit, dispatch }, { type, search }
'setErrorMessage', 'setErrorMessage',
{ {
text: __('Error loading merge requests.'), text: __('Error loading merge requests.'),
action: payload => action: (payload) =>
dispatch('fetchMergeRequests', payload).then(() => dispatch('fetchMergeRequests', payload).then(() =>
dispatch('setErrorMessage', null, { root: true }), dispatch('setErrorMessage', null, { root: true }),
), ),
......
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
}, },
[types.RECEIVE_MERGE_REQUESTS_SUCCESS](state, data) { [types.RECEIVE_MERGE_REQUESTS_SUCCESS](state, data) {
state.isLoading = false; state.isLoading = false;
state.mergeRequests = data.map(mergeRequest => ({ state.mergeRequests = data.map((mergeRequest) => ({
id: mergeRequest.id, id: mergeRequest.id,
iid: mergeRequest.iid, iid: mergeRequest.iid,
title: mergeRequest.title, title: mergeRequest.title,
......
export const isAliveView = state => view => export const isAliveView = (state) => (view) =>
state.keepAliveViews[view] || (state.isOpen && state.currentView === view); state.keepAliveViews[view] || (state.isOpen && state.currentView === view);
...@@ -47,7 +47,7 @@ export const receiveLatestPipelineSuccess = ({ rootGetters, commit }, { pipeline ...@@ -47,7 +47,7 @@ export const receiveLatestPipelineSuccess = ({ rootGetters, commit }, { pipeline
if (pipelines && pipelines.length) { if (pipelines && pipelines.length) {
const lastCommitHash = rootGetters.lastCommit && rootGetters.lastCommit.id; const lastCommitHash = rootGetters.lastCommit && rootGetters.lastCommit.id;
lastCommitPipeline = pipelines.find(pipeline => pipeline.commit.id === lastCommitHash); lastCommitPipeline = pipelines.find((pipeline) => pipeline.commit.id === lastCommitHash);
} }
commit(types.RECEIVE_LASTEST_PIPELINE_SUCCESS, lastCommitPipeline); commit(types.RECEIVE_LASTEST_PIPELINE_SUCCESS, lastCommitPipeline);
...@@ -63,7 +63,7 @@ export const fetchLatestPipeline = ({ dispatch, rootGetters }) => { ...@@ -63,7 +63,7 @@ export const fetchLatestPipeline = ({ dispatch, rootGetters }) => {
method: 'lastCommitPipelines', method: 'lastCommitPipelines',
data: { getters: rootGetters }, data: { getters: rootGetters },
successCallback: ({ data }) => dispatch('receiveLatestPipelineSuccess', data), successCallback: ({ data }) => dispatch('receiveLatestPipelineSuccess', data),
errorCallback: err => dispatch('receiveLatestPipelineError', err), errorCallback: (err) => dispatch('receiveLatestPipelineError', err),
}); });
if (!Visibility.hidden()) { if (!Visibility.hidden()) {
...@@ -85,7 +85,7 @@ export const receiveJobsError = ({ commit, dispatch }, stage) => { ...@@ -85,7 +85,7 @@ export const receiveJobsError = ({ commit, dispatch }, stage) => {
'setErrorMessage', 'setErrorMessage',
{ {
text: __('An error occurred while loading the pipelines jobs.'), text: __('An error occurred while loading the pipelines jobs.'),
action: payload => action: (payload) =>
dispatch('fetchJobs', payload).then(() => dispatch('fetchJobs', payload).then(() =>
dispatch('setErrorMessage', null, { root: true }), dispatch('setErrorMessage', null, { root: true }),
), ),
......
...@@ -23,7 +23,7 @@ export default { ...@@ -23,7 +23,7 @@ export default {
yamlError: pipeline.yaml_errors, yamlError: pipeline.yaml_errors,
}; };
state.stages = pipeline.details.stages.map((stage, i) => { state.stages = pipeline.details.stages.map((stage, i) => {
const foundStage = state.stages.find(s => s.id === i); const foundStage = state.stages.find((s) => s.id === i);
return { return {
id: i, id: i,
dropdownPath: stage.dropdown_path, dropdownPath: stage.dropdown_path,
...@@ -39,26 +39,26 @@ export default { ...@@ -39,26 +39,26 @@ export default {
} }
}, },
[types.REQUEST_JOBS](state, id) { [types.REQUEST_JOBS](state, id) {
state.stages = state.stages.map(stage => ({ state.stages = state.stages.map((stage) => ({
...stage, ...stage,
isLoading: stage.id === id ? true : stage.isLoading, isLoading: stage.id === id ? true : stage.isLoading,
})); }));
}, },
[types.RECEIVE_JOBS_ERROR](state, id) { [types.RECEIVE_JOBS_ERROR](state, id) {
state.stages = state.stages.map(stage => ({ state.stages = state.stages.map((stage) => ({
...stage, ...stage,
isLoading: stage.id === id ? false : stage.isLoading, isLoading: stage.id === id ? false : stage.isLoading,
})); }));
}, },
[types.RECEIVE_JOBS_SUCCESS](state, { id, data }) { [types.RECEIVE_JOBS_SUCCESS](state, { id, data }) {
state.stages = state.stages.map(stage => ({ state.stages = state.stages.map((stage) => ({
...stage, ...stage,
isLoading: stage.id === id ? false : stage.isLoading, isLoading: stage.id === id ? false : stage.isLoading,
jobs: stage.id === id ? data.latest_statuses.map(normalizeJob) : stage.jobs, jobs: stage.id === id ? data.latest_statuses.map(normalizeJob) : stage.jobs,
})); }));
}, },
[types.TOGGLE_STAGE_COLLAPSE](state, id) { [types.TOGGLE_STAGE_COLLAPSE](state, id) {
state.stages = state.stages.map(stage => ({ state.stages = state.stages.map((stage) => ({
...stage, ...stage,
isCollapsed: stage.id === id ? !stage.isCollapsed : stage.isCollapsed, isCollapsed: stage.id === id ? !stage.isCollapsed : stage.isCollapsed,
})); }));
......
export const normalizeJob = job => ({ export const normalizeJob = (job) => ({
id: job.id, id: job.id,
name: job.name, name: job.name,
status: job.status, status: job.status,
......
...@@ -36,7 +36,7 @@ export const fetchConfigCheck = ({ dispatch, rootState, rootGetters }) => { ...@@ -36,7 +36,7 @@ export const fetchConfigCheck = ({ dispatch, rootState, rootGetters }) => {
.then(() => { .then(() => {
dispatch('receiveConfigCheckSuccess'); dispatch('receiveConfigCheckSuccess');
}) })
.catch(e => { .catch((e) => {
dispatch('receiveConfigCheckError', e); dispatch('receiveConfigCheckError', e);
}); });
}; };
...@@ -92,7 +92,7 @@ export const fetchRunnersCheck = ({ dispatch, rootGetters }, options = {}) => { ...@@ -92,7 +92,7 @@ export const fetchRunnersCheck = ({ dispatch, rootGetters }, options = {}) => {
.then(({ data }) => { .then(({ data }) => {
dispatch('receiveRunnersCheckSuccess', data); dispatch('receiveRunnersCheckSuccess', data);
}) })
.catch(e => { .catch((e) => {
dispatch('receiveRunnersCheckError', e); dispatch('receiveRunnersCheckError', e);
}); });
}; };
...@@ -45,7 +45,7 @@ export const startSession = ({ state, dispatch, rootGetters, rootState }) => { ...@@ -45,7 +45,7 @@ export const startSession = ({ state, dispatch, rootGetters, rootState }) => {
.then(({ data }) => { .then(({ data }) => {
dispatch('receiveStartSessionSuccess', data); dispatch('receiveStartSessionSuccess', data);
}) })
.catch(error => { .catch((error) => {
dispatch('receiveStartSessionError', error); dispatch('receiveStartSessionError', error);
}); });
}; };
...@@ -73,7 +73,7 @@ export const stopSession = ({ state, dispatch }) => { ...@@ -73,7 +73,7 @@ export const stopSession = ({ state, dispatch }) => {
.then(() => { .then(() => {
dispatch('receiveStopSessionSuccess'); dispatch('receiveStopSessionSuccess');
}) })
.catch(err => { .catch((err) => {
dispatch('receiveStopSessionError', err); dispatch('receiveStopSessionError', err);
}); });
}; };
...@@ -103,7 +103,7 @@ export const restartSession = ({ state, dispatch, rootState }) => { ...@@ -103,7 +103,7 @@ export const restartSession = ({ state, dispatch, rootState }) => {
.then(({ data }) => { .then(({ data }) => {
dispatch('receiveStartSessionSuccess', data); dispatch('receiveStartSessionSuccess', data);
}) })
.catch(error => { .catch((error) => {
const responseStatus = error.response && error.response.status; const responseStatus = error.response && error.response.status;
// We may have removed the build, in this case we'll just create a new session // We may have removed the build, in this case we'll just create a new session
if ( if (
......
...@@ -58,7 +58,7 @@ export const fetchSessionStatus = ({ dispatch, state }) => { ...@@ -58,7 +58,7 @@ export const fetchSessionStatus = ({ dispatch, state }) => {
.then(({ data }) => { .then(({ data }) => {
dispatch('receiveSessionStatusSuccess', data); dispatch('receiveSessionStatusSuccess', data);
}) })
.catch(error => { .catch((error) => {
dispatch('receiveSessionStatusError', error); dispatch('receiveSessionStatusError', error);
}); });
}; };
export const allCheck = state => { export const allCheck = (state) => {
const checks = Object.values(state.checks); const checks = Object.values(state.checks);
if (checks.some(check => check.isLoading)) { if (checks.some((check) => check.isLoading)) {
return { isLoading: true }; return { isLoading: true };
} }
const invalidCheck = checks.find(check => !check.isValid); const invalidCheck = checks.find((check) => !check.isValid);
const isValid = !invalidCheck; const isValid = !invalidCheck;
const message = !invalidCheck ? '' : invalidCheck.message; const message = !invalidCheck ? '' : invalidCheck.message;
......
...@@ -46,7 +46,7 @@ export const configCheckError = (status, helpUrl) => { ...@@ -46,7 +46,7 @@ export const configCheckError = (status, helpUrl) => {
return UNEXPECTED_ERROR_CONFIG; return UNEXPECTED_ERROR_CONFIG;
}; };
export const runnersCheckEmpty = helpUrl => export const runnersCheckEmpty = (helpUrl) =>
sprintf( sprintf(
EMPTY_RUNNERS, EMPTY_RUNNERS,
{ {
......
import { STARTING, PENDING, RUNNING } from './constants'; import { STARTING, PENDING, RUNNING } from './constants';
export const isStartingStatus = status => status === STARTING || status === PENDING; export const isStartingStatus = (status) => status === STARTING || status === PENDING;
export const isRunningStatus = status => status === RUNNING; export const isRunningStatus = (status) => status === RUNNING;
export const isEndingStatus = status => !isStartingStatus(status) && !isRunningStatus(status); export const isEndingStatus = (status) => !isStartingStatus(status) && !isRunningStatus(status);
...@@ -9,7 +9,7 @@ export const upload = ({ rootState, commit }) => { ...@@ -9,7 +9,7 @@ export const upload = ({ rootState, commit }) => {
.then(() => { .then(() => {
commit(types.SET_SUCCESS); commit(types.SET_SUCCESS);
}) })
.catch(err => { .catch((err) => {
commit(types.SET_ERROR, err); commit(types.SET_ERROR, err);
}); });
}; };
...@@ -34,7 +34,7 @@ export const start = ({ rootState, commit }) => { ...@@ -34,7 +34,7 @@ export const start = ({ rootState, commit }) => {
.then(() => { .then(() => {
commit(types.SET_SUCCESS); commit(types.SET_SUCCESS);
}) })
.catch(err => { .catch((err) => {
commit(types.SET_ERROR, err); commit(types.SET_ERROR, err);
throw err; throw err;
}); });
......
...@@ -61,7 +61,7 @@ export default { ...@@ -61,7 +61,7 @@ export default {
}); });
} else { } else {
const tree = entry.tree.filter( const tree = entry.tree.filter(
f => foundEntry.tree.find(e => e.path === f.path) === undefined, (f) => foundEntry.tree.find((e) => e.path === f.path) === undefined,
); );
Object.assign(foundEntry, { Object.assign(foundEntry, {
tree: sortTree(foundEntry.tree.concat(tree)), tree: sortTree(foundEntry.tree.concat(tree)),
...@@ -72,7 +72,7 @@ export default { ...@@ -72,7 +72,7 @@ export default {
}, []); }, []);
const currentTree = state.trees[`${state.currentProjectId}/${state.currentBranchId}`]; const currentTree = state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
const foundEntry = currentTree.tree.find(e => e.path === data.treeList[0].path); const foundEntry = currentTree.tree.find((e) => e.path === data.treeList[0].path);
if (!foundEntry) { if (!foundEntry) {
Object.assign(currentTree, { Object.assign(currentTree, {
...@@ -125,7 +125,7 @@ export default { ...@@ -125,7 +125,7 @@ export default {
}); });
}, },
[types.UPDATE_FILE_AFTER_COMMIT](state, { file, lastCommit }) { [types.UPDATE_FILE_AFTER_COMMIT](state, { file, lastCommit }) {
const changedFile = state.changedFiles.find(f => f.path === file.path); const changedFile = state.changedFiles.find((f) => f.path === file.path);
const { prevPath } = file; const { prevPath } = file;
Object.assign(state.entries[file.path], { Object.assign(state.entries[file.path], {
...@@ -172,7 +172,7 @@ export default { ...@@ -172,7 +172,7 @@ export default {
entry.deleted = true; entry.deleted = true;
if (parent) { if (parent) {
parent.tree = parent.tree.filter(f => f.path !== entry.path); parent.tree = parent.tree.filter((f) => f.path !== entry.path);
} }
if (entry.type === 'blob') { if (entry.type === 'blob') {
...@@ -181,8 +181,8 @@ export default { ...@@ -181,8 +181,8 @@ export default {
// changed and staged. Otherwise, we'd need to somehow evaluate the difference between // changed and staged. Otherwise, we'd need to somehow evaluate the difference between
// changed and HEAD. // changed and HEAD.
// https://gitlab.com/gitlab-org/create-stage/-/issues/12669 // https://gitlab.com/gitlab-org/create-stage/-/issues/12669
state.changedFiles = state.changedFiles.filter(f => f.path !== path); state.changedFiles = state.changedFiles.filter((f) => f.path !== path);
state.stagedFiles = state.stagedFiles.filter(f => f.path !== path); state.stagedFiles = state.stagedFiles.filter((f) => f.path !== path);
} else { } else {
state.changedFiles = state.changedFiles.concat(entry); state.changedFiles = state.changedFiles.concat(entry);
} }
......
...@@ -12,7 +12,7 @@ export default { ...@@ -12,7 +12,7 @@ export default {
if (active && !state.entries[path].pending) { if (active && !state.entries[path].pending) {
Object.assign(state, { Object.assign(state, {
openFiles: state.openFiles.map(f => openFiles: state.openFiles.map((f) =>
Object.assign(f, { active: f.pending ? false : f.active }), Object.assign(f, { active: f.pending ? false : f.active }),
), ),
}); });
...@@ -28,21 +28,21 @@ export default { ...@@ -28,21 +28,21 @@ export default {
if (entry.opened) { if (entry.opened) {
Object.assign(state, { Object.assign(state, {
openFiles: state.openFiles.filter(f => f.path !== path).concat(state.entries[path]), openFiles: state.openFiles.filter((f) => f.path !== path).concat(state.entries[path]),
}); });
} else { } else {
Object.assign(state, { Object.assign(state, {
openFiles: state.openFiles.filter(f => f.key !== entry.key), openFiles: state.openFiles.filter((f) => f.key !== entry.key),
}); });
} }
}, },
[types.SET_FILE_DATA](state, { data, file }) { [types.SET_FILE_DATA](state, { data, file }) {
const stateEntry = state.entries[file.path]; const stateEntry = state.entries[file.path];
const stagedFile = state.stagedFiles.find(f => f.path === file.path); const stagedFile = state.stagedFiles.find((f) => f.path === file.path);
const openFile = state.openFiles.find(f => f.path === file.path); const openFile = state.openFiles.find((f) => f.path === file.path);
const changedFile = state.changedFiles.find(f => f.path === file.path); const changedFile = state.changedFiles.find((f) => f.path === file.path);
[stateEntry, stagedFile, openFile, changedFile].forEach(f => { [stateEntry, stagedFile, openFile, changedFile].forEach((f) => {
if (f) { if (f) {
Object.assign( Object.assign(
f, f,
...@@ -57,10 +57,10 @@ export default { ...@@ -57,10 +57,10 @@ export default {
}, },
[types.SET_FILE_RAW_DATA](state, { file, raw, fileDeletedAndReadded = false }) { [types.SET_FILE_RAW_DATA](state, { file, raw, fileDeletedAndReadded = false }) {
const openPendingFile = state.openFiles.find( const openPendingFile = state.openFiles.find(
f => (f) =>
f.path === file.path && f.pending && !(f.tempFile && !f.prevPath && !fileDeletedAndReadded), f.path === file.path && f.pending && !(f.tempFile && !f.prevPath && !fileDeletedAndReadded),
); );
const stagedFile = state.stagedFiles.find(f => f.path === file.path); const stagedFile = state.stagedFiles.find((f) => f.path === file.path);
if (file.tempFile && file.content === '' && !fileDeletedAndReadded) { if (file.tempFile && file.content === '' && !fileDeletedAndReadded) {
Object.assign(state.entries[file.path], { content: raw }); Object.assign(state.entries[file.path], { content: raw });
...@@ -86,7 +86,7 @@ export default { ...@@ -86,7 +86,7 @@ export default {
}); });
}, },
[types.UPDATE_FILE_CONTENT](state, { path, content }) { [types.UPDATE_FILE_CONTENT](state, { path, content }) {
const stagedFile = state.stagedFiles.find(f => f.path === path); const stagedFile = state.stagedFiles.find((f) => f.path === path);
const rawContent = stagedFile ? stagedFile.content : state.entries[path].raw; const rawContent = stagedFile ? stagedFile.content : state.entries[path].raw;
const changed = content !== rawContent; const changed = content !== rawContent;
...@@ -112,7 +112,7 @@ export default { ...@@ -112,7 +112,7 @@ export default {
}); });
}, },
[types.DISCARD_FILE_CHANGES](state, path) { [types.DISCARD_FILE_CHANGES](state, path) {
const stagedFile = state.stagedFiles.find(f => f.path === path); const stagedFile = state.stagedFiles.find((f) => f.path === path);
const entry = state.entries[path]; const entry = state.entries[path];
const { deleted } = entry; const { deleted } = entry;
...@@ -137,14 +137,14 @@ export default { ...@@ -137,14 +137,14 @@ export default {
}, },
[types.REMOVE_FILE_FROM_CHANGED](state, path) { [types.REMOVE_FILE_FROM_CHANGED](state, path) {
Object.assign(state, { Object.assign(state, {
changedFiles: state.changedFiles.filter(f => f.path !== path), changedFiles: state.changedFiles.filter((f) => f.path !== path),
}); });
}, },
[types.STAGE_CHANGE](state, { path, diffInfo }) { [types.STAGE_CHANGE](state, { path, diffInfo }) {
const stagedFile = state.stagedFiles.find(f => f.path === path); const stagedFile = state.stagedFiles.find((f) => f.path === path);
Object.assign(state, { Object.assign(state, {
changedFiles: state.changedFiles.filter(f => f.path !== path), changedFiles: state.changedFiles.filter((f) => f.path !== path),
entries: Object.assign(state.entries, { entries: Object.assign(state.entries, {
[path]: Object.assign(state.entries[path], { [path]: Object.assign(state.entries[path], {
staged: diffInfo.exists, staged: diffInfo.exists,
...@@ -162,12 +162,12 @@ export default { ...@@ -162,12 +162,12 @@ export default {
} }
if (!diffInfo.exists) { if (!diffInfo.exists) {
state.stagedFiles = state.stagedFiles.filter(f => f.path !== path); state.stagedFiles = state.stagedFiles.filter((f) => f.path !== path);
} }
}, },
[types.UNSTAGE_CHANGE](state, { path, diffInfo }) { [types.UNSTAGE_CHANGE](state, { path, diffInfo }) {
const changedFile = state.changedFiles.find(f => f.path === path); const changedFile = state.changedFiles.find((f) => f.path === path);
const stagedFile = state.stagedFiles.find(f => f.path === path); const stagedFile = state.stagedFiles.find((f) => f.path === path);
if (!changedFile && stagedFile) { if (!changedFile && stagedFile) {
Object.assign(state.entries[path], { Object.assign(state.entries[path], {
...@@ -182,11 +182,11 @@ export default { ...@@ -182,11 +182,11 @@ export default {
} }
if (!diffInfo.exists) { if (!diffInfo.exists) {
state.changedFiles = state.changedFiles.filter(f => f.path !== path); state.changedFiles = state.changedFiles.filter((f) => f.path !== path);
} }
Object.assign(state, { Object.assign(state, {
stagedFiles: state.stagedFiles.filter(f => f.path !== path), stagedFiles: state.stagedFiles.filter((f) => f.path !== path),
entries: Object.assign(state.entries, { entries: Object.assign(state.entries, {
[path]: Object.assign(state.entries[path], { [path]: Object.assign(state.entries[path], {
staged: false, staged: false,
...@@ -206,7 +206,7 @@ export default { ...@@ -206,7 +206,7 @@ export default {
state.entries[file.path].opened = false; state.entries[file.path].opened = false;
state.entries[file.path].active = false; state.entries[file.path].active = false;
state.entries[file.path].lastOpenedAt = new Date().getTime(); state.entries[file.path].lastOpenedAt = new Date().getTime();
state.openFiles.forEach(f => state.openFiles.forEach((f) =>
Object.assign(f, { Object.assign(f, {
opened: false, opened: false,
active: false, active: false,
...@@ -224,13 +224,13 @@ export default { ...@@ -224,13 +224,13 @@ export default {
}, },
[types.REMOVE_PENDING_TAB](state, file) { [types.REMOVE_PENDING_TAB](state, file) {
Object.assign(state, { Object.assign(state, {
openFiles: state.openFiles.filter(f => f.key !== file.key), openFiles: state.openFiles.filter((f) => f.key !== file.key),
}); });
}, },
[types.REMOVE_FILE_FROM_STAGED_AND_CHANGED](state, file) { [types.REMOVE_FILE_FROM_STAGED_AND_CHANGED](state, file) {
Object.assign(state, { Object.assign(state, {
changedFiles: state.changedFiles.filter(f => f.key !== file.key), changedFiles: state.changedFiles.filter((f) => f.key !== file.key),
stagedFiles: state.stagedFiles.filter(f => f.key !== file.key), stagedFiles: state.stagedFiles.filter((f) => f.key !== file.key),
}); });
Object.assign(state.entries[file.path], { Object.assign(state.entries[file.path], {
......
...@@ -45,7 +45,7 @@ export default { ...@@ -45,7 +45,7 @@ export default {
? state.entries[entry.parentPath] ? state.entries[entry.parentPath]
: state.trees[`${state.currentProjectId}/${state.currentBranchId}`]; : state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
if (!parent.tree.find(f => f.path === path)) { if (!parent.tree.find((f) => f.path === path)) {
parent.tree = sortTree(parent.tree.concat(entry)); parent.tree = sortTree(parent.tree.concat(entry));
} }
}, },
......
...@@ -11,7 +11,7 @@ function getPathsFromData(el) { ...@@ -11,7 +11,7 @@ function getPathsFromData(el) {
} }
export default function createTerminalPlugin(el) { export default function createTerminalPlugin(el) {
return store => { return (store) => {
store.registerModule('terminal', terminalModule()); store.registerModule('terminal', terminalModule());
store.dispatch('terminal/setPaths', getPathsFromData(el)); store.dispatch('terminal/setPaths', getPathsFromData(el));
......
...@@ -12,7 +12,7 @@ const UPLOAD_DEBOUNCE = 200; ...@@ -12,7 +12,7 @@ const UPLOAD_DEBOUNCE = 200;
* - Listens for file change event to control upload. * - Listens for file change event to control upload.
*/ */
export default function createMirrorPlugin() { export default function createMirrorPlugin() {
return store => { return (store) => {
store.registerModule('terminalSync', terminalSyncModule()); store.registerModule('terminalSync', terminalSyncModule());
const upload = debounce(() => { const upload = debounce(() => {
...@@ -36,8 +36,8 @@ export default function createMirrorPlugin() { ...@@ -36,8 +36,8 @@ export default function createMirrorPlugin() {
}; };
store.watch( store.watch(
x => x.terminal && x.terminal.session && x.terminal.session.status, (x) => x.terminal && x.terminal.session && x.terminal.session.status,
val => { (val) => {
if (isRunningStatus(val)) { if (isRunningStatus(val)) {
start(); start();
} else if (isEndingStatus(val)) { } else if (isEndingStatus(val)) {
......
...@@ -34,7 +34,7 @@ export const dataStructure = () => ({ ...@@ -34,7 +34,7 @@ export const dataStructure = () => ({
mimeType: '', mimeType: '',
}); });
export const decorateData = entity => { export const decorateData = (entity) => {
const { const {
id, id,
type, type,
...@@ -69,7 +69,7 @@ export const decorateData = entity => { ...@@ -69,7 +69,7 @@ export const decorateData = entity => {
}); });
}; };
export const setPageTitle = title => { export const setPageTitle = (title) => {
document.title = title; document.title = title;
}; };
...@@ -78,7 +78,7 @@ export const setPageTitleForFile = (state, file) => { ...@@ -78,7 +78,7 @@ export const setPageTitleForFile = (state, file) => {
setPageTitle(title); setPageTitle(title);
}; };
export const commitActionForFile = file => { export const commitActionForFile = (file) => {
if (file.prevPath) { if (file.prevPath) {
return commitActionTypes.move; return commitActionTypes.move;
} else if (file.deleted) { } else if (file.deleted) {
...@@ -90,7 +90,7 @@ export const commitActionForFile = file => { ...@@ -90,7 +90,7 @@ export const commitActionForFile = file => {
return commitActionTypes.update; return commitActionTypes.update;
}; };
export const getCommitFiles = stagedFiles => export const getCommitFiles = (stagedFiles) =>
stagedFiles.reduce((acc, file) => { stagedFiles.reduce((acc, file) => {
if (file.type === 'tree') return acc; if (file.type === 'tree') return acc;
...@@ -109,7 +109,7 @@ export const createCommitPayload = ({ ...@@ -109,7 +109,7 @@ export const createCommitPayload = ({
}) => ({ }) => ({
branch, branch,
commit_message: state.commitMessage || getters.preBuiltCommitMessage, commit_message: state.commitMessage || getters.preBuiltCommitMessage,
actions: getCommitFiles(rootState.stagedFiles).map(f => { actions: getCommitFiles(rootState.stagedFiles).map((f) => {
const isBlob = isBlobUrl(f.rawPath); const isBlob = isBlobUrl(f.rawPath);
const content = isBlob ? btoa(f.content) : f.content; const content = isBlob ? btoa(f.content) : f.content;
...@@ -139,9 +139,9 @@ const sortTreesByTypeAndName = (a, b) => { ...@@ -139,9 +139,9 @@ const sortTreesByTypeAndName = (a, b) => {
return 0; return 0;
}; };
export const sortTree = sortedTree => export const sortTree = (sortedTree) =>
sortedTree sortedTree
.map(entity => .map((entity) =>
Object.assign(entity, { Object.assign(entity, {
tree: entity.tree.length ? sortTree(entity.tree) : [], tree: entity.tree.length ? sortTree(entity.tree) : [],
}), }),
...@@ -151,7 +151,7 @@ export const sortTree = sortedTree => ...@@ -151,7 +151,7 @@ export const sortTree = sortedTree =>
export const filePathMatches = (filePath, path) => filePath.indexOf(`${path}/`) === 0; export const filePathMatches = (filePath, path) => filePath.indexOf(`${path}/`) === 0;
export const getChangesCountForFiles = (files, path) => export const getChangesCountForFiles = (files, path) =>
files.filter(f => filePathMatches(f.path, path)).length; files.filter((f) => filePathMatches(f.path, path)).length;
export const mergeTrees = (fromTree, toTree) => { export const mergeTrees = (fromTree, toTree) => {
if (!fromTree || !fromTree.length) { if (!fromTree || !fromTree.length) {
...@@ -162,7 +162,7 @@ export const mergeTrees = (fromTree, toTree) => { ...@@ -162,7 +162,7 @@ export const mergeTrees = (fromTree, toTree) => {
if (!n) { if (!n) {
return t; return t;
} }
const existingTreeNode = t.find(el => el.path === n.path); const existingTreeNode = t.find((el) => el.path === n.path);
if (existingTreeNode && n.tree.length > 0) { if (existingTreeNode && n.tree.length > 0) {
existingTreeNode.opened = true; existingTreeNode.opened = true;
...@@ -183,7 +183,7 @@ export const mergeTrees = (fromTree, toTree) => { ...@@ -183,7 +183,7 @@ export const mergeTrees = (fromTree, toTree) => {
export const swapInStateArray = (state, arr, key, entryPath) => export const swapInStateArray = (state, arr, key, entryPath) =>
Object.assign(state, { Object.assign(state, {
[arr]: state[arr].map(f => (f.key === key ? state.entries[entryPath] : f)), [arr]: state[arr].map((f) => (f.key === key ? state.entries[entryPath] : f)),
}); });
export const getEntryOrRoot = (state, path) => export const getEntryOrRoot = (state, path) =>
...@@ -216,12 +216,12 @@ export const removeFromParentTree = (state, oldKey, parentPath) => { ...@@ -216,12 +216,12 @@ export const removeFromParentTree = (state, oldKey, parentPath) => {
}; };
export const updateFileCollections = (state, key, entryPath) => { export const updateFileCollections = (state, key, entryPath) => {
['openFiles', 'changedFiles', 'stagedFiles'].forEach(fileCollection => { ['openFiles', 'changedFiles', 'stagedFiles'].forEach((fileCollection) => {
swapInStateArray(state, fileCollection, key, entryPath); swapInStateArray(state, fileCollection, key, entryPath);
}); });
}; };
export const cleanTrailingSlash = path => path.replace(/\/$/, ''); export const cleanTrailingSlash = (path) => path.replace(/\/$/, '');
export const pathsAreEqual = (a, b) => { export const pathsAreEqual = (a, b) => {
const cleanA = a ? cleanTrailingSlash(a) : ''; const cleanA = a ? cleanTrailingSlash(a) : '';
......
...@@ -21,8 +21,8 @@ export const syncRouterAndStore = (router, store) => { ...@@ -21,8 +21,8 @@ export const syncRouterAndStore = (router, store) => {
// sync store to router // sync store to router
disposables.push( disposables.push(
store.watch( store.watch(
state => state.router.fullPath, (state) => state.router.fullPath,
fullPath => { (fullPath) => {
if (currentPath === fullPath) { if (currentPath === fullPath) {
return; return;
} }
...@@ -36,7 +36,7 @@ export const syncRouterAndStore = (router, store) => { ...@@ -36,7 +36,7 @@ export const syncRouterAndStore = (router, store) => {
// sync router to store // sync router to store
disposables.push( disposables.push(
router.afterEach(to => { router.afterEach((to) => {
if (currentPath === to.fullPath) { if (currentPath === to.fullPath) {
return; return;
} }
...@@ -47,7 +47,7 @@ export const syncRouterAndStore = (router, store) => { ...@@ -47,7 +47,7 @@ export const syncRouterAndStore = (router, store) => {
); );
const unsync = () => { const unsync = () => {
disposables.forEach(fn => fn()); disposables.forEach((fn) => fn());
}; };
return unsync; return unsync;
......
...@@ -3,17 +3,17 @@ import { flatten, isString } from 'lodash'; ...@@ -3,17 +3,17 @@ import { flatten, isString } from 'lodash';
import { SIDE_LEFT, SIDE_RIGHT } from './constants'; import { SIDE_LEFT, SIDE_RIGHT } from './constants';
import { performanceMarkAndMeasure } from '~/performance/utils'; import { performanceMarkAndMeasure } from '~/performance/utils';
const toLowerCase = x => x.toLowerCase(); const toLowerCase = (x) => x.toLowerCase();
const monacoLanguages = languages.getLanguages(); const monacoLanguages = languages.getLanguages();
const monacoExtensions = new Set( const monacoExtensions = new Set(
flatten(monacoLanguages.map(lang => lang.extensions?.map(toLowerCase) || [])), flatten(monacoLanguages.map((lang) => lang.extensions?.map(toLowerCase) || [])),
); );
const monacoMimetypes = new Set( const monacoMimetypes = new Set(
flatten(monacoLanguages.map(lang => lang.mimetypes?.map(toLowerCase) || [])), flatten(monacoLanguages.map((lang) => lang.mimetypes?.map(toLowerCase) || [])),
); );
const monacoFilenames = new Set( const monacoFilenames = new Set(
flatten(monacoLanguages.map(lang => lang.filenames?.map(toLowerCase) || [])), flatten(monacoLanguages.map((lang) => lang.filenames?.map(toLowerCase) || [])),
); );
const KNOWN_TYPES = [ const KNOWN_TYPES = [
...@@ -44,7 +44,7 @@ const KNOWN_TYPES = [ ...@@ -44,7 +44,7 @@ const KNOWN_TYPES = [
]; ];
export function isTextFile({ name, raw, content, mimeType = '' }) { export function isTextFile({ name, raw, content, mimeType = '' }) {
const knownType = KNOWN_TYPES.find(type => type.isMatch(mimeType, name)); const knownType = KNOWN_TYPES.find((type) => type.isMatch(mimeType, name));
if (knownType) return knownType.isText; if (knownType) return knownType.isText;
// does the string contain ascii characters only (ranges from space to tilde, tabs and new lines) // does the string contain ascii characters only (ranges from space to tilde, tabs and new lines)
...@@ -56,20 +56,20 @@ export function isTextFile({ name, raw, content, mimeType = '' }) { ...@@ -56,20 +56,20 @@ export function isTextFile({ name, raw, content, mimeType = '' }) {
return isString(fileContents) && (fileContents === '' || asciiRegex.test(fileContents)); return isString(fileContents) && (fileContents === '' || asciiRegex.test(fileContents));
} }
export const createPathWithExt = p => { export const createPathWithExt = (p) => {
const ext = p.lastIndexOf('.') >= 0 ? p.substring(p.lastIndexOf('.') + 1) : ''; const ext = p.lastIndexOf('.') >= 0 ? p.substring(p.lastIndexOf('.') + 1) : '';
return `${p.substring(1, p.lastIndexOf('.') + 1 || p.length)}${ext || '.js'}`; return `${p.substring(1, p.lastIndexOf('.') + 1 || p.length)}${ext || '.js'}`;
}; };
export const trimPathComponents = path => export const trimPathComponents = (path) =>
path path
.split('/') .split('/')
.map(s => s.trim()) .map((s) => s.trim())
.join('/'); .join('/');
export function registerLanguages(def, ...defs) { export function registerLanguages(def, ...defs) {
defs.forEach(lang => registerLanguages(lang)); defs.forEach((lang) => registerLanguages(lang));
const languageId = def.id; const languageId = def.id;
...@@ -80,7 +80,7 @@ export function registerLanguages(def, ...defs) { ...@@ -80,7 +80,7 @@ export function registerLanguages(def, ...defs) {
export function registerSchema(schema) { export function registerSchema(schema) {
const defaults = [languages.json.jsonDefaults, languages.yaml.yamlDefaults]; const defaults = [languages.json.jsonDefaults, languages.yaml.yamlDefaults];
defaults.forEach(d => defaults.forEach((d) =>
d.setDiagnosticsOptions({ d.setDiagnosticsOptions({
validate: true, validate: true,
enableSchemaRequest: true, enableSchemaRequest: true,
...@@ -91,7 +91,7 @@ export function registerSchema(schema) { ...@@ -91,7 +91,7 @@ export function registerSchema(schema) {
); );
} }
export const otherSide = side => (side === SIDE_RIGHT ? SIDE_LEFT : SIDE_RIGHT); export const otherSide = (side) => (side === SIDE_RIGHT ? SIDE_LEFT : SIDE_RIGHT);
export function trimTrailingWhitespace(content) { export function trimTrailingWhitespace(content) {
return content.replace(/[^\S\r\n]+$/gm, ''); return content.replace(/[^\S\r\n]+$/gm, '');
...@@ -125,9 +125,9 @@ export function getPathParent(path) { ...@@ -125,9 +125,9 @@ export function getPathParent(path) {
* @param {File} file * @param {File} file
*/ */
export function readFileAsDataURL(file) { export function readFileAsDataURL(file) {
return new Promise(resolve => { return new Promise((resolve) => {
const reader = new FileReader(); const reader = new FileReader();
reader.addEventListener('load', e => resolve(e.target.result), { once: true }); reader.addEventListener('load', (e) => resolve(e.target.result), { once: true });
reader.readAsDataURL(file); reader.readAsDataURL(file);
}); });
} }
......
...@@ -3,7 +3,7 @@ import { spriteIcon } from '~/lib/utils/common_utils'; ...@@ -3,7 +3,7 @@ import { spriteIcon } from '~/lib/utils/common_utils';
export function createImageBadge(noteId, { x, y }, classNames = []) { export function createImageBadge(noteId, { x, y }, classNames = []) {
const buttonEl = document.createElement('button'); const buttonEl = document.createElement('button');
const classList = classNames.concat(['js-image-badge']); const classList = classNames.concat(['js-image-badge']);
classList.forEach(className => buttonEl.classList.add(className)); classList.forEach((className) => buttonEl.classList.add(className));
buttonEl.setAttribute('type', 'button'); buttonEl.setAttribute('type', 'button');
buttonEl.setAttribute('disabled', true); buttonEl.setAttribute('disabled', true);
buttonEl.dataset.noteId = noteId; buttonEl.dataset.noteId = noteId;
......
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