style: lint repository (#11346)

* style: lint uncommon rules

* style: fix `no-wrapper-object-types`

* fix: type errors after Object -> object change

* style: fix `prefer-const`

* build: add eslint/prettier exclusions
This commit is contained in:
Lucian Mocanu 2025-03-20 22:15:39 +02:00 committed by GitHub
parent de8eb04c72
commit 8c2b2ae240
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
212 changed files with 684 additions and 660 deletions

5
.prettierignore Normal file
View File

@ -0,0 +1,5 @@
build/
coverage/
node_modules/
gulpfile.ts

View File

@ -1,5 +1,5 @@
module.exports = {
semi: false,
trailingComma: "all",
arrowParens: "always",
arrowParens: "always",
semi: false,
trailingComma: "all",
}

View File

@ -2,50 +2,55 @@ import eslint from "@eslint/js"
import tseslint from "typescript-eslint"
import globals from "globals"
export default tseslint.config({
files: ["**/*.ts"],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: "tsconfig.json",
},
globals: {
...globals.browser,
...globals.node,
},
export default tseslint.config([
{
ignores: ["build/**", "node_modules/**"],
},
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
rules: {
// exceptions
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-empty-object-type": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-misused-new": "warn",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/no-require-imports": "warn",
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
"@typescript-eslint/no-unsafe-function-type": "warn",
"@typescript-eslint/no-unused-expressions": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{ argsIgnorePattern: "^_" },
],
"@typescript-eslint/no-wrapper-object-types": "warn",
"@typescript-eslint/triple-slash-reference": "warn",
"no-async-promise-executor": "warn",
"no-control-regex": "warn",
"no-empty": "warn",
"no-loss-of-precision": "warn",
"no-prototype-builtins": "warn",
"no-regex-spaces": "warn",
{
files: ["**/*.ts"],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: "tsconfig.json",
},
globals: {
...globals.browser,
...globals.node,
},
},
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
rules: {
// exceptions
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-empty-object-type": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-misused-new": "warn",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/no-require-imports": "warn",
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
"@typescript-eslint/no-unsafe-function-type": "warn",
"@typescript-eslint/no-unused-expressions": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{ argsIgnorePattern: "^_" },
],
"@typescript-eslint/no-wrapper-object-types": "warn",
"@typescript-eslint/triple-slash-reference": "warn",
"no-async-promise-executor": "warn",
"no-control-regex": "warn",
"no-empty": "warn",
"no-loss-of-precision": "warn",
"no-prototype-builtins": "warn",
"no-regex-spaces": "warn",
// custom
"prefer-const": "warn",
"prefer-rest-params": "warn",
"prefer-spread": "warn",
// deprecated: stylistic
"no-extra-semi": "warn",
// custom
"prefer-const": "warn",
"prefer-rest-params": "warn",
"prefer-spread": "warn",
// deprecated: stylistic
"no-extra-semi": "warn",
},
},
})
])

View File

@ -1,12 +1,11 @@
import { Gulpclass, Task, SequenceTask, MergedTask } from "gulpclass";
import fs from "fs/promises";
import gulp from "gulp";
import shell from "gulp-shell";
import replace from "gulp-replace";
import rename from "gulp-rename";
import replace from "gulp-replace";
import shell from "gulp-shell";
import sourcemaps from "gulp-sourcemaps";
import ts from "gulp-typescript";
import { Gulpclass, MergedTask, SequenceTask, Task } from "gulpclass";
import { rimraf } from "rimraf";
@Gulpclass()

View File

@ -243,8 +243,8 @@
"package": "gulp package",
"pack": "gulp pack",
"lint": "eslint .",
"format": "prettier --cache --write --end-of-line auto \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"",
"format:ci": "prettier --check --end-of-line auto \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"",
"format": "prettier --cache --write \"./**/*.ts\"",
"format:ci": "prettier --check \"./**/*.ts\"",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1"
},
"bin": {
@ -258,4 +258,4 @@
"url": "https://opencollective.com/typeorm",
"logo": "https://opencollective.com/opencollective/logo.txt"
}
}
}

View File

@ -18,12 +18,12 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
async (dataSource) => {
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.likesCount = 100
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
postRepository
.save(post)

View File

@ -21,25 +21,25 @@ const dataSource = new DataSource(options)
dataSource
.initialize()
.then((dataSource) => {
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
let postCover = new Cover()
const postCover = new Cover()
postCover.url = "http://covers.com/post.jpg"
let details = new PostDetails()
const details = new PostDetails()
details.meta = "hello"
details.comment = "wow"
let category1 = new Category()
const category1 = new Category()
category1.description = "about post1"
let category2 = new Category()
const category2 = new Category()
category2.description = "about post2"
let image = new Image()
const image = new Image()
image.name = "post.jpg"
let post = new Post()
const post = new Post()
post.title = "Hello post"
post.text = "Hello world of post#1"
post.cover = postCover

View File

@ -17,7 +17,7 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let entity = new EverythingEntity()
const entity = new EverythingEntity()
entity.date = new Date(1980, 11, 1)
entity.name = "max 255 chars name"
entity.text = "this is pretty long text"
@ -39,7 +39,7 @@ dataSource.initialize().then(
entity.alsoJson = { hello: "olleh", world: "dlrow" }
entity.enum = SampleEnum.ONE
let postRepository = dataSource.getRepository(EverythingEntity)
const postRepository = dataSource.getRepository(EverythingEntity)
postRepository
.save(entity)

View File

@ -18,11 +18,11 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
postRepository
.save(post)

View File

@ -20,18 +20,18 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let category1 = new PostCategory()
const category1 = new PostCategory()
category1.name = "post category #1"
let category2 = new PostCategory()
const category2 = new PostCategory()
category2.name = "post category #2"
let author = new PostAuthor()
const author = new PostAuthor()
author.name = "Umed"
author.firstName = "Uma"
author.secondName = "Edi"
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.author = author
@ -47,15 +47,15 @@ dataSource.initialize().then(
author = new PostAuthor();
author.name = "Umed";*/
let blog = new Blog()
const blog = new Blog()
blog.text = "Hello how are you?"
blog.title = "hello"
blog.author = author
blog.title2312312 = "awesome title!"
blog.categories.push(category1, category2)
let postRepository = dataSource.getRepository(Post)
let blogRepository = dataSource.getRepository(Blog)
const postRepository = dataSource.getRepository(Post)
const blogRepository = dataSource.getRepository(Blog)
postRepository
.save(post)

View File

@ -17,15 +17,15 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let author = new PostAuthor()
const author = new PostAuthor()
author.name = "Umed"
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.author = author
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
postRepository
.save(post)

View File

@ -18,12 +18,12 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.likesCount = 0
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
postRepository
.save(post)

View File

@ -17,11 +17,11 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
postRepository
.save(post)

View File

@ -19,14 +19,14 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let postRepository = dataSource.getRepository(Post)
let authorRepository = dataSource.getRepository(Author)
let categoryRepository = dataSource.getRepository(Category)
const postRepository = dataSource.getRepository(Post)
const authorRepository = dataSource.getRepository(Author)
const categoryRepository = dataSource.getRepository(Category)
let author = authorRepository.create()
const author = authorRepository.create()
author.name = "Umed"
let post = postRepository.create()
const post = postRepository.create()
post.text = "Hello how are you?"
post.title = "hello"
post.author = author.asPromise()
@ -40,7 +40,7 @@ dataSource.initialize().then(
)
console.log(post)
let secondPost = postRepository.create()
const secondPost = postRepository.create()
secondPost.text = "Second post"
secondPost.title = "About second post"
author.posts = Promise.resolve([secondPost])
@ -80,13 +80,13 @@ dataSource.initialize().then(
console.log("Two post's author has been removed.")
console.log("Now lets check many-to-many relations")
let category1 = categoryRepository.create()
const category1 = categoryRepository.create()
category1.name = "Hello category1"
let category2 = categoryRepository.create()
const category2 = categoryRepository.create()
category2.name = "Bye category2"
let post = postRepository.create()
const post = postRepository.create()
post.title = "Post & Categories"
post.text = "Post with many categories"
post.categories = Promise.resolve([category1, category2])

View File

@ -20,24 +20,24 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let postRepository = dataSource.getRepository(Post)
let authorRepository = dataSource.getRepository(Author)
let categoryRepository = dataSource.getRepository(Category)
let metadataRepository = dataSource.getRepository(PostMetadata)
const postRepository = dataSource.getRepository(Post)
const authorRepository = dataSource.getRepository(Author)
const categoryRepository = dataSource.getRepository(Category)
const metadataRepository = dataSource.getRepository(PostMetadata)
let category1 = categoryRepository.create()
const category1 = categoryRepository.create()
category1.name = "Hello category1"
let category2 = categoryRepository.create()
const category2 = categoryRepository.create()
category2.name = "Bye category2"
let author = authorRepository.create()
const author = authorRepository.create()
author.name = "Umed"
let metadata = metadataRepository.create()
const metadata = metadataRepository.create()
metadata.comment = "Metadata about post"
let post = postRepository.create()
const post = postRepository.create()
post.text = "Hello how are you?"
post.title = "hello"
post.author = author

View File

@ -31,17 +31,17 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let details = new PostDetails()
const details = new PostDetails()
details.authorName = "Umed"
details.comment = "about post"
details.metadata = "post,details,one-to-one"
let post = new Post()
const post = new Post()
post.text = "hello how are you?"
post.title = "hello"
post.details = details
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
postRepository
.save(post)

View File

@ -19,22 +19,22 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let entityManager = dataSource.manager
const entityManager = dataSource.manager
let postRepository = dataSource.getRepository(Post)
let authorRepository = dataSource.getRepository(Author)
let categoryRepository = dataSource.getRepository(Category)
const postRepository = dataSource.getRepository(Post)
const authorRepository = dataSource.getRepository(Author)
const categoryRepository = dataSource.getRepository(Category)
let category1 = categoryRepository.create()
const category1 = categoryRepository.create()
category1.name = "Hello category1"
let category2 = categoryRepository.create()
const category2 = categoryRepository.create()
category2.name = "Bye category2"
let author = authorRepository.create()
const author = authorRepository.create()
author.name = "Umed"
let post = postRepository.create()
const post = postRepository.create()
post.text = "Hello how are you?"
post.title = "hello"
post.authorId = 1

View File

@ -19,18 +19,18 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
let author = new Author()
const author = new Author()
author.name = "Umed"
let category1 = new Category()
const category1 = new Category()
category1.name = "Category #1"
let category2 = new Category()
const category2 = new Category()
category2.name = "Category #2"
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.author = author

View File

@ -17,23 +17,23 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let categoryRepository = dataSource.getTreeRepository(Category)
const categoryRepository = dataSource.getTreeRepository(Category)
let childChildCategory1 = new Category()
const childChildCategory1 = new Category()
childChildCategory1.name = "Child #1 of Child #1 of Category #1"
let childChildCategory2 = new Category()
const childChildCategory2 = new Category()
childChildCategory2.name = "Child #1 of Child #2 of Category #1"
let childCategory1 = new Category()
const childCategory1 = new Category()
childCategory1.name = "Child #1 of Category #1"
childCategory1.childCategories = [childChildCategory1]
let childCategory2 = new Category()
const childCategory2 = new Category()
childCategory2.name = "Child #2 of Category #1"
childCategory2.childCategories = [childChildCategory2]
let category1 = new Category()
const category1 = new Category()
category1.name = "Category #1"
category1.childCategories = [childCategory1, childCategory2]

View File

@ -19,24 +19,24 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
let category1 = new Category()
const category1 = new Category()
category1.name = "category #1"
let category2 = new Category()
const category2 = new Category()
category2.name = "category #2"
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.categories = [category1, category2]
let author = new Author()
const author = new Author()
author.name = "Umed"
post.author = author
let author2 = new Author()
const author2 = new Author()
author2.name = "Bakhrom"
postRepository
@ -55,7 +55,7 @@ dataSource.initialize().then(
"Lets update a post - add a new category and change author",
)
let category3 = new Category()
const category3 = new Category()
category3.name = "category #3"
post.categories.push(category3)

View File

@ -40,9 +40,9 @@ const dataSource = new DataSource(options)
dataSource
.initialize()
.then((dataSource) => {
let postRepository = dataSource.getRepository<Post>("Post")
const postRepository = dataSource.getRepository<Post>("Post")
let post: Post = {
const post: Post = {
title: "Hello post",
text: "I am virtual post!",
details: {

View File

@ -18,8 +18,8 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let postRepository = dataSource.getRepository(Post)
let authorRepository = dataSource.getRepository(Author)
const postRepository = dataSource.getRepository(Post)
const authorRepository = dataSource.getRepository(Author)
const authorPromise = authorRepository
.findOneBy({ id: 1 })

View File

@ -19,7 +19,7 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let questionRepository = dataSource.getRepository(Question)
const questionRepository = dataSource.getRepository(Question)
const question = new Question()
question.title = "Hello question!"

View File

@ -17,7 +17,7 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
async (dataSource) => {
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
const post = new Post()
post.id = 1

View File

@ -20,7 +20,7 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
async (dataSource) => {
let employeeRepository = dataSource.getRepository(Employee)
const employeeRepository = dataSource.getRepository(Employee)
const employee = new Employee()
employee.id = 1
employee.firstName = "umed"
@ -39,7 +39,7 @@ dataSource.initialize().then(
console.log("-----------------")
let homesitterRepository = dataSource.getRepository(Homesitter)
const homesitterRepository = dataSource.getRepository(Homesitter)
const homesitter = new Homesitter()
homesitter.id = 2
homesitter.firstName = "umed"
@ -58,7 +58,7 @@ dataSource.initialize().then(
console.log("-----------------")
let studentRepository = dataSource.getRepository(Student)
const studentRepository = dataSource.getRepository(Student)
const student = new Student()
student.id = 3
student.firstName = "umed"

View File

@ -37,17 +37,17 @@ const dataSource = new DataSource(options)
dataSource
.initialize()
.then((dataSource) => {
let details = new PostDetails()
const details = new PostDetails()
details.authorName = "Umed"
details.comment = "about post"
details.metadata = "post,details,one-to-one"
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.details = details
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
postRepository
.save(post)

View File

@ -15,24 +15,24 @@ const dataSource = new DataSource(options)
dataSource
.initialize()
.then(async (dataSource) => {
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
let post1 = new Post("Me", "hello me", [
const post1 = new Post("Me", "hello me", [
new Category("programming"),
new Category("family"),
new Category("chocolate"),
])
let post2 = new Post("Zorro", "hello zorro", [
const post2 = new Post("Zorro", "hello zorro", [
new Category("woman"),
new Category("money"),
new Category("weapon"),
])
let post3 = new Post("About earth", "hello earth", [
const post3 = new Post("About earth", "hello earth", [
new Category("kids"),
new Category("people"),
new Category("animals"),
])
let post4 = new Post("Zorro", "hello zorro", [
const post4 = new Post("Zorro", "hello zorro", [
new Category("woman"),
new Category("money"),
new Category("weapon"),

View File

@ -17,23 +17,23 @@ const dataSource = new DataSource(options)
dataSource
.initialize()
.then(async (dataSource) => {
let category1 = new Category()
const category1 = new Category()
category1.name = "Animals"
let category2 = new Category()
const category2 = new Category()
category2.name = "People"
let author = new Author()
const author = new Author()
author.firstName = "Umed"
author.lastName = "Khudoiberdiev"
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.author = author
post.categories = [category1, category2]
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
await postRepository.save(post)
console.log("Post has been saved")

View File

@ -20,15 +20,15 @@ dataSource
.initialize()
.then(async (dataSource) => {
// first insert all the data
let author = new Author()
const author = new Author()
author.firstName = "Umed"
author.lastName = "Khudoiberdiev"
let post = new Post()
const post = new Post()
post.title = "hello"
post.author = author
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
await postRepository.save(post)
console.log(

View File

@ -17,18 +17,18 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let details1 = new PostDetails()
const details1 = new PostDetails()
details1.comment = "People"
let details2 = new PostDetails()
const details2 = new PostDetails()
details2.comment = "Human"
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.details = [details1, details2]
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
postRepository
.save(post)

View File

@ -21,22 +21,22 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let category1 = new PostCategory()
const category1 = new PostCategory()
category1.name = "post category #1"
let category2 = new PostCategory()
const category2 = new PostCategory()
category2.name = "post category #2"
let author = new PostAuthor()
const author = new PostAuthor()
author.name = "Umed"
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.categories.push(category1, category2)
post.author = author
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
postRepository
.save(post)

View File

@ -19,16 +19,16 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let category1 = new PostCategory()
const category1 = new PostCategory()
category1.name = "post category #1"
let category2 = new PostCategory()
const category2 = new PostCategory()
category2.name = "post category #2"
let author = new PostAuthor()
const author = new PostAuthor()
author.name = "Umed"
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.author = author
@ -43,14 +43,14 @@ dataSource.initialize().then(
author = new PostAuthor();
author.name = "Umed";*/
let blog = new Blog()
const blog = new Blog()
blog.text = "Hello how are you?"
blog.title = "hello"
blog.author = author
blog.categories.push(category1, category2)
let postRepository = dataSource.getRepository(Post)
let blogRepository = dataSource.getRepository(Blog)
const postRepository = dataSource.getRepository(Post)
const blogRepository = dataSource.getRepository(Blog)
postRepository
.save(post)

View File

@ -18,20 +18,20 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
const posts: Post[] = []
let author = new PostAuthor()
const author = new PostAuthor()
author.name = "Umed"
for (let i = 0; i < 100; i++) {
let category1 = new PostCategory()
const category1 = new PostCategory()
category1.name = "post category #1"
let category2 = new PostCategory()
const category2 = new PostCategory()
category2.name = "post category #2"
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.categories.push(category1, category2)

View File

@ -16,12 +16,12 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let categoryRepository = dataSource.getRepository(Category)
const categoryRepository = dataSource.getRepository(Category)
let category1 = new Category()
const category1 = new Category()
category1.name = "category #1"
let mainCategory = new Category()
const mainCategory = new Category()
mainCategory.manyCategories = []
mainCategory.name = "main category"
mainCategory.oneCategory = category1

View File

@ -19,22 +19,22 @@ const options: DataSourceOptions = {
const dataSource = new DataSource(options)
dataSource.initialize().then(
(dataSource) => {
let category1 = new PostCategory()
const category1 = new PostCategory()
category1.name = "post category #1"
let category2 = new PostCategory()
const category2 = new PostCategory()
category2.name = "post category #2"
let author = new PostAuthor()
const author = new PostAuthor()
author.name = "Umed"
let post = new Post()
const post = new Post()
post.text = "Hello how are you?"
post.title = "hello"
post.categories.push(category1, category2)
post.author = author
let postRepository = dataSource.getRepository(Post)
const postRepository = dataSource.getRepository(Post)
postRepository
.save(post)

View File

@ -301,7 +301,7 @@ export class DbQueryResultCache implements QueryResultCache {
identifiers: string[],
queryRunner?: QueryRunner,
): Promise<void> {
let _queryRunner: QueryRunner = queryRunner || this.getQueryRunner()
const _queryRunner: QueryRunner = queryRunner || this.getQueryRunner()
await Promise.all(
identifiers.map((identifier) => {
const qb = _queryRunner.manager.createQueryBuilder()

View File

@ -645,7 +645,7 @@ export class DataSource {
const metadataFromMap = this.entityMetadatasMap.get(target)
if (metadataFromMap) return metadataFromMap
for (let [_, metadata] of this.entityMetadatasMap) {
for (const [_, metadata] of this.entityMetadatasMap) {
if (
InstanceChecker.isEntitySchema(target) &&
metadata.name === target.options.name
@ -737,7 +737,7 @@ export class DataSource {
)
// set current data source to the entities
for (let entityMetadata of entityMetadatas) {
for (const entityMetadata of entityMetadatas) {
if (
InstanceChecker.isBaseEntityConstructor(entityMetadata.target)
) {

View File

@ -130,7 +130,7 @@ export class DriverUtils {
const joiner =
buildOptions && buildOptions.joiner ? buildOptions.joiner : "_"
let newAlias = alias.length === 1 ? alias[0] : alias.join(joiner)
const newAlias = alias.length === 1 ? alias[0] : alias.join(joiner)
if (
maxAliasLength &&
@ -236,7 +236,7 @@ export class DriverUtils {
let hostReplicaSet = undefined
let replicaSet = undefined
let optionsObject: any = {}
const optionsObject: any = {}
if (afterBase && afterBase.indexOf("?") !== -1) {
// split params
@ -280,7 +280,7 @@ export class DriverUtils {
;[host, port] = hostAndPort.split(":")
}
let connectionUrl: any = {
const connectionUrl: any = {
type: type,
host: host,
hostReplicaSet: hostReplicaSet,

View File

@ -429,7 +429,7 @@ export class AuroraMysqlDriver implements Driver {
return full
}
let value: any = parameters[key]
const value: any = parameters[key]
if (isArray) {
return value
@ -470,7 +470,7 @@ export class AuroraMysqlDriver implements Driver {
schema?: string,
database?: string,
): string {
let tablePath = [tableName]
const tablePath = [tableName]
if (database) {
tablePath.unshift(database)

View File

@ -2623,7 +2623,7 @@ export class AuroraMysqlQueryRunner
table: Table,
indexOrName: TableIndex | string,
): Query {
let indexName = InstanceChecker.isTableIndex(indexOrName)
const indexName = InstanceChecker.isTableIndex(indexOrName)
? indexOrName.name
: indexOrName
return new Query(

View File

@ -526,7 +526,7 @@ export class CockroachDriver implements Driver {
return this.parametersPrefix + parameterIndexMap.get(key)
}
let value: any = parameters[key]
const value: any = parameters[key]
if (isArray) {
return value
@ -564,7 +564,7 @@ export class CockroachDriver implements Driver {
* E.g. myDB.mySchema.myTable
*/
buildTableName(tableName: string, schema?: string): string {
let tablePath = [tableName]
const tablePath = [tableName]
if (schema) {
tablePath.unshift(schema)

View File

@ -107,7 +107,7 @@ export class CordovaQueryRunner extends AbstractSqliteQueryRunner {
if (query.substr(0, 11) === "INSERT INTO") {
result.raw = raw.insertId
} else {
let resultSet = []
const resultSet = []
for (let i = 0; i < raw.rows.length; i++) {
resultSet.push(raw.rows.item(i))
}

View File

@ -223,7 +223,7 @@ export class ExpoQueryRunner extends AbstractSqliteQueryRunner {
}
if (raw?.hasOwnProperty("rows")) {
let resultSet = []
const resultSet = []
for (let i = 0; i < raw.rows.length; i++) {
resultSet.push(raw.rows.item(i))
}

View File

@ -505,7 +505,7 @@ export class MysqlDriver implements Driver {
return full
}
let value: any = parameters[key]
const value: any = parameters[key]
if (isArray) {
return value
@ -546,7 +546,7 @@ export class MysqlDriver implements Driver {
schema?: string,
database?: string,
): string {
let tablePath = [tableName]
const tablePath = [tableName]
if (database) {
tablePath.unshift(database)

View File

@ -3200,7 +3200,7 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
table: Table,
indexOrName: TableIndex | string,
): Query {
let indexName = InstanceChecker.isTableIndex(indexOrName)
const indexName = InstanceChecker.isTableIndex(indexOrName)
? indexOrName.name
: indexOrName
return new Query(

View File

@ -397,7 +397,7 @@ export class OracleDriver implements Driver {
return this.parametersPrefix + parameterIndexMap.get(key)
}
let value: any = parameters[key]
const value: any = parameters[key]
if (isArray) {
return value
@ -443,7 +443,7 @@ export class OracleDriver implements Driver {
schema?: string,
database?: string,
): string {
let tablePath = [tableName]
const tablePath = [tableName]
if (schema) {
tablePath.unshift(schema)

View File

@ -667,7 +667,7 @@ export class OracleQueryRunner extends BaseQueryRunner implements QueryRunner {
const oldTable = InstanceChecker.isTable(oldTableOrName)
? oldTableOrName
: await this.getCachedTable(oldTableOrName)
let newTable = oldTable.clone()
const newTable = oldTable.clone()
const { database: dbName, tableName: oldTableName } =
this.driver.parseTableName(oldTable)
@ -2980,7 +2980,7 @@ export class OracleQueryRunner extends BaseQueryRunner implements QueryRunner {
* Builds drop index sql.
*/
protected dropIndexSql(indexOrName: TableIndex | string): Query {
let indexName = InstanceChecker.isTableIndex(indexOrName)
const indexName = InstanceChecker.isTableIndex(indexOrName)
? indexOrName.name
: indexOrName
return new Query(`DROP INDEX "${indexName}"`)

View File

@ -854,7 +854,7 @@ export class PostgresDriver implements Driver {
return this.parametersPrefix + parameterIndexMap.get(key)
}
let value: any = parameters[key]
const value: any = parameters[key]
if (isArray) {
return value
@ -892,7 +892,7 @@ export class PostgresDriver implements Driver {
* E.g. myDB.mySchema.myTable
*/
buildTableName(tableName: string, schema?: string): string {
let tablePath = [tableName]
const tablePath = [tableName]
if (schema) {
tablePath.unshift(schema)

View File

@ -949,7 +949,7 @@ export class PostgresQueryRunner
const enumColumns = newTable.columns.filter(
(column) => column.type === "enum" || column.type === "simple-enum",
)
for (let column of enumColumns) {
for (const column of enumColumns) {
// skip renaming for user-defined enum name
if (column.enumName) continue

View File

@ -466,7 +466,7 @@ export class ReactNativeDriver implements Driver {
return full
}
let value: any = parameters[key]
const value: any = parameters[key]
if (isArray) {
return value

View File

@ -105,7 +105,7 @@ export class ReactNativeQueryRunner extends AbstractSqliteQueryRunner {
}
if (raw?.hasOwnProperty("rows")) {
let records = []
const records = []
for (let i = 0; i < raw.rows.length; i++) {
records.push(raw.rows.item(i))
}

View File

@ -371,7 +371,7 @@ export class SapDriver implements Driver {
return full
}
let value: any = parameters[key]
const value: any = parameters[key]
if (isArray) {
return value
@ -412,7 +412,7 @@ export class SapDriver implements Driver {
* E.g. myDB.mySchema.myTable
*/
buildTableName(tableName: string, schema?: string): string {
let tablePath = [tableName]
const tablePath = [tableName]
if (schema) {
tablePath.unshift(schema)

View File

@ -3152,7 +3152,7 @@ export class SapQueryRunner extends BaseQueryRunner implements QueryRunner {
table: Table,
indexOrName: TableIndex | string,
): Query {
let indexName = InstanceChecker.isTableIndex(indexOrName)
const indexName = InstanceChecker.isTableIndex(indexOrName)
? indexOrName.name
: indexOrName
const parsedTableName = this.driver.parseTableName(table)

View File

@ -268,7 +268,7 @@ export class SpannerDriver implements Driver {
return this.parametersPrefix + parameterIndexMap.get(key)
}
let value: any = parameters[key]
const value: any = parameters[key]
if (value === null) {
return full
@ -309,7 +309,7 @@ export class SpannerDriver implements Driver {
return full
}
let value: any = parameters[key]
const value: any = parameters[key]
if (value === null) {
return " IS NULL"
}
@ -336,7 +336,7 @@ export class SpannerDriver implements Driver {
schema?: string,
database?: string,
): string {
let tablePath = [tableName]
const tablePath = [tableName]
if (database) {
tablePath.unshift(database)

View File

@ -1480,10 +1480,10 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
const isAnotherTransactionActive = this.isTransactionActive
if (!isAnotherTransactionActive) await this.startTransaction()
try {
for (let query of dropIndexQueries) {
for (const query of dropIndexQueries) {
await this.updateDDL(query["query"])
}
for (let query of dropFKQueries) {
for (const query of dropFKQueries) {
await this.updateDDL(query["query"])
}
@ -1491,7 +1491,7 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
// await this.updateDDL(query["query"])
// }
for (let query of dropTableQueries) {
for (const query of dropTableQueries) {
await this.updateDDL(query["query"])
}
@ -2027,7 +2027,7 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
}
protected async insertViewDefinitionSql(view: View): Promise<Query> {
let { schema, tableName: name } = this.driver.parseTableName(view)
const { schema, tableName: name } = this.driver.parseTableName(view)
const type = view.materialized
? MetadataTableType.MATERIALIZED_VIEW
@ -2058,7 +2058,7 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
* Builds remove view sql.
*/
protected async deleteViewDefinitionSql(view: View): Promise<Query> {
let { schema, tableName: name } = this.driver.parseTableName(view)
const { schema, tableName: name } = this.driver.parseTableName(view)
const type = view.materialized
? MetadataTableType.MATERIALIZED_VIEW
@ -2091,7 +2091,7 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
table: Table,
indexOrName: TableIndex | string,
): Query {
let indexName =
const indexName =
indexOrName instanceof TableIndex ? indexOrName.name : indexOrName
return new Query(`DROP INDEX \`${indexName}\``)
}
@ -2139,7 +2139,7 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
const referencedColumnNames = foreignKey.referencedColumnNames
.map((column) => this.driver.escape(column))
.join(",")
let sql =
const sql =
`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT \`${
foreignKey.name
}\` FOREIGN KEY (${columnNames}) ` +

View File

@ -468,7 +468,7 @@ export abstract class AbstractSqliteDriver implements Driver {
return full
}
let value: any = parameters[key]
const value: any = parameters[key]
if (isArray) {
return value

View File

@ -1369,7 +1369,7 @@ export abstract class AbstractSqliteQueryRunner
// find column name with auto increment
let autoIncrementColumnName: string | undefined = undefined
const tableSql: string = dbTable["sql"]
let autoIncrementIndex = tableSql
const autoIncrementIndex = tableSql
.toUpperCase()
.indexOf("AUTOINCREMENT")
if (autoIncrementIndex !== -1) {
@ -1460,16 +1460,16 @@ export abstract class AbstractSqliteQueryRunner
}
// parse datatype and attempt to retrieve length, precision and scale
let pos = tableColumn.type.indexOf("(")
const pos = tableColumn.type.indexOf("(")
if (pos !== -1) {
const fullType = tableColumn.type
let dataType = fullType.substr(0, pos)
const dataType = fullType.substr(0, pos)
if (
this.driver.withLengthColumnTypes.find(
(col) => col === dataType,
)
) {
let len = parseInt(
const len = parseInt(
fullType.substring(
pos + 1,
fullType.length - 1,
@ -1727,7 +1727,7 @@ export abstract class AbstractSqliteQueryRunner
table.name,
)} (${columnDefinitions}`
let [databaseNew, tableName] = this.splitTablePath(table.name)
const [databaseNew, tableName] = this.splitTablePath(table.name)
const newTableName = temporaryTable
? `${databaseNew ? `${databaseNew}.` : ""}${tableName.replace(
/^temporary_/,
@ -1933,7 +1933,7 @@ export abstract class AbstractSqliteQueryRunner
* Builds drop index sql.
*/
protected dropIndexSql(indexOrName: TableIndex | string): Query {
let indexName = InstanceChecker.isTableIndex(indexOrName)
const indexName = InstanceChecker.isTableIndex(indexOrName)
? indexOrName.name
: indexOrName
return new Query(`DROP INDEX ${this.escapePath(indexName!)}`)
@ -1998,7 +1998,7 @@ export abstract class AbstractSqliteQueryRunner
// change table name into 'temporary_table'
let [databaseNew, tableNameNew] = this.splitTablePath(newTable.name)
let [, tableNameOld] = this.splitTablePath(oldTable.name)
const [, tableNameOld] = this.splitTablePath(oldTable.name)
newTable.name = tableNameNew = `${
databaseNew ? `${databaseNew}.` : ""
}temporary_${tableNameNew}`

View File

@ -231,7 +231,7 @@ export class SqljsDriver extends AbstractSqliteDriver {
) {
const query = "SELECT last_insert_rowid()"
try {
let result = this.databaseConnection.exec(query)
const result = this.databaseConnection.exec(query)
this.connection.logger.logQuery(query)
return OrmUtils.mergeDeep(
map,

View File

@ -388,7 +388,7 @@ export class SqlServerDriver implements Driver {
return this.parametersPrefix + parameterIndexMap.get(key)
}
let value: any = parameters[key]
const value: any = parameters[key]
if (isArray) {
return value
@ -430,7 +430,7 @@ export class SqlServerDriver implements Driver {
schema?: string,
database?: string,
): string {
let tablePath = [tableName]
const tablePath = [tableName]
if (schema) {
tablePath.unshift(schema)

View File

@ -796,7 +796,7 @@ export class SqlServerQueryRunner
const oldTable = InstanceChecker.isTable(oldTableOrName)
? oldTableOrName
: await this.getCachedTable(oldTableOrName)
let newTable = oldTable.clone()
const newTable = oldTable.clone()
// we need database name and schema name to rename FK constraints
let dbName: string | undefined = undefined
@ -2634,7 +2634,7 @@ export class SqlServerQueryRunner
const isAnotherTransactionActive = this.isTransactionActive
if (!isAnotherTransactionActive) await this.startTransaction()
try {
let allViewsSql = database
const allViewsSql = database
? `SELECT * FROM "${database}"."INFORMATION_SCHEMA"."VIEWS"`
: `SELECT * FROM "INFORMATION_SCHEMA"."VIEWS"`
const allViewsResults: ObjectLiteral[] = await this.query(
@ -2649,7 +2649,7 @@ export class SqlServerQueryRunner
}),
)
let allTablesSql = database
const allTablesSql = database
? `SELECT * FROM "${database}"."INFORMATION_SCHEMA"."TABLES" WHERE "TABLE_TYPE" = 'BASE TABLE'`
: `SELECT * FROM "INFORMATION_SCHEMA"."TABLES" WHERE "TABLE_TYPE" = 'BASE TABLE'`
const allTablesResults: ObjectLiteral[] = await this.query(
@ -3747,7 +3747,7 @@ export class SqlServerQueryRunner
table: Table,
indexOrName: TableIndex | string,
): Query {
let indexName = InstanceChecker.isTableIndex(indexOrName)
const indexName = InstanceChecker.isTableIndex(indexOrName)
? indexOrName.name
: indexOrName
return new Query(

View File

@ -275,7 +275,7 @@ export class MongoEntityManager extends EntityManager {
if (Array.isArray(entity)) {
result.raw = await this.insertMany(target, entity)
Object.keys(result.raw.insertedIds).forEach((key: any) => {
let insertedId = result.raw.insertedIds[key]
const insertedId = result.raw.insertedIds[key]
result.generatedMaps.push(
this.connection.driver.createGeneratedMap(
this.connection.getMetadata(target),

View File

@ -305,7 +305,7 @@ export class FindOptionsUtils {
// go through all matched relations and add join for them
matchedBaseRelations.forEach((relation) => {
// generate a relation alias
let relationAlias: string = DriverUtils.buildAlias(
const relationAlias: string = DriverUtils.buildAlias(
qb.connection.driver,
{ joiner: "__" },
alias,

View File

@ -18,7 +18,7 @@ export class AdvancedConsoleLogger extends AbstractLogger {
) {
const messages = this.prepareLogMessages(logMessage)
for (let message of messages) {
for (const message of messages) {
switch (message.type ?? level) {
case "log":
case "schema-build":

View File

@ -69,7 +69,7 @@ export class DebugLogger extends AbstractLogger {
appendParameterAsComment: false,
})
for (let message of messages) {
for (const message of messages) {
const messageTypeOrLevel = message.type ?? level
if (messageTypeOrLevel in this.logger) {

View File

@ -40,7 +40,7 @@ export class FileLogger extends AbstractLogger {
const strings: string[] = []
for (let message of messages) {
for (const message of messages) {
switch (message.type ?? level) {
case "log":
strings.push(`[LOG]: ${message.message}`)

View File

@ -19,7 +19,7 @@ export class SimpleConsoleLogger extends AbstractLogger {
highlightSql: false,
})
for (let message of messages) {
for (const message of messages) {
switch (message.type ?? level) {
case "log":
case "schema-build":

View File

@ -916,7 +916,7 @@ export class ColumnMetadata {
*/
compareEntityValue(entity: any, valueToCompareWith: any) {
const columnValue = this.getEntityValue(entity)
if (ObjectUtils.isObject(columnValue)) {
if (typeof columnValue?.equals === "function") {
return columnValue.equals(valueToCompareWith)
}
return columnValue === valueToCompareWith

View File

@ -262,7 +262,7 @@ export class EmbeddedMetadata {
if (connection.driver.options.type === "mongodb")
return this.propertyName
let prefixes: string[] = []
const prefixes: string[] = []
if (this.parentEmbeddedMetadata)
prefixes.push(this.parentEmbeddedMetadata.buildPrefix(connection))

View File

@ -206,7 +206,7 @@ export class MigrationExecutor {
)
// get the time when last migration was executed
let lastTimeExecutedMigration =
const lastTimeExecutedMigration =
this.getLatestTimestampMigration(executedMigrations)
// get all user's migrations in the source code
@ -409,7 +409,7 @@ export class MigrationExecutor {
)
// get the time when last migration was executed
let lastTimeExecutedMigration =
const lastTimeExecutedMigration =
this.getLatestExecutedMigration(executedMigrations)
// if no migrations found in the database then nothing to revert

View File

@ -53,7 +53,7 @@ export class EntityPersistExecutor {
// save data in the query runner - this is useful functionality to share data from outside of the world
// with third classes - like subscribers and listener methods
let oldQueryRunnerData = queryRunner.data
const oldQueryRunnerData = queryRunner.data
if (this.options && this.options.data) {
queryRunner.data = this.options.data
}
@ -81,7 +81,7 @@ export class EntityPersistExecutor {
if (entityTarget === Object)
throw new CannotDetermineEntityError(this.mode)
let metadata = this.connection
const metadata = this.connection
.getMetadata(entityTarget)
.findInheritanceMetadata(entity)

View File

@ -141,7 +141,7 @@ export class SubjectDatabaseEntityLoader {
})
// this way we tell what subjects we tried to load database entities of
for (let subject of allSubjects) {
for (const subject of allSubjects) {
subject.databaseEntityLoaded = true
}
},

View File

@ -616,7 +616,7 @@ export class SubjectExecutor {
}
const updateResult = await updateQueryBuilder.execute()
let updateGeneratedMap = updateResult.generatedMaps[0]
const updateGeneratedMap = updateResult.generatedMaps[0]
if (updateGeneratedMap) {
subject.metadata.columns.forEach((column) => {
const value = column.getEntityValue(updateGeneratedMap!)

View File

@ -166,9 +166,9 @@ export class SubjectTopologicalSorter {
*/
protected toposort(edges: any[][]) {
function uniqueNodes(arr: any[]) {
let res = []
const res = []
for (let i = 0, len = arr.length; i < len; i++) {
let edge: any = arr[i]
const edge: any = arr[i]
if (res.indexOf(edge[0]) < 0) res.push(edge[0])
if (res.indexOf(edge[1]) < 0) res.push(edge[1])
}
@ -203,13 +203,13 @@ export class SubjectTopologicalSorter {
visited[i] = true
// outgoing edges
let outgoing = edges.filter(function (edge) {
const outgoing = edges.filter(function (edge) {
return edge[0] === node
})
if ((i = outgoing.length)) {
let preds = predecessors.concat(node)
const preds = predecessors.concat(node)
do {
let child = outgoing[--i][1]
const child = outgoing[--i][1]
visit(child, nodes.indexOf(child), preds)
} while (i)
}

View File

@ -68,7 +68,7 @@ export class OneToOneInverseSideSubjectBuilder {
// get related entities of persisted entity
// by example: get category from the passed to persist post entity
let relatedEntity: ObjectLiteral | null = relation.getEntityValue(
const relatedEntity: ObjectLiteral | null = relation.getEntityValue(
subject.entity!,
) // by example: relatedEntity is a category here
if (relatedEntity === undefined)

View File

@ -251,7 +251,7 @@ export class NestedSetSubjectExecutor {
metadata.nestedSetRightColumn!.databaseName,
)
let entitiesIds: ObjectLiteral[] = []
const entitiesIds: ObjectLiteral[] = []
for (const subject of subjects) {
const entityId = metadata.getEntityIdMap(subject.entity)
@ -260,7 +260,7 @@ export class NestedSetSubjectExecutor {
}
}
let entitiesNs = await this.getNestedSetIds(metadata, entitiesIds)
const entitiesNs = await this.getNestedSetIds(metadata, entitiesIds)
for (const entity of entitiesNs) {
const treeSize = entity.right - entity.left + 1

View File

@ -85,7 +85,7 @@ export class JoinAttribute {
*/
get isSelected(): boolean {
if (!this.isSelectedEvaluated) {
let getValue = () => {
const getValue = () => {
for (const select of this.queryExpressionMap.selects) {
if (select.selection === this.alias.name) return true
@ -159,7 +159,7 @@ export class JoinAttribute {
*/
get relation(): RelationMetadata | undefined {
if (!this.relationEvaluated) {
let getValue = () => {
const getValue = () => {
if (!QueryBuilderUtils.isAliasProperty(this.entityOrProperty))
return undefined

View File

@ -1510,7 +1510,7 @@ export abstract class QueryBuilder<Entity extends ObjectLiteral> {
parameterValue: any,
): WhereClauseCondition {
if (InstanceChecker.isFindOperator(parameterValue)) {
let parameters: any[] = []
const parameters: any[] = []
if (parameterValue.useParameter) {
if (parameterValue.objectLiteralParameters) {
this.setParameters(parameterValue.objectLiteralParameters)

View File

@ -432,9 +432,9 @@ export class RelationIdLoader {
},
)
if (relatedEntities && hasAllJoinColumnsInEntity) {
let relationIdMaps: ObjectLiteral[] = []
const relationIdMaps: ObjectLiteral[] = []
entities.forEach((entity) => {
let relationIdMap: ObjectLiteral = {}
const relationIdMap: ObjectLiteral = {}
relation.entityMetadata.primaryColumns.forEach(
(primaryColumn) => {
const key =

View File

@ -3867,7 +3867,7 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
alias: string,
embedPrefix?: string,
) {
for (let key in select) {
for (const key in select) {
if (select[key] === undefined || select[key] === false) continue
const propertyPath = embedPrefix ? embedPrefix + "." + key : key
@ -4112,7 +4112,7 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
alias: string,
embedPrefix?: string,
) {
for (let key in order) {
for (const key in order) {
if (order[key] === undefined) continue
const propertyPath = embedPrefix ? embedPrefix + "." + key : key
@ -4146,7 +4146,7 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
? "NULLS LAST"
: undefined
let aliasPath = `${alias}.${propertyPath}`
const aliasPath = `${alias}.${propertyPath}`
// const selection = this.expressionMap.selects.find(
// (s) => s.selection === aliasPath,
// )

View File

@ -550,7 +550,7 @@ export class SoftDeleteQueryBuilder<Entity extends ObjectLiteral>
* Creates "LIMIT" parts of SQL query.
*/
protected createLimitExpression(): string {
let limit: number | undefined = this.expressionMap.limit
const limit: number | undefined = this.expressionMap.limit
if (limit) {
if (DriverUtils.isMySQLFamily(this.connection.driver)) {

View File

@ -480,7 +480,7 @@ export class UpdateQueryBuilder<Entity extends ObjectLiteral>
// it doesn't make sense to update undefined properties, so just skip them
const valuesSetNormalized: ObjectLiteral = {}
for (let key in valuesSet) {
for (const key in valuesSet) {
if (valuesSet[key] !== undefined) {
valuesSetNormalized[key] = valuesSet[key]
}
@ -650,7 +650,7 @@ export class UpdateQueryBuilder<Entity extends ObjectLiteral>
}
} else {
Object.keys(valuesSetNormalized).map((key) => {
let value = valuesSetNormalized[key]
const value = valuesSetNormalized[key]
// todo: duplication zone
if (typeof value === "function") {
@ -740,7 +740,7 @@ export class UpdateQueryBuilder<Entity extends ObjectLiteral>
* Creates "LIMIT" parts of SQL query.
*/
protected createLimitExpression(): string {
let limit: number | undefined = this.expressionMap.limit
const limit: number | undefined = this.expressionMap.limit
if (limit) {
if (

View File

@ -173,7 +173,7 @@ export class RawSqlResultsToEntityTransformer {
)
if (discriminatorMetadata) metadata = discriminatorMetadata
}
let entity: any = metadata.create(this.queryRunner, {
const entity: any = metadata.create(this.queryRunner, {
fromDeserializer: true,
pojo: this.pojo,
})

View File

@ -21,8 +21,8 @@ import { TypeORMError } from "../error"
* @param result An array in which the results will be populated
*/
function createDFS(edges: any, leavesOnly: any, result: any) {
let currentPath: any[] = []
let visited: any = {}
const currentPath: any[] = []
const visited: any = {}
return function DFS(currentNode: any) {
visited[currentNode] = true
currentPath.push(currentNode)
@ -167,10 +167,10 @@ export class DepGraph {
*/
dependenciesOf(node: any, leavesOnly: any) {
if (this.hasNode(node)) {
let result: any[] = []
let DFS = createDFS(this.outgoingEdges, leavesOnly, result)
const result: any[] = []
const DFS = createDFS(this.outgoingEdges, leavesOnly, result)
DFS(node)
let idx = result.indexOf(node)
const idx = result.indexOf(node)
if (idx >= 0) {
result.splice(idx, 1)
}
@ -189,10 +189,10 @@ export class DepGraph {
*/
dependantsOf(node: any, leavesOnly: any) {
if (this.hasNode(node)) {
let result: any[] = []
let DFS = createDFS(this.incomingEdges, leavesOnly, result)
const result: any[] = []
const DFS = createDFS(this.incomingEdges, leavesOnly, result)
DFS(node)
let idx = result.indexOf(node)
const idx = result.indexOf(node)
if (idx >= 0) {
result.splice(idx, 1)
}
@ -210,20 +210,20 @@ export class DepGraph {
* If `leavesOnly` is true, only nodes that do not depend on any other nodes will be returned.
*/
overallOrder(leavesOnly?: any) {
let self = this
let result: any[] = []
let keys = Object.keys(this.nodes)
const self = this
const result: any[] = []
const keys = Object.keys(this.nodes)
if (keys.length === 0) {
return result // Empty graph
} else {
// Look for cycles - we run the DFS starting at all the nodes in case there
// are several disconnected subgraphs inside this dependency graph.
let CycleDFS = createDFS(this.outgoingEdges, false, [])
const CycleDFS = createDFS(this.outgoingEdges, false, [])
keys.forEach(function (n: any) {
CycleDFS(n)
})
let DFS = createDFS(this.outgoingEdges, leavesOnly, result)
const DFS = createDFS(this.outgoingEdges, leavesOnly, result)
// Find all potential starting points (nodes with nothing depending on them) an
// run a DFS starting at these points to get the order
keys.filter(function (node) {

View File

@ -24,10 +24,10 @@ export async function importClassesFromDirectories(
) {
allLoaded.push(exported)
} else if (Array.isArray(exported)) {
exported.forEach((i: any) => loadFileClasses(i, allLoaded))
exported.forEach((value) => loadFileClasses(value, allLoaded))
} else if (ObjectUtils.isObject(exported)) {
Object.keys(exported).forEach((key) =>
loadFileClasses(exported[key], allLoaded),
Object.values(exported).forEach((value) =>
loadFileClasses(value, allLoaded),
)
}
return allLoaded

View File

@ -132,7 +132,7 @@ export class InstanceChecker {
return (
typeof obj === "object" &&
obj !== null &&
(obj as { "@instanceof": Symbol })["@instanceof"] ===
(obj as { "@instanceof": symbol })["@instanceof"] ===
Symbol.for(name)
)
}

View File

@ -6,7 +6,7 @@ export class ObjectUtils {
* We cannot use instanceof because it has problems when running on different contexts.
* And we don't simply use typeof because typeof null === "object".
*/
static isObject(val: any): val is Object {
static isObject(val: any): val is object {
return val !== null && typeof val === "object"
}
@ -15,7 +15,7 @@ export class ObjectUtils {
* We cannot use instanceof because it has problems when running on different contexts.
* And we don't simply use typeof because typeof null === "object".
*/
static isObjectWithName(val: any): val is Object & { name: string } {
static isObjectWithName(val: any): val is object & { name: string } {
return (
val !== null && typeof val === "object" && val["name"] !== undefined
)

View File

@ -228,7 +228,7 @@ export class OrmUtils {
}
static replaceEmptyObjectsWithBooleans(obj: any) {
for (let key in obj) {
for (const key in obj) {
if (obj[key] && typeof obj[key] === "object") {
if (Object.keys(obj[key]).length === 0) {
obj[key] = true
@ -240,8 +240,8 @@ export class OrmUtils {
}
static propertyPathsToTruthyObject(paths: string[]) {
let obj: any = {}
for (let path of paths) {
const obj: any = {}
for (const path of paths) {
const props = path.split(".")
if (!props.length) continue
@ -249,7 +249,7 @@ export class OrmUtils {
obj[props[0]] = {}
}
let recursiveChild = obj[props[0]]
for (let [key, prop] of props.entries()) {
for (const [key, prop] of props.entries()) {
if (key === 0) continue
if (recursiveChild[prop]) {

View File

@ -12,12 +12,12 @@ export class RandomGenerator {
* returns 1: '54916d2e62f65b3afa6e192e6a601cdbe5cb5897'
*/
static sha1(str: string) {
let _rotLeft = function (n: any, s: any) {
let t4 = (n << s) | (n >>> (32 - s))
const _rotLeft = function (n: any, s: any) {
const t4 = (n << s) | (n >>> (32 - s))
return t4
}
let _cvtHex = function (val: any) {
const _cvtHex = function (val: any) {
let str = ""
let i
let v
@ -31,7 +31,7 @@ export class RandomGenerator {
let blockstart
let i, j
let W = new Array(80)
const W = new Array(80)
let H0 = 0x67452301
let H1 = 0xefcdab89
let H2 = 0x98badcfe
@ -42,9 +42,9 @@ export class RandomGenerator {
// utf8_encode
str = /*unescape*/ encodeURIComponent(str)
let strLen = str.length
const strLen = str.length
let wordArray = []
const wordArray = []
for (i = 0; i < strLen - 3; i += 4) {
j =
(str.charCodeAt(i) << 24) |

View File

@ -1,4 +1,4 @@
// Escape special characters in regular expressions
// Per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
const ESCAPE_REGEXP = /[.*+\-?^${}()|[\]\\]/g
export const escapeRegExp = (s: String) => s.replace(ESCAPE_REGEXP, "\\$&")
export const escapeRegExp = (s: string) => s.replace(ESCAPE_REGEXP, "\\$&")

View File

@ -20,7 +20,7 @@ export class Complex {
complex: Complex
}
constructor(from: String) {
constructor(from: string) {
this.circularReferenceToMySelf = { complex: this }
const [x, y] = from.split(" ")
this.x = +x

View File

@ -293,7 +293,7 @@ describe("Connection", () => {
connections.map(async (connection) => {
await connection.synchronize(true)
const queryRunner = connection.createQueryRunner()
let schema = await queryRunner.getTables(["view"])
const schema = await queryRunner.getTables(["view"])
await queryRunner.release()
expect(schema.some((table) => table.name === "view")).to.be
.false

View File

@ -50,7 +50,7 @@ describe("database schema > column length > mssql", () => {
it("all types should update their size", () =>
Promise.all(
connections.map(async (connection) => {
let metadata = connection.getMetadata(Post)
const metadata = connection.getMetadata(Post)
metadata.findColumnWithPropertyName("char")!.length = "100"
metadata.findColumnWithPropertyName("varchar")!.length = "100"
metadata.findColumnWithPropertyName("nchar")!.length = "100"
@ -88,7 +88,7 @@ describe("database schema > column length > mssql", () => {
it("all relevant types should update their size to max", () =>
Promise.all(
connections.map(async (connection) => {
let metadata = connection.getMetadata(Post)
const metadata = connection.getMetadata(Post)
metadata.findColumnWithPropertyName("varchar")!.length = "MAX"
metadata.findColumnWithPropertyName("nvarchar")!.length = "MAX"
metadata.findColumnWithPropertyName("varbinary")!.length = "MAX"

View File

@ -38,7 +38,7 @@ describe("database schema > column length > mysql", () => {
it("all types should update their length", () =>
Promise.all(
connections.map(async (connection) => {
let metadata = connection.getMetadata(Post)
const metadata = connection.getMetadata(Post)
metadata.findColumnWithPropertyName("char")!.length = "100"
metadata.findColumnWithPropertyName("varchar")!.length = "100"

View File

@ -44,7 +44,7 @@ describe("database schema > column length > postgres", () => {
it("all types should update their size", () =>
Promise.all(
connections.map(async (connection) => {
let metadata = connection.getMetadata(Post)
const metadata = connection.getMetadata(Post)
metadata.findColumnWithPropertyName(
"characterVarying",
)!.length = "100"

View File

@ -47,7 +47,7 @@ describe("database schema > column length > sap", () => {
it("all types should update their size", () =>
Promise.all(
connections.map(async (connection) => {
let metadata = connection.getMetadata(Post)
const metadata = connection.getMetadata(Post)
metadata.findColumnWithPropertyName("varchar")!.length = "100"
metadata.findColumnWithPropertyName("nvarchar")!.length = "100"
metadata.findColumnWithPropertyName("alphanum")!.length = "100"

View File

@ -50,7 +50,7 @@ describe("database schema > column length > sqlite", () => {
it("all types should update their size", () =>
Promise.all(
connections.map(async (connection) => {
let metadata = connection.getMetadata(Post)
const metadata = connection.getMetadata(Post)
metadata.findColumnWithPropertyName("character")!.length = "100"
metadata.findColumnWithPropertyName("varchar")!.length = "100"
metadata.findColumnWithPropertyName("nchar")!.length = "100"

View File

@ -213,10 +213,10 @@ export class Post {
// -------------------------------------------------------------------------
@Column("jsonb")
jsonb: Object
jsonb: object
@Column("json")
json: Object
json: object
// -------------------------------------------------------------------------
// Array Type

View File

@ -184,7 +184,7 @@ export class Post {
classEnum1: FruitEnum
@Column("json")
json: Object
json: object
@Column("simple-array")
simpleArray: string[]

View File

@ -142,7 +142,7 @@ export class Post {
// -------------------------------------------------------------------------
@Column("point")
point: string | Object
point: string | object
@Column("line")
line: string
@ -151,7 +151,7 @@ export class Post {
lseg: string | string[]
@Column("box")
box: string | Object
box: string | object
@Column("path")
path: string
@ -160,7 +160,7 @@ export class Post {
polygon: string
@Column("circle")
circle: string | Object
circle: string | object
// -------------------------------------------------------------------------
// Network Address Type
@ -210,10 +210,10 @@ export class Post {
// -------------------------------------------------------------------------
@Column("json")
json: Object
json: object
@Column("jsonb")
jsonb: Object
jsonb: object
// -------------------------------------------------------------------------
// Range Type

View File

@ -61,7 +61,7 @@ export class Post {
bool: boolean
@Column("json")
json: Object
json: object
@Column("string", { array: true })
array: string[]

Some files were not shown because too many files have changed in this diff Show More