code linting

This commit is contained in:
Kononnable 2019-10-11 12:41:33 +02:00
parent 95e0cc5854
commit bd8a79040c
7 changed files with 6 additions and 67 deletions

View File

@ -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";

View File

@ -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 =

View File

@ -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
);

View File

@ -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";

View File

@ -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";

View File

@ -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();

View File

@ -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('"')