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,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