Skip to content

Commit

Permalink
add curly to eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
nevio18324 committed Dec 23, 2024
1 parent dab4bea commit dff56db
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 29 deletions.
8 changes: 6 additions & 2 deletions frontend/cypress/e2e/check-in.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,12 @@ function getCurrentDate() {

let dd_str = '' + dd;
let mm_str = '' + mm;
if (dd < 10) dd_str = '0' + dd_str;
if (mm < 10) mm_str = '0' + mm_str;
if (dd < 10) {
dd_str = '0' + dd_str;
}
if (mm < 10) {
mm_str = '0' + mm_str;
}

return dd_str + '.' + mm_str + '.' + yyyy;
}
32 changes: 24 additions & 8 deletions frontend/cypress/support/helper/scoringSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export function validateScoring(isOverview: boolean, percentage: number) {
validateScoringWidth('commit', scoringValue.commitPercent, isOverview);
validateScoringWidth('target', scoringValue.targetPercent, isOverview);

if (percentage == 0) return;
if (percentage == 0) {
return;
}
validateScoringColor('fail', rgbCode, isOverview);
validateScoringColor('commit', rgbCode, isOverview);
validateScoringColor('target', rgbCode, isOverview);
Expand All @@ -34,10 +36,18 @@ export function getPercentageMetric(baseline: number, stretchGoal: number, value
}

export function getPercentageOrdinal(zone: string) {
if (zone == 'stretch') return 101;
if (zone == 'target') return 99.99;
if (zone == 'commit') return 70;
if (zone == 'fail') return 30;
if (zone == 'stretch') {
return 101;
}
if (zone == 'target') {
return 99.99;
}
if (zone == 'commit') {
return 70;
}
if (zone == 'fail') {
return 30;
}
return 0;
}

Expand Down Expand Up @@ -79,9 +89,15 @@ function checkVisibilityOfScoringComponent(isOverview: boolean, displayProperty:
}

function colorFromPercentage(percentage: number) {
if (percentage >= 100) return 'rgba(0, 0, 0, 0)';
if (percentage > 70) return 'rgb(30, 138, 41)';
if (percentage > 30) return 'rgb(255, 214, 0)';
if (percentage >= 100) {
return 'rgba(0, 0, 0, 0)';
}
if (percentage > 70) {
return 'rgb(30, 138, 41)';
}
if (percentage > 30) {
return 'rgb(255, 214, 0)';
}
return 'rgb(186, 56, 56)';
}

Expand Down
4 changes: 3 additions & 1 deletion frontend/cypress/support/helper/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ function doUntil(
limit = 100,
count = 0
) {
if (count >= limit) return;
if (count >= limit) {
return;
}

cy.focused()
.then((element) => {
Expand Down
1 change: 1 addition & 0 deletions frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default tsEslint.config(
//eslint rules
'unused-imports/no-unused-imports': 'error',
'no-undef': 'error',
curly: 'error',
'prefer-rest-params': 'error',
'space-before-function-paren': ['error', 'never'],

Expand Down
4 changes: 3 additions & 1 deletion frontend/src/app/components/team/team.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export class TeamComponent {
this.configService.config$.pipe(first())
.subscribe((config: ClientConfig) => {
const configuredIconSrc = config.customStyles['okr-add-objective-icon'];
if (configuredIconSrc) this.addIconSrc.next(configuredIconSrc);
if (configuredIconSrc) {
this.addIconSrc.next(configuredIconSrc);
}
});
}

Expand Down
8 changes: 6 additions & 2 deletions frontend/src/app/interceptors/error-interceptor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export class ErrorInterceptor implements HttpInterceptor {

handleSuccessToaster(response: any, method: HttpType) {
const successMessageObj = this.getSuccessMessageKey(response.url, response.status, method);
if (!successMessageObj) return;
if (!successMessageObj) {
return;
}

let messageKey = successMessageObj.key;
const isBacklogQuarter = !GJ_REGEX_PATTERN.test(response.body?.quarterLabel);
Expand All @@ -65,7 +67,9 @@ export class ErrorInterceptor implements HttpInterceptor {
getSuccessMessageKey(url: string, statusCode: number, method: HttpType) {
for (const key in SUCCESS_MESSAGE_MAP) {
const value = SUCCESS_MESSAGE_MAP[key];
if (!url.includes(key)) continue;
if (!url.includes(key)) {
continue;
}

for (const toasterMessage of value.methods) {
if (toasterMessage.method == method) {
Expand Down
20 changes: 15 additions & 5 deletions frontend/src/app/shared/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export function getValueFromQuery(query: any, fallback?: number): number[] {
.flat()
.map((id: any) => Number(id))
.filter((id: number) => Number.isInteger(id));
if (fallback === undefined) return values;
if (fallback === undefined) {
return values;
}
return values.length > 0 ? values : [fallback];
}

Expand All @@ -47,8 +49,12 @@ export function calculateCurrentPercentage(keyResultMetric: KeyResultMetricMin):
const value: number = +(keyResultMetric.lastCheckIn?.value ?? 0);
const baseline: number = +keyResultMetric.baseline;
const stretchGoal: number = +keyResultMetric.stretchGoal;
if (isLastCheckInNegative(baseline, stretchGoal, value)) return 0;
if (value == stretchGoal) return 100;
if (isLastCheckInNegative(baseline, stretchGoal, value)) {
return 0;
}
if (value == stretchGoal) {
return 100;
}

return Math.abs(value - baseline) / Math.abs(stretchGoal - baseline) * 100;
}
Expand All @@ -72,15 +78,19 @@ export function optionalReplaceWithNulls(param: object): Record<string, any> {
}

export function areEqual(arr1: number[], arr2: number[]) {
if (arr1.length !== arr2.length) return false;
if (arr1.length !== arr2.length) {
return false;
}

// implement custom sort if necessary
arr1.sort((a, b) => a - b);
arr2.sort((a, b) => a - b);

// use normal for loop so we can return immediately if not equal
for (let i = 0; i < arr1.length; i++) {
if (arr1[i] !== arr2[i]) return false;
if (arr1[i] !== arr2[i]) {
return false;
}
}

return true;
Expand Down
24 changes: 18 additions & 6 deletions frontend/src/app/shared/custom/scoring/scoring.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ export class ScoringComponent implements OnInit, AfterViewInit, OnChanges {
* Define width of scoring elements
* All checked individually because that if one is undefined, the others can still be set
*/
if (this.failElement) this.failElement.nativeElement.style.width = this.failPercent + '%';
if (this.commitElement) this.commitElement.nativeElement.style.width = this.commitPercent + '%';
if (this.targetElement) this.targetElement.nativeElement.style.width = this.targetPercent + '%';
if (this.failElement) {
this.failElement.nativeElement.style.width = this.failPercent + '%';
}
if (this.commitElement) {
this.commitElement.nativeElement.style.width = this.commitPercent + '%';
}
if (this.targetElement) {
this.targetElement.nativeElement.style.width = this.targetPercent + '%';
}

if (this.keyResult.keyResultType == 'metric') {
this.labelPercentage.subscribe((value) => {
Expand All @@ -91,9 +97,15 @@ export class ScoringComponent implements OnInit, AfterViewInit, OnChanges {
const scoringClass = this.getScoringColorClassAndSetBorder();
if (scoringClass !== null) {
// All checked individually because that if one is undefined, the others can still be set
if (this.targetElement) this.targetElement.nativeElement.classList.add(scoringClass);
if (this.commitElement) this.commitElement.nativeElement.classList.add(scoringClass);
if (this.failElement) this.failElement.nativeElement.classList.add(scoringClass);
if (this.targetElement) {
this.targetElement.nativeElement.classList.add(scoringClass);
}
if (this.commitElement) {
this.commitElement.nativeElement.classList.add(scoringClass);
}
if (this.failElement) {
this.failElement.nativeElement.classList.add(scoringClass);
}
}

// Fill out icon if target percent has reached 100 percent or more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ export class ObjectiveFormComponent implements OnInit, OnDestroy {
// Subscribe to teams$ to find and update the current team
this.teams$.subscribe((teams) => {
const currentTeam = teams.find((team) => team.id === teamId);
if (currentTeam) this.currentTeam.next(currentTeam);
if (currentTeam) {
this.currentTeam.next(currentTeam);
}
});

this.objectiveForm.patchValue({
Expand Down Expand Up @@ -193,7 +195,9 @@ export class ObjectiveFormComponent implements OnInit, OnDestroy {
}))
});
} else {
if (this.data.action == 'releaseBacklog') objectiveDTO.state = 'ONGOING' as State;
if (this.data.action == 'releaseBacklog') {
objectiveDTO.state = 'ONGOING' as State;
}
if (this.data.objective.objectiveId && id) {
objectiveDTO.id = id;
return this.objectiveService.updateObjective(objectiveDTO);
Expand Down Expand Up @@ -261,7 +265,9 @@ export class ObjectiveFormComponent implements OnInit, OnDestroy {
const currentQuarter: Quarter | undefined = this.quarters.find((quarter) => quarter.id == this.objectiveForm.value.quarter);
if (currentQuarter) {
const isBacklogCurrent = !this.isBacklogQuarter(currentQuarter.label);
if (this.data.action == 'duplicate') return true;
if (this.data.action == 'duplicate') {
return true;
}
if (this.data.objective.objectiveId) {
return isBacklogCurrent ? this.state == 'DRAFT' : true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export class DeleteUserComponent implements OnInit, OnDestroy {
}

hasOkrUserRoleOkrChampion() {
if (this.okrUser == undefined) return false;
if (this.okrUser == undefined) {
return false;
}
return this.okrUser.isOkrChampion;
}

Expand Down

0 comments on commit dff56db

Please sign in to comment.