diff --git a/package.json b/package.json index da52b24..aac190d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "jest": "^29.4.3", "lint-staged": "^13.2.3", "npm-run-all": "^4.1.5", - "prettier": "^2.8.4", + "prettier": "^3.0.3", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.8.1", diff --git a/src/client/components/ArticleInfo.tsx b/src/client/components/ArticleInfo.tsx index b14490e..71b8471 100644 --- a/src/client/components/ArticleInfo.tsx +++ b/src/client/components/ArticleInfo.tsx @@ -32,7 +32,7 @@ export const ArticleInfo = ({ isOlderThanRemote, }: Props) => { const [isOpen, setIsOpen] = useState( - localStorage.getItem("openInfoState") === "true" ? true : false + localStorage.getItem("openInfoState") === "true" ? true : false, ); const toggleAccordion = (event: React.MouseEvent) => { diff --git a/src/client/components/Header.tsx b/src/client/components/Header.tsx index adb6688..1810569 100644 --- a/src/client/components/Header.tsx +++ b/src/client/components/Header.tsx @@ -37,7 +37,7 @@ export const Header = ({ if (isOlderThanRemote) { if ( !window.confirm( - "この記事はQiita上の記事より古い可能性があります。上書きしますか?" + "この記事はQiita上の記事より古い可能性があります。上書きしますか?", ) ) { return; diff --git a/src/client/components/HotReloadRoot.tsx b/src/client/components/HotReloadRoot.tsx index 696c4a4..46d36f2 100644 --- a/src/client/components/HotReloadRoot.tsx +++ b/src/client/components/HotReloadRoot.tsx @@ -35,7 +35,7 @@ export const HotReloadRoot = ({ children }: Props) => { export const useHotReloadEffect = ( callback: () => unknown, - deps: unknown[] + deps: unknown[], ) => { const { reloadedAt } = useContext(HotReloadContext); diff --git a/src/client/components/SidebarArticles.tsx b/src/client/components/SidebarArticles.tsx index e7d8e60..a8fcb60 100644 --- a/src/client/components/SidebarArticles.tsx +++ b/src/client/components/SidebarArticles.tsx @@ -47,7 +47,7 @@ export const SidebarArticles = ({ items, sortType, articleState }: Props) => { }; const [isDetailsOpen, setIsDetailsOpen] = useState( - localStorage.getItem(StorageName[articleState]) === "true" + localStorage.getItem(StorageName[articleState]) === "true", ); const toggleAccordion = (event: React.MouseEvent) => { @@ -138,7 +138,7 @@ const articlesListItemStyle = css({ gap: getSpace(1), lineHeight: LineHeight.bodyDense, padding: `${getSpace(3 / 4)}px ${getSpace(5 / 2)}px ${getSpace( - 3 / 4 + 3 / 4, )}px ${getSpace(3 / 2)}px`, whiteSpace: "nowrap", textOverflow: "ellipsis", diff --git a/src/client/components/SidebarContents.tsx b/src/client/components/SidebarContents.tsx index 0c313f0..81c6299 100644 --- a/src/client/components/SidebarContents.tsx +++ b/src/client/components/SidebarContents.tsx @@ -28,7 +28,7 @@ type SortType = (typeof SortType)[keyof typeof SortType]; export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => { const [items, setItems] = useState(); const [isOpen, setIsOpen] = useState( - localStorage.getItem("openSidebarState") === "true" + localStorage.getItem("openSidebarState") === "true", ); const [sortType, setSortType] = useState(SortType.ByUpdatedAt); @@ -646,7 +646,7 @@ const articlesListItemStyle = css({ gap: getSpace(1), lineHeight: LineHeight.bodyDense, padding: `${getSpace(3 / 4)}px ${getSpace(5 / 2)}px ${getSpace( - 3 / 4 + 3 / 4, )}px ${getSpace(3 / 2)}px`, whiteSpace: "nowrap", textOverflow: "ellipsis", diff --git a/src/client/components/Slide/SlideViewerContent.tsx b/src/client/components/Slide/SlideViewerContent.tsx index 21c1957..6ea4043 100644 --- a/src/client/components/Slide/SlideViewerContent.tsx +++ b/src/client/components/Slide/SlideViewerContent.tsx @@ -38,7 +38,7 @@ export const SlideViewerContent = ({ onPrevious(); } }, - [onPrevious, onNext] + [onPrevious, onNext], ); return ( diff --git a/src/client/components/Slide/SlideViewerDashboard.tsx b/src/client/components/Slide/SlideViewerDashboard.tsx index 84a5038..2b9fa9c 100644 --- a/src/client/components/Slide/SlideViewerDashboard.tsx +++ b/src/client/components/Slide/SlideViewerDashboard.tsx @@ -50,10 +50,14 @@ export const SlideViewerDashboard = ({ onMouseMove={(event) => { setIsTooltipVisible(true); setTooltipLeftDistance( - event.clientX - event.currentTarget.getBoundingClientRect().left + event.clientX - event.currentTarget.getBoundingClientRect().left, ); setDestinationPage( - getMagnitudeFromRange(event.currentTarget, event.clientX, totalPage) + getMagnitudeFromRange( + event.currentTarget, + event.clientX, + totalPage, + ), ); }} onMouseLeave={() => { diff --git a/src/client/components/Slide/SlideViewerDashboardNavigation.tsx b/src/client/components/Slide/SlideViewerDashboardNavigation.tsx index 5f8b046..8c338ae 100644 --- a/src/client/components/Slide/SlideViewerDashboardNavigation.tsx +++ b/src/client/components/Slide/SlideViewerDashboardNavigation.tsx @@ -25,7 +25,7 @@ export const SlideViewerDashboardNavigation = ({ "slideMode-Dashboard_button--prev", { "slideMode-Dashboard_button--clickable": !disablePrevious, - } + }, )} disabled={disablePrevious} onClick={() => onPrevious()} @@ -41,7 +41,7 @@ export const SlideViewerDashboardNavigation = ({ "slideMode-Dashboard_button--next", { "slideMode-Dashboard_button--clickable": !disableNext, - } + }, )} disabled={disableNext} onClick={() => onNext()} diff --git a/src/client/components/Slide/get-magnitude-from-range.ts b/src/client/components/Slide/get-magnitude-from-range.ts index 1ac89f9..169faae 100644 --- a/src/client/components/Slide/get-magnitude-from-range.ts +++ b/src/client/components/Slide/get-magnitude-from-range.ts @@ -1,7 +1,7 @@ export function getMagnitudeFromRange( target: Element, x: number, - length: number + length: number, ) { const rect = target.getBoundingClientRect(); return Math.ceil((x - rect.left) / (rect.width / length)); diff --git a/src/client/components/Slide/slide-pages.ts b/src/client/components/Slide/slide-pages.ts index e24beff..20d2f87 100644 --- a/src/client/components/Slide/slide-pages.ts +++ b/src/client/components/Slide/slide-pages.ts @@ -6,7 +6,7 @@ export const slidePages = (article: { body: string; }): string[] => [ `

${escape( - article.title + article.title, )}

by ${ article.author.urlName }
`, diff --git a/src/client/components/Snackbar.tsx b/src/client/components/Snackbar.tsx index ebfce4b..0077763 100644 --- a/src/client/components/Snackbar.tsx +++ b/src/client/components/Snackbar.tsx @@ -49,7 +49,7 @@ export const Snackbar = ({ message, setMessage }: Props) => { const snackbarStyle = ( isMessageExists: boolean, - isMessageTypeSuccess: boolean + isMessageTypeSuccess: boolean, ) => css({ alignItems: "center", diff --git a/src/client/components/Tooltip.tsx b/src/client/components/Tooltip.tsx index 545a768..c2cd4df 100644 --- a/src/client/components/Tooltip.tsx +++ b/src/client/components/Tooltip.tsx @@ -37,7 +37,7 @@ export const Tooltip = ({ handleHide(); } }, - [isShow, handleHide] + [isShow, handleHide], ); useEffect(() => { @@ -77,7 +77,7 @@ const toolTipItemStyle = ( isShow: boolean, horizontal: string, vertical: string, - offset: number + offset: number, ) => css({ visibility: isShow ? "visible" : "hidden", diff --git a/src/client/index.html b/src/client/index.html index 24dbf82..f31c3b8 100644 --- a/src/client/index.html +++ b/src/client/index.html @@ -1,4 +1,4 @@ - + diff --git a/src/client/lib/entries.ts b/src/client/lib/entries.ts index 5c26d45..3a50d5d 100644 --- a/src/client/lib/entries.ts +++ b/src/client/lib/entries.ts @@ -5,7 +5,7 @@ export const entries = (o: T) => { // Wrapped Object.fromEntries with strict type export const fromEntries = ( - e: Iterable + e: Iterable, ) => { return Object.fromEntries(e) as { [key in K]: V }; }; diff --git a/src/client/lib/mixins.ts b/src/client/lib/mixins.ts index 9539ac8..6eeaa59 100644 --- a/src/client/lib/mixins.ts +++ b/src/client/lib/mixins.ts @@ -24,5 +24,5 @@ export const breakpoint = { XXL: 2559, } as const; export const viewport = fromEntries( - entries(breakpoint).map(([k, v]) => [k, viewportMaker(v)]) + entries(breakpoint).map(([k, v]) => [k, viewportMaker(v)]), ); diff --git a/src/client/lib/window-size.ts b/src/client/lib/window-size.ts index a62d35a..0f5d1d8 100644 --- a/src/client/lib/window-size.ts +++ b/src/client/lib/window-size.ts @@ -11,7 +11,7 @@ export const useWindowSize = () => { }, [isClient]); const [windowDimensions, setWindowDimensions] = useState( - getWindowDimensions() + getWindowDimensions(), ); useEffect(() => { const onResize = () => { diff --git a/src/commands/init.ts b/src/commands/init.ts index 1137770..74c83b4 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -37,7 +37,7 @@ const rootDir = process.cwd(); const workflowsDirectoryPath = path.join(rootDir, ".github/workflows"); const publishWorkflowFilePath = path.join( workflowsDirectoryPath, - "publish.yml" + "publish.yml", ); const gitignoreFilePath = path.join(rootDir, ".gitignore"); @@ -62,7 +62,7 @@ export const init = async () => { const userConfigFileContent = JSON.stringify( await config.getUserConfig(), null, - 2 + 2, ); writeFile(userConfigFilePath, userConfigFileContent); diff --git a/src/commands/login.ts b/src/commands/login.ts index ad1ab89..e1fefd7 100644 --- a/src/commands/login.ts +++ b/src/commands/login.ts @@ -13,7 +13,7 @@ export const login = async () => { console.log(` 以下のURLにアクセスしてトークンを発行してください。(「read_qiita」と「write_qiita」にチェックを入れてください) ${chalk.bold( - "https://qiita.com/settings/tokens/new?read_qiita=1&write_qiita=1&description=qiita-cli" + "https://qiita.com/settings/tokens/new?read_qiita=1&write_qiita=1&description=qiita-cli", )} `); const token = await rl.question("発行したトークンを入力: "); diff --git a/src/commands/publish.ts b/src/commands/publish.ts index 1b3466b..31cb3f8 100644 --- a/src/commands/publish.ts +++ b/src/commands/publish.ts @@ -15,7 +15,7 @@ export const publish = async (argv: string[]) => { "--force": Boolean, "-f": "--force", }, - { argv } + { argv }, ); const qiitaApi = await getQiitaApiInstance(); @@ -44,27 +44,30 @@ export const publish = async (argv: string[]) => { // Validate const enableForcePublish = args["--force"]; - const invalidItemMessages = targetItems.reduce((acc, item) => { - const frontmatterErrors = checkFrontmatterType(item); - if (frontmatterErrors.length > 0) - return [...acc, { name: item.name, errors: frontmatterErrors }]; + const invalidItemMessages = targetItems.reduce( + (acc, item) => { + const frontmatterErrors = checkFrontmatterType(item); + if (frontmatterErrors.length > 0) + return [...acc, { name: item.name, errors: frontmatterErrors }]; - const validationErrors = validateItem(item); - if (validationErrors.length > 0) - return [...acc, { name: item.name, errors: validationErrors }]; + const validationErrors = validateItem(item); + if (validationErrors.length > 0) + return [...acc, { name: item.name, errors: validationErrors }]; - if (!enableForcePublish && item.isOlderThanRemote) { - return [ - ...acc, - { - name: item.name, - errors: ["内容がQiita上の記事より古い可能性があります"], - }, - ]; - } + if (!enableForcePublish && item.isOlderThanRemote) { + return [ + ...acc, + { + name: item.name, + errors: ["内容がQiita上の記事より古い可能性があります"], + }, + ]; + } - return acc; - }, [] as { name: string; errors: string[] }[]); + return acc; + }, + [] as { name: string; errors: string[] }[], + ); if (invalidItemMessages.length > 0) { const chalk = (await import("chalk")).default; invalidItemMessages.forEach((msg) => { diff --git a/src/commands/pull.ts b/src/commands/pull.ts index 4f3c340..1b06b97 100644 --- a/src/commands/pull.ts +++ b/src/commands/pull.ts @@ -9,7 +9,7 @@ export const pull = async (argv: string[]) => { "--force": Boolean, "-f": "--force", }, - { argv } + { argv }, ); const qiitaApi = await getQiitaApiInstance(); diff --git a/src/lib/check-frontmatter-type.ts b/src/lib/check-frontmatter-type.ts index 00d077f..a31c168 100644 --- a/src/lib/check-frontmatter-type.ts +++ b/src/lib/check-frontmatter-type.ts @@ -80,7 +80,7 @@ const checkId: CheckType = { const getErrorMessages = ( frontMatter: FrontMatter, - checkTypes: CheckType[] + checkTypes: CheckType[], ): string[] => { return checkTypes.reduce((errorMessages: string[], checkType) => { if (!checkType.isValid(frontMatter)) { diff --git a/src/lib/config.test.ts b/src/lib/config.test.ts index 81ac679..7e4bb33 100644 --- a/src/lib/config.test.ts +++ b/src/lib/config.test.ts @@ -75,7 +75,7 @@ describe("config", () => { it("returns default path", () => { expect(config.getCredentialDir()).toEqual( - "/home/test-user/.config/qiita-cli" + "/home/test-user/.config/qiita-cli", ); }); @@ -88,7 +88,7 @@ describe("config", () => { it("returns customized path", () => { expect(config.getCredentialDir()).toEqual( - "/home/test-user/qiita-articles/my-credential" + "/home/test-user/qiita-articles/my-credential", ); }); }); @@ -102,7 +102,7 @@ describe("config", () => { it("returns default path", () => { expect(config.getItemsRootDir()).toEqual( - "/home/test-user/qiita-articles" + "/home/test-user/qiita-articles", ); }); @@ -115,7 +115,7 @@ describe("config", () => { it("returns customized path", () => { expect(config.getItemsRootDir()).toEqual( - "/home/test-user/qiita-articles/my-root" + "/home/test-user/qiita-articles/my-root", ); }); }); @@ -130,7 +130,7 @@ describe("config", () => { it("returns default path", () => { expect(config.getUserConfigDir()).toEqual( - "/home/test-user/qiita-articles" + "/home/test-user/qiita-articles", ); }); @@ -143,7 +143,7 @@ describe("config", () => { it("returns customized path", () => { expect(config.getUserConfigDir()).toEqual( - "/home/test-user/qiita-articles/my-root" + "/home/test-user/qiita-articles/my-root", ); }); }); @@ -158,7 +158,7 @@ describe("config", () => { it("returns default path", () => { expect(config.getUserConfigFilePath()).toEqual( - "/home/test-user/qiita-articles/qiita.config.json" + "/home/test-user/qiita-articles/qiita.config.json", ); }); @@ -171,7 +171,7 @@ describe("config", () => { it("returns customized path", () => { expect(config.getUserConfigFilePath()).toEqual( - "/home/test-user/qiita-articles/my-root/qiita.config.json" + "/home/test-user/qiita-articles/my-root/qiita.config.json", ); }); }); @@ -185,7 +185,7 @@ describe("config", () => { it("returns default path", () => { expect(config.getCacheDataDir()).toEqual( - "/home/test-user/.cache/qiita-cli" + "/home/test-user/.cache/qiita-cli", ); }); diff --git a/src/lib/config.ts b/src/lib/config.ts index 873b99b..4eb33a6 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -36,7 +36,7 @@ class Config { this.itemsRootDir = this.resolveItemsRootDir(options.itemsRootDir); this.userConfigDir = this.resolveUserConfigDirPath(options.userConfigDir); this.userConfigFilePath = this.resolveUserConfigFilePath( - options.userConfigDir + options.userConfigDir, ); this.cacheDataDir = this.resolveCacheDataDir(); this.credential = new Credential({ @@ -51,7 +51,7 @@ class Config { itemsRootDir: this.itemsRootDir, userConfigFilePath: this.userConfigFilePath, cacheDataDir: this.cacheDataDir, - }) + }), ); } @@ -114,10 +114,10 @@ class Config { if (fsSync.existsSync(this.getUserConfigFilePath())) { const userConfigFileData = await fs.readFile( - this.userConfigFilePath as string + this.userConfigFilePath as string, ); const userConfig = JSON.parse( - userConfigFileData.toString() + userConfigFileData.toString(), ) as UserConfig; return { ...defaultConfig, ...userConfig }; } @@ -262,7 +262,7 @@ class Credential { ? this.currentProfile : credentialData.default; const credential = credentialData.credentials.find( - (cred) => cred.name === profile + (cred) => cred.name === profile, ); if (!credential) { @@ -273,7 +273,7 @@ class Credential { configDebugger( "use credential", - JSON.stringify({ ...credential, accessToken: "******" }) + JSON.stringify({ ...credential, accessToken: "******" }), ); return credential; @@ -302,7 +302,7 @@ class Credential { default: credentialData.default, credentials: [ ...credentialData.credentials.filter( - (cred) => cred.name !== credential.name + (cred) => cred.name !== credential.name, ), credential, ], @@ -311,7 +311,7 @@ class Credential { await fs.writeFile( this.credentialFilePath, JSON.stringify(newCredentialData, null, 2), - { encoding: "utf8", mode: 0o600 } + { encoding: "utf8", mode: 0o600 }, ); this.refresh(); diff --git a/src/lib/error-handler.ts b/src/lib/error-handler.ts index a3939ac..7a02f4a 100644 --- a/src/lib/error-handler.ts +++ b/src/lib/error-handler.ts @@ -17,11 +17,11 @@ export const handleError = async (error: Error) => { case QiitaFetchError.name: console.error( chalk.red.bold( - "Qiita APIへのリクエストでネットワークエラーが発生しました" - ) + "Qiita APIへのリクエストでネットワークエラーが発生しました", + ), ); console.error( - chalk.red(" インターネットに接続されているかご確認ください") + chalk.red(" インターネットに接続されているかご確認ください"), ); break; case QiitaBadRequestError.name: @@ -31,23 +31,23 @@ export const handleError = async (error: Error) => { case QiitaUnauthorizedError.name: console.error(chalk.red.bold("Qiitaの認証に失敗しました")); console.error( - chalk.red(" loginコマンドでQiitaにログインしているかご確認ください") + chalk.red(" loginコマンドでQiitaにログインしているかご確認ください"), ); console.error( - chalk.red(" Qiitaのアクセストークンが正しいかご確認ください") + chalk.red(" Qiitaのアクセストークンが正しいかご確認ください"), ); break; case QiitaForbiddenError.name: console.error(chalk.red.bold("Qiita APIへのリクエストに失敗しました")); console.error( - chalk.red(" Qiitaのアクセストークンが正しいかご確認ください") + chalk.red(" Qiitaのアクセストークンが正しいかご確認ください"), ); console.error(chalk.red("")); break; case QiitaNotFoundError.name: console.error(chalk.red.bold("記事が見つかりませんでした")); console.error( - chalk.red(" Qiita上で記事が削除されていないかご確認ください") + chalk.red(" Qiita上で記事が削除されていないかご確認ください"), ); break; case QiitaRateLimitError.name: @@ -60,15 +60,15 @@ export const handleError = async (error: Error) => { break; case QiitaUnknownError.name: console.error( - chalk.red.bold("Qiita APIへのリクエストで不明なエラーが発生しました") + chalk.red.bold("Qiita APIへのリクエストで不明なエラーが発生しました"), ); console.error( chalk.red( - " バグの可能性がある場合は、Qiita Discussionsよりご報告いただけると幸いです" - ) + " バグの可能性がある場合は、Qiita Discussionsよりご報告いただけると幸いです", + ), ); console.error( - chalk.red(" https://github.com/increments/qiita-discussions") + chalk.red(" https://github.com/increments/qiita-discussions"), ); break; @@ -76,11 +76,11 @@ export const handleError = async (error: Error) => { console.error(chalk.red.bold(`エラーが発生しました (${error.message})`)); console.error( chalk.red( - " バグの可能性がある場合は、Qiita Discussionsよりご報告いただけると幸いです" - ) + " バグの可能性がある場合は、Qiita Discussionsよりご報告いただけると幸いです", + ), ); console.error( - chalk.red(" https://github.com/increments/qiita-discussions") + chalk.red(" https://github.com/increments/qiita-discussions"), ); } }; diff --git a/src/lib/file-system-repo.test.ts b/src/lib/file-system-repo.test.ts index eecd281..a505e71 100644 --- a/src/lib/file-system-repo.test.ts +++ b/src/lib/file-system-repo.test.ts @@ -38,7 +38,7 @@ describe("FileSystemRepo", () => { expect(item).toBeNull(); expect(mockFs.readdir.mock.calls).toHaveLength(1); expect(mockFs.readdir.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}` + `${dataRootDir}/${subDir}`, ); }); }); @@ -67,14 +67,14 @@ tags: [] expect(item?.id).toBe(itemId); expect(mockFs.readdir.mock.calls).toHaveLength(1); expect(mockFs.readdir.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}` + `${dataRootDir}/${subDir}`, ); expect(mockFs.readFile.mock.calls).toHaveLength(2); expect(mockFs.readFile.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}/${filename}` + `${dataRootDir}/${subDir}/${filename}`, ); expect(mockFs.readFile.mock.calls[1][0]).toBe( - `${dataRootDir}/${subDir}/.remote/${itemId}.md` + `${dataRootDir}/${subDir}/.remote/${itemId}.md`, ); }); }); @@ -99,7 +99,7 @@ tags: [] expect(item).toBeNull(); expect(mockFs.readdir.mock.calls).toHaveLength(1); expect(mockFs.readdir.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}` + `${dataRootDir}/${subDir}`, ); }); }); @@ -128,14 +128,14 @@ tags: [] expect(item?.id).toBe(id); expect(mockFs.readdir.mock.calls).toHaveLength(1); expect(mockFs.readdir.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}` + `${dataRootDir}/${subDir}`, ); expect(mockFs.readFile.mock.calls).toHaveLength(2); expect(mockFs.readFile.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}/${basename}.md` + `${dataRootDir}/${subDir}/${basename}.md`, ); expect(mockFs.readFile.mock.calls[1][0]).toBe( - `${dataRootDir}/${subDir}/.remote/${id}.md` + `${dataRootDir}/${subDir}/.remote/${id}.md`, ); }); }); @@ -245,7 +245,7 @@ slide: false expect(mockFs.writeFile.mock.calls).toHaveLength(1); expect(mockFs.writeFile.mock.calls[0]).toHaveLength(3); expect(mockFs.writeFile.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}/newArticle001.md` + `${dataRootDir}/${subDir}/newArticle001.md`, ); const { data } = matter(mockFs.writeFile.mock.calls[0][1] as string); expect(data.id).toBeNull(); @@ -271,7 +271,7 @@ slide: false expect(mockFs.writeFile.mock.calls).toHaveLength(1); expect(mockFs.writeFile.mock.calls[0]).toHaveLength(3); expect(mockFs.writeFile.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}/test01.md` + `${dataRootDir}/${subDir}/test01.md`, ); const { data } = matter(mockFs.writeFile.mock.calls[0][1] as string); expect(data.id).toBeNull(); @@ -315,7 +315,7 @@ updated `; const subject = ( beforeSync: boolean = false, - forceUpdate: boolean = false + forceUpdate: boolean = false, ) => { return instance.saveItem(item, beforeSync, forceUpdate); }; @@ -331,10 +331,10 @@ updated expect(mockFs.readFile.mock.calls).toHaveLength(1); expect(mockFs.writeFile.mock.calls).toHaveLength(2); expect(mockFs.writeFile.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}/.remote/${remoteFilename}` + `${dataRootDir}/${subDir}/.remote/${remoteFilename}`, ); expect(mockFs.writeFile.mock.calls[1][0]).toBe( - `${dataRootDir}/${subDir}/${localFilename}` + `${dataRootDir}/${subDir}/${localFilename}`, ); }); }); @@ -352,7 +352,7 @@ updated expect(mockFs.readFile.mock.calls).toHaveLength(3); expect(mockFs.writeFile.mock.calls).toHaveLength(1); expect(mockFs.writeFile.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}/.remote/${remoteFilename}` + `${dataRootDir}/${subDir}/.remote/${remoteFilename}`, ); }); }); @@ -369,10 +369,10 @@ updated expect(mockFs.readFile.mock.calls).toHaveLength(3); expect(mockFs.writeFile.mock.calls).toHaveLength(2); expect(mockFs.writeFile.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}/.remote/${remoteFilename}` + `${dataRootDir}/${subDir}/.remote/${remoteFilename}`, ); expect(mockFs.writeFile.mock.calls[1][0]).toBe( - `${dataRootDir}/${subDir}/.remote/${remoteFilename}` + `${dataRootDir}/${subDir}/.remote/${remoteFilename}`, ); }); }); @@ -391,10 +391,10 @@ updated expect(mockFs.readFile.mock.calls).toHaveLength(3); expect(mockFs.writeFile.mock.calls).toHaveLength(2); expect(mockFs.writeFile.mock.calls[0][0]).toBe( - `${dataRootDir}/${subDir}/.remote/${remoteFilename}` + `${dataRootDir}/${subDir}/.remote/${remoteFilename}`, ); expect(mockFs.writeFile.mock.calls[1][0]).toBe( - `${dataRootDir}/${subDir}/${localFilename}` + `${dataRootDir}/${subDir}/${localFilename}`, ); }); }); diff --git a/src/lib/file-system-repo.ts b/src/lib/file-system-repo.ts index 0a7ada4..337d574 100644 --- a/src/lib/file-system-repo.ts +++ b/src/lib/file-system-repo.ts @@ -216,7 +216,7 @@ export class FileSystemRepo { private async getItemFilenames(remote: boolean = false) { return await fs.readdir( this.getRootOrRemotePath(remote), - FileSystemRepo.fileSystemOptions() + FileSystemRepo.fileSystemOptions(), ); } @@ -234,7 +234,7 @@ export class FileSystemRepo { const basename = `${prefix}${suffix}`; const filenameCandidate = this.getFilename(basename); const found = itemFilenames.find( - (filename) => filename === filenameCandidate + (filename) => filename === filenameCandidate, ); if (!found) { return basename; @@ -252,14 +252,14 @@ export class FileSystemRepo { private async setItemData( fileContent: FileContent, remote: boolean = false, - basename: string | null = null + basename: string | null = null, ) { if (!fileContent.id) { return; } const filepath = this.getFilePath( basename || this.defaultBasename(fileContent), - remote + remote, ); const data = fileContent.toSaveFormat(); await fs.writeFile(filepath, data, FileSystemRepo.fileSystemOptions()); @@ -267,12 +267,12 @@ export class FileSystemRepo { private async getItemData( itemFilename: string, - remote: boolean = false + remote: boolean = false, ): Promise { try { const fileContent = await fs.readFile( path.join(this.getRootOrRemotePath(remote), itemFilename), - FileSystemRepo.fileSystemOptions() + FileSystemRepo.fileSystemOptions(), ); return FileContent.read(fileContent); } catch (err: any) { @@ -283,7 +283,7 @@ export class FileSystemRepo { private async syncItem( item: Item, beforeSync: boolean = false, - forceUpdate: boolean = false + forceUpdate: boolean = false, ) { const fileContent = FileContent.fromItem(item); @@ -295,7 +295,7 @@ export class FileSystemRepo { const basename = localResult?.name || null; const remoteFileContent = await this.getItemData( this.getFilename(item.id), - true + true, ); if (data === null || remoteFileContent?.equals(data) || forceUpdate) { @@ -317,7 +317,7 @@ export class FileSystemRepo { async saveItem( item: Item, beforeSync: boolean = false, - forceUpdate: boolean = false + forceUpdate: boolean = false, ) { await this.syncItem(item, beforeSync, forceUpdate); } @@ -447,7 +447,7 @@ export class FileSystemRepo { await fs.writeFile( newFilePath, newData, - FileSystemRepo.fileSystemOptions() + FileSystemRepo.fileSystemOptions(), ); } diff --git a/src/lib/get-latest-package-version/fetch-package-version.ts b/src/lib/get-latest-package-version/fetch-package-version.ts index 5f1498a..0b9b89d 100644 --- a/src/lib/get-latest-package-version/fetch-package-version.ts +++ b/src/lib/get-latest-package-version/fetch-package-version.ts @@ -3,7 +3,7 @@ import { PackageSettings } from "../package-settings"; export const fetchLatestPackageVersion = async () => { try { const response = await fetch( - `https://registry.npmjs.org/${PackageSettings.name}/latest` + `https://registry.npmjs.org/${PackageSettings.name}/latest`, ); const json = await response.json(); const latestVersion = json.version as string; diff --git a/src/lib/get-latest-package-version/get-latest-package-version.test.ts b/src/lib/get-latest-package-version/get-latest-package-version.test.ts index bd8e11d..13277de 100644 --- a/src/lib/get-latest-package-version/get-latest-package-version.test.ts +++ b/src/lib/get-latest-package-version/get-latest-package-version.test.ts @@ -6,7 +6,7 @@ import * as packageVersionCache from "./package-version-cache"; describe("getLatestPackageVersion", () => { const mockFetchLatestPackageVersion = jest.spyOn( fetchPackageVersion, - "fetchLatestPackageVersion" + "fetchLatestPackageVersion", ); const mockGetCacheData = jest.spyOn(packageVersionCache, "getCacheData"); const mockSetCacheData = jest.spyOn(packageVersionCache, "setCacheData"); @@ -27,7 +27,7 @@ describe("getLatestPackageVersion", () => { beforeEach(() => { mockGetCacheData.mockReturnValue(cacheData); mockDateNow.mockReturnValue( - new Date("2023-07-13T11:00:00.000Z").getTime() + new Date("2023-07-13T11:00:00.000Z").getTime(), ); }); diff --git a/src/lib/qiita-cli-url.ts b/src/lib/qiita-cli-url.ts index 89f5275..8728d6e 100644 --- a/src/lib/qiita-cli-url.ts +++ b/src/lib/qiita-cli-url.ts @@ -7,7 +7,7 @@ export const itemsIndexPath = () => { export const itemsShowPath = ( itemId: string, - params?: ItemsShowQueryParams + params?: ItemsShowQueryParams, ): string => { const url: string = `/items/${itemId}`; @@ -22,7 +22,7 @@ export const itemsShowPath = ( export const apiItemsShowPath = ( itemId: string, - params?: ItemsShowQueryParams + params?: ItemsShowQueryParams, ): string => { const url: string = `/api/items/${itemId}`; diff --git a/src/lib/sync-articles-from-qiita.test.ts b/src/lib/sync-articles-from-qiita.test.ts index ec8a1da..fae7320 100644 --- a/src/lib/sync-articles-from-qiita.test.ts +++ b/src/lib/sync-articles-from-qiita.test.ts @@ -16,7 +16,7 @@ describe("syncArticlesFromQiita", () => { const mockAuthenticatedUserItems = jest.spyOn( qiitaApi, - "authenticatedUserItems" + "authenticatedUserItems", ); const mockSaveItems = jest.spyOn(fileSystemRepo, "saveItems"); const mockGetUserConfig = jest.spyOn(mockConfig, "getUserConfig"); @@ -71,7 +71,7 @@ describe("syncArticlesFromQiita", () => { describe("with forceUpdate", () => { const expectSaveItemsToBeCalledWithForceUpdate = async ( - forceUpdate: boolean + forceUpdate: boolean, ) => { mockGetUserConfig.mockImplementation(async () => ({ includePrivate: true, diff --git a/src/lib/validators/item-validator.test.ts b/src/lib/validators/item-validator.test.ts index 12c5cce..3f5b866 100644 --- a/src/lib/validators/item-validator.test.ts +++ b/src/lib/validators/item-validator.test.ts @@ -72,7 +72,7 @@ describe("validateItem", () => { it("return validation error message", () => { expect(errorMessages.length).toEqual(1); expect(errorMessages[0]).toContain( - "タグは1つ以上、5つ以内で指定してください" + "タグは1つ以上、5つ以内で指定してください", ); }); }); @@ -86,7 +86,7 @@ describe("validateItem", () => { it("return validation error message", () => { expect(errorMessages.length).toEqual(1); expect(errorMessages[0]).toContain( - "タグは1つ以上、5つ以内で指定してください" + "タグは1つ以上、5つ以内で指定してください", ); }); }); @@ -106,7 +106,7 @@ describe("validateItem", () => { it("returns validation error message", () => { expect(errorMessages.length).toEqual(1); expect(errorMessages[0]).toContain( - "限定共有記事にOrganizationを紐付けることはできません" + "限定共有記事にOrganizationを紐付けることはできません", ); }); }); diff --git a/src/lib/validators/item-validator.ts b/src/lib/validators/item-validator.ts index b27869b..682cf15 100644 --- a/src/lib/validators/item-validator.ts +++ b/src/lib/validators/item-validator.ts @@ -62,7 +62,7 @@ const validateOrganizationSecretItem: Validator = { const getValidationErrorMessages = ( item: Item, - validators: Validator[] + validators: Validator[], ): string[] => { return validators.reduce((errorMessages: string[], validator) => { if (!validator.isValid(item)) { diff --git a/src/main.ts b/src/main.ts index c6424ce..0685462 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,7 +19,7 @@ const args = arg( }, { permissive: true, - } + }, ); const commandName = args._[0] || "preview"; diff --git a/src/qiita-api/index.ts b/src/qiita-api/index.ts index 655e9ee..02c294f 100644 --- a/src/qiita-api/index.ts +++ b/src/qiita-api/index.ts @@ -97,7 +97,7 @@ export class QiitaApi { JSON.stringify({ status: response.status, responseBody, - }) + }), ); } diff --git a/src/server/api/assets.ts b/src/server/api/assets.ts index 4792a13..4a258e4 100644 --- a/src/server/api/assets.ts +++ b/src/server/api/assets.ts @@ -3,7 +3,7 @@ import { Router } from "express"; const redirectToArticleCss = async ( req: Express.Request, - res: Express.Response + res: Express.Response, ) => { const url = process.env.QIITA_ASSETS_ARTICLE_CSS || @@ -13,7 +13,7 @@ const redirectToArticleCss = async ( const redirectToEmbedInitJs = async ( req: Express.Request, - res: Express.Response + res: Express.Response, ) => { const url = process.env.QIITA_ASSETS_EMBED_INIT_JS || @@ -23,7 +23,7 @@ const redirectToEmbedInitJs = async ( const redirectToFavicon = async ( req: Express.Request, - res: Express.Response + res: Express.Response, ) => { const url = process.env.QIITA_ASSETS_FAVICON || diff --git a/src/server/api/items.ts b/src/server/api/items.ts index 829d3b4..d35699b 100644 --- a/src/server/api/items.ts +++ b/src/server/api/items.ts @@ -44,7 +44,7 @@ const itemsIndex = async (req: Express.Request, res: Express.Response) => { private: [] as ItemViewModel[], draft: [] as ItemViewModel[], public: [] as ItemViewModel[], - } + }, ); res.json(result); diff --git a/src/server/api/readme.ts b/src/server/api/readme.ts index 91de1b7..b55be25 100644 --- a/src/server/api/readme.ts +++ b/src/server/api/readme.ts @@ -8,7 +8,7 @@ const readmeIndex = async (req: Express.Request, res: Express.Response) => { try { const fileContent = await fs.readFile( path.join(path.resolve(__dirname), "../../../", "README.md"), - { encoding: "utf8" } + { encoding: "utf8" }, ); const qiitaApi = await getQiitaApiInstance(); const renderedBody = await qiitaApi.preview(fileContent); diff --git a/yarn.lock b/yarn.lock index 1925137..8b677a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4292,10 +4292,10 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -prettier@^2.8.4: - version "2.8.4" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.4.tgz#34dd2595629bfbb79d344ac4a91ff948694463c3" - integrity sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw== +prettier@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643" + integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg== pretty-error@^4.0.0: version "4.0.0"