Skip to content

Commit

Permalink
refactor(globals): correct UPPER_CASE casing for globals (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi committed Aug 29, 2023
1 parent b3472bd commit 669ffa1
Show file tree
Hide file tree
Showing 261 changed files with 12,567 additions and 12,154 deletions.
23 changes: 18 additions & 5 deletions config/eslint/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,34 @@ const MAX_LENGTH_DEFAULT_CONFIG = {
const BOOLEAN_PREFIXES = ["is", "was", "are", "were", "should", "has", "can", "does", "do", "did", "must"];
const NAMING_CONVENTION_DEFAULT_CONFIG = [
{
selector: ["enum", "enumMember"],
selector: ["enumMember"],
format: ["UPPER_CASE"],
}, {
selector: ["class", "interface", "typeParameter"],
},
{
selector: ["class", "interface", "typeParameter", "enum"],
format: ["PascalCase"],
}, {
},
{
selector: ["function", "classProperty", "classMethod", "accessor"],
format: ["camelCase"],
leadingUnderscore: "allow",
}, {
},
{
selector: ["variable", "classProperty"],
types: ["boolean"],
format: ["PascalCase"],
prefix: BOOLEAN_PREFIXES,
},
{
selector: ["variable"],
modifiers: ["exported"],
format: ["UPPER_CASE"],
},
{
selector: ["objectLiteralProperty"],
modifiers: ["exported"],
format: ["UPPER_CASE"],
},
];

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions config/jest/jest-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Config } from "jest";

import { compilerOptions } from "../../tsconfig.json";

const config: Config = {
const JEST_E2E_CONFIG: Config = {
moduleFileExtensions: ["js", "ts"],
rootDir: "../../",
testEnvironment: "node",
Expand Down Expand Up @@ -35,4 +35,4 @@ const config: Config = {
},
};

export default config;
export default JEST_E2E_CONFIG;
4 changes: 2 additions & 2 deletions config/jest/jest-global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Config } from "jest";

import { compilerOptions } from "../../tsconfig.json";

const config: Config = {
const JEST_GLOBAL_CONFIG: Config = {
moduleFileExtensions: ["js", "ts"],
rootDir: "../../",
testEnvironment: "node",
Expand Down Expand Up @@ -37,4 +37,4 @@ const config: Config = {
},
};

export default config;
export default JEST_GLOBAL_CONFIG;
4 changes: 2 additions & 2 deletions config/jest/jest-unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Config } from "jest";

import { compilerOptions } from "../../tsconfig.json";

const config: Config = {
const JEST_UNIT_CONFIG: Config = {
moduleFileExtensions: ["js", "ts"],
rootDir: "../../",
testEnvironment: "node",
Expand Down Expand Up @@ -38,4 +38,4 @@ const config: Config = {
},
};

export default config;
export default JEST_UNIT_CONFIG;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { ApiPropertyOptions } from "@nestjs/swagger";

import type { GameAdditionalCard } from "@/modules/game/schemas/game-additional-card/game-additional-card.schema";
import { ROLES } from "@/modules/role/constants/role.constant";
import { RoleNames } from "@/modules/role/enums/role.enum";

const GAME_ADDITIONAL_CARDS_THIEF_ROLE_NAMES: Readonly<RoleNames[]> = Object.freeze(ROLES.filter(({ minInGame, name }) => name !== RoleNames.THIEF && minInGame === undefined).map(({ name }) => name));

const GAME_ADDITIONAL_CARDS_FIELDS_SPECS: Readonly<Record<keyof GameAdditionalCard, ApiPropertyOptions>> = Object.freeze({
_id: { required: true },
roleName: {
required: true,
enum: RoleNames,
},
recipient: {
required: true,
enum: [RoleNames.THIEF],
},
isUsed: {
required: true,
default: false,
},
});

const GAME_ADDITIONAL_CARDS_API_PROPERTIES: Readonly<Record<keyof GameAdditionalCard, ApiPropertyOptions>> = Object.freeze({
_id: {
description: "Game additional card Mongo Object Id",
...GAME_ADDITIONAL_CARDS_FIELDS_SPECS._id,
},
roleName: {
description: `Game additional card role name. If \`recipient\` is \`${RoleNames.THIEF}\`, possible values are : ${GAME_ADDITIONAL_CARDS_THIEF_ROLE_NAMES.toString()}`,
...GAME_ADDITIONAL_CARDS_FIELDS_SPECS.roleName,
},
recipient: {
description: "Game additional card recipient",
...GAME_ADDITIONAL_CARDS_FIELDS_SPECS.recipient,
},
isUsed: {
description: "If set to `true`, the card has been used by its recipient",
...GAME_ADDITIONAL_CARDS_FIELDS_SPECS.isUsed,
},
});

export {
GAME_ADDITIONAL_CARDS_THIEF_ROLE_NAMES,
GAME_ADDITIONAL_CARDS_FIELDS_SPECS,
GAME_ADDITIONAL_CARDS_API_PROPERTIES,
};
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
import type { ApiPropertyOptions } from "@nestjs/swagger";

import { gameSourceValues } from "@/modules/game/constants/game.constant";
import { GAME_SOURCE_VALUES } from "@/modules/game/constants/game.constant";
import type { GameHistoryRecordPlaySource } from "@/modules/game/schemas/game-history-record/game-history-record-play/game-history-record-play-source.schema";

const gameHistoryRecordPlaySourceFieldsSpecs = Object.freeze<Record<keyof GameHistoryRecordPlaySource, ApiPropertyOptions>>({
const GAME_HISTORY_RECORD_PLAY_SOURCE_FIELDS_SPECS = Object.freeze<Record<keyof GameHistoryRecordPlaySource, ApiPropertyOptions>>({
name: {
required: true,
enum: gameSourceValues,
enum: GAME_SOURCE_VALUES,
},
players: {
minItems: 1,
required: true,
},
});

const gameHistoryRecordPlaySourceApiProperties = Object.freeze<Record<keyof GameHistoryRecordPlaySource, ApiPropertyOptions>>({
const GAME_HISTORY_RECORD_PLAY_SOURCE_API_PROPERTIES = Object.freeze<Record<keyof GameHistoryRecordPlaySource, ApiPropertyOptions>>({
name: {
description: "Source of the play",
...gameHistoryRecordPlaySourceFieldsSpecs.name,
...GAME_HISTORY_RECORD_PLAY_SOURCE_FIELDS_SPECS.name,
},
players: {
description: "Players that made the play",
...gameHistoryRecordPlaySourceFieldsSpecs.players,
...GAME_HISTORY_RECORD_PLAY_SOURCE_FIELDS_SPECS.players,
},
});

export { gameHistoryRecordPlaySourceFieldsSpecs, gameHistoryRecordPlaySourceApiProperties };
export {
GAME_HISTORY_RECORD_PLAY_SOURCE_FIELDS_SPECS,
GAME_HISTORY_RECORD_PLAY_SOURCE_API_PROPERTIES,
};
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import type { ApiPropertyOptions } from "@nestjs/swagger";

import { WITCH_POTIONS } from "@/modules/game/enums/game-play.enum";
import { WitchPotions } from "@/modules/game/enums/game-play.enum";
import type { GameHistoryRecordPlayTarget } from "@/modules/game/schemas/game-history-record/game-history-record-play/game-history-record-play-target.schema";

const gameHistoryRecordPlayTargetFieldsSpecs = Object.freeze<Record<keyof GameHistoryRecordPlayTarget, ApiPropertyOptions>>({
const GAME_HISTORY_RECORD_PLAY_TARGET_FIELDS_SPECS = Object.freeze<Record<keyof GameHistoryRecordPlayTarget, ApiPropertyOptions>>({
player: { required: true },
isInfected: { required: false },
drankPotion: {
enum: WITCH_POTIONS,
enum: WitchPotions,
required: false,
},
});

const gameHistoryRecordPlayTargetApiProperties = Object.freeze<Record<keyof GameHistoryRecordPlayTarget, ApiPropertyOptions>>({
const GAME_HISTORY_RECORD_PLAY_TARGET_API_PROPERTIES = Object.freeze<Record<keyof GameHistoryRecordPlayTarget, ApiPropertyOptions>>({
player: {
description: "Targeted player of this play",
...gameHistoryRecordPlayTargetFieldsSpecs.player,
...GAME_HISTORY_RECORD_PLAY_TARGET_FIELDS_SPECS.player,
},
isInfected: {
description: "Only if there is the `vile father of wolves` in the game and the action is eat from werewolves. If set to `true`, the target joined the werewolves side",
...gameHistoryRecordPlayTargetFieldsSpecs.isInfected,
...GAME_HISTORY_RECORD_PLAY_TARGET_FIELDS_SPECS.isInfected,
},
drankPotion: {
description: "Only if there is the `witch` in the game. The consequences depends on the type of potion",
...gameHistoryRecordPlayTargetFieldsSpecs.drankPotion,
...GAME_HISTORY_RECORD_PLAY_TARGET_FIELDS_SPECS.drankPotion,
},
});

export { gameHistoryRecordPlayTargetFieldsSpecs, gameHistoryRecordPlayTargetApiProperties };
export {
GAME_HISTORY_RECORD_PLAY_TARGET_FIELDS_SPECS,
GAME_HISTORY_RECORD_PLAY_TARGET_API_PROPERTIES,
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ import type { ApiPropertyOptions } from "@nestjs/swagger";

import type { GameHistoryRecordPlayVote } from "@/modules/game/schemas/game-history-record/game-history-record-play/game-history-record-play-vote.schema";

const gameHistoryRecordPlayVoteFieldsSpecs = Object.freeze<Record<keyof GameHistoryRecordPlayVote, ApiPropertyOptions>>({
const GAME_HISTORY_RECORD_PLAY_VOTE_FIELDS_SPECS = Object.freeze<Record<keyof GameHistoryRecordPlayVote, ApiPropertyOptions>>({
source: { required: true },
target: { required: true },
});

const gameHistoryRecordPlayTargetApiProperties = Object.freeze<Record<keyof GameHistoryRecordPlayVote, ApiPropertyOptions>>({
const GAME_HISTORY_RECORD_PLAY_VOTE_API_PROPERTIES = Object.freeze<Record<keyof GameHistoryRecordPlayVote, ApiPropertyOptions>>({
source: {
description: "Player who made the vote",
...gameHistoryRecordPlayVoteFieldsSpecs.source,
...GAME_HISTORY_RECORD_PLAY_VOTE_FIELDS_SPECS.source,
},
target: {
description: "Player targeted by the vote",
...gameHistoryRecordPlayVoteFieldsSpecs.target,
...GAME_HISTORY_RECORD_PLAY_VOTE_FIELDS_SPECS.target,
},
});

export { gameHistoryRecordPlayVoteFieldsSpecs, gameHistoryRecordPlayTargetApiProperties };
export {
GAME_HISTORY_RECORD_PLAY_VOTE_FIELDS_SPECS,
GAME_HISTORY_RECORD_PLAY_VOTE_API_PROPERTIES,
};
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import type { ApiPropertyOptions } from "@nestjs/swagger";

import { GAME_HISTORY_RECORD_VOTING_RESULTS } from "@/modules/game/enums/game-history-record.enum";
import { GameHistoryRecordVotingResults } from "@/modules/game/enums/game-history-record.enum";
import type { GameHistoryRecordPlayVoting } from "@/modules/game/schemas/game-history-record/game-history-record-play/game-history-record-play-voting.schema";

const gameHistoryRecordPlayVotingFieldsSpecs = Object.freeze<Record<keyof GameHistoryRecordPlayVoting, ApiPropertyOptions>>({
const GAME_HISTORY_RECORD_PLAY_VOTING_FIELDS_SPECS = Object.freeze<Record<keyof GameHistoryRecordPlayVoting, ApiPropertyOptions>>({
result: {
required: true,
enum: GAME_HISTORY_RECORD_VOTING_RESULTS,
enum: GameHistoryRecordVotingResults,
},
nominatedPlayers: { required: false },
});

const gameHistoryRecordPlayVotingApiProperties = Object.freeze<Record<keyof GameHistoryRecordPlayVoting, ApiPropertyOptions>>({
const GAME_HISTORY_RECORD_PLAY_VOTING_API_PROPERTIES = Object.freeze<Record<keyof GameHistoryRecordPlayVoting, ApiPropertyOptions>>({
result: {
description: "Define the results and their consequences",
...gameHistoryRecordPlayVotingFieldsSpecs.result,
...GAME_HISTORY_RECORD_PLAY_VOTING_FIELDS_SPECS.result,
},
nominatedPlayers: {
description: "Nominated players from the play votes",
...gameHistoryRecordPlayVotingFieldsSpecs.nominatedPlayers,
...GAME_HISTORY_RECORD_PLAY_VOTING_FIELDS_SPECS.nominatedPlayers,
},
});

export {
gameHistoryRecordPlayVotingFieldsSpecs,
gameHistoryRecordPlayVotingApiProperties,
GAME_HISTORY_RECORD_PLAY_VOTING_FIELDS_SPECS,
GAME_HISTORY_RECORD_PLAY_VOTING_API_PROPERTIES,
};

0 comments on commit 669ffa1

Please sign in to comment.