🔧 (eslint)

This commit is contained in:
Julien Calixte
2021-05-09 00:50:41 +02:00
parent a9fba33760
commit 9afe9ef289
6 changed files with 125 additions and 125 deletions

View File

@@ -7,6 +7,7 @@ module.exports = {
'plugin:vue/vue3-essential', 'plugin:vue/vue3-essential',
'eslint:recommended', 'eslint:recommended',
'plugin:vue/recommended', 'plugin:vue/recommended',
'@vue/typescript/recommended',
'@vue/prettier/@typescript-eslint', '@vue/prettier/@typescript-eslint',
'plugin:prettier-vue/recommended' 'plugin:prettier-vue/recommended'
], ],

View File

@@ -1,53 +1,53 @@
<template> <template>
<header class="header-note"> <header class="header-note">
<router-link <router-link
:to="{ name: 'Home' }" :to="{ name: 'Home' }"
class="button is-small is-white back-button" class="button is-small is-white back-button"
> >
<img src="@/assets/icons/dark-left-arrow.svg" alt="go back left arrow" /> <img src="@/assets/icons/dark-left-arrow.svg" alt="go back left arrow" />
</router-link> </router-link>
<router-link <router-link
class="special-folder" class="special-folder"
:to="{ name: 'DraftNotes', params: { user, repo } }" :to="{ name: 'DraftNotes', params: { user, repo } }"
> >
draft draft
</router-link> </router-link>
<router-link <router-link
class="special-folder" class="special-folder"
:to="{ name: 'FleetingNotes', params: { user, repo } }" :to="{ name: 'FleetingNotes', params: { user, repo } }"
> >
inbox inbox
</router-link> </router-link>
</header> </header>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue' import { defineComponent } from 'vue'
export default defineComponent({ export default defineComponent({
name: 'HeaderNote', name: 'HeaderNote',
props: { props: {
user: { type: String, required: true }, user: { type: String, required: true },
repo: { type: String, required: true } repo: { type: String, required: true }
} }
}) })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.header-note { .header-note {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
margin-top: 10px; margin-top: 10px;
.special-folder { .special-folder {
text-align: center; text-align: center;
} }
img { img {
&:hover { &:hover {
cursor: pointer; cursor: pointer;
} }
} }
} }
</style> </style>

View File

@@ -20,7 +20,7 @@
</div> </div>
<div class="column"> <div class="column">
<p> <p>
<router-link :to="{ name: 'RepoList' }" v-if="isLogged" <router-link v-if="isLogged" :to="{ name: 'RepoList' }"
>Manage your repos</router-link >Manage your repos</router-link
> >
</p> </p>
@@ -49,17 +49,15 @@
<form @submit.prevent> <form @submit.prevent>
<div class="columns is-centered is-vcentered to-user-repo"> <div class="columns is-centered is-vcentered to-user-repo">
<div class="column"> <div class="column">https://github.com/</div>
https://github.com/
</div>
<div class="columns column is-mobile is-centered is-vcentered"> <div class="columns column is-mobile is-centered is-vcentered">
<div class="column"> <div class="column">
<div class="field"> <div class="field">
<div class="control"> <div class="control">
<input <input
v-model="userInput"
class="input" class="input"
type="text" type="text"
v-model="userInput"
placeholder="user" placeholder="user"
/> />
</div> </div>
@@ -70,9 +68,9 @@
<div class="field"> <div class="field">
<div class="control"> <div class="control">
<input <input
v-model="repoInput"
class="input" class="input"
type="text" type="text"
v-model="repoInput"
placeholder="repo" placeholder="repo"
/> />
</div> </div>
@@ -109,8 +107,8 @@ import { useFavoriteRepos } from '@/modules/repo/hooks/useFavoriteRepos.hook'
import SignInGithub from '@/components/SignInGithub.vue' import SignInGithub from '@/components/SignInGithub.vue'
export default defineComponent({ export default defineComponent({
components: { SignInGithub },
name: 'WelcomeWord', name: 'WelcomeWord',
components: { SignInGithub },
setup() { setup() {
const { isLogged, username } = useGitHubLogin() const { isLogged, username } = useGitHubLogin()
const { savedFavoriteRepos } = useFavoriteRepos() const { savedFavoriteRepos } = useFavoriteRepos()

View File

@@ -100,8 +100,9 @@ export const useNote = (containerClass: string) => {
if (isMobile.value) { if (isMobile.value) {
container.style.height = `${(stackedNotes.value.length + 1) * 100}vh` container.style.height = `${(stackedNotes.value.length + 1) * 100}vh`
} else { } else {
container.style.width = `${NOTE_WIDTH * container.style.width = `${
(stackedNotes.value.length + 1)}px` NOTE_WIDTH * (stackedNotes.value.length + 1)
}px`
} }
} }

View File

@@ -1,31 +1,31 @@
import { data } from '@/data/data' import { data } from '@/data/data'
import { DataType } from '@/data/DataType.enum' import { DataType } from '@/data/DataType.enum'
import { Note } from '@/modules/note/models/Note' import { Note } from '@/modules/note/models/Note'
import { useAsyncState } from '@vueuse/core' import { useAsyncState } from '@vueuse/core'
import { computed } from 'vue' import { computed } from 'vue'
export const useNoteCache = (sha: string) => { export const useNoteCache = (sha: string) => {
const noteId = computed(() => data.generateId(DataType.Note, sha)) const noteId = computed(() => data.generateId(DataType.Note, sha))
const getCachedNote = async () => data.get<DataType.Note, Note>(noteId.value) const getCachedNote = async () => data.get<DataType.Note, Note>(noteId.value)
const cachedNote = useAsyncState(getCachedNote, null) const cachedNote = useAsyncState(getCachedNote, null)
const saveCacheNote = async (content: string) => { const saveCacheNote = async (content: string) => {
const newNote: Note = { const newNote: Note = {
_id: noteId.value, _id: noteId.value,
$type: DataType.Note, $type: DataType.Note,
content content
} }
await data.update(newNote) await data.update(newNote)
await cachedNote.execute() await cachedNote.execute()
} }
return { return {
cachedNote: cachedNote.state, cachedNote: cachedNote.state,
isReady: cachedNote.isReady, isReady: cachedNote.isReady,
getCachedNote, getCachedNote,
saveCacheNote saveCacheNote
} }
} }

View File

@@ -1,32 +1,32 @@
const sanitizePath = (path: string) => { const sanitizePath = (path: string) => {
if (path.startsWith('./')) { if (path.startsWith('./')) {
return decodeURIComponent(path.replace('./', '')) return decodeURIComponent(path.replace('./', ''))
} }
return decodeURIComponent(path) return decodeURIComponent(path)
} }
const removeNoteFilename = (pathNote: string) => { const removeNoteFilename = (pathNote: string) => {
const path = pathNote.split('/') const path = pathNote.split('/')
path.pop() path.pop()
return sanitizePath(path.join('/')) return sanitizePath(path.join('/'))
} }
export const resolvePath = ( export const resolvePath = (
currentAbsolutePathNote: string, currentAbsolutePathNote: string,
pathToResolve: string pathToResolve: string
) => { ) => {
let currentAbsolutePath = removeNoteFilename(currentAbsolutePathNote) let currentAbsolutePath = removeNoteFilename(currentAbsolutePathNote)
pathToResolve = sanitizePath(pathToResolve) pathToResolve = sanitizePath(pathToResolve)
while (pathToResolve.startsWith('../')) { while (pathToResolve.startsWith('../')) {
const adjustedAbsolutePath = currentAbsolutePath.split('/') const adjustedAbsolutePath = currentAbsolutePath.split('/')
adjustedAbsolutePath.pop() adjustedAbsolutePath.pop()
currentAbsolutePath = adjustedAbsolutePath.join('/') currentAbsolutePath = adjustedAbsolutePath.join('/')
pathToResolve = pathToResolve.replace('../', '') pathToResolve = pathToResolve.replace('../', '')
} }
return currentAbsolutePath return currentAbsolutePath
? `${currentAbsolutePath}/${pathToResolve}` ? `${currentAbsolutePath}/${pathToResolve}`
: pathToResolve : pathToResolve
} }