From 70be2502751a3f7361032db47314d1b143094f3f Mon Sep 17 00:00:00 2001 From: Nevio Di Gennaro Date: Thu, 19 Dec 2024 08:00:37 +0100 Subject: [PATCH] activate no non null asserted optional chain rule --- frontend/eslint.config.mjs | 23 ++++++++++++------- .../keyresult-dialog.component.ts | 2 +- frontend/src/app/shared/common.ts | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjs index 53040aa86f..556517afd3 100644 --- a/frontend/eslint.config.mjs +++ b/frontend/eslint.config.mjs @@ -75,11 +75,11 @@ export default tsEslint.config( }, ], 'prefer-rest-params': 'error', - '@typescript-eslint/no-empty-function': ['error', {allow: ['arrowFunctions', 'constructors']}], + '@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions', 'constructors'] }], '@stylistic/lines-around-comment': ['error'], '@angular-eslint/no-empty-lifecycle-method': 'error', '@angular-eslint/component-class-suffix': 'error', - '@typescript-eslint/no-non-null-asserted-optional-chain': 'off', + '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', '@typescript-eslint/no-non-null-assertion': 'off', '@stylistic/no-extra-parens': 'off', '@typescript-eslint/no-confusing-non-null-assertion': 'off', @@ -92,15 +92,15 @@ export default tsEslint.config( // '@stylistic/quotes': ['error', 'double'], '@stylistic/padded-blocks': ['error', 'never'], '@stylistic/dot-location': ['error', 'property'], - '@stylistic/newline-per-chained-call': ['error', {ignoreChainWithDepth: 1}], + '@stylistic/newline-per-chained-call': ['error', { ignoreChainWithDepth: 1 }], '@stylistic/indent': ['error', 2], '@stylistic/quote-props': ['error', 'as-needed'], '@stylistic/object-property-newline': ['error'], '@stylistic/multiline-ternary': ['off'], '@stylistic/object-curly-spacing': ['error', 'always'], - '@stylistic/array-bracket-newline': ['error', {minItems: 4}], + '@stylistic/array-bracket-newline': ['error', { minItems: 4 }], '@stylistic/semi-style': ['error'], - '@stylistic/function-paren-newline': ['error', {minItems: 4}], + '@stylistic/function-paren-newline': ['error', { minItems: 4 }], '@angular-eslint/directive-selector': [ 'error', { @@ -135,18 +135,25 @@ export default tsEslint.config( files: ['**/*.html'], extends: [ ...angular.configs.templateRecommended, + // Add any other recommended configs here if needed ], languageOptions: { + // Choose one parser. For Angular templates, usually angular.templateParser is needed. parser: angular.templateParser, }, - rules: { + // Combine all sets of rules + ...html.configs.recommended.rules, ...html.configs['flat/recommended'].rules, + '@angular-eslint/template/eqeqeq': 'error', '@html-eslint/indent': ['error', 2], - '@html-eslint/require-img-alt': 'off', + '@html-eslint/require-img-alt': 'error', + '@html-eslint/require-closing-tags': ['error', { selfClosing: 'always' }], + '@angular-eslint/template/banana-in-box': 'error', + '@angular-eslint/template/no-negated-async': 'error', + //For Some reason the following rule does not work with the angular-parser '@html-eslint/element-newline': 'off', - '@html-eslint/require-closing-tags': ['error', {selfClosing: 'always'}], }, }, { diff --git a/frontend/src/app/components/keyresult-dialog/keyresult-dialog.component.ts b/frontend/src/app/components/keyresult-dialog/keyresult-dialog.component.ts index 52982057c6..6651272d6f 100644 --- a/frontend/src/app/components/keyresult-dialog/keyresult-dialog.component.ts +++ b/frontend/src/app/components/keyresult-dialog/keyresult-dialog.component.ts @@ -58,7 +58,7 @@ export class KeyresultDialogComponent { objective: this.data.objective, id: this.data.keyResult?.id } as KeyResultOrdinalDTO); keyResult.id = this.data.keyResult?.id; - keyResult.version = this.data.keyResult?.version!; + keyResult.version = this.data.keyResult?.version; keyResult.actionList = keyResult.actionList!.filter((action: Action) => action.action !== ""); this.keyResultService.saveKeyResult(keyResult) .subscribe((returnValue) => { diff --git a/frontend/src/app/shared/common.ts b/frontend/src/app/shared/common.ts index 413de277ff..b97ae74502 100644 --- a/frontend/src/app/shared/common.ts +++ b/frontend/src/app/shared/common.ts @@ -42,7 +42,7 @@ export function isLastCheckInNegative (baseline: number, stretchGoal: number, va } export function calculateCurrentPercentage (keyResultMetric: KeyResultMetricMin): number { - const value: number = +keyResultMetric.lastCheckIn?.value!; + const value: number = +keyResultMetric.lastCheckIn?.value; const baseline: number = +keyResultMetric.baseline; const stretchGoal: number = +keyResultMetric.stretchGoal; if (isLastCheckInNegative(baseline,