Having two entity typeorm with a bi-directional one-to-one relationship:
Departament:
@Entity('Departament')
export default class Departament {
@PrimaryGeneratedColumn()
id: string;
@Column()
departament_name: string;
@OneToOne(type => User, user => user.departament)
@JoinColumn()
user: User;
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at' })
UpdatedAt: Date;
}
User:
@Entity('User')
export default class User {
@PrimaryGeneratedColumn()
id: string;
@Column()
name: string;
@Column()
last_name: string;
@Column()
email: string;
@Column()
login: string;
@Column()
password: string;
@OneToOne(type => Departament, departament => departament.user)
departament: Departament;
}
Here are my .eslintrc settings:
{
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": [
"airbnb-base",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"prettier/prettier": "error",
"no-new": "off",
"no-underscore-dangle": "off",
"class-methods-use-this": "off",
"no-await-in-loop": "off",
"import/prefer-default-export": "off",
"import/extensions": [
"error",
"ignorePackages",
{
"ts": "never"
}
],
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": ["**/*.spec.ts", "src/utils/tests/*.ts"]
}
],
"no-useless-constructor": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "_"
}
],
"@typescript-eslint/no-useless-constructor": "error",
"camelcase": "off",
"@typescript-eslint/camelcase": "off"
},
"overrides": [
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
],
"settings": {
"import/extensions": [".ts", ".js"],
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".js"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
}
}
}
}
Encountering these errors:
Error: dependency cycle detected.eslintimport/no-cycle
Specifically on (user and department)
And also this error:
'type' is defined but never used. Allowed unused args must match /_/u.eslint@typescript-eslint/no-unused-vars
I'm struggling to resolve this issue and unsure of the best course of action as I follow the TypeORM getting started guide.