Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Enable more Typescript Eslint rules) #1457

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions app/domains/beratungshilfe/formular/stringReplacements.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CheckboxValue } from "~/components/inputs/Checkbox";
import { beratungshilfePersoenlicheDatenDone } from "~/domains/beratungshilfe/formular/persoenlicheDaten/doneFunctions";
import { findCourtIfUnique } from "~/services/gerichtsfinder/amtsgerichtData.server";
import { anwaltlicheVertretungDone } from "./anwaltlicheVertretung/guards";
Expand Down Expand Up @@ -50,26 +51,26 @@ export const weiteresEinkommenStrings = (
) => {
const { weitereseinkommen } = context;
return {
arbeitslosenGeld: weitereseinkommen?.arbeitlosengeld === "on",
wohngeld: weitereseinkommen?.wohngeld === "on",
bafoeg: weitereseinkommen?.bafoeg === "on",
rente: weitereseinkommen?.rente === "on",
krankengeld: weitereseinkommen?.krankengeld === "on",
elterngeld: weitereseinkommen?.elterngeld === "on",
arbeitslosenGeld: weitereseinkommen?.arbeitlosengeld === CheckboxValue.on,
wohngeld: weitereseinkommen?.wohngeld === CheckboxValue.on,
bafoeg: weitereseinkommen?.bafoeg === CheckboxValue.on,
rente: weitereseinkommen?.rente === CheckboxValue.on,
krankengeld: weitereseinkommen?.krankengeld === CheckboxValue.on,
elterngeld: weitereseinkommen?.elterngeld === CheckboxValue.on,
};
};

export const ausgabenStrings = (context: BeratungshilfeFormularContext) => {
return {
hasSchwangerschaft:
context.hasAusgaben === "yes" &&
context.ausgabensituation?.pregnancy === "on",
context.ausgabensituation?.pregnancy === CheckboxValue.on,
hasSchwerbehinderung:
context.hasAusgaben === "yes" &&
context.ausgabensituation?.disability === "on",
context.ausgabensituation?.disability === CheckboxValue.on,
hasMedicalReasons:
context.hasAusgaben === "yes" &&
context.ausgabensituation?.medicalReasons === "on",
context.ausgabensituation?.medicalReasons === CheckboxValue.on,
hasWeitereAusgaben:
context.hasAusgaben === "yes" &&
context.ausgaben &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { BeratungshilfePDF } from "data/pdf/beratungshilfe/beratungshilfe.generated";
import { CheckboxValue } from "~/components/inputs/Checkbox";
import type { BeratungshilfeFinanzielleAngaben } from "~/domains/beratungshilfe/formular/finanzielleAngaben/context";
import type { besondereBelastungenSchema } from "~/domains/shared/formular/finanzielleAngaben/context";
import {
Expand Down Expand Up @@ -39,7 +40,9 @@ export const fillAusgaben: BerHPdfFillFunction = ({ userData, pdfValues }) => {

const { ausgabensituation } = userData;
const belastungen = Object.values(ausgabensituation ?? {});
const hasBesondereBelastung = belastungen.some((value) => value === "on");
const hasBesondereBelastung = belastungen.some(
(value) => value === CheckboxValue.on,
);
const noBesondereBelastung = !hasBesondereBelastung && belastungen.length > 0;

pdfValues.g9SonstigeBelastungenJ.value = hasBesondereBelastung;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CheckboxValue } from "~/components/inputs/Checkbox";
import type { Guards } from "~/domains/guards.server";
import type { PartnerEinkuenfteContext } from "~/domains/prozesskostenhilfe/formular/finanzielleAngaben/context";
import type { ProzesskostenhilfeFinanzielleAngabenEinkuenfteContext } from "~/domains/prozesskostenhilfe/formular/finanzielleAngaben/einkuenfte/context";
Expand Down Expand Up @@ -51,10 +52,14 @@ export const finanzielleAngabeEinkuenfteGuards = {
context: { pageData, arbeitsausgaben },
}) => isValidArrayIndex(arbeitsausgaben, pageData),
receivesPension: ({ context }) => context.receivesPension === "yes",
hasWohngeld: ({ context: { hasWohngeld } }) => hasWohngeld === "on",
hasKrankengeld: ({ context: { hasKrankengeld } }) => hasKrankengeld === "on",
hasElterngeld: ({ context: { hasElterngeld } }) => hasElterngeld === "on",
hasKindergeld: ({ context: { hasKindergeld } }) => hasKindergeld === "on",
hasWohngeld: ({ context: { hasWohngeld } }) =>
hasWohngeld === CheckboxValue.on,
hasKrankengeld: ({ context: { hasKrankengeld } }) =>
hasKrankengeld === CheckboxValue.on,
hasElterngeld: ({ context: { hasElterngeld } }) =>
hasElterngeld === CheckboxValue.on,
hasKindergeld: ({ context: { hasKindergeld } }) =>
hasKindergeld === CheckboxValue.on,
hasFurtherIncome,
hasFurtherIncomeAndEmptyArray: ({ context }) =>
hasFurtherIncome({ context }) &&
Expand Down Expand Up @@ -98,10 +103,14 @@ export const partnerEinkuenfteGuards = {
context["partner-receivesPension"] === "yes",
receivesSupport: ({ context }) =>
context["partner-receivesSupport"] === "yes",
hasWohngeld: ({ context }) => context["partner-hasWohngeld"] === "on",
hasKrankengeld: ({ context }) => context["partner-hasKrankengeld"] === "on",
hasElterngeld: ({ context }) => context["partner-hasElterngeld"] === "on",
hasKindergeld: ({ context }) => context["partner-hasKindergeld"] === "on",
hasWohngeld: ({ context }) =>
context["partner-hasWohngeld"] === CheckboxValue.on,
hasKrankengeld: ({ context }) =>
context["partner-hasKrankengeld"] === CheckboxValue.on,
hasElterngeld: ({ context }) =>
context["partner-hasElterngeld"] === CheckboxValue.on,
hasKindergeld: ({ context }) =>
context["partner-hasKindergeld"] === CheckboxValue.on,
hasFurtherIncome: partnerHasFurtherIncome,
hasFurtherIncomeAndEmptyArray: ({ context }) =>
partnerHasFurtherIncome({ context }) &&
Expand Down
22 changes: 13 additions & 9 deletions app/domains/prozesskostenhilfe/formular/stringReplacements.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CheckboxValue } from "~/components/inputs/Checkbox";
import { antragstellendePersonDone } from "~/domains/prozesskostenhilfe/formular/antragstellendePerson/context";
import { einkuenfteDone } from "~/domains/prozesskostenhilfe/formular/finanzielleAngaben/einkuenfte/doneFunctions";
import { parseCurrencyStringDE } from "~/services/validation/money/formatCents";
Expand Down Expand Up @@ -63,9 +64,9 @@ export const belegeStrings = (context: ProzesskostenhilfeFormularContext) => {
hasAbzuege: parseCurrencyStringDE(context.selbststaendigAbzuege) > 0,
hasWerbungskosten: context.hasArbeitsausgaben === "yes",
hasRente: context.receivesPension === "yes",
hasWohngeld: context.hasWohngeld === "on",
hasKrankengeld: context.hasKrankengeld === "on",
hasElterngeld: context.hasElterngeld === "on",
hasWohngeld: context.hasWohngeld === CheckboxValue.on,
hasKrankengeld: context.hasKrankengeld === CheckboxValue.on,
hasElterngeld: context.hasElterngeld === CheckboxValue.on,
hasWeitereEinkuenfte:
context.weitereEinkuenfte && context.weitereEinkuenfte.length > 0,
partnerHasBuergergeld:
Expand All @@ -86,9 +87,10 @@ export const belegeStrings = (context: ProzesskostenhilfeFormularContext) => {
parseCurrencyStringDE(context["partner-selbststaendigAbzuege"]) > 0,
partnerHasWerbungskosten: context["partner-hasArbeitsausgaben"] === "yes",
partnerHasRente: context["partner-receivesPension"] === "yes",
partnerHasWohngeld: context["partner-hasWohngeld"] === "on",
partnerHasKrankengeld: context["partner-hasKrankengeld"] === "on",
partnerHasElterngeld: context["partner-hasElterngeld"] === "on",
partnerHasWohngeld: context["partner-hasWohngeld"] === CheckboxValue.on,
partnerHasKrankengeld:
context["partner-hasKrankengeld"] === CheckboxValue.on,
partnerHasElterngeld: context["partner-hasElterngeld"] === CheckboxValue.on,
partnerWeitereEinkuenfte:
context["partner-weitereEinkuenfte"] &&
context["partner-weitereEinkuenfte"].length > 0,
Expand All @@ -111,10 +113,12 @@ export const belegeStrings = (context: ProzesskostenhilfeFormularContext) => {
hasGiroTagesSparKonto: context.geldanlagen?.some(
(geldanlage) => geldanlage.art === "giroTagesgeldSparkonto",
),
hasSchwangerschaft: context.besondereBelastungen?.pregnancy === "on",
hasSchwerbehinderung: context.besondereBelastungen?.disability === "on",
hasSchwangerschaft:
context.besondereBelastungen?.pregnancy === CheckboxValue.on,
hasSchwerbehinderung:
context.besondereBelastungen?.disability === CheckboxValue.on,
hasKostenaufwaendigeErnaehrung:
context.besondereBelastungen?.medicalReasons === "on",
context.besondereBelastungen?.medicalReasons === CheckboxValue.on,
hasVersicherung:
context.versicherungen && context.versicherungen?.length > 0,
hasRatenzahlung:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CheckboxValue } from "~/components/inputs/Checkbox";
import { finanzielleAngabeEinkuenfteGuards as guards } from "~/domains/prozesskostenhilfe/formular/finanzielleAngaben/einkuenfte/guards";
import {
type AttachmentEntries,
Expand Down Expand Up @@ -108,28 +109,28 @@ export const fillAndereLeistungen: PkhPdfFillFunction = ({
userData,
pdfValues,
}) => {
if (userData.hasWohngeld === "on") {
if (userData.hasWohngeld === CheckboxValue.on) {
pdfValues.ja_19.value = true;
pdfValues.monatlicheBruttoeinnahmendurchWohngeldinEuro7.value = `${removeDecimalsFromCurrencyString(userData.wohngeldAmount)} ${nettoString}`;
} else if (userData.hasFurtherIncome) {
pdfValues.nein_20.value = true;
}

if (userData.hasKrankengeld === "on") {
if (userData.hasKrankengeld === CheckboxValue.on) {
pdfValues.ja_18.value = true;
pdfValues.monatlicheBruttoeinnahmendurchNichtselbststaendigeArbeitinEuro12.value = `${removeDecimalsFromCurrencyString(userData.krankengeldAmount)} ${nettoString}`;
} else if (userData.hasFurtherIncome) {
pdfValues.nein_19.value = true;
}

if (userData.hasElterngeld === "on") {
if (userData.hasElterngeld === CheckboxValue.on) {
pdfValues.ja_20.value = true;
pdfValues.monatlicheBruttoeinnahmendurchNichtselbststaendigeArbeitinEuro13.value = `${removeDecimalsFromCurrencyString(userData.elterngeldAmount)} ${nettoString}`;
} else if (userData.hasFurtherIncome) {
pdfValues.nein_21.value = true;
}

if (userData.hasKindergeld === "on") {
if (userData.hasKindergeld === CheckboxValue.on) {
pdfValues.ja_17.value = true;
pdfValues.monatlicheBruttoeinnahmendurchKindergeldIKinderzuschlaginEuro6.value = `${removeDecimalsFromCurrencyString(userData.kindergeldAmount)} ${nettoString}`;
} else if (userData.hasFurtherIncome) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CheckboxValue } from "~/components/inputs/Checkbox";
import { partnerEinkuenfteGuards as guards } from "~/domains/prozesskostenhilfe/formular/finanzielleAngaben/einkuenfte/guards";
import {
type AttachmentEntries,
Expand Down Expand Up @@ -107,28 +108,28 @@ export const fillAndereLeistungenPartner: PkhPdfFillFunction = ({
userData,
pdfValues,
}) => {
if (userData["partner-hasWohngeld"] === "on") {
if (userData["partner-hasWohngeld"] === CheckboxValue.on) {
pdfValues.ja_32.value = true;
pdfValues.monatlicheBruttoeinnahmenH6.value = `${removeDecimalsFromCurrencyString(userData["partner-wohngeldAmount"])} ${nettoString}`;
} else if (userData["partner-hasFurtherIncome"]) {
pdfValues.nein_33.value = true;
}

if (userData["partner-hasKrankengeld"] === "on") {
if (userData["partner-hasKrankengeld"] === CheckboxValue.on) {
pdfValues.ja_31.value = true;
pdfValues.monatlicheBruttoeinnahmenH11.value = `${removeDecimalsFromCurrencyString(userData["partner-krankengeldAmount"])} ${nettoString}`;
} else if (userData["partner-hasFurtherIncome"]) {
pdfValues.nein_32.value = true;
}

if (userData["partner-hasElterngeld"] === "on") {
if (userData["partner-hasElterngeld"] === CheckboxValue.on) {
pdfValues.ja_33.value = true;
pdfValues.monatlicheBruttoeinnahmenH12.value = `${removeDecimalsFromCurrencyString(userData["partner-elterngeldAmount"])} ${nettoString}`;
} else if (userData["partner-hasFurtherIncome"]) {
pdfValues.nein_34.value = true;
}

if (userData["partner-hasKindergeld"] === "on") {
if (userData["partner-hasKindergeld"] === CheckboxValue.on) {
pdfValues.ja_30.value = true;
pdfValues.monatlicheBruttoeinnahmenH5.value = `${removeDecimalsFromCurrencyString(userData["partner-kindergeldAmount"])} ${nettoString}`;
} else if (userData["partner-hasFurtherIncome"]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CheckboxValue } from "~/components/inputs/Checkbox";
import { ausgabenSituationMapping } from "~/domains/beratungshilfe/services/pdf/pdfForm/G_ausgaben";
import { finanzielleAngabeEinkuenfteGuards as einkuenfteGuards } from "~/domains/prozesskostenhilfe/formular/finanzielleAngaben/einkuenfte/guards";
import { SEE_IN_ATTACHMENT_DESCRIPTION } from "~/services/pdf/attachment";
Expand All @@ -17,7 +18,7 @@ export const fillBelastungen: PkhPdfFillFunction = ({
}

const belastungen = Object.entries(userData.besondereBelastungen)
.filter(([_, val]) => val === "on")
.filter(([_, val]) => val === CheckboxValue.on)
.map(([key]) =>
key in ausgabenSituationMapping
? ausgabenSituationMapping[key as keyof typeof ausgabenSituationMapping]
Expand Down
2 changes: 1 addition & 1 deletion app/services/flow/stepIdConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const stateValueToStepIds = (stateValue: StateValue): string[] => {
}
return Object.entries(stateValue)
.map(([key, value]) =>
stateValueToStepIds(value as StateValue).map((substate) =>
stateValueToStepIds(value!).map((substate) =>
substate ? [key, substate].join("/") : key,
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const buildMoneyValidationSchema = (
.min(1, "required")
.transform((v) => preprocessMoney(v))
.refine((v) => validateMoney(v), { message: "wrong_format" })
.transform((v) => moneyToCents(v) as number)
.transform((v) => moneyToCents(v)!)
.refine((v) => v >= (opts.min ?? Number.MIN_SAFE_INTEGER), {
message: "too_little",
})
Expand Down
12 changes: 3 additions & 9 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ export default tseslint.config(
"sonarjs/no-array-index-key": "warn",
"sonarjs/no-redeclare": "off",
"sonarjs/no-nested-functions": "warn",
"sonarjs/sonar-no-unused-vars": "off",
"sonarjs/function-return-type": "off",

// duplicates of typescript-eslint rules (prefer typescript-eslint as their rule pages are clearer)
"sonarjs/sonar-no-unused-vars": "off",
"sonarjs/no-misused-promises": "off",
"sonarjs/different-types-comparison": "off",
"sonarjs/sonar-prefer-regexp-exec": "off",
Expand All @@ -129,12 +129,10 @@ export default tseslint.config(
"sonarjs/no-unstable-nested-components": "warn", // TODO: enable later
"sonarjs/deprecation": "off", // TODO: enable after remix upgrades to react router v7 and we move to Single Fetch

// fix/reevaluate
"sonarjs/no-alphabetical-sort": "off",

// typescript-eslint
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/only-throw-error": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
Expand All @@ -146,20 +144,15 @@ export default tseslint.config(
"@typescript-eslint/array-type": "off", // TODO: enable later

// fix/reevaluate
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/only-throw-error": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/prefer-optional-chain": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/non-nullable-type-assertion-style": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
},
},
Expand All @@ -172,6 +165,7 @@ export default tseslint.config(
rules: {
...vitest.configs.recommended.rules,
"vitest/valid-title": "off", // TODO: enable later
"@typescript-eslint/unbound-method": "off",
"require-await": "error",
},
},
Expand Down
Loading