Skip to content

Commit 5e7f334

Browse files
committed
Add Prettier
1 parent 7d6edbd commit 5e7f334

40 files changed

+5754
-5694
lines changed

.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
typedoc/
3+
package.json
4+
package-lock.json
5+
package-lock.json.*

.prettierrc

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"tabWidth": 4,
3+
"printWidth": 120,
4+
"semi": false,
5+
"singleQuote": true,
6+
"trailingComma": "es5",
7+
"proseWrap": "preserve",
8+
"overrides": [
9+
{
10+
"files": ["{*.json,.prettierrc}"],
11+
"options": {
12+
"tabWidth": 2
13+
}
14+
}
15+
]
16+
}

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ install:
88
- npm install
99

1010
script:
11-
- npm run lint
11+
- npm run prettier
12+
- npm run tslint
1213
- npm run build
1314
- npm test
1415
- npm run typedoc

README.md

+49-48
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
21
# Typescript Typings for [Sequelize](http://sequelizejs.com).
32

4-
[![Build Status](https://travis-ci.org/types/sequelize.svg?branch=master)](https://travis-ci.org/types/sequelize)
5-
[![dependencies Status](https://david-dm.org/types/sequelize/status.svg)](https://david-dm.org/types/sequelize)
6-
[![devDependencies Status](https://david-dm.org/types/sequelize/dev-status.svg)](https://david-dm.org/types/sequelize?type=dev)
7-
[![peerDependencies Status](https://david-dm.org/types/sequelize/peer-status.svg)](https://david-dm.org/types/sequelize?type=peer)
3+
[![build](https://travis-ci.org/types/sequelize.svg?branch=master)](https://travis-ci.org/types/sequelize)
4+
[![dependencies](https://david-dm.org/types/sequelize/status.svg)](https://david-dm.org/types/sequelize)
5+
[![devDependencies](https://david-dm.org/types/sequelize/dev-status.svg)](https://david-dm.org/types/sequelize?type=dev)
6+
[![peerDependencies](https://david-dm.org/types/sequelize/peer-status.svg)](https://david-dm.org/types/sequelize?type=peer)
7+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
88

99
## [API Documentation](https://typed-sequelize.surge.sh)
1010

@@ -18,62 +18,63 @@ npm install --save-dev types/sequelize#<commit hash>
1818

1919
```ts
2020
import {
21-
Model,
22-
FindOptions,
23-
STRING,
24-
BelongsTo,
25-
BelongsToGetAssociationMixin,
26-
BelongsToSetAssociationMixin,
27-
BelongsToCreateAssociationMixin
28-
} from 'sequelize';
29-
import {sequelize} from '../connection';
21+
Model,
22+
FindOptions,
23+
STRING,
24+
BelongsTo,
25+
BelongsToGetAssociationMixin,
26+
BelongsToSetAssociationMixin,
27+
BelongsToCreateAssociationMixin,
28+
} from 'sequelize'
29+
import { sequelize } from '../connection'
3030

3131
export class User extends Model {
32-
33-
static associations: {
34-
group: BelongsTo
35-
};
36-
37-
id: number;
38-
username: string;
39-
firstName: string;
40-
lastName: string;
41-
createdAt: Date;
42-
updatedAt: Date;
43-
44-
// mixins for association (optional)
45-
groupId: number;
46-
group: UserGroup;
47-
getGroup: BelongsToGetAssociationMixin<UserGroup>;
48-
setGroup: BelongsToSetAssociationMixin<UserGroup, number>;
49-
createGroup: BelongsToCreateAssociationMixin<UserGroup>;
32+
static associations: {
33+
group: BelongsTo
34+
}
35+
36+
id: number
37+
username: string
38+
firstName: string
39+
lastName: string
40+
createdAt: Date
41+
updatedAt: Date
42+
43+
// mixins for association (optional)
44+
groupId: number
45+
group: UserGroup
46+
getGroup: BelongsToGetAssociationMixin<UserGroup>
47+
setGroup: BelongsToSetAssociationMixin<UserGroup, number>
48+
createGroup: BelongsToCreateAssociationMixin<UserGroup>
5049
}
5150

52-
User.init({
53-
username: STRING,
54-
firstName: STRING,
55-
lastName: STRING
56-
}, { sequelize });
51+
User.init(
52+
{
53+
username: STRING,
54+
firstName: STRING,
55+
lastName: STRING,
56+
},
57+
{ sequelize }
58+
)
5759

5860
// associate
5961
// it is important to import _after_ the model above is already exported so the circular reference works.
60-
import {UserGroup} from './UserGroup';
61-
User.belongsTo(UserGroup, {as: 'group', foreignKey: 'groupId'});
62+
import { UserGroup } from './UserGroup'
63+
User.belongsTo(UserGroup, { as: 'group', foreignKey: 'groupId' })
6264
```
6365

6466
```ts
65-
import {User, Group} from './models/User';
67+
import { User, Group } from './models/User'
6668

6769
async function test() {
70+
const user = (await User.findOne({ include: [Group] })) as User
71+
user.firstName = 'John'
72+
await user.save()
73+
await user.setGroup(2)
6874

69-
const user = await User.findOne({include: [Group]}) as User;
70-
user.firstName = 'John';
71-
await user.save();
72-
await user.setGroup(2);
73-
74-
new User();
75-
new User({firstName: 'John'});
75+
new User()
76+
new User({ firstName: 'John' })
7677

77-
const user2 = await User.create({firstName: 'John', groupId: 1}) as User;
78+
const user2 = (await User.create({ firstName: 'John', groupId: 1 })) as User
7879
}
7980
```

docs_index.md

+46-44
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
21
_Start typing to search_
32

43
## API
4+
55
<ul class="tsd-index-list" style="list-style: none">
66
<li class="tsd-kind-class"><a class="tsd-kind-icon" href="classes/_lib_sequelize_d_.sequelize.html">Sequelize</a></li>
77
<li class="tsd-kind-class"><a class="tsd-kind-icon" href="classes/_lib_model_d_.model.html">Model</a></li>
@@ -13,6 +13,7 @@ _Start typing to search_
1313
</ul>
1414

1515
#### Associations
16+
1617
<ul class="tsd-index-list" style="list-style: none">
1718
<li class="tsd-kind-module"><a class="tsd-kind-icon" href="modules/_lib_associations_belongs_to_many_d_.html">BelongsToMany</a></li>
1819
<li class="tsd-kind-module"><a class="tsd-kind-icon" href="modules/_lib_associations_belongs_to_d_.html">BelongsTo</a></li>
@@ -26,65 +27,66 @@ _User.ts_
2627

2728
```ts
2829
import {
29-
Model,
30-
FindOptions,
31-
DataTypes,
32-
BelongsTo,
33-
BelongsToGetAssociationMixin,
34-
BelongsToSetAssociationMixin,
35-
BelongsToCreateAssociationMixin
36-
} from 'sequelize';
37-
import {sequelize} from '../connection';
30+
Model,
31+
FindOptions,
32+
DataTypes,
33+
BelongsTo,
34+
BelongsToGetAssociationMixin,
35+
BelongsToSetAssociationMixin,
36+
BelongsToCreateAssociationMixin,
37+
} from 'sequelize'
38+
import { sequelize } from '../connection'
3839

3940
export class User extends Model {
40-
41-
static associations: {
42-
group: BelongsTo
43-
};
44-
45-
id: number;
46-
username: string;
47-
firstName: string;
48-
lastName: string;
49-
createdAt: Date;
50-
updatedAt: Date;
51-
52-
// mixins for association (optional)
53-
groupId: number;
54-
group: UserGroup;
55-
getGroup: BelongsToGetAssociationMixin<UserGroup>;
56-
setGroup: BelongsToSetAssociationMixin<UserGroup, number>;
57-
createGroup: BelongsToCreateAssociationMixin<UserGroup>;
41+
static associations: {
42+
group: BelongsTo
43+
}
44+
45+
id: number
46+
username: string
47+
firstName: string
48+
lastName: string
49+
createdAt: Date
50+
updatedAt: Date
51+
52+
// mixins for association (optional)
53+
groupId: number
54+
group: UserGroup
55+
getGroup: BelongsToGetAssociationMixin<UserGroup>
56+
setGroup: BelongsToSetAssociationMixin<UserGroup, number>
57+
createGroup: BelongsToCreateAssociationMixin<UserGroup>
5858
}
5959

60-
User.init({
61-
username: DataTypes.STRING,
62-
firstName: DataTypes.STRING,
63-
lastName: DataTypes.STRING
64-
}, {sequelize});
60+
User.init(
61+
{
62+
username: DataTypes.STRING,
63+
firstName: DataTypes.STRING,
64+
lastName: DataTypes.STRING,
65+
},
66+
{ sequelize }
67+
)
6568

6669
// associate
6770
// it is important to import _after_ the model above is already exported
6871
// so the circular dependency works.
69-
import {UserGroup} from './UserGroup';
70-
User.belongsTo(UserGroup, {as: 'group', foreignKey: 'groupId'});
72+
import { UserGroup } from './UserGroup'
73+
User.belongsTo(UserGroup, { as: 'group', foreignKey: 'groupId' })
7174
```
7275

7376
_app.ts_
7477

7578
```ts
76-
import {User, Group} from './models/User';
79+
import { User, Group } from './models/User'
7780

7881
async function test() {
82+
const user = await User.findOne({ include: [Group] })
83+
user.firstName = 'John'
84+
await user.save()
85+
await user.setGroup(2)
7986

80-
const user = await User.findOne({include: [Group]});
81-
user.firstName = 'John';
82-
await user.save();
83-
await user.setGroup(2);
84-
85-
new User();
86-
new User({firstName: 'John'});
87+
new User()
88+
new User({ firstName: 'John' })
8789

88-
const user2 = await User.create({firstName: 'John', groupId: 1});
90+
const user2 = await User.create({ firstName: 'John', groupId: 1 })
8991
}
9092
```

index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export * from './lib/sequelize';
2-
export * from './lib/query-interface';
1+
export * from './lib/sequelize'
2+
export * from './lib/query-interface'
33
export * from './lib/data-types'

0 commit comments

Comments
 (0)