Skip to content

Commit

Permalink
Chore/client tests codestyle docs (#1305)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Krusche authored May 2, 2020
1 parent ca8f3ea commit cb7d306
Show file tree
Hide file tree
Showing 436 changed files with 6,099 additions and 9,247 deletions.
5 changes: 0 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ src/main/generated/
src/main/java/
src/main/jib/
src/main/resources/
src/test/
src/test/javascript/e2e/
src/test/javascript/protractor.conf.js
src/test/javascript/jest.conf.js
src/test/k6/
uploads/
webpack/
target/
Expand Down
21 changes: 15 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"plugins": [
"@typescript-eslint",
"@typescript-eslint/tslint"
"@typescript-eslint/tslint",
"chai-friendly"
],
"extends": [
// "plugin:@typescript-eslint/eslint-recommended",
// "plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
Expand All @@ -22,7 +21,10 @@
"@typescript-eslint/tslint/config": [
"error",
{
"lintFile": "./tslint.json"
"lintFile": "./tslint.json",
"rules": {
"no-unused-expressions": "off"
}
}
],
"@typescript-eslint/no-unused-vars": [
Expand All @@ -33,6 +35,13 @@
"ignoreRestSiblings": false
}
],
"@typescript-eslint/no-non-null-assertion": "off"
}
"@typescript-eslint/no-non-null-assertion": "off",
"chai-friendly/no-unused-expressions": 2
},
"overrides": [{
"files": ["mock-*.ts"],
"rules": {
"@typescript-eslint/no-unused-vars": "off"
}
}]
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"compare-versions": "3.6.0",
"core-js": "3.6.5",
"dompurify": "2.0.10",
"eslint-plugin-chai-friendly": "0.5.0",
"export-to-csv": "0.2.1",
"franc-min": "5.0.0",
"interactjs": "1.9.10",
Expand Down Expand Up @@ -77,6 +78,7 @@
"sugar": "2.0.6",
"ts-jest": "25.4.0",
"tslib": "1.11.1",
"tslint-no-unused-expression-chai": "0.1.4",
"webstomp-client": "1.2.6",
"yarn": "1.22.4",
"zone.js": "0.10.3"
Expand Down Expand Up @@ -176,8 +178,8 @@
"src/{main,test}/java/**/*.java": "bash ./linting.sh"
},
"scripts": {
"prettier:format": "prettier --write 'src/{main/webapp,test}/**/*.{json,ts,css,scss,html}'",
"prettier:check": "prettier --check 'src/{main/webapp,test}/**/*.{json,ts,css,scss,html}'",
"prettier:format": "prettier --write 'src/{main/webapp,test}/**/*.{json,ts,js,css,scss,html}'",
"prettier:check": "prettier --check 'src/{main/webapp,test}/**/*.{json,ts,js,css,scss,html}'",
"lint": "eslint . --ext .ts",
"lint:fix": "yarn run lint --fix",
"lint:doc": "tslint --config tslint-doc.json --project tsconfig.json -e 'node_modules/**'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export class PasswordResetFinishComponent implements OnInit, AfterViewInit {
}

ngAfterViewInit() {
if (this.elementRef.nativeElement.querySelector('#password') != null) {
this.renderer.selectRootElement('#password', true).focus();
const passwordElement = this.elementRef.nativeElement.querySelector('#password');
if (passwordElement != null) {
this.renderer.selectRootElement(passwordElement, true).focus();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export class PasswordResetInitComponent implements OnInit, AfterViewInit {
}

ngAfterViewInit() {
this.renderer.selectRootElement('#email', true).focus();
const emailElement = this.elementRef.nativeElement.querySelector('#email');
if (emailElement != null) {
this.renderer.selectRootElement(emailElement, true).focus();
}
}

requestReset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ export class NotificationMgmtUpdateComponent implements OnInit {
this.isSaving = true;
if (this.notification.id) {
this.systemNotificationService.update(this.notification).subscribe(
(response) => this.onSaveSuccess(response.body!),
() => this.onSaveSuccess(),
() => this.onSaveError(),
);
} else {
this.systemNotificationService.create(this.notification).subscribe(
(response) => this.onSaveSuccess(response.body!),
() => this.onSaveSuccess(),
() => this.onSaveError(),
);
}
}

private onSaveSuccess(result: SystemNotification) {
private onSaveSuccess() {
this.isSaving = false;
this.previousState();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, Route, RouterStateSnapshot } from '@angular/router';
import { ActivatedRouteSnapshot, Resolve, Route } from '@angular/router';
import { JhiResolvePagingParams } from 'ng-jhipster';
import { NotificationMgmtUpdateComponent } from 'app/admin/notification-management/notification-management-update.component';
import { SystemNotification } from 'app/entities/system-notification.model';
Expand All @@ -14,9 +14,8 @@ export class NotificationMgmtResolve implements Resolve<any> {
/**
* Resolves the route and initializes system notification from id route param
* @param route
* @param state
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
resolve(route: ActivatedRouteSnapshot) {
const id = route.params['id'] ? route.params['id'] : null;
if (id) {
return this.service.find(parseInt(id, 10));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ export class UserManagementUpdateComponent implements OnInit {
this.isSaving = true;
if (this.user.id !== null) {
this.userService.update(this.user).subscribe(
(response) => this.onSaveSuccess(response.body!),
() => this.onSaveSuccess(),
() => this.onSaveError(),
);
} else {
this.userService.create(this.user).subscribe(
(response) => this.onSaveSuccess(response.body!),
() => this.onSaveSuccess(),
() => this.onSaveError(),
);
}
Expand All @@ -66,7 +66,7 @@ export class UserManagementUpdateComponent implements OnInit {
* Set isSaving to false and navigate to previous page
* @param result
*/
private onSaveSuccess(result: User) {
private onSaveSuccess() {
this.isSaving = false;
this.previousState();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, Route, RouterStateSnapshot } from '@angular/router';
import { ActivatedRouteSnapshot, Resolve, Route } from '@angular/router';
import { JhiResolvePagingParams } from 'ng-jhipster';
import { User } from 'app/core/user/user.model';
import { UserService } from 'app/core/user/user.service';
Expand All @@ -14,9 +14,8 @@ export class UserMgmtResolve implements Resolve<any> {
/**
* Resolve route to find the user before the route is activated
* @param route contains the information about a route associated with a component loaded in an outlet at a particular moment in time
* @param state represents the state of the router at a moment in time
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
resolve(route: ActivatedRouteSnapshot) {
const login = route.params['login'] ? route.params['login'] : null;
if (login) {
return this.userService.find(login);
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/app.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ if (module['hot']) {

platformBrowserDynamic()
.bootstrapModule(ArtemisAppModule, { preserveWhitespaces: true })
.then((platformRef) => {})
.then(() => {})
.catch((err) => console.error(err));
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { Component, Input, OnChanges } from '@angular/core';
import * as moment from 'moment';
import { Exercise } from 'app/entities/exercise.model';

Expand All @@ -22,7 +22,7 @@ export class AssessmentWarningComponent implements OnChanges {
currentDate: moment.MomentInput;
isBeforeDueDate = false;

ngOnChanges(changes: SimpleChanges): void {
ngOnChanges(): void {
const dueDate = this.exercise.dueDate;
if (dueDate != null) {
this.isBeforeDueDate = dueDate.isAfter(this.currentDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class ComplaintsForTutorComponent implements OnInit {
this.complaintResponseService.create(this.complaintResponse).subscribe(
(response) => {
this.handled = true;
// eslint-disable-next-line chai-friendly/no-unused-expressions
this.complaint.complaintType === ComplaintType.MORE_FEEDBACK
? this.jhiAlertService.success('artemisApp.moreFeedbackResponse.created')
: this.jhiAlertService.success('artemisApp.complaintResponse.created');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class ListOfComplaintsComponent implements OnInit {
modalRef.componentInstance.result = cloneDeep(complaint.result);
modalRef.componentInstance.onResultModified.subscribe(() => this.loadComplaints());
modalRef.result.then(
(_) => this.loadComplaints(),
() => this.loadComplaints(),
() => {},
);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/core/auth/user-route-access-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LocalStorageService } from 'ngx-webstorage';
import { AccountService } from 'app/core/auth/account.service';
import { StateStorageService } from 'app/core/auth/state-storage.service';
import { OrionVersionValidator } from 'app/shared/orion/outdated-plugin-warning/orion-version-validator.service';
import { filter, first, switchMap } from 'rxjs/operators';
import { first, switchMap } from 'rxjs/operators';
import { from, of } from 'rxjs';

@Injectable({ providedIn: 'root' })
Expand Down
14 changes: 0 additions & 14 deletions src/main/webapp/app/core/config/uib-pagination.config.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class AuthExpiredInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).pipe(
tap(
(event: HttpEvent<any>) => {},
() => {},
(err: any) => {
if (err instanceof HttpErrorResponse) {
if (err.status === 401) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ErrorHandlerInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).pipe(
tap(
(event: HttpEvent<any>) => {},
() => {},
(err: any) => {
if (err instanceof HttpErrorResponse) {
if (!(err.status === 401 && (err.message === '' || (err.url && err.url.includes('/api/account'))))) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/core/login/login.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class LoginService {
return new Promise((resolve, reject) => {
this.authServerProvider.login(credentials).subscribe(
(data) => {
this.accountService.identity(true).then((user) => {
this.accountService.identity(true).then(() => {
this.websocketService.sendActivity();
resolve(data);
});
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/app/core/websocket/websocket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class JhiWebsocketService implements IWebsocketService, OnDestroy {
};
this.stompClient = over(socket, options);
// Note: at the moment, debugging is deactivated to prevent console log statements
this.stompClient.debug = function (str) {};
this.stompClient.debug = function () {};
const headers = <ConnectionHeaders>{};
headers['X-CSRF-TOKEN'] = this.csrfService.getCSRF();

Expand Down Expand Up @@ -148,7 +148,7 @@ export class JhiWebsocketService implements IWebsocketService, OnDestroy {

// Setup periodic logs of websocket connection numbers
this.logTimers.push(
timer(0, 60000).subscribe((x) => {
timer(0, 60000).subscribe(() => {
console.log('\n\n');
console.log(`${this.subscribers.size} websocket subscriptions: `, this.subscribers.keys());
// this.subscribers.forEach((sub, topic) => console.log(topic));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export class CourseScoresComponent implements OnInit, OnDestroy {
if (this.exerciseTitlesPerType.get(exerciseType) && this.exerciseTitlesPerType.get(exerciseType)!.length !== 0) {
const exerciseTypeName = capitalizeFirstLetter(exerciseType);
const exerciseTitleKeys = this.exerciseTitlesPerType.get(exerciseType)!;
exerciseTitleKeys.forEach((title, index) => {
exerciseTitleKeys.forEach((title) => {
emptyLine[title] = '';
});
emptyLine[exerciseTypeName + ' ' + POINTS_KEY] = '';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { SERVER_API_URL } from 'app/app.constants';
import { Injectable } from '@angular/core';
import { ProgrammingSubmission } from 'app/entities/programming-submission.model';
import { Result } from 'app/entities/result.model';
Expand Down
6 changes: 2 additions & 4 deletions src/main/webapp/app/course/manage/course-group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class CourseGroupComponent implements OnInit, OnDestroy {
// Flash green background color to signal to the user that this record was added
this.flashRowClass(cssClasses.newlyAddedMember);
},
(err) => {
() => {
this.isTransitioning = false;
},
);
Expand Down Expand Up @@ -237,10 +237,8 @@ export class CourseGroupComponent implements OnInit, OnDestroy {

/**
* Computes the row class that is being added to all rows of the datatable
*
* @param row Row from ngx datatable
*/
dataTableRowClass = (row: any) => {
dataTableRowClass = () => {
return this.rowClass;
};

Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/app/course/manage/course-management.route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { HttpResponse } from '@angular/common/http';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot, Routes } from '@angular/router';
import { ActivatedRouteSnapshot, Resolve, Routes } from '@angular/router';
import { UserRouteAccessService } from 'app/core/auth/user-route-access-service';
import { Observable, of } from 'rxjs';
import { filter, map } from 'rxjs/operators';
Expand All @@ -16,7 +16,7 @@ import { CourseGroupComponent } from 'app/course/manage/course-group.component';
export class CourseResolve implements Resolve<Course> {
constructor(private service: CourseManagementService) {}

resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Course> {
resolve(route: ActivatedRouteSnapshot): Observable<Course> {
const id = route.params['courseId'] ? route.params['courseId'] : null;
if (id) {
return this.service.find(id).pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ export class CourseManagementService {
}

private reconnectObjects(res: EntityArrayResponseType): EntityArrayResponseType {
if (res.body) {
/*if (res.body) {
res.body.forEach((course: Course) => {
// TODO: implement
});
}
}*/
return res;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/app/course/manage/course-update.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class CourseUpdateComponent implements OnInit {

private subscribeToSaveResponse(result: Observable<HttpResponse<Course>>) {
result.subscribe(
(res: HttpResponse<Course>) => this.onSaveSuccess(),
() => this.onSaveSuccess(),
(res: HttpErrorResponse) => this.onSaveError(res),
);
}
Expand Down Expand Up @@ -197,7 +197,7 @@ export class CourseUpdateComponent implements OnInit {
this.courseImageFile = null;
this.courseImageFileName = result.path;
},
(error) => {
() => {
this.isUploadingCourseImage = false;
this.courseImageFile = null;
this.courseImageFileName = this.course.courseIcon;
Expand Down
13 changes: 0 additions & 13 deletions src/main/webapp/app/entities/lti-outcome-url.model.ts

This file was deleted.

Loading

0 comments on commit cb7d306

Please sign in to comment.