From 41ffde4ef9a8a9b38fd2c096380bae722e70f34c Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 30 Jun 2022 22:38:00 +0900 Subject: [PATCH 01/12] `npm uninstall prettier` --- package-lock.json | 22 ---------------------- package.json | 1 - 2 files changed, 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6ab93068..d41e3e05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,6 @@ "eslint-plugin-prefer-arrow": "^1.2.3", "eslint-plugin-react-hooks": "^4.6.0", "jest": "^28.1.2", - "prettier": "^2.7.1", "ts-jest": "^28.0.5", "ts-node": "^10.8.1", "typescript": "^4.7.4", @@ -5348,21 +5347,6 @@ "node": ">= 0.8.0" } }, - "node_modules/prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", - "dev": true, - "bin": { - "prettier": "bin-prettier.js" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, "node_modules/pretty-format": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", @@ -10178,12 +10162,6 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, - "prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", - "dev": true - }, "pretty-format": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", diff --git a/package.json b/package.json index 7dfc6e10..cb7f6481 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "eslint-plugin-prefer-arrow": "^1.2.3", "eslint-plugin-react-hooks": "^4.6.0", "jest": "^28.1.2", - "prettier": "^2.7.1", "ts-jest": "^28.0.5", "ts-node": "^10.8.1", "typescript": "^4.7.4", From f1909bb87c5e576bed22e14a8f6e7501b74895e2 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 30 Jun 2022 22:38:36 +0900 Subject: [PATCH 02/12] `npm install --save-dev dprint` --- package-lock.json | 88 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 89 insertions(+) diff --git a/package-lock.json b/package-lock.json index d41e3e05..1b4ed05a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "@typescript-eslint/eslint-plugin": "^5.30.0", "@typescript-eslint/parser": "^5.30.0", "@vitejs/plugin-react": "^1.3.2", + "dprint": "^0.30.0", "esbuild": "^0.14.48", "eslint": "^8.18.0", "eslint-plugin-deprecation": "^1.3.2", @@ -2405,6 +2406,15 @@ "node-int64": "^0.4.0" } }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -2689,6 +2699,19 @@ "integrity": "sha512-NMt+m9zFMPZe0JcY9gN224Qvk6qLIdqex29clBvc/y75ZBX9YA9wNK3frsYvu2DI1xcCIwxwnX+TlsJ2DSOADg==", "dev": true }, + "node_modules/dprint": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/dprint/-/dprint-0.30.0.tgz", + "integrity": "sha512-9HtWvFM02I66k5VU1iUWkpD0HJ9jvsFQALQzB8qat0N8YcSeyBPthIy8AqBnIE/ahVTaQXooPGV3WWoWXlRwFA==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "yauzl": "=2.10.0" + }, + "bin": { + "dprint": "bin.js" + } + }, "node_modules/electron-to-chromium": { "version": "1.4.148", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.148.tgz", @@ -3495,6 +3518,15 @@ "bser": "2.1.1" } }, + "node_modules/fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dev": true, + "dependencies": { + "pend": "~1.2.0" + } + }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -5275,6 +5307,12 @@ "node": ">=8" } }, + "node_modules/pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", + "dev": true + }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -6273,6 +6311,16 @@ "node": ">=12" } }, + "node_modules/yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dev": true, + "dependencies": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + }, "node_modules/yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", @@ -8035,6 +8083,12 @@ "node-int64": "^0.4.0" } }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true + }, "buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -8255,6 +8309,15 @@ "integrity": "sha512-NMt+m9zFMPZe0JcY9gN224Qvk6qLIdqex29clBvc/y75ZBX9YA9wNK3frsYvu2DI1xcCIwxwnX+TlsJ2DSOADg==", "dev": true }, + "dprint": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/dprint/-/dprint-0.30.0.tgz", + "integrity": "sha512-9HtWvFM02I66k5VU1iUWkpD0HJ9jvsFQALQzB8qat0N8YcSeyBPthIy8AqBnIE/ahVTaQXooPGV3WWoWXlRwFA==", + "dev": true, + "requires": { + "yauzl": "=2.10.0" + } + }, "electron-to-chromium": { "version": "1.4.148", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.148.tgz", @@ -8769,6 +8832,15 @@ "bser": "2.1.1" } }, + "fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dev": true, + "requires": { + "pend": "~1.2.0" + } + }, "file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -10118,6 +10190,12 @@ "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", + "dev": true + }, "picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -10793,6 +10871,16 @@ "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==", "dev": true }, + "yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dev": true, + "requires": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + }, "yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", diff --git a/package.json b/package.json index cb7f6481..b555ba6c 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@typescript-eslint/eslint-plugin": "^5.30.0", "@typescript-eslint/parser": "^5.30.0", "@vitejs/plugin-react": "^1.3.2", + "dprint": "^0.30.0", "esbuild": "^0.14.48", "eslint": "^8.18.0", "eslint-plugin-deprecation": "^1.3.2", From 6cfb2e2b17b790b15ae83f8220fb2848154ef0b9 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 30 Jun 2022 22:51:10 +0900 Subject: [PATCH 03/12] Integrate dprint to avoid prettier blocking no-mixed-operators --- .github/workflows/main.yml | 2 +- .vscode/extensions.json | 5 +++++ .vscode/settings.json | 4 ++-- README.md | 13 ++++++++++--- dprint.json | 25 +++++++++++++++++++++++++ package.json | 4 ++-- renovate.json | 15 +++++++++++++++ 7 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 dprint.json create mode 100644 renovate.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 81f598cc..e73178ce 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -95,6 +95,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: dprint/check@v2.0 - uses: actions/setup-node@v3 with: node-version: 18 @@ -117,5 +118,4 @@ jobs: run: npm install - name: lint run: | - npm run prettier-check npm run eslint diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..eb741821 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "dprint.dprint" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 0c74962e..fb024594 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { "typescript.tsdk": "node_modules/typescript/lib", - "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.defaultFormatter": "dprint.dprint", "editor.formatOnSave": true -} \ No newline at end of file +} diff --git a/README.md b/README.md index 5c4671d3..6a2b5533 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,13 @@ # mobu + + + [![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-) + + [![Actions Status](https://github.com/mobu-of-the-world/mobu/workflows/CI/badge.svg)](https://github.com/mobu-of-the-world/mobu/actions) A web application to manage participants and timer for mob-programming! @@ -37,11 +42,12 @@ MIT Yosuke Akatsuka (a.k.a [pankona](https://github.com/pankona)) - ## Contributors ✨ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): + + @@ -59,7 +65,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d - -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! \ No newline at end of file + + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! diff --git a/dprint.json b/dprint.json new file mode 100644 index 00000000..98172f6d --- /dev/null +++ b/dprint.json @@ -0,0 +1,25 @@ +{ + "typescript": { + "module.sortImportDeclarations": "maintain", + "module.sortExportDeclarations": "maintain", + "importDeclaration.sortNamedImports": "maintain", + "exportDeclaration.sortNamedExports": "maintain" + }, + "json": { + }, + "markdown": { + }, + "includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs,json,md,html,css}"], + "excludes": [ + ".git", + "**/node_modules", + "**/*-lock.json", + "build" + ], + "plugins": [ + "https://plugins.dprint.dev/typescript-0.69.5.wasm", + "https://plugins.dprint.dev/json-0.15.3.wasm", + "https://plugins.dprint.dev/markdown-0.13.3.wasm", + "https://plugins.dprint.dev/prettier-0.9.0.json@76c20538ea4231b3daa9b62059f90ec144200cab5477b7e95b730cbb3ed48957" + ] +} diff --git a/package.json b/package.json index b555ba6c..03f5b15a 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,8 @@ "build": "tsc --noEmit && vite build", "test": "jest --watch", "test:ci": "jest", - "prettier-check": "prettier --list-different \"src/**/*.{ts,tsx,css,scss}\"", - "prettier:fix": "prettier --write \"src/**/*.{ts,tsx,css,scss}\"", + "format:check": "dprint check", + "format:fix": "dprint fmt", "eslint": "eslint \"src/**/*.{ts,tsx}\"", "eslint:fix": "eslint --fix \"src/**/*.{ts,tsx}\"" }, diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..f4b9c9c0 --- /dev/null +++ b/renovate.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "github>kachick/renovate-config-dprint" + ], + "labels": ["dependencies", "renovate"], + "automerge": true, + "packageRules": [ + { + "groupName": "node", + "matchPackageNames": ["node"], + "enabled": false + } + ] +} From fba0ecab0725991a8c01a47ed520ec9e8f45cdc8 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 30 Jun 2022 23:54:38 +0900 Subject: [PATCH 04/12] Avoid unexpected space removing by dprint --- src/session/SoundConfig.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session/SoundConfig.tsx b/src/session/SoundConfig.tsx index 42d27c0d..a0135e83 100644 --- a/src/session/SoundConfig.tsx +++ b/src/session/SoundConfig.tsx @@ -18,7 +18,7 @@ const SoundConfig = (props: SoundConfigProps) => { return (
- Bell 🛎 : + {`Bell 🛎 : `}
From a791b7a81b39d7942d104ef047c84d5f09e93bc1 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 30 Jun 2022 23:58:06 +0900 Subject: [PATCH 05/12] `npm run format:fix` --- src/common/constants.ts | 3 +-- src/common/cssHelpers.test.ts | 4 ++-- src/common/cssHelpers.ts | 3 +-- src/common/usersContexts.tsx | 2 +- src/header/Menu.tsx | 3 +-- src/index.tsx | 2 +- src/session/Interval.tsx | 4 ++-- src/session/Session.tsx | 9 +++------ src/session/Timer.tsx | 16 ++++++++-------- src/userList/UserList.tsx | 7 +++---- src/userList/UserListHelpers.ts | 6 +++--- src/userList/UserRegister.tsx | 11 +++++------ tsconfig.json | 2 +- 13 files changed, 32 insertions(+), 40 deletions(-) diff --git a/src/common/constants.ts b/src/common/constants.ts index 78ce8ece..eca835ed 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -1,2 +1 @@ -export const GITHUB_REPOSITORY_URL = - "https://github.com/mobu-of-the-world/mobu" as const; +export const GITHUB_REPOSITORY_URL = "https://github.com/mobu-of-the-world/mobu" as const; diff --git a/src/common/cssHelpers.test.ts b/src/common/cssHelpers.test.ts index 73845d81..77300dd2 100644 --- a/src/common/cssHelpers.test.ts +++ b/src/common/cssHelpers.test.ts @@ -3,10 +3,10 @@ import { buildClassNames } from "./cssHelpers"; test("returns combined classnames as a string that trimmed empty", async () => { expect(buildClassNames(["button", "button-primary"])).toBe( - "button button-primary" + "button button-primary", ); expect(buildClassNames(["button", undefined])).toBe("button"); expect(buildClassNames(["button", undefined, "hidden"])).toBe( - "button hidden" + "button hidden", ); }); diff --git a/src/common/cssHelpers.ts b/src/common/cssHelpers.ts index a32b8cd7..2a445657 100644 --- a/src/common/cssHelpers.ts +++ b/src/common/cssHelpers.ts @@ -1,2 +1 @@ -export const buildClassNames = (classNames: (string | undefined)[]): string => - classNames.filter(Boolean).join(" "); +export const buildClassNames = (classNames: (string | undefined)[]): string => classNames.filter(Boolean).join(" "); diff --git a/src/common/usersContexts.tsx b/src/common/usersContexts.tsx index 30f1e10b..5bbdf465 100644 --- a/src/common/usersContexts.tsx +++ b/src/common/usersContexts.tsx @@ -3,7 +3,7 @@ import { getStorageUsers, setStorageUsers } from "./storage"; const usersContext = createContext([]); const setPersistedUsersContext = createContext<(newUsers: string[]) => void>( - () => undefined + () => undefined, ); export const UsersProvider = ({ children }: { children: ReactElement }) => { diff --git a/src/header/Menu.tsx b/src/header/Menu.tsx index 9e32121f..e12c4672 100644 --- a/src/header/Menu.tsx +++ b/src/header/Menu.tsx @@ -4,8 +4,7 @@ import { buildClassNames } from "../common/cssHelpers"; import css from "./Menu.module.css"; -const visibilityClassname = (isVisible: boolean): "visible" | "hidden" => - isVisible ? "visible" : "hidden"; +const visibilityClassname = (isVisible: boolean): "visible" | "hidden" => isVisible ? "visible" : "hidden"; const Menu = ({ isVisible, diff --git a/src/index.tsx b/src/index.tsx index 5a984623..1947907d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -11,5 +11,5 @@ assertIsDefined(root); createRoot(root).render( - + , ); diff --git a/src/session/Interval.tsx b/src/session/Interval.tsx index ce75f0f5..1c0c344c 100644 --- a/src/session/Interval.tsx +++ b/src/session/Interval.tsx @@ -27,7 +27,7 @@ const Interval = ({ setIntervalSeconds(newIntervalSeconds); } }, - [setIntervalSeconds] + [setIntervalSeconds], ), minutes: useCallback( (event: ChangeEvent) => { @@ -37,7 +37,7 @@ const Interval = ({ setIntervalSeconds(newIntervalSeconds); } }, - [setIntervalSeconds] + [setIntervalSeconds], ), }[unit]; diff --git a/src/session/Session.tsx b/src/session/Session.tsx index 78d9ce32..4167adbe 100644 --- a/src/session/Session.tsx +++ b/src/session/Session.tsx @@ -3,10 +3,7 @@ import { useState } from "react"; import Timer from "./Timer"; import Interval from "./Interval"; import SoundConfig from "./SoundConfig"; -import { - getStorageSoundEnabled, - setStorageSoundEnabled, -} from "../common/storage"; +import { getStorageSoundEnabled, setStorageSoundEnabled } from "../common/storage"; import css from "./Session.module.css"; @@ -15,10 +12,10 @@ const initialIntervalSeconds = 60 * 30; const Session = () => { const [iterationCount, setIterationCount] = useState(0); const [intervalSeconds, setIntervalSeconds] = useState( - initialIntervalSeconds + initialIntervalSeconds, ); const [isSoundEnabled, setIsSoundEnabled] = useState( - getStorageSoundEnabled() + getStorageSoundEnabled(), ); return ( diff --git a/src/session/Timer.tsx b/src/session/Timer.tsx index 00c39e75..f633d64b 100644 --- a/src/session/Timer.tsx +++ b/src/session/Timer.tsx @@ -36,10 +36,8 @@ const Timer = ({ setIsCounting(false); setPersistedUsers( users.length >= 2 - ? [...users.slice(1, users.length), users[0]].flatMap((user) => - user ? [user] : [] - ) - : users + ? [...users.slice(1, users.length), users[0]].flatMap((user) => user ? [user] : []) + : users, ); if (isSoundEnabled) { const bell = new Audio(audiofile); @@ -53,7 +51,7 @@ const Timer = ({ setCountTotal(countTotal + 1); } }, - isCounting ? 1000 : null + isCounting ? 1000 : null, ); const onStartOrPause = useCallback(() => { @@ -66,9 +64,11 @@ const Timer = ({ setIterationCount(1); if (window.Notification && Notification.permission !== "granted") { - const alertMessageByNotificationPermission: Readonly<{ - [key in NotificationPermission]: string; - }> = { + const alertMessageByNotificationPermission: Readonly< + { + [key in NotificationPermission]: string; + } + > = { granted: "Thanks to accept the notification :)", denied: "You rejected the notification :(Please accept it.", default: "Can not judge to use notification :(Please accept it.", diff --git a/src/userList/UserList.tsx b/src/userList/UserList.tsx index 4ef56c23..da1e7b1d 100644 --- a/src/userList/UserList.tsx +++ b/src/userList/UserList.tsx @@ -52,13 +52,12 @@ const UserList = () => { ev.preventDefault(); const droppedData = ev.dataTransfer.getData("text/plain"); const droppedMatchedGroups = droppedData.match( - /^user-(?.+)$/ + /^user-(?.+)$/, )?.groups; - const droppedUsername = - droppedMatchedGroups && droppedMatchedGroups["droppedUsername"]; + const droppedUsername = droppedMatchedGroups && droppedMatchedGroups["droppedUsername"]; if (typeof droppedUsername === "string") { setPersistedUsers( - newUsersAfterDropped(users, user, droppedUsername) + newUsersAfterDropped(users, user, droppedUsername), ); } return false; diff --git a/src/userList/UserListHelpers.ts b/src/userList/UserListHelpers.ts index 87ae6591..c37aa5d8 100644 --- a/src/userList/UserListHelpers.ts +++ b/src/userList/UserListHelpers.ts @@ -1,13 +1,13 @@ export const newUsersAfterDropped = ( originalUsers: string[], currentUser: string, - droppedUser: string + droppedUser: string, ): string[] => { const droppedUserNewIndex = originalUsers.findIndex( - (element) => element === currentUser + (element) => element === currentUser, ); const droppedUserOldIndex = originalUsers.findIndex( - (element) => element === droppedUser + (element) => element === droppedUser, ); const newUsers = [...originalUsers]; diff --git a/src/userList/UserRegister.tsx b/src/userList/UserRegister.tsx index f23ed4d3..914a1405 100644 --- a/src/userList/UserRegister.tsx +++ b/src/userList/UserRegister.tsx @@ -18,7 +18,7 @@ const UserRegister = () => { (event: React.ChangeEvent) => { setUsername(event.currentTarget.value); }, - [] + [], ); const onUserRegister = useCallback( (event: React.FormEvent) => { @@ -26,12 +26,11 @@ const UserRegister = () => { setPersistedUsers([...users, username.trim()]); setUsername(emptyUsername); }, - [setPersistedUsers, username, users] + [setPersistedUsers, username, users], ); - const registerDisabled = - username === emptyUsername || - blankStringsPattern.test(username) || - users.includes(username); + const registerDisabled = username === emptyUsername + || blankStringsPattern.test(username) + || users.includes(username); return (
diff --git a/tsconfig.json b/tsconfig.json index 5c69e368..afd645bb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "esnext" ], "noEmit": true, - "jsx": "react-jsx", + "jsx": "react-jsx" }, "include": ["src/**/*", "tests/**/*", "*.config.ts"] } From bbd0c6f6e8011603f8e879bfcfbee324f8db5a5f Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 30 Jun 2022 23:59:07 +0900 Subject: [PATCH 06/12] Enable `no-mixed-operators` in eslint --- .eslintrc.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.json b/.eslintrc.json index ef16a52e..fca89f3b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,6 +16,7 @@ } }, "rules": { + "no-mixed-operators": "error", "react-hooks/rules-of-hooks": "error", "react-hooks/exhaustive-deps": "warn", "no-unused-vars": "off", From d21ca200318d0e5e177db52024d313dea81cab38 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 30 Jun 2022 23:59:45 +0900 Subject: [PATCH 07/12] Fix `no-mixed-operators` --- src/session/Timer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session/Timer.tsx b/src/session/Timer.tsx index f633d64b..60e4ee6b 100644 --- a/src/session/Timer.tsx +++ b/src/session/Timer.tsx @@ -31,7 +31,7 @@ const Timer = ({ useInterval( () => { if (countInIteration > 0 && countInIteration % intervalSeconds === 0) { - setIterationCount(countTotal / intervalSeconds + 1); + setIterationCount((countTotal / intervalSeconds) + 1); setCountInIteration(0); setIsCounting(false); setPersistedUsers( From df2f35f5726aa3756767791393ab80dbeb0d07ff Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Fri, 1 Jul 2022 00:39:17 +0900 Subject: [PATCH 08/12] Enable `operatorPosition: true` as closed to prettier --- dprint.json | 3 ++- src/session/Timer.tsx | 6 +++--- src/userList/UserRegister.tsx | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dprint.json b/dprint.json index 98172f6d..2ce7cf34 100644 --- a/dprint.json +++ b/dprint.json @@ -3,7 +3,8 @@ "module.sortImportDeclarations": "maintain", "module.sortExportDeclarations": "maintain", "importDeclaration.sortNamedImports": "maintain", - "exportDeclaration.sortNamedExports": "maintain" + "exportDeclaration.sortNamedExports": "maintain", + "operatorPosition": "sameLine" }, "json": { }, diff --git a/src/session/Timer.tsx b/src/session/Timer.tsx index 60e4ee6b..0f8cabdd 100644 --- a/src/session/Timer.tsx +++ b/src/session/Timer.tsx @@ -35,9 +35,9 @@ const Timer = ({ setCountInIteration(0); setIsCounting(false); setPersistedUsers( - users.length >= 2 - ? [...users.slice(1, users.length), users[0]].flatMap((user) => user ? [user] : []) - : users, + users.length >= 2 ? + [...users.slice(1, users.length), users[0]].flatMap((user) => user ? [user] : []) : + users, ); if (isSoundEnabled) { const bell = new Audio(audiofile); diff --git a/src/userList/UserRegister.tsx b/src/userList/UserRegister.tsx index 914a1405..a9315aa4 100644 --- a/src/userList/UserRegister.tsx +++ b/src/userList/UserRegister.tsx @@ -28,9 +28,9 @@ const UserRegister = () => { }, [setPersistedUsers, username, users], ); - const registerDisabled = username === emptyUsername - || blankStringsPattern.test(username) - || users.includes(username); + const registerDisabled = username === emptyUsername || + blankStringsPattern.test(username) || + users.includes(username); return (
From 9ec1a77c8c11abc27f58227445ac87eb44dbb4d8 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Fri, 1 Jul 2022 01:38:04 +0900 Subject: [PATCH 09/12] Enable prettier for YAML --- .github/dependabot.yml | 40 ++++++++--------- .github/workflows/codeql-analysis.yml | 58 ++++++++++++------------- .github/workflows/dependency-review.yml | 12 ++--- dprint.json | 2 +- 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 68683e33..cbab4fa4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,22 +1,22 @@ version: 2 updates: -- package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - reviewers: - - "mobu-of-the-world/maintainers" - labels: - - automerge -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 - reviewers: - - "mobu-of-the-world/maintainers" - labels: - - automerge - ignore: - - dependency-name: "@types/*" - update-types: ["version-update:semver-major"] + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + reviewers: + - "mobu-of-the-world/maintainers" + labels: + - automerge + - package-ecosystem: npm + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + reviewers: + - "mobu-of-the-world/maintainers" + labels: + - automerge + ignore: + - dependency-name: "@types/*" + update-types: ["version-update:semver-major"] diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 20d62a1f..b415f255 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,12 +13,12 @@ name: "CodeQL" on: push: - branches: [ main ] + branches: [main] pull_request: # The branches below must be a subset of the branches above - branches: [ main ] + branches: [main] schedule: - - cron: '19 13 * * 6' + - cron: "19 13 * * 6" jobs: analyze: @@ -28,40 +28,40 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'javascript' ] + language: ["javascript"] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] # Learn more: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language - #- run: | - # make bootstrap - # make release + #- run: | + # make bootstrap + # make release - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 9128e835..86365d81 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -1,10 +1,10 @@ -name: 'Dependency Review' +name: "Dependency Review" on: pull_request: paths: - - '.github/workflows/**' - - 'package.json' - - 'package-lock.json' + - ".github/workflows/**" + - "package.json" + - "package-lock.json" permissions: contents: read @@ -13,7 +13,7 @@ jobs: dependency-review: runs-on: ubuntu-latest steps: - - name: 'Checkout Repository' + - name: "Checkout Repository" uses: actions/checkout@v3 - - name: 'Dependency Review' + - name: "Dependency Review" uses: actions/dependency-review-action@v2 diff --git a/dprint.json b/dprint.json index 2ce7cf34..d28a461d 100644 --- a/dprint.json +++ b/dprint.json @@ -10,7 +10,7 @@ }, "markdown": { }, - "includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs,json,md,html,css}"], + "includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs,json,md,html,css,yml}"], "excludes": [ ".git", "**/node_modules", From e320279c9b20d56da9f1c8f5cbf30421a9888606 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Fri, 1 Jul 2022 01:50:29 +0900 Subject: [PATCH 10/12] Prefer single quote for YAML https://stackoverflow.com/a/22235064 --- .github/dependabot.yml | 16 ++++++++-------- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/dependency-review.yml | 12 ++++++------ dprint.json | 3 +++ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cbab4fa4..74ddaed9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,22 +1,22 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: 'github-actions' + directory: '/' schedule: - interval: "daily" + interval: 'daily' reviewers: - - "mobu-of-the-world/maintainers" + - 'mobu-of-the-world/maintainers' labels: - automerge - package-ecosystem: npm - directory: "/" + directory: '/' schedule: interval: daily open-pull-requests-limit: 10 reviewers: - - "mobu-of-the-world/maintainers" + - 'mobu-of-the-world/maintainers' labels: - automerge ignore: - - dependency-name: "@types/*" - update-types: ["version-update:semver-major"] + - dependency-name: '@types/*' + update-types: ['version-update:semver-major'] diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index b415f255..239b3d08 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,7 +9,7 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: 'CodeQL' on: push: @@ -18,7 +18,7 @@ on: # The branches below must be a subset of the branches above branches: [main] schedule: - - cron: "19 13 * * 6" + - cron: '19 13 * * 6' jobs: analyze: @@ -28,7 +28,7 @@ jobs: strategy: fail-fast: false matrix: - language: ["javascript"] + language: ['javascript'] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] # Learn more: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 86365d81..9128e835 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -1,10 +1,10 @@ -name: "Dependency Review" +name: 'Dependency Review' on: pull_request: paths: - - ".github/workflows/**" - - "package.json" - - "package-lock.json" + - '.github/workflows/**' + - 'package.json' + - 'package-lock.json' permissions: contents: read @@ -13,7 +13,7 @@ jobs: dependency-review: runs-on: ubuntu-latest steps: - - name: "Checkout Repository" + - name: 'Checkout Repository' uses: actions/checkout@v3 - - name: "Dependency Review" + - name: 'Dependency Review' uses: actions/dependency-review-action@v2 diff --git a/dprint.json b/dprint.json index d28a461d..89f0d51e 100644 --- a/dprint.json +++ b/dprint.json @@ -10,6 +10,9 @@ }, "markdown": { }, + "prettier": { + "singleQuote": true + }, "includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs,json,md,html,css,yml}"], "excludes": [ ".git", From 7727cefa4da02a87a2843c9d2f7eb1f79675e0f7 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Fri, 1 Jul 2022 01:55:17 +0900 Subject: [PATCH 11/12] Add eslint plugin for vscode recommendations --- .vscode/extensions.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index eb741821..82a4fa38 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,6 @@ { "recommendations": [ + "dbaeumer.vscode-eslint", "dprint.dprint" ] } From 4df60290e4a96ac0b4eae63facbb54efcb83bff8 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Fri, 1 Jul 2022 10:07:38 +0900 Subject: [PATCH 12/12] Prevent unexpected merge for renovate PRs https://docs.renovatebot.com/modules/manager/ --- renovate.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/renovate.json b/renovate.json index f4b9c9c0..207997cf 100644 --- a/renovate.json +++ b/renovate.json @@ -5,11 +5,5 @@ ], "labels": ["dependencies", "renovate"], "automerge": true, - "packageRules": [ - { - "groupName": "node", - "matchPackageNames": ["node"], - "enabled": false - } - ] + "enabledManagers": ["regex"] }