Skip to content

Commit

Permalink
ESLint 🎨
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentlaine committed Nov 21, 2023
1 parent 995623a commit 7968ddf
Show file tree
Hide file tree
Showing 98 changed files with 1,586 additions and 508 deletions.
25 changes: 25 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.eslint.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'airbnb-base',
'airbnb-typescript/base',
'prettier',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
restore-keys: |
${{ runner.os }}-node-
- run: npm install #TODO: --only-prod, le build crash à voir pq
- run: npm install -g @angular/cli > /dev/null
- run: npm run build:prod
- run: yarn install #TODO: --only-prod, le build crash à voir pq
- run: yarn install -g @angular/cli > /dev/null
- run: yarn build:prod
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "ng build",
"build:prod": "uglifyjs ./src/assets/scripts/embbed-chatbot.js -m -o ./src/assets/scripts/embbed-chatbot.min.js && ng build webchat --configuration production --base-href /chatbot/ --output-hashing=all && ng build --configuration production --base-href /backoffice/ --output-hashing=all",
"test": "ng test",
"lint": "ng lint",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"e2e": "ng e2e",
"cypress:local": "concurrently \"npm run start:local\" \"cypress open\"",
"cypress:dev": "concurrently \"npm run start:dev\" \"cypress open\"",
Expand Down Expand Up @@ -60,11 +60,18 @@
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^18.11.18",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"codelyzer": "^6.0.2",
"concurrently": "^5.3.0",
"cypress": "^7.7.0",
"cypress-file-upload": "^5.0.8",
"cypress-intellij-reporter": "^0.0.6",
"eslint": "^8.54.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"jasmine-core": "~4.5.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.4.1",
Expand All @@ -73,9 +80,9 @@
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "^2.0.0",
"ng-packagr": "^15.1.0",
"prettier": "^3.1.0",
"protractor": "~7.0.0",
"ts-node": "~7.0.0",
"tslint": "^6.1.3",
"typescript": "~4.9.4"
}
}
6 changes: 3 additions & 3 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app.routing';
import { MAT_DATE_LOCALE } from '@angular/material/core';
import { ServiceWorkerModule } from '@angular/service-worker';
import { environment } from '../environments/environment';
import { HIGHLIGHT_OPTIONS, HighlightOptions } from 'ngx-highlightjs';
import { CoreModule } from '@core/core.module';
import { environment } from '../environments/environment';
import { AppRoutingModule } from './app.routing';
import { AppComponent } from './app.component';

@NgModule({
declarations: [
Expand Down
6 changes: 3 additions & 3 deletions src/app/core/core.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NotAuthenticatedLayoutComponent } from './components/not-authenticated-layout/not-authenticated-layout.component';
import { RouterModule } from '@angular/router';
import { AuthenticatedLayoutComponent } from './components/authenticated-layout/authenticated-layout.component';
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';
import { JwtInterceptor } from './interceptors/jwt.interceptor';
import { ErrorInterceptor } from './interceptors/error.interceptor';
import { ToastrModule } from 'ngx-toastr';
import { AuthenticatedLayoutComponent } from './components/authenticated-layout/authenticated-layout.component';
import { NotAuthenticatedLayoutComponent } from './components/not-authenticated-layout/not-authenticated-layout.component';
import { FooterComponent } from './components/footer/footer.component';
import { MaterialModule } from '../modules/material/material.module';
import { SideMenuComponent } from './components/authenticated-layout/side-menu/side-menu.component';
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/guards/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export class AuthGuard implements CanActivate, CanActivateChild {
if (this._authService.isAuthenticated() && isAuthPage) {
this._router.navigate(['']);
return false;
} else if (!this._authService.isAuthenticated() && !isAuthPage) {
} if (!this._authService.isAuthenticated() && !isAuthPage) {
this._router.navigate(['auth']);
return false;
} else if (allowedRole && !isAuthPage && this._authService.isAuthenticated() && this._authService.user.role !== allowedRole) {
} if (allowedRole && !isAuthPage && this._authService.isAuthenticated() && this._authService.user.role !== allowedRole) {
this._router.navigate(['']);
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/interceptors/error.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Inject, Injectable } from '@angular/core';
import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { Router } from '@angular/router';
import { AuthService } from '../services/auth.service';
import { ToastrService } from 'ngx-toastr';
import { AuthService } from '../services/auth.service';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -38,7 +38,7 @@ export class ErrorInterceptor implements HttpInterceptor {
}

private _showBackendMessage(err: HttpErrorResponse): void {
const error: Error = err.error;
const {error} = err;
const messageToShow = (error && error.message) ? this._generateErrorMessage(error.message) : 'Une erreur est survenue';
this._toastr.error(messageToShow);
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/core/interceptors/jwt.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AuthService } from '../services/auth.service';
export class JwtInterceptor implements HttpInterceptor {

token$: Observable<string>;

currentToken: string;

constructor(private _authService: AuthService) {
Expand All @@ -22,7 +23,7 @@ export class JwtInterceptor implements HttpInterceptor {
}

let newHeaders = request.headers.set('Authorization',
'Bearer ' + this.currentToken);
`Bearer ${ this.currentToken}`);
newHeaders = newHeaders.set('Cache-Control', 'no-cache');
newHeaders = newHeaders.set('Pragma', 'no-cache');
newHeaders = newHeaders.set('Expires', 'Sat, 01 Jan 2000 00:00:00 GMT');
Expand Down
1 change: 1 addition & 0 deletions src/app/core/models/auth-response.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import { User } from './user.model';

export class AuthResponse {
chatbotToken: string;

user: User;
}
20 changes: 20 additions & 0 deletions src/app/core/models/config.model.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,52 @@
export class Config {
name: string;

function: string;

icon: string;

primaryColor: string;

secondaryColor: string;

mediaSize: number;

trainingRasa: boolean;

needTraining: boolean;

lastTrainingAt: string;

storage: boolean;

apiKey: string;

// EMBEDDED
embeddedIcon: string;

description: string;

help: string;

helpBtn: string;

chatBtn: string;

faqBtn: string;

showFaq: boolean;

showFallbackSuggestions: boolean;

// DESCRIPTION
problematic: string;

audience: string;

// CONFIG
showIntentSearch: boolean;

delayBetweenMessages: number;

isTree: boolean;
}
2 changes: 2 additions & 0 deletions src/app/core/models/file-historic.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export class FileHistoric {
id: number;

name: string;

createdAt: Date;
}
3 changes: 3 additions & 0 deletions src/app/core/models/file-template-check-resume.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export class FileTemplateCheckResume {
categories: string[];

questionsNumber: number;

warnings: { [key: string]: string } = {};

errors: { [key: string]: string } = {};
}
3 changes: 3 additions & 0 deletions src/app/core/models/import-file.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export class ImportFile {
file: File;

deleteIntents: boolean;

oldURL: string;

newURL: string;
}
2 changes: 2 additions & 0 deletions src/app/core/models/import-response.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export class ImportResponse {
intents: number;

knowledges: number;

responses: number;
}
10 changes: 9 additions & 1 deletion src/app/core/models/inbox.model.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { Intent } from './intent.model';
import { InboxStatus } from '@enum/inbox-status.enum';
import { User } from '@model/user.model';
import { Intent } from './intent.model';

export class Inbox {
id: number;

confidence: number;

intentRanking: {name: string, confidence: number}[];

question: string;

response: any[];

timestamp: number;

status: InboxStatus;

intent: Intent;

user?: User;
}
9 changes: 9 additions & 0 deletions src/app/core/models/intent.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@ import { IntentStatus } from '@enum/intent-status.enum';

export class Intent {
id: string;

mainQuestion: string;

status: IntentStatus;

category: string;

hidden: boolean;

responses: Response[];

knowledges: Knowledge[];

createdAt: Date;

updatedAt: Date;

expiresAt: Date;

// For inbox
confidence?: number;

previousIntents: Intent[];

nextIntents: Intent[];

linkedResponses: number;

constructor() {
Expand Down
1 change: 1 addition & 0 deletions src/app/core/models/knowledge.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export class Knowledge {
id: number;

question: string;
}
1 change: 1 addition & 0 deletions src/app/core/models/login.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export class Login {
email: string;

password: string;
}
4 changes: 4 additions & 0 deletions src/app/core/models/media.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import { Intent } from '@model/intent.model';

export class Media {
id: number;

file: string;

createdAt: string;

addedBy: string;

size: number;

intents?: Intent[];
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/models/pagination-helper.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import { PaginatedResult } from '@model/paginated-result.model';
export class PaginationHelper {

currentPage: number = null;

totalPages: number;

totalElements: number;

itemCount: number;

last: boolean;

constructor(public size = 20) {
Expand Down
1 change: 1 addition & 0 deletions src/app/core/models/reset-password.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export class ResetPassword {
password: string;

token: string;
}
2 changes: 2 additions & 0 deletions src/app/core/models/response.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { Intent } from '@model/intent.model';

export class Response {
id: number;

responseType: ResponseType;

response: string;

intentId?: string;
Expand Down
5 changes: 5 additions & 0 deletions src/app/core/models/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import { UserRole } from '@enum/user-role.enum';

export class User {
email: string;

firstName: string;

lastName: string;

role = UserRole.writer;

createdAt: string;

disabled: boolean;

endDate?: string;
}
Loading

0 comments on commit 7968ddf

Please sign in to comment.