mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
style: Enable some linter rules (#10592)
* style: 🚨 enable some linter rules * Revert "style: 🚨 enable some linter rules" This reverts commit 239fa2deb7aaf22cfac4bbb1369d6d973327efd4. * revert: ⏪ revert role "prefer-const" * revert: ⏪ enable linter warnings * style: 🚨 enable rule "no-extra-boolean-cast" * revert: ⏪ disable rule "no-empty" * style: 🚨 add linter rule "no-useless-escape" * style: 🚨 add linter rule "no-unsafe-optional-chaining"
This commit is contained in:
parent
62f574bc5b
commit
e22481904a
@ -18,14 +18,10 @@
|
||||
"@typescript-eslint/triple-slash-reference": "warn",
|
||||
"no-async-promise-executor": "warn",
|
||||
"no-control-regex": "warn",
|
||||
"no-debugger": "warn",
|
||||
"no-empty": "warn",
|
||||
"no-extra-boolean-cast": "warn",
|
||||
"no-extra-semi": "warn",
|
||||
"no-prototype-builtins": "warn",
|
||||
"no-regex-spaces": "warn",
|
||||
"no-unsafe-optional-chaining": "warn",
|
||||
"no-useless-escape": "warn",
|
||||
"prefer-const": "warn",
|
||||
"prefer-rest-params": "warn",
|
||||
"prefer-spread": "warn"
|
||||
|
||||
@ -3348,10 +3348,10 @@ export class CockroachQueryRunner
|
||||
} else {
|
||||
tableColumn.default = dbColumn[
|
||||
"column_default"
|
||||
].replace(/:::[\w\s\[\]\"]+/g, "")
|
||||
].replace(/:::[\w\s[\]"]+/g, "")
|
||||
tableColumn.default =
|
||||
tableColumn.default.replace(
|
||||
/^(-?[\d\.]+)$/,
|
||||
/^(-?[\d.]+)$/,
|
||||
"($1)",
|
||||
)
|
||||
|
||||
@ -3744,7 +3744,7 @@ export class CockroachQueryRunner
|
||||
protected async getVersion(): Promise<string> {
|
||||
const result = await this.query(`SELECT version()`)
|
||||
return result[0]["version"].replace(
|
||||
/^CockroachDB CCL v([\d\.]+) .*$/,
|
||||
/^CockroachDB CCL v([\d.]+) .*$/,
|
||||
"$1",
|
||||
)
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ export class PostgresDriver implements Driver {
|
||||
}[]
|
||||
}
|
||||
const versionString = results.rows[0].version.replace(
|
||||
/^PostgreSQL ([\d\.]+) .*$/,
|
||||
/^PostgreSQL ([\d.]+) .*$/,
|
||||
"$1",
|
||||
)
|
||||
this.version = versionString
|
||||
@ -745,7 +745,7 @@ export class PostgresDriver implements Driver {
|
||||
} else if (columnMetadata.type === "simple-json") {
|
||||
value = DateUtils.stringToSimpleJson(value)
|
||||
} else if (columnMetadata.type === "cube") {
|
||||
value = value.replace(/[\(\)\s]+/g, "") // remove whitespace
|
||||
value = value.replace(/[()\s]+/g, "") // remove whitespace
|
||||
if (columnMetadata.isArray) {
|
||||
/**
|
||||
* Strips these groups from `{"1,2,3","",NULL}`:
|
||||
@ -753,7 +753,7 @@ export class PostgresDriver implements Driver {
|
||||
* 2. ["", undefined] <- cube of arity 0
|
||||
* 3. [undefined, "NULL"] <- NULL
|
||||
*/
|
||||
const regexp = /(?:\"((?:[\d\s\.,])*)\")|(?:(NULL))/g
|
||||
const regexp = /(?:"((?:[\d\s.,])*)")|(?:(NULL))/g
|
||||
const unparsedArrayString = value
|
||||
|
||||
value = []
|
||||
|
||||
@ -3775,7 +3775,7 @@ export class PostgresQueryRunner
|
||||
} else {
|
||||
tableColumn.default = dbColumn[
|
||||
"column_default"
|
||||
].replace(/::[\w\s.\[\]\-"]+/g, "")
|
||||
].replace(/::[\w\s.[\]\-"]+/g, "")
|
||||
tableColumn.default =
|
||||
tableColumn.default.replace(
|
||||
/^(-?\d+)$/,
|
||||
@ -4148,7 +4148,7 @@ export class PostgresQueryRunner
|
||||
*/
|
||||
protected async getVersion(): Promise<string> {
|
||||
const result = await this.query(`SELECT version()`)
|
||||
return result[0]["version"].replace(/^PostgreSQL ([\d\.]+) .*$/, "$1")
|
||||
return result[0]["version"].replace(/^PostgreSQL ([\d.]+) .*$/, "$1")
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1468,7 +1468,7 @@ export abstract class AbstractSqliteQueryRunner
|
||||
const fullType = tableColumn.type
|
||||
let dataType = fullType.substr(0, pos)
|
||||
if (
|
||||
!!this.driver.withLengthColumnTypes.find(
|
||||
this.driver.withLengthColumnTypes.find(
|
||||
(col) => col === dataType,
|
||||
)
|
||||
) {
|
||||
@ -1484,7 +1484,7 @@ export abstract class AbstractSqliteQueryRunner
|
||||
}
|
||||
}
|
||||
if (
|
||||
!!this.driver.withPrecisionColumnTypes.find(
|
||||
this.driver.withPrecisionColumnTypes.find(
|
||||
(col) => col === dataType,
|
||||
)
|
||||
) {
|
||||
@ -1496,7 +1496,7 @@ export abstract class AbstractSqliteQueryRunner
|
||||
tableColumn.precision = +matches[1]
|
||||
}
|
||||
if (
|
||||
!!this.driver.withScaleColumnTypes.find(
|
||||
this.driver.withScaleColumnTypes.find(
|
||||
(col) => col === dataType,
|
||||
)
|
||||
) {
|
||||
|
||||
@ -533,7 +533,7 @@ export class InsertQueryBuilder<
|
||||
|
||||
if (Array.isArray(overwrite)) {
|
||||
updatePart.push(
|
||||
...overwrite?.map(
|
||||
...overwrite.map(
|
||||
(column) =>
|
||||
`${this.escape(
|
||||
column,
|
||||
|
||||
@ -767,15 +767,15 @@ export abstract class QueryBuilder<Entity extends ObjectLiteral> {
|
||||
statement = statement.replace(
|
||||
new RegExp(
|
||||
// Avoid a lookbehind here since it's not well supported
|
||||
`([ =\(]|^.{0})` + // any of ' =(' or start of line
|
||||
`([ =(]|^.{0})` + // any of ' =(' or start of line
|
||||
// followed by our prefix, e.g. 'tablename.' or ''
|
||||
`${
|
||||
replaceAliasNamePrefixes
|
||||
? "(" + replaceAliasNamePrefixes + ")"
|
||||
: ""
|
||||
}([^ =\(\)\,]+)` + // a possible property name: sequence of anything but ' =(),'
|
||||
}([^ =(),]+)` + // a possible property name: sequence of anything but ' =(),'
|
||||
// terminated by ' =),' or end of line
|
||||
`(?=[ =\)\,]|.{0}$)`,
|
||||
`(?=[ =),]|.{0}$)`,
|
||||
"gm",
|
||||
),
|
||||
(...matches) => {
|
||||
|
||||
@ -30,5 +30,5 @@ export function filepathToName(filepath: string): string {
|
||||
* Cross platform isAbsolute
|
||||
*/
|
||||
export function isAbsolute(filepath: string): boolean {
|
||||
return !!filepath.match(/^(?:[a-z]:|[\\]|[\/])/i)
|
||||
return !!filepath.match(/^(?:[a-z]:|[\\]|[/])/i)
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ describe("cube-postgres", () => {
|
||||
// to be working on Postgres version >=10.6.
|
||||
const [{ version }] = await connection.query("SELECT version()")
|
||||
const semverArray = version
|
||||
.replace(/^PostgreSQL ([\d\.]+) .*$/, "$1")
|
||||
.replace(/^PostgreSQL ([\d.]+) .*$/, "$1")
|
||||
.split(".")
|
||||
.map(Number)
|
||||
if (!(semverArray[0] >= 10 && semverArray[1] >= 6)) {
|
||||
|
||||
@ -100,7 +100,7 @@ describe("multi-database > basic-functionality", () => {
|
||||
const expectedMainPath = path.join(
|
||||
tempPath,
|
||||
(connections[0].options.database as string).match(
|
||||
/^.*[\\|\/](?<filename>[^\\|\/]+)$/,
|
||||
/^.*[\\|/](?<filename>[^\\|/]+)$/,
|
||||
)!.groups!["filename"],
|
||||
)
|
||||
|
||||
|
||||
@ -272,7 +272,7 @@ describe("repository > find options > comment", () => {
|
||||
const lines = logs.toString().split("\n")
|
||||
const lastLine = lines[lines.length - 2] // last line is blank after newline
|
||||
// remove timestamp and prefix
|
||||
const sql = lastLine.replace(/^.*\[QUERY\]\: /, "")
|
||||
const sql = lastLine.replace(/^.*\[QUERY\]: /, "")
|
||||
expect(sql).to.match(/^\/\* This is a query comment. \*\//)
|
||||
}),
|
||||
))
|
||||
|
||||
@ -25,7 +25,6 @@ describe("github issues > #10054 Nested 'Or' Condition/Operation Support in Repo
|
||||
it("should find person where name starts with foo or equal to jane", async () => {
|
||||
await Promise.all(
|
||||
dataSources.map(async (dataSource) => {
|
||||
debugger
|
||||
const foo = new Person()
|
||||
foo.name = "Foo"
|
||||
foo.age = null
|
||||
|
||||
@ -31,7 +31,7 @@ describe("github issues > #9318 Change version query from SHOW server_version to
|
||||
connection.driver as PostgresDriver
|
||||
const result = await connection.query("SELECT VERSION()")
|
||||
const dbVersion = result[0]["version"].replace(
|
||||
/^PostgreSQL ([\d\.]+) .*$/,
|
||||
/^PostgreSQL ([\d.]+) .*$/,
|
||||
"$1",
|
||||
)
|
||||
const versionGreaterOfEqualTo12 = VersionUtils.isGreaterOrEqual(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user