Skip to content

Commit

Permalink
chore(internal): add linter for member ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Sep 17, 2023
1 parent f66a22a commit 1f57cf0
Show file tree
Hide file tree
Showing 18 changed files with 90 additions and 151 deletions.
23 changes: 19 additions & 4 deletions server/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
tsconfigRootDir : __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
plugins: ['@typescript-eslint/eslint-plugin', 'sort-class-members'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
Expand All @@ -23,11 +23,26 @@ module.exports = {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
"prettier/prettier": [
"error",
'prettier/prettier': [
'error',
{
"endOfLine": "auto"
'endOfLine': 'auto'
},
],
'sort-class-members/sort-class-members': [
2,
{
'order': [
'[static-properties]',
'[static-methods]',
'[properties]',
'[conventional-private-properties]',
'constructor',
'[methods]',
'[conventional-private-methods]'
],
'accessorPairPositioning': 'getThenSet'
}
]
},
};
108 changes: 27 additions & 81 deletions server/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@nestjs/websockets": "^10.2.4",
"bcrypt": "^5.1.0",
"censor-sensor": "^1.0.6",
"eslint-plugin-sort-class-members": "^1.18.0",
"fast-json-patch": "^3.1.1",
"fs-extra": "^11.1.1",
"gameanalytics-node-sdk": "^1.1.4",
Expand Down
7 changes: 2 additions & 5 deletions server/src/modules/achievements/achievements.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ import { ObjectId } from '@mikro-orm/mongodb';

@Entity()
export class Achievements implements IAchievements {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

@Unique()
@Property({ hidden: true })
userId: string;

@Property()
achievements: Record<string, number>;
@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(userId: string) {
this.userId = userId;
Expand Down
12 changes: 6 additions & 6 deletions server/src/modules/content/content.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ censor.disableTier(2);

@Injectable()
export class ContentService {
public get censor(): CensorSensor {
return censor;
}

public content = {
meta: {},
locations: {},
Expand All @@ -42,6 +38,12 @@ export class ContentService {
npcs: {},
};

constructor(private logger: Logger) {}

public get censor(): CensorSensor {
return censor;
}

private get locations(): Record<string, ILocation> {
return this.content.locations;
}
Expand Down Expand Up @@ -82,8 +84,6 @@ export class ContentService {
return this.content.npcs;
}

constructor(private logger: Logger) {}

public async reloadContent() {
this.logger.log('Loading game content over HTTP...');

Expand Down
7 changes: 3 additions & 4 deletions server/src/modules/crafting/crafting.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import { ObjectId } from '@mikro-orm/mongodb';

@Entity()
export class Crafting implements ICrafting {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

Expand All @@ -25,7 +22,6 @@ export class Crafting implements ICrafting {

@Property()
armorerXp: number;

@Property()
artisanLevel: number;

Expand All @@ -44,6 +40,9 @@ export class Crafting implements ICrafting {
@Property()
currentlyCraftingDoneAt: number;

@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(userId: string) {
this.userId = userId;

Expand Down
6 changes: 3 additions & 3 deletions server/src/modules/discoveries/discoveries.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import { ObjectId } from '@mikro-orm/mongodb';

@Entity()
export class Discoveries implements IDiscoveries {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

Expand Down Expand Up @@ -59,6 +56,9 @@ export class Discoveries implements IDiscoveries {
@Property()
totalMonsterClaims: number;

@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(userId: string) {
this.userId = userId;

Expand Down
6 changes: 3 additions & 3 deletions server/src/modules/fight/fight.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import { generateUUID } from '@utils/uuid';

@Entity()
export class Fight implements IFight {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey()
id!: string;

Expand Down Expand Up @@ -54,6 +51,9 @@ export class Fight implements IFight {
@Property()
statusMessage: IFightStatusMessage[];

@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(
involvedPlayers: string[],
turnOrder: string[],
Expand Down
9 changes: 2 additions & 7 deletions server/src/modules/inventory/inventory.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,19 @@ import { ObjectId } from '@mikro-orm/mongodb';

@Entity()
export class Inventory implements IInventory {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

@Unique()
@Property({ hidden: true })
userId: string;

@Property()
equippedItems: Record<ItemSlot, IEquipment | undefined>;

@Property()
otherJobEquipment: Record<string, Record<ItemSlot, IEquipment | undefined>>;

@Property()
resources: Record<string, number>;
@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(userId: string) {
this.userId = userId;
Expand Down
9 changes: 2 additions & 7 deletions server/src/modules/inventory/inventoryitem.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,19 @@ import { ObjectId } from '@mikro-orm/mongodb';

@Entity()
export class InventoryItem implements IInventoryItem {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

@Index()
@Property({ hidden: true })
userId: string;

@Property()
itemId: string;

@Property()
instanceId: string;

@Property()
isInUse: boolean;
@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(userId: string, itemId: string, instanceId: string) {
this.userId = userId;
Expand Down
9 changes: 2 additions & 7 deletions server/src/modules/lottery/dailylottery.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,19 @@ import { generateUUID } from '@utils/uuid';

@Entity()
export class DailyRandomLottery {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

@Property()
internalId: string;

@Index()
@Property()
createdAt: Date;

@Property()
winnerId: string;

@Property()
claimed: boolean;
@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(winnerId: string) {
this.createdAt = new Date();
Expand Down
6 changes: 3 additions & 3 deletions server/src/modules/market/marketitem.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import { generateUUID } from '@utils/uuid';

@Entity()
export class MarketItem implements IMarketItem {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

Expand Down Expand Up @@ -49,6 +46,9 @@ export class MarketItem implements IMarketItem {
@Property()
meta: IMarketItemMeta;

@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(
userId: string,
itemId: string,
Expand Down
6 changes: 3 additions & 3 deletions server/src/modules/market/marketsale.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import { generateUUID } from '@utils/uuid';

@Entity()
export class MarketSale implements IMarketSale {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

Expand Down Expand Up @@ -49,6 +46,9 @@ export class MarketSale implements IMarketSale {
@Index({ options: { expireAfterSeconds: 0 } })
expiresAt: Date;

@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(
seller: string,
buyer: string,
Expand Down
6 changes: 3 additions & 3 deletions server/src/modules/notification/notification.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import { generateUUID } from '@utils/uuid';

@Entity()
export class Notification implements INotification {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

Expand Down Expand Up @@ -44,6 +41,9 @@ export class Notification implements INotification {
@Property()
actions?: INotificationAction[];

@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(
userId: string,
text: string,
Expand Down
6 changes: 3 additions & 3 deletions server/src/modules/player/player.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import { ObjectId } from '@mikro-orm/mongodb';

@Entity()
export class Player implements IPlayer {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

Expand Down Expand Up @@ -73,6 +70,9 @@ export class Player implements IPlayer {
@Property()
cosmetics: IPlayerCosmetics;

@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(userId: string) {
this.userId = userId;

Expand Down
6 changes: 3 additions & 3 deletions server/src/modules/stats/stats.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import { Discoveries } from '@modules/discoveries/discoveries.schema';

@Entity()
export class Stats implements IStats {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

Expand Down Expand Up @@ -45,6 +42,9 @@ export class Stats implements IStats {
@Property()
stats: Partial<Record<TrackedStat, number>>;

@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(userId: string) {
this.userId = userId;

Expand Down
6 changes: 3 additions & 3 deletions server/src/modules/user/user.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ export type UserId = User['_id'];

@Entity()
export class User implements IUser {
@PrimaryKey()
_id!: ObjectId;

@SerializedPrimaryKey()
id!: string;

Expand All @@ -38,6 +35,9 @@ export class User implements IUser {
@Property()
email: string;

@PrimaryKey()
_id!: ObjectId;

constructor(
username: string,
discriminator: string,
Expand Down
8 changes: 2 additions & 6 deletions server/src/modules/wave/playerwave.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,19 @@ import { ObjectId } from '@mikro-orm/mongodb';

@Entity()
export class PlayerWave {
@PrimaryKey({ hidden: true })
_id!: ObjectId;

@SerializedPrimaryKey({ hidden: true })
id!: string;

@Index()
@Property()
playerWaving: string;

@Index()
@Property()
playerWavingAt: string;

@Property()
@Index({ options: { expireAfterSeconds: 0 } })
expiresAt: Date;
@PrimaryKey({ hidden: true })
_id!: ObjectId;

constructor(
playerWaving: string,
Expand Down

0 comments on commit 1f57cf0

Please sign in to comment.