mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
fix lint.
This commit is contained in:
parent
766af46198
commit
d683766030
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user