From bd8a79040c4c2c63a44201bf0ded80f7fc0d39ef Mon Sep 17 00:00:00 2001 From: Kononnable Date: Fri, 11 Oct 2019 12:41:33 +0200 Subject: [PATCH] code linting --- src/Engine.ts | 1 - src/NamingStrategy.ts | 9 ++------- src/drivers/AbstractDriver.ts | 33 --------------------------------- src/drivers/MysqlDriver.ts | 5 ----- src/drivers/PostgresDriver.ts | 5 ----- src/drivers/SqliteDriver.ts | 7 +------ test/utils/EntityFileToJson.ts | 13 +++---------- 7 files changed, 6 insertions(+), 67 deletions(-) diff --git a/src/Engine.ts b/src/Engine.ts index 93e26fd..1dba8e0 100644 --- a/src/Engine.ts +++ b/src/Engine.ts @@ -7,7 +7,6 @@ import MssqlDriver from "./drivers/MssqlDriver"; import MariaDbDriver from "./drivers/MariaDbDriver"; import IConnectionOptions from "./IConnectionOptions"; import IGenerationOptions from "./IGenerationOptions"; -import EntityInfo from "./oldModels/EntityInfo"; import PostgresDriver from "./drivers/PostgresDriver"; import MysqlDriver from "./drivers/MysqlDriver"; import OracleDriver from "./drivers/OracleDriver"; diff --git a/src/NamingStrategy.ts b/src/NamingStrategy.ts index 399ea44..42bd127 100644 --- a/src/NamingStrategy.ts +++ b/src/NamingStrategy.ts @@ -1,17 +1,12 @@ import AbstractNamingStrategy from "./AbstractNamingStrategy"; import { Relation } from "./models/Relation"; -import { Entity } from "./models/Entity"; import { RelationId } from "./models/RelationId"; import changeCase = require("change-case"); /* eslint-disable class-methods-use-this */ export default class NamingStrategy extends AbstractNamingStrategy { - public relationIdName( - relationId: RelationId, - relation: Relation, - owner: Entity - ): string { + public relationIdName(relationId: RelationId, relation: Relation): string { const columnOldName = relationId.fieldName; const isRelationToMany = @@ -32,7 +27,7 @@ export default class NamingStrategy extends AbstractNamingStrategy { return columnName; } - public relationName(relation: Relation, owner: Entity): string { + public relationName(relation: Relation): string { const columnOldName = relation.fieldName; const isRelationToMany = diff --git a/src/drivers/AbstractDriver.ts b/src/drivers/AbstractDriver.ts index 889f291..7ea68ed 100644 --- a/src/drivers/AbstractDriver.ts +++ b/src/drivers/AbstractDriver.ts @@ -6,9 +6,6 @@ import { import { JoinColumnOptions, RelationOptions } from "typeorm"; import { DataTypeDefaults } from "typeorm/driver/types/DataTypeDefaults"; import * as TomgUtils from "../Utils"; -import EntityInfo from "../oldModels/EntityInfo"; -import RelationInfo from "../oldModels/RelationInfo"; -import ColumnInfo from "../oldModels/ColumnInfo"; import IConnectionOptions from "../IConnectionOptions"; import { Entity } from "../models/Entity"; import { RelationInternal } from "../models/RelationInternal"; @@ -255,36 +252,6 @@ export default abstract class AbstractDriver { generationOptions: IGenerationOptions ) { relationsTemp.forEach(relationTmp => { - if (relationTmp.ownerColumns.length > 1) { - const relatedTable = entities.find( - entity => entity.tscName === relationTmp.ownerTable.tscName - )!; - // if ( - // relatedTable.columns.length !== - // relationTmp.ownerColumns.length * 2 - // ) { - // TomgUtils.LogError( - // `Relation between tables ${relationTmp.ownerTable.sqlName} and ${relationTmp.relatedTable.sqlName} wasn't generated correctly - complex relationships aren't supported yet.`, - // false - // ); - // return; - // } - - const secondRelation = relationsTemp.find( - relation => - relation.ownerTable.tscName === relatedTable.tscName && - relation.relatedTable.tscName !== - relationTmp.relatedTable.tscName - )!; - // if (!secondRelation) { - // TomgUtils.LogError( - // `Relation between tables ${relationTmp.ownerTable.sqlName} and ${relationTmp.relatedTable.sqlName} wasn't generated correctly - complex relationships aren't supported yet.`, - // false - // ); - // return; - // } - } - const ownerEntity = entities.find( entity => entity.tscName === relationTmp.ownerTable.tscName ); diff --git a/src/drivers/MysqlDriver.ts b/src/drivers/MysqlDriver.ts index 96561fe..f6cc0eb 100644 --- a/src/drivers/MysqlDriver.ts +++ b/src/drivers/MysqlDriver.ts @@ -4,11 +4,6 @@ import * as TypeormDriver from "typeorm/driver/mysql/MysqlDriver"; import { DataTypeDefaults } from "typeorm/driver/types/DataTypeDefaults"; import * as TomgUtils from "../Utils"; import AbstractDriver from "./AbstractDriver"; -import EntityInfo from "../oldModels/EntityInfo"; -import ColumnInfo from "../oldModels/ColumnInfo"; -import IndexInfo from "../oldModels/IndexInfo"; -import IndexColumnInfo from "../oldModels/IndexColumnInfo"; -import RelationTempInfo from "../oldModels/RelationTempInfo"; import IConnectionOptions from "../IConnectionOptions"; import { Entity } from "../models/Entity"; import { Column } from "../models/Column"; diff --git a/src/drivers/PostgresDriver.ts b/src/drivers/PostgresDriver.ts index 7571591..50bfb0c 100644 --- a/src/drivers/PostgresDriver.ts +++ b/src/drivers/PostgresDriver.ts @@ -4,11 +4,6 @@ import * as TypeormDriver from "typeorm/driver/postgres/PostgresDriver"; import { DataTypeDefaults } from "typeorm/driver/types/DataTypeDefaults"; import * as TomgUtils from "../Utils"; import AbstractDriver from "./AbstractDriver"; -import EntityInfo from "../oldModels/EntityInfo"; -import ColumnInfo from "../oldModels/ColumnInfo"; -import IndexInfo from "../oldModels/IndexInfo"; -import IndexColumnInfo from "../oldModels/IndexColumnInfo"; -import RelationTempInfo from "../oldModels/RelationTempInfo"; import IConnectionOptions from "../IConnectionOptions"; import { Entity } from "../models/Entity"; import { Column } from "../models/Column"; diff --git a/src/drivers/SqliteDriver.ts b/src/drivers/SqliteDriver.ts index c6fe377..60ce45a 100644 --- a/src/drivers/SqliteDriver.ts +++ b/src/drivers/SqliteDriver.ts @@ -4,11 +4,6 @@ import { DataTypeDefaults } from "typeorm/driver/types/DataTypeDefaults"; import * as sqliteLib from "sqlite3"; import * as TomgUtils from "../Utils"; import AbstractDriver from "./AbstractDriver"; -import EntityInfo from "../oldModels/EntityInfo"; -import ColumnInfo from "../oldModels/ColumnInfo"; -import IndexInfo from "../oldModels/IndexInfo"; -import IndexColumnInfo from "../oldModels/IndexColumnInfo"; -import RelationTempInfo from "../oldModels/RelationTempInfo"; import IConnectionOptions from "../IConnectionOptions"; import { Entity } from "../models/Entity"; import { Column } from "../models/Column"; @@ -78,7 +73,7 @@ export default class SqliteDriver extends AbstractDriver { const defaultValue = SqliteDriver.ReturnDefaultValueFunction( resp.dflt_value ); - let columnType = resp.type + const columnType = resp.type .replace(/\([0-9 ,]+\)/g, "") .toLowerCase() .trim(); diff --git a/test/utils/EntityFileToJson.ts b/test/utils/EntityFileToJson.ts index afb861a..d091b89 100644 --- a/test/utils/EntityFileToJson.ts +++ b/test/utils/EntityFileToJson.ts @@ -92,16 +92,9 @@ export default class EntityFileToJson { /default: \(\) => (.*)/, `default: $1` ); - try { - col.columnOptions = JSON.parse( - badJSON.replace( - /(['"])?([a-z0-9A-Z_]+)(['"])?:/g, - '"$2": ' - ) - ); - } catch (error) { - debugger; - } + col.columnOptions = JSON.parse( + badJSON.replace(/(['"])?([a-z0-9A-Z_]+)(['"])?:/g, '"$2": ') + ); } else if ( decoratorParameters[0] === '"' && decoratorParameters.endsWith('"')