fix lint.

This commit is contained in:
Simon Larsen 2022-06-06 14:08:59 +01:00
parent 766af46198
commit d683766030
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
6 changed files with 22 additions and 24 deletions

View File

@ -4,6 +4,7 @@
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true,
"tsx": true,
"spread": true
},
"sourceType": "module",
@ -179,7 +180,7 @@
},
"settings": {
"react": {
"version": "16.5"
"version": "18.1.0"
}
}
}

View File

@ -29,16 +29,16 @@ import Phone from '../Types/Phone';
import PositiveNumber from '../Types/PositiveNumber';
export type DbTypes =
string |
number |
PositiveNumber |
Email |
HashedString |
URL |
Phone |
JSONObject |
JSONArray |
Buffer;
| string
| number
| PositiveNumber
| Email
| HashedString
| URL
| Phone
| JSONObject
| JSONArray
| Buffer;
export default class BaseModel extends BaseEntity {
@TableColumn({ title: 'ID' })
@ -152,16 +152,16 @@ export default class BaseModel extends BaseEntity {
return new Columns(Object.keys(getTableColumns(this)));
}
public hasValue(columnName: string) {
return !!(this as any)[columnName];
public hasValue(columnName: string): boolean {
return Boolean((this as any)[columnName]);
}
public getValue<T extends DbTypes>(columnName: string): T {
return (this as any)[columnName] as T;
}
public setValue<T extends DbTypes>(columnName: string, value: T) {
return (this as any)[columnName] = value;
public setValue<T extends DbTypes>(columnName: string, value: T): void {
(this as any)[columnName] = value;
}
public getUniqueColumns(): Columns {

View File

@ -81,7 +81,7 @@ class User extends BaseModel {
length: ColumnLength.HashedString,
unique: false,
nullable: true,
transformer: HashedString.getDatabaseTransformer()
transformer: HashedString.getDatabaseTransformer(),
})
public password?: HashedString = undefined;

View File

@ -33,7 +33,6 @@ export default class HashedString extends DatabaseProperty {
protected static override toDatabase(
value: HashedString | FindOperator<HashedString>
): string | null {
if (value) {
return value.toString();
}
@ -57,7 +56,6 @@ export default class HashedString extends DatabaseProperty {
const valueToHash: string = (encryptionSecret || '') + this.value;
this.isHashed = true;
this.value = CryptoJS.SHA256(valueToHash).toString();
return this.value;
}

View File

@ -123,12 +123,11 @@ class DatabaseService<TBaseModel extends BaseModel> {
protected async hash(data: TBaseModel): Promise<TBaseModel> {
const columns: Columns = data.getHashedColumns();
for (const key of columns.columns) {
if (
data.hasValue(key) &&
!((data.getValue(key) as HashedString).isValueHashed())
data.hasValue(key) &&
!(data.getValue(key) as HashedString).isValueHashed()
) {
await ((data as any)[key] as HashedString).hashValue(
EncryptionSecret

View File

@ -33,8 +33,8 @@
"count-total-lines-of-code": "git grep ^ | wc -l",
"uninstall": "docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)",
"delete-all-local-branches": "git branch | grep -v 'master' | xargs git branch -D",
"lint": "ejslint home/views/*.ejs && eslint '**/*.ts' -c .eslintrc.json --ignore-path .eslintignore ",
"fix-lint": "eslint '**/*.ts' -c .eslintrc.json --ignore-path .eslintignore --fix ",
"lint": "ejslint home/views/*.ejs && eslint '**/*.ts,**/*.tsx' -c .eslintrc.json --ignore-path .eslintignore ",
"fix-lint": "eslint '**/*.ts*' -c .eslintrc.json --ignore-path .eslintignore --fix ",
"fix": "npm run fix-lint",
"build": "docker-compose --env-file ./docker-enterprise.env build",
"build-ci": "docker-compose --env-file ./docker-enterprise.env -f docker-compose.ci.yml build $npm_config_services",