From cd1c784048ec0b986de976888f0fc8af5b63bf76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:47:36 +0000 Subject: [PATCH 1/2] Bump @vue/eslint-config-typescript from 14.0.0 to 14.1.3 Bumps [@vue/eslint-config-typescript](https://github.com/vuejs/eslint-config-typescript) from 14.0.0 to 14.1.3. - [Release notes](https://github.com/vuejs/eslint-config-typescript/releases) - [Commits](https://github.com/vuejs/eslint-config-typescript/compare/v14.0.0...v14.1.3) --- updated-dependencies: - dependency-name: "@vue/eslint-config-typescript" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 27 +++++++++++++-------------- package.json | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index f23cba1..0bac029 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@playwright/test": "^1.48.1", "@testing-library/vue": "^8.1.0", "@vitejs/plugin-vue": "^5.1.4", - "@vue/eslint-config-typescript": "^14.0.0", + "@vue/eslint-config-typescript": "^14.1.3", "@vue/tsconfig": "^0.5.1", "eslint": "^9.13.0", "eslint-config-prettier": "^9.1.0", @@ -3410,15 +3410,14 @@ } }, "node_modules/@vue/eslint-config-typescript": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/@vue/eslint-config-typescript/-/eslint-config-typescript-14.0.0.tgz", - "integrity": "sha512-JNlgQivBBkj7EvvOchSbGQ1ATO9AquVK6hzn6RsXZO/7anI8A9PGq7w6ca2NepuRXNOF6A9C5T00Qi+zfWL1gg==", + "version": "14.1.3", + "resolved": "https://registry.npmjs.org/@vue/eslint-config-typescript/-/eslint-config-typescript-14.1.3.tgz", + "integrity": "sha512-L4NUJQz/0We2QYtrNwRAGRy4KfpOagl5V3MpZZ+rQ51a+bKjlKYYrugi7lp7PIX8LolRgu06ZwDoswnSGWnAmA==", "dev": true, - "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "^8.6.0", - "@typescript-eslint/parser": "^8.6.0", - "typescript-eslint": "^8.6.0", + "@typescript-eslint/eslint-plugin": "^8.8.1", + "fast-glob": "^3.3.2", + "typescript-eslint": "^8.8.1", "vue-eslint-parser": "^9.4.3" }, "engines": { @@ -11258,14 +11257,14 @@ } }, "@vue/eslint-config-typescript": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/@vue/eslint-config-typescript/-/eslint-config-typescript-14.0.0.tgz", - "integrity": "sha512-JNlgQivBBkj7EvvOchSbGQ1ATO9AquVK6hzn6RsXZO/7anI8A9PGq7w6ca2NepuRXNOF6A9C5T00Qi+zfWL1gg==", + "version": "14.1.3", + "resolved": "https://registry.npmjs.org/@vue/eslint-config-typescript/-/eslint-config-typescript-14.1.3.tgz", + "integrity": "sha512-L4NUJQz/0We2QYtrNwRAGRy4KfpOagl5V3MpZZ+rQ51a+bKjlKYYrugi7lp7PIX8LolRgu06ZwDoswnSGWnAmA==", "dev": true, "requires": { - "@typescript-eslint/eslint-plugin": "^8.6.0", - "@typescript-eslint/parser": "^8.6.0", - "typescript-eslint": "^8.6.0", + "@typescript-eslint/eslint-plugin": "^8.8.1", + "fast-glob": "^3.3.2", + "typescript-eslint": "^8.8.1", "vue-eslint-parser": "^9.4.3" } }, diff --git a/package.json b/package.json index 0535a67..58d889b 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@playwright/test": "^1.48.1", "@testing-library/vue": "^8.1.0", "@vitejs/plugin-vue": "^5.1.4", - "@vue/eslint-config-typescript": "^14.0.0", + "@vue/eslint-config-typescript": "^14.1.3", "@vue/tsconfig": "^0.5.1", "eslint": "^9.13.0", "eslint-config-prettier": "^9.1.0", From 72414047447a26d40c62a835cbd6285de541f2be Mon Sep 17 00:00:00 2001 From: Winston Liu Date: Mon, 28 Oct 2024 12:30:12 -0700 Subject: [PATCH 2/2] Switch to strictTypeChecked --- eslint.config.js | 13 +++++++++++-- src/ReloadPrompt.vue | 2 +- src/components/CardPicker.vue | 4 +++- src/components/Hand.vue | 3 ++- src/operation.ts | 14 +++++++------- src/solver.ts | 2 +- tests/component/CardPicker.test.ts | 2 +- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 47854c5..017c86f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -5,14 +5,21 @@ import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended" export default [ ...pluginVue.configs["flat/recommended"], ...vueTsEslintConfig({ - // TODO: Change to "strictTypeChecked" when https://github.com/vuejs/eslint-config-typescript/issues/85 is fixed. - extends: ["strict"], + extends: ["strictTypeChecked"], }), { + files: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.vue"], rules: { "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", "vue/multi-word-component-names": "off", + "@typescript-eslint/restrict-template-expressions": [ + "error", + { + allowNumber: true, + allowBoolean: true, + }, + ], }, }, { @@ -20,6 +27,8 @@ export default [ rules: { // .to.be.empty, .to.be.true, etc. are valid Vitest assertions. "@typescript-eslint/no-unused-expressions": "off", + // Complains about { rerender } in tests, which is okay. + "@typescript-eslint/unbound-method": "off", }, }, eslintPluginPrettierRecommended, diff --git a/src/ReloadPrompt.vue b/src/ReloadPrompt.vue index 6f49f19..e5304e4 100644 --- a/src/ReloadPrompt.vue +++ b/src/ReloadPrompt.vue @@ -7,7 +7,7 @@ const { needRefresh, updateServiceWorker } = useRegisterSW({ // Check every hour for updates (which if found will then show the reload prompt) setInterval( () => { - registration.update(); + void registration.update(); }, 60 * 60 * 1000, ); diff --git a/src/components/CardPicker.vue b/src/components/CardPicker.vue index e33e907..61ee3b9 100644 --- a/src/components/CardPicker.vue +++ b/src/components/CardPicker.vue @@ -52,7 +52,9 @@ const emit = defineEmits<{ // Use selected as a "proxy" since props.value is readonly const selected = computed({ get: () => props.value, - set: (newValue) => emit("select", newValue), + set: (newValue) => { + emit("select", newValue); + }, }); const getRandomSuit = () => suits[Math.floor(Math.random() * suits.length)]; diff --git a/src/components/Hand.vue b/src/components/Hand.vue index 3eb5b0d..eece471 100644 --- a/src/components/Hand.vue +++ b/src/components/Hand.vue @@ -26,6 +26,7 @@ const emit = defineEmits<{ handUpdated: [card: Card]; }>(); -const updateHand = (id: number, value: number) => +const updateHand = (id: number, value: number) => { emit("handUpdated", { id, value }); +}; diff --git a/src/operation.ts b/src/operation.ts index 3ea1706..1687b99 100644 --- a/src/operation.ts +++ b/src/operation.ts @@ -1,6 +1,6 @@ export interface Operation { operate(a: number, b: number): number; - toString(a: unknown, b: unknown): string; + toString(a: number | string, b: number | string): string; } export const Add: Operation = { @@ -8,7 +8,7 @@ export const Add: Operation = { return a + b; }, - toString(a: unknown, b: unknown): string { + toString(a: number | string, b: number | string): string { return `${a} + ${b}`; }, }; @@ -18,7 +18,7 @@ export const Subtract: Operation = { return a - b; }, - toString(a: unknown, b: unknown): string { + toString(a: number | string, b: number | string): string { return `${a} - ${b}`; }, }; @@ -28,7 +28,7 @@ export const Multiply: Operation = { return a * b; }, - toString(a: unknown, b: unknown): string { + toString(a: number | string, b: number | string): string { return `${a} * ${b}`; }, }; @@ -38,7 +38,7 @@ export const Divide: Operation = { return a / b; }, - toString(a: unknown, b: unknown): string { + toString(a: number | string, b: number | string): string { return `${a} / ${b}`; }, }; @@ -48,7 +48,7 @@ export const Exponent: Operation = { return a ** b; }, - toString(a: unknown, b: unknown): string { + toString(a: number | string, b: number | string): string { return `${a} ^ ${b}`; }, }; @@ -58,7 +58,7 @@ export const Log: Operation = { return Math.log(b) / Math.log(a); }, - toString(a: unknown, b: unknown): string { + toString(a: number | string, b: number | string): string { return `log_${a}(${b})`; }, }; diff --git a/src/solver.ts b/src/solver.ts index eb11866..92c5a24 100644 --- a/src/solver.ts +++ b/src/solver.ts @@ -128,7 +128,7 @@ export function print(solutions: Solution[]): string[] { const left = `(${operations[0].toString(solution[1], solution[2])})`; const right = `(${operations[1].toString(left, solution[3])})`; outputs.push(operations[2].toString(solution[0], right)); - } else if (parentheses === 4) { + } else { // a (b (c d)) const left = `(${operations[0].toString(solution[2], solution[3])})`; const right = `(${operations[1].toString(solution[1], left)})`; diff --git a/tests/component/CardPicker.test.ts b/tests/component/CardPicker.test.ts index dd38af9..5a19505 100644 --- a/tests/component/CardPicker.test.ts +++ b/tests/component/CardPicker.test.ts @@ -25,7 +25,7 @@ describe("CardPicker", () => { screen.getByTestId("card"); }); - test("Renders a random card on load", async () => { + test("Renders a random card on load", () => { render(CardPicker, { props }); const card = screen.getByTestId("card");