-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f8ae33
commit 1aa1c20
Showing
8 changed files
with
2,883 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Flat configuration | ||
|
||
This is the new way to configure ESLint ("flat configuration"). Supported from ESLint >= 9. | ||
|
||
## Usage | ||
|
||
Install the package for the plugin: | ||
|
||
```sh | ||
npm install -D eslint-plugin-typeorm-typescript | ||
``` | ||
|
||
Add the recommended configuration to `eslint.config.mjs`: | ||
|
||
```js | ||
import eslint from '@eslint/js'; | ||
import tseslint from 'typescript-eslint'; | ||
import typeormTypescriptRecommended from 'eslint-plugin-typeorm-typescript/recommended'; | ||
|
||
export default tseslint.config( | ||
eslint.configs.recommended, | ||
...tseslint.configs.recommended, | ||
typeormTypescriptRecommended, | ||
); | ||
``` | ||
|
||
If you want to change the options, enable the plugin and the rules manually: | ||
|
||
```js | ||
import eslint from '@eslint/js'; | ||
import tseslint from 'typescript-eslint'; | ||
import typeormTypescriptPlugin from 'eslint-plugin-typeorm-typescript'; | ||
|
||
export default tseslint.config( | ||
eslint.configs.recommended, | ||
...tseslint.configs.recommended, | ||
{ | ||
plugins: {'typeorm-typescript': typeormTypescriptPlugin}, | ||
rules: { | ||
"typeorm-typescript/enforce-column-types": "error", | ||
"typeorm-typescript/enforce-relation-types": "warn", | ||
"typeorm-typescript/enforce-consistent-nullability": ["error", { "specifyNullable": "always" }] | ||
} | ||
} | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// @ts-check | ||
|
||
import eslint from '@eslint/js'; | ||
import tseslint from 'typescript-eslint'; | ||
import typeormTypescriptPlugin from 'eslint-plugin-typeorm-typescript'; | ||
|
||
export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended, { | ||
plugins: { | ||
'typeorm-typescript': typeormTypescriptPlugin, | ||
}, | ||
rules: { | ||
'typeorm-typescript/enforce-column-types': [ | ||
'error', | ||
// It will check bigint and decimal correctly | ||
{ driver: 'sqlite' }, | ||
], | ||
'typeorm-typescript/enforce-relation-types': [ | ||
'error', | ||
// It will force Relation<...> wrappers | ||
{ specifyRelation: 'always' } | ||
], | ||
'typeorm-typescript/enforce-consistent-nullability': [ | ||
'error', | ||
// It will force nullable everywhere | ||
{ specifyNullable: 'always' }, | ||
], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Entity, Column, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; | ||
|
||
@Entity() | ||
export class Post { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column({ type: 'number' }) | ||
userId: number; | ||
} | ||
|
||
@Entity() | ||
export class User { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column({ type: 'string' }) | ||
name: number; | ||
|
||
@Column({ type: 'decimal' }) | ||
wage: string; | ||
|
||
@OneToMany(() => Post, (post) => post.userId) | ||
posts: Post; | ||
} |
Oops, something went wrong.