From 9afe9ef2893546273ce5c213c62821df1567880a Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sun, 9 May 2021 00:50:41 +0200 Subject: [PATCH] :wrench: (eslint) --- .eslintrc.js | 1 + src/components/HeaderNote.vue | 106 +++++++++++------------ src/components/WelcomeWorld.vue | 12 ++- src/hooks/useNote.hook.ts | 5 +- src/modules/note/hooks/useNoteCache.ts | 62 ++++++------- src/modules/repo/services/resolvePath.ts | 64 +++++++------- 6 files changed, 125 insertions(+), 125 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index d470e2c..e397752 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,6 +7,7 @@ module.exports = { 'plugin:vue/vue3-essential', 'eslint:recommended', 'plugin:vue/recommended', + '@vue/typescript/recommended', '@vue/prettier/@typescript-eslint', 'plugin:prettier-vue/recommended' ], diff --git a/src/components/HeaderNote.vue b/src/components/HeaderNote.vue index 87c8ef8..261953b 100644 --- a/src/components/HeaderNote.vue +++ b/src/components/HeaderNote.vue @@ -1,53 +1,53 @@ - - - - - + + + + + diff --git a/src/components/WelcomeWorld.vue b/src/components/WelcomeWorld.vue index c3a7f63..4f01c15 100644 --- a/src/components/WelcomeWorld.vue +++ b/src/components/WelcomeWorld.vue @@ -20,7 +20,7 @@

- Manage your repos

@@ -49,17 +49,15 @@
-
- https://github.com/ -
+
https://github.com/
@@ -70,9 +68,9 @@
@@ -109,8 +107,8 @@ import { useFavoriteRepos } from '@/modules/repo/hooks/useFavoriteRepos.hook' import SignInGithub from '@/components/SignInGithub.vue' export default defineComponent({ - components: { SignInGithub }, name: 'WelcomeWord', + components: { SignInGithub }, setup() { const { isLogged, username } = useGitHubLogin() const { savedFavoriteRepos } = useFavoriteRepos() diff --git a/src/hooks/useNote.hook.ts b/src/hooks/useNote.hook.ts index 64948c9..fbb3637 100644 --- a/src/hooks/useNote.hook.ts +++ b/src/hooks/useNote.hook.ts @@ -100,8 +100,9 @@ export const useNote = (containerClass: string) => { if (isMobile.value) { container.style.height = `${(stackedNotes.value.length + 1) * 100}vh` } else { - container.style.width = `${NOTE_WIDTH * - (stackedNotes.value.length + 1)}px` + container.style.width = `${ + NOTE_WIDTH * (stackedNotes.value.length + 1) + }px` } } diff --git a/src/modules/note/hooks/useNoteCache.ts b/src/modules/note/hooks/useNoteCache.ts index fad2d05..1f86f96 100644 --- a/src/modules/note/hooks/useNoteCache.ts +++ b/src/modules/note/hooks/useNoteCache.ts @@ -1,31 +1,31 @@ -import { data } from '@/data/data' -import { DataType } from '@/data/DataType.enum' -import { Note } from '@/modules/note/models/Note' -import { useAsyncState } from '@vueuse/core' -import { computed } from 'vue' - -export const useNoteCache = (sha: string) => { - const noteId = computed(() => data.generateId(DataType.Note, sha)) - const getCachedNote = async () => data.get(noteId.value) - - const cachedNote = useAsyncState(getCachedNote, null) - - const saveCacheNote = async (content: string) => { - const newNote: Note = { - _id: noteId.value, - $type: DataType.Note, - content - } - - await data.update(newNote) - - await cachedNote.execute() - } - - return { - cachedNote: cachedNote.state, - isReady: cachedNote.isReady, - getCachedNote, - saveCacheNote - } -} +import { data } from '@/data/data' +import { DataType } from '@/data/DataType.enum' +import { Note } from '@/modules/note/models/Note' +import { useAsyncState } from '@vueuse/core' +import { computed } from 'vue' + +export const useNoteCache = (sha: string) => { + const noteId = computed(() => data.generateId(DataType.Note, sha)) + const getCachedNote = async () => data.get(noteId.value) + + const cachedNote = useAsyncState(getCachedNote, null) + + const saveCacheNote = async (content: string) => { + const newNote: Note = { + _id: noteId.value, + $type: DataType.Note, + content + } + + await data.update(newNote) + + await cachedNote.execute() + } + + return { + cachedNote: cachedNote.state, + isReady: cachedNote.isReady, + getCachedNote, + saveCacheNote + } +} diff --git a/src/modules/repo/services/resolvePath.ts b/src/modules/repo/services/resolvePath.ts index 1b37cec..5aada86 100644 --- a/src/modules/repo/services/resolvePath.ts +++ b/src/modules/repo/services/resolvePath.ts @@ -1,32 +1,32 @@ -const sanitizePath = (path: string) => { - if (path.startsWith('./')) { - return decodeURIComponent(path.replace('./', '')) - } - return decodeURIComponent(path) -} - -const removeNoteFilename = (pathNote: string) => { - const path = pathNote.split('/') - path.pop() - - return sanitizePath(path.join('/')) -} - -export const resolvePath = ( - currentAbsolutePathNote: string, - pathToResolve: string -) => { - let currentAbsolutePath = removeNoteFilename(currentAbsolutePathNote) - pathToResolve = sanitizePath(pathToResolve) - - while (pathToResolve.startsWith('../')) { - const adjustedAbsolutePath = currentAbsolutePath.split('/') - adjustedAbsolutePath.pop() - currentAbsolutePath = adjustedAbsolutePath.join('/') - pathToResolve = pathToResolve.replace('../', '') - } - - return currentAbsolutePath - ? `${currentAbsolutePath}/${pathToResolve}` - : pathToResolve -} +const sanitizePath = (path: string) => { + if (path.startsWith('./')) { + return decodeURIComponent(path.replace('./', '')) + } + return decodeURIComponent(path) +} + +const removeNoteFilename = (pathNote: string) => { + const path = pathNote.split('/') + path.pop() + + return sanitizePath(path.join('/')) +} + +export const resolvePath = ( + currentAbsolutePathNote: string, + pathToResolve: string +) => { + let currentAbsolutePath = removeNoteFilename(currentAbsolutePathNote) + pathToResolve = sanitizePath(pathToResolve) + + while (pathToResolve.startsWith('../')) { + const adjustedAbsolutePath = currentAbsolutePath.split('/') + adjustedAbsolutePath.pop() + currentAbsolutePath = adjustedAbsolutePath.join('/') + pathToResolve = pathToResolve.replace('../', '') + } + + return currentAbsolutePath + ? `${currentAbsolutePath}/${pathToResolve}` + : pathToResolve +}