From 9b49aedccb84a7ed9a1e0ac04589c3d284c7d2e5 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Tue, 20 Dec 2022 21:26:25 -0600 Subject: [PATCH] Add eslint rule for strict boolean expressions and fix linting issues --- .eslintrc.js | 12 ++++++++-- src/App.vue | 2 +- src/components/Info.vue | 2 +- src/components/Modal.vue | 4 ++-- src/components/NaNScreen.vue | 8 +++---- src/components/Options.vue | 2 +- src/components/Save.vue | 6 ++--- src/components/SavesManager.vue | 2 +- src/components/fields/Slider.vue | 2 +- src/components/fields/Text.vue | 2 +- src/components/fields/Toggle.vue | 2 +- src/components/math/Fraction.vue | 1 + src/components/math/Sqrt.vue | 6 +++-- src/data/common.tsx | 6 ++--- src/data/projEntry.tsx | 4 ++-- src/features/achievements/achievement.tsx | 2 +- src/features/bars/bar.ts | 8 ++++++- src/features/boards/Board.vue | 2 +- src/features/boards/BoardNode.vue | 8 +++---- src/features/buyable.tsx | 28 ++++++++++++++--------- src/features/challenges/Challenge.vue | 8 +++---- src/features/challenges/challenge.tsx | 16 +++++++++---- src/features/clickables/Clickable.vue | 2 +- src/features/clickables/clickable.ts | 15 ++++++++---- src/features/conversion.ts | 17 ++++++++------ src/features/feature.ts | 4 ++-- src/features/milestones/Milestone.vue | 4 ++-- src/features/milestones/milestone.tsx | 15 +++++++++--- src/features/reset.ts | 2 +- src/features/trees/tree.ts | 4 ++-- src/features/upgrades/Upgrade.vue | 4 ++-- src/features/upgrades/upgrade.ts | 7 ++++-- src/game/modifiers.tsx | 6 ++--- src/game/persistence.ts | 6 ++--- src/util/proxies.ts | 2 +- src/util/save.ts | 9 ++++++-- src/util/vue.tsx | 5 +++- 37 files changed, 147 insertions(+), 88 deletions(-) create mode 100644 src/components/math/Fraction.vue diff --git a/.eslintrc.js b/.eslintrc.js index 2a1d0bc..a881f38 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -11,7 +11,8 @@ module.exports = { "@vue/eslint-config-prettier" ], parserOptions: { - ecmaVersion: 2020 + ecmaVersion: 2020, + project: "tsconfig.json" }, ignorePatterns: ["src/lib"], rules: { @@ -19,7 +20,14 @@ module.exports = { "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", "vue/script-setup-uses-vars": "warn", "vue/no-mutating-props": "off", - "vue/multi-word-component-names": "off" + "vue/multi-word-component-names": "off", + "@typescript-eslint/strict-boolean-expressions": [ + "error", + { + allowNullableObject: true, + allowNullableBoolean: true + } + ] }, globals: { defineProps: "readonly", diff --git a/src/App.vue b/src/App.vue index 05fa7fd..6535b0a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -31,7 +31,7 @@ const theme = computed(() => themes[settings.theme].variables as CSSProperties); const showTPS = toRef(settings, "showTPS"); const gameComponent = computed(() => { - return coerceComponent(jsx(() => <>{gameComponents.map(render)})); + return coerceComponent(jsx(() => (<>{gameComponents.map(render)}))); }); diff --git a/src/components/Info.vue b/src/components/Info.vue index 1da5db1..24a15e8 100644 --- a/src/components/Info.vue +++ b/src/components/Info.vue @@ -80,7 +80,7 @@ const isOpen = ref(false); const timePlayed = computed(() => formatTime(player.timePlayed)); const infoComponent = computed(() => { - return coerceComponent(jsx(() => <>{infoComponents.map(render)})); + return coerceComponent(jsx(() => (<>{infoComponents.map(render)}))); }); defineExpose({ diff --git a/src/components/Modal.vue b/src/components/Modal.vue index 7a3ee19..9fd5f06 100644 --- a/src/components/Modal.vue +++ b/src/components/Modal.vue @@ -40,7 +40,7 @@