chore: lint and fmt

This commit is contained in:
Julien Calixte
2026-03-28 09:38:55 +01:00
parent 8e8706e258
commit 5f48aa5690
108 changed files with 726 additions and 680 deletions

View File

@@ -1,10 +1,10 @@
import { computed, onMounted, ref } from 'vue'
import { computed, onMounted, ref } from "vue"
import { data } from '@/data/data'
import { DataType } from '@/data/DataType.enum'
import { useRepos } from '@/hooks/useRepos.hook'
import { RepoBase } from '@/modules/repo/interfaces/RepoBase'
import { FavoriteRepo } from '@/modules/repo/models/FavoriteRepo'
import { data } from "@/data/data"
import { DataType } from "@/data/DataType.enum"
import { useRepos } from "@/hooks/useRepos.hook"
import { RepoBase } from "@/modules/repo/interfaces/RepoBase"
import { FavoriteRepo } from "@/modules/repo/models/FavoriteRepo"
export const useFavoriteRepos = () => {
const { repos } = useRepos()

View File

@@ -1,8 +1,8 @@
import { computed } from 'vue'
import { computed } from "vue"
import { useRepos } from '@/hooks/useRepos.hook'
import { useFavoriteRepos } from '@/modules/repo/hooks/useFavoriteRepos.hook'
import { RepoBase } from '@/modules/repo/interfaces/RepoBase'
import { useRepos } from "@/hooks/useRepos.hook"
import { useFavoriteRepos } from "@/modules/repo/hooks/useFavoriteRepos.hook"
import { RepoBase } from "@/modules/repo/interfaces/RepoBase"
export const useRepoList = () => {
const { savedFavoriteRepos, addFavorite, removeFavorite } = useFavoriteRepos()

View File

@@ -1,5 +1,5 @@
import { DataType } from '@/data/DataType.enum'
import { Model } from '@/data/models/Model'
import { DataType } from "@/data/DataType.enum"
import { Model } from "@/data/models/Model"
export interface FavoriteRepo extends Model<DataType.FavoriteRepo> {
isFavorite: boolean

View File

@@ -1,6 +1,6 @@
import { DataType } from '@/data/DataType.enum'
import { Model } from '@/data/models/Model'
import { RepoFile } from '@/modules/repo/interfaces/RepoFile'
import { DataType } from "@/data/DataType.enum"
import { Model } from "@/data/models/Model"
import { RepoFile } from "@/modules/repo/interfaces/RepoFile"
export interface SavedRepo extends Model<DataType.SavedRepo> {
user: string

View File

@@ -1,11 +1,11 @@
import { Octokit } from '@octokit/rest'
import { Octokit } from "@octokit/rest"
import { getAccessToken } from '@/modules/user/service/signIn'
import { getAccessToken } from "@/modules/user/service/signIn"
export const getOctokit = async (): Promise<Octokit> => {
const response = await getAccessToken()
return new Octokit({
auth: response?.token ?? ''
auth: response?.token ?? ""
})
}

View File

@@ -6,7 +6,7 @@ import { getOctokit } from "@/modules/repo/services/octo"
export const getFiles = async (
owner: string,
repo: string,
repo: string
): Promise<RepoFile[]> => {
if (!owner || !repo) {
return []
@@ -15,7 +15,7 @@ export const getFiles = async (
const commits = await octokit.request("GET /repos/{owner}/{repo}/commits", {
owner,
repo,
repo
})
const lastCommit = commits.data.shift()
@@ -30,8 +30,8 @@ export const getFiles = async (
owner,
repo,
tree_sha: lastCommit.commit.tree.sha,
recursive: "true",
},
recursive: "true"
}
)
return treeResponse?.data.tree.filter((t) => t.type === "blob") ?? []
@@ -60,7 +60,7 @@ export const getMainReadme = async (owner: string, repo: string) => {
const { render } = markdownBuilder()
const { getCachedNote, saveCacheNote } = prepareNoteCache(
`${owner}-${repo}-README`,
`${owner}-${repo}-README`
)
try {
@@ -68,7 +68,7 @@ export const getMainReadme = async (owner: string, repo: string) => {
const README = await octokit.repos.getReadme({
owner,
repo,
repo
})
if (README) {
@@ -90,7 +90,7 @@ export const getMainReadme = async (owner: string, repo: string) => {
export const getUserSettingsContent = async (
user: string,
repo: string,
files: RepoFile[],
files: RepoFile[]
): Promise<Omit<UserSettings, "chosenFontFamily"> | null> => {
const configFile = files.find((file) => file.path === ".remanso.json")
@@ -110,7 +110,7 @@ export const getUserSettingsContent = async (
export const queryFileContent = async (
user: string,
repo: string,
sha: string,
sha: string
) => {
const octokit = await getOctokit()
@@ -123,8 +123,8 @@ export const queryFileContent = async (
{
owner: user,
repo: repo,
file_sha: sha,
},
file_sha: sha
}
)
return file?.data.content ?? null

View File

@@ -1,43 +1,43 @@
import { describe, expect, it } from 'vitest'
import { describe, expect, it } from "vitest"
import { resolvePath } from './resolvePath'
import { resolvePath } from "./resolvePath"
describe('resolve path service', () => {
it('set the absolute path if path to resolve is empty', () => {
expect(resolvePath('standard/README.md', '')).toEqual('standard/')
describe("resolve path service", () => {
it("set the absolute path if path to resolve is empty", () => {
expect(resolvePath("standard/README.md", "")).toEqual("standard/")
})
it('returns the path sanitized if there is no absolute path', () => {
expect(resolvePath('', './here/note.md')).toEqual('here/note.md')
it("returns the path sanitized if there is no absolute path", () => {
expect(resolvePath("", "./here/note.md")).toEqual("here/note.md")
})
it('set the absolute path from the current path', () => {
expect(resolvePath('standard/README.md', './other-note.md')).toEqual(
'standard/other-note.md'
it("set the absolute path from the current path", () => {
expect(resolvePath("standard/README.md", "./other-note.md")).toEqual(
"standard/other-note.md"
)
})
it('set the absolute path from the current path with multiple level', () => {
it("set the absolute path from the current path with multiple level", () => {
expect(
resolvePath('standard/you/are/here/README.md', './other-note.md')
).toEqual('standard/you/are/here/other-note.md')
resolvePath("standard/you/are/here/README.md", "./other-note.md")
).toEqual("standard/you/are/here/other-note.md")
})
it('set the absolute path from the current path with a go back in the relative path', () => {
it("set the absolute path from the current path with a go back in the relative path", () => {
expect(
resolvePath('standard/you/are/here/README.md', '../other-note.md')
).toEqual('standard/you/are/other-note.md')
resolvePath("standard/you/are/here/README.md", "../other-note.md")
).toEqual("standard/you/are/other-note.md")
expect(
resolvePath('standard/you/are/here/README.md', '../../other-note.md')
).toEqual('standard/you/other-note.md')
resolvePath("standard/you/are/here/README.md", "../../other-note.md")
).toEqual("standard/you/other-note.md")
expect(
resolvePath('standard/you/are/here/README.md', './../../other-note.md')
).toEqual('standard/you/other-note.md')
resolvePath("standard/you/are/here/README.md", "./../../other-note.md")
).toEqual("standard/you/other-note.md")
expect(
resolvePath('standard/you/are/here/README.md', './../../../other-note.md')
).toEqual('standard/other-note.md')
resolvePath("standard/you/are/here/README.md", "./../../../other-note.md")
).toEqual("standard/other-note.md")
})
})

View File

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

View File

@@ -9,7 +9,7 @@ import {
getCachedMainReadme,
getFiles,
getMainReadme,
getUserSettingsContent,
getUserSettingsContent
} from "@/modules/repo/services/repo"
import { refreshToken } from "@/modules/user/service/signIn"
@@ -29,7 +29,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
files: [],
readme: undefined,
userSettings: undefined,
needToLogin: false,
needToLogin: false
}),
actions: {
async setUserRepo(user: string, repo: string) {
@@ -38,7 +38,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
const savedRepoId = data.generateId(DataType.SavedRepo, `${user}-${repo}`)
const cachedSavedRepo = await data.get<DataType.SavedRepo, SavedRepo>(
savedRepoId,
savedRepoId
)
if (cachedSavedRepo) {
@@ -68,14 +68,14 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
$type: DataType.SavedRepo,
repo,
user,
files,
files
})
this.files = files
return getUserSettingsContent(user, repo, files)
})
.then((userSettings) => {
const chosenFontFamily = userSettings?.fontFamilies?.find(
(font) => font === this.userSettings?.chosenFontFamily,
(font) => font === this.userSettings?.chosenFontFamily
)
? this.userSettings?.chosenFontFamily
: userSettings?.fontFamily
@@ -94,7 +94,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
data.update<DataType.UserSettings, UserSettings>({
...this.userSettings,
_id: userSettingsId,
_id: userSettingsId
})
})
@@ -116,7 +116,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
const savedRepoId = data.generateId(
DataType.SavedRepo,
`${this.user}-${this.repo}`,
`${this.user}-${this.repo}`
)
const newFiles = [...this.files.filter((f) => f.sha !== file.sha), file]
data.update<DataType.SavedRepo, SavedRepo>({
@@ -124,7 +124,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
$type: DataType.SavedRepo,
repo: this.repo,
user: this.user,
files: newFiles,
files: newFiles
})
this.files = newFiles
},
@@ -147,7 +147,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
const userSettingsId = `UserSetting-${this.user}-${this.repo}`
data.update<DataType.UserSettings, UserSettings>({
...this.userSettings,
_id: userSettingsId,
_id: userSettingsId
})
},
setFontSize(fontSize: string) {
@@ -159,8 +159,8 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
const userSettingsId = `UserSetting-${this.user}-${this.repo}`
data.update<DataType.UserSettings, UserSettings>({
...this.userSettings,
_id: userSettingsId,
_id: userSettingsId
})
},
},
}
}
})