Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
NedcloarBR committed Oct 16, 2024
1 parent 45fd39b commit 9bde5d0
Show file tree
Hide file tree
Showing 65 changed files with 228 additions and 139 deletions.
15 changes: 14 additions & 1 deletion .commitlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@
"type-enum": [
2,
"always",
["chore", "build", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test", "types"]
[
"chore",
"build",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
"types"
]
]
}
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"test:watch": "vitest --watch",
"test:coverage": "vitest run --coverage",
"test:ui": "vitest --ui",
"format": "yarn dlx @biomejs/biome format --write ./",
"lint": "yarn dlx @biomejs/biome lint ./",
"check": "yarn dlx @biomejs/biome check --apply ./",
"postinstall": "prisma generate && husky || true"
"format": "yarn biome format --write ./",
"lint": "yarn biome lint ./",
"check": "yarn biome check --write ./",
"postinstall": "prisma generate && husky"
},
"dependencies": {
"@necord/lavalink": "^1.1.0",
Expand Down Expand Up @@ -66,11 +66,11 @@
"topgg-autoposter": "^2.0.2"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@biomejs/biome": "^1.9.3",
"@commitlint/cli": "^19.4.1",
"@commitlint/config-angular": "^19.4.1",
"@commitlint/config-conventional": "^19.4.1",
"@nedcloarbr/biome-config": "^1.4.0",
"@nedcloarbr/biome-config": "^1.6.0",
"@nestjs/cli": "^10.4.5",
"@nestjs/schematics": "^10.1.4",
"@nestjs/testing": "^10.4.1",
Expand Down
11 changes: 8 additions & 3 deletions src/common/decorators/ValidatedOptions.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { PipeTransform, ValidationPipe } from "@nestjs/common";
import { type PipeTransform, ValidationPipe } from "@nestjs/common";
import { Options } from "necord";

export const ValidatedOptions = (...dataOrPipes: PipeTransform[] | string[]) => {
return Options(...dataOrPipes, new ValidationPipe({ validateCustomDecorators: true }));
export const ValidatedOptions = (
...dataOrPipes: PipeTransform[] | string[]
) => {
return Options(
...dataOrPipes,
new ValidationPipe({ validateCustomDecorators: true }),
);
};
1 change: 1 addition & 0 deletions src/common/guards/CommandConfig.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Inject,
Injectable,
} from "@nestjs/common";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { Reflector } from "@nestjs/core";
import type { ChatInputCommandInteraction } from "discord.js";
import { NecordExecutionContext } from "necord";
Expand Down
3 changes: 3 additions & 0 deletions src/common/guards/CommandPermissions.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Config } from "@/modules/config/types";
import { formatArray } from "@/utils/Tools";
import {
LOCALIZATION_ADAPTER,
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
NestedLocalizationAdapter,
} from "@necord/localization";
import {
Expand All @@ -10,7 +11,9 @@ import {
Inject,
Injectable,
} from "@nestjs/common";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { ConfigService } from "@nestjs/config";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { Reflector } from "@nestjs/core";
import type { ChatInputCommandInteraction } from "discord.js";
import { NecordExecutionContext } from "necord";
Expand Down
1 change: 0 additions & 1 deletion src/common/guards/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./CommandConfig.guard";
export * from "./CommandPermissions.guard";

12 changes: 6 additions & 6 deletions src/common/interceptors/Command.interceptor.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
BadRequestException,
Injectable,
type CallHandler,
type ExecutionContext,
type NestInterceptor,
BadRequestException,
type CallHandler,
type ExecutionContext,
Injectable,
type NestInterceptor,
} from "@nestjs/common";
import { catchError, type Observable } from "rxjs";
import { type Observable, catchError } from "rxjs";
import { CommandError } from "../errors/Command.error";

@Injectable()
Expand Down
3 changes: 2 additions & 1 deletion src/lib/sharding.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "node:path";
import { Config } from "@/modules/config/types";
import type { Config } from "@/modules/config/types";
import { Logger } from "@nestjs/common";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { ConfigService } from "@nestjs/config";
import { ShardingManager as _ShardingManager } from "discord.js";

Expand Down
4 changes: 3 additions & 1 deletion src/lib/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export const otelSDK = new NodeSDK({
setImmediate(() => {
const meterProvider = metrics.getMeterProvider();
const meter = meterProvider.getMeter("node-metrics");
setupNodeMetrics(meter, { labels: resource.attributes as any });
setupNodeMetrics(meter, {
labels: resource.attributes as Record<string, string>,
});
});

process.on("SIGTERM", () => {
Expand Down
9 changes: 8 additions & 1 deletion src/modules/commands/Commands.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@ import {
CommandPermissionsKey,
type CommandPermissionsOptions,
} from "@/common/decorators";
import { CommandConfigKey, CommandConfigOptions } from "@/common/decorators/";
import {
CommandConfigKey,
type CommandConfigOptions,
} from "@/common/decorators";
import {
Injectable,
Logger,
type OnApplicationBootstrap,
} from "@nestjs/common";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { ConfigService } from "@nestjs/config";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { Reflector } from "@nestjs/core";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { Client } from "discord.js";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import {
ExplorerService,
SlashCommand,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type TranslationFn,
localizationMapByKey,
} from "@necord/localization";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { ConfigService } from "@nestjs/config";
import {
ApplicationIntegrationType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CommandConfig, CommandPermissions } from "@/common/decorators/";
import {
CurrentTranslate,
TranslationFn,
type TranslationFn,
localizationMapByKey,
} from "@necord/localization";
import { Logger } from "@nestjs/common";
import { ApplicationIntegrationType, InteractionContextType } from "discord.js";
import { Ctx, SlashCommandContext, Subcommand } from "necord";
import { Ctx, type SlashCommandContext, Subcommand } from "necord";
import { DeveloperToolsCommand } from "../DeveloperTools.decorator";

@DeveloperToolsCommand()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CommandConfig, CommandPermissions } from "@/common/decorators";
import { WAIT } from "@/utils/Tools";
import {
CurrentTranslate,
TranslationFn,
type TranslationFn,
localizationMapByKey,
} from "@necord/localization";
import { Logger } from "@nestjs/common";
Expand All @@ -11,8 +11,9 @@ import {
InteractionContextType,
channelMention,
} from "discord.js";
import { Ctx, Options, SlashCommandContext, Subcommand } from "necord";
import { Ctx, Options, type SlashCommandContext, Subcommand } from "necord";
import { ModerationCommand } from "../../Moderation.decorator";
// biome-ignore lint/style/useImportType: <Cannot useImportType in classes with validation system>
import { ClearDTO } from "./clear.dto";

@ModerationCommand()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/config/Config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Config, ENVIRONMENT } from "./types";
import type { Config, ENVIRONMENT } from "./types";

export const config = (): Config => ({
ENVIRONMENT: process.env.ENVIRONMENT as ENVIRONMENT,
Expand Down
7 changes: 4 additions & 3 deletions src/modules/config/NecordConfig.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { NecordLavalinkModuleOptions } from "@necord/lavalink";
import type { NecordLavalinkModuleOptions } from "@necord/lavalink";
import {
GuildResolver,
NecordLocalizationOptions,
type NecordLocalizationOptions,
NestedLocalizationAdapter,
} from "@necord/localization";
import { NecordPaginationOptions } from "@necord/pagination";
import type { NecordPaginationOptions } from "@necord/pagination";
import { Injectable } from "@nestjs/common";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { ConfigService } from "@nestjs/config";
import {
GatewayIntentBits,
Expand Down
3 changes: 3 additions & 0 deletions src/modules/core/NDB.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import type { Content } from "@/types";
import {
LOCALIZATION_ADAPTER,
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
NestedLocalizationAdapter,
} from "@necord/localization";

import {
type ButtonsAppearance,
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
NecordPaginationService,
PageBuilder,
} from "@necord/pagination";
Expand Down
2 changes: 1 addition & 1 deletion src/modules/database/database.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Services } from "@/types/Constants";
import { Global, Module, Provider } from "@nestjs/common";
import { Global, Module, type Provider } from "@nestjs/common";
import { PrismaModule } from "nestjs-prisma";
import { DatabaseService } from "./database.service";
import { RepositoriesModule } from "./repositories/Repositories.module";
Expand Down
4 changes: 2 additions & 2 deletions src/modules/database/entities/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./Guild.entity"
export * from "./User.entity"
export * from "./Guild.entity";
export * from "./User.entity";
4 changes: 3 additions & 1 deletion src/modules/database/repositories/Guild.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable, Logger } from "@nestjs/common";
import type { Prisma } from "@prisma/client";
import type { DefaultArgs } from "@prisma/client/runtime/library";
import type { Guild } from "discord.js";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { PrismaService } from "nestjs-prisma";
import type { GuildEntity } from "../entities";
import { DatabaseStatus } from "../types";
Expand Down Expand Up @@ -36,7 +37,8 @@ export class GuildRepository implements IGuildRepository {

public async create(
guild: Guild,
): Promise<{ callback: void | GuildEntity; status: DatabaseStatus }> {
// biome-ignore lint/suspicious/noConfusingVoidType: <Prisma returns void if no data is returned>
): Promise<{ callback: GuildEntity | void; status: DatabaseStatus }> {
let status = DatabaseStatus.Created;
const callback = await this.prisma.guild
.create({
Expand Down
12 changes: 7 additions & 5 deletions src/modules/database/repositories/User.repository.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Injectable, Logger } from "@nestjs/common";
import { Prisma } from "@prisma/client";
import { DefaultArgs } from "@prisma/client/runtime/library";
import { User } from "discord.js";
import type { Prisma } from "@prisma/client";
import type { DefaultArgs } from "@prisma/client/runtime/library";
import type { User } from "discord.js";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { PrismaService } from "nestjs-prisma";
import { UserEntity } from "../entities";
import type { UserEntity } from "../entities";
import { DatabaseStatus } from "../types";
import { IUserRepository } from "./interfaces";
import type { IUserRepository } from "./interfaces";

@Injectable()
export class UserRepository implements IUserRepository {
Expand Down Expand Up @@ -38,6 +39,7 @@ export class UserRepository implements IUserRepository {

public async create(
user: User,
// biome-ignore lint/suspicious/noConfusingVoidType: <Prisma returns void if no data is returned>
): Promise<{ callback: UserEntity | void; status: DatabaseStatus }> {
let status = DatabaseStatus.Created;
const callback = await this.prisma.user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface IGuildRepository {
getAll(): Promise<GuildEntity[]>;
create(
guild: Guild,
// biome-ignore lint/suspicious/noConfusingVoidType: <Prisma returns void if no data is returned>
): Promise<{ callback: GuildEntity | void; status: DatabaseStatus }>;
update(oldGuild: Guild, newGuild: Guild): Promise<GuildEntity>;
delete(guild: Guild): Promise<GuildEntity>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface IUserRepository {
getAll(): Promise<UserEntity[]>;
create(
user: User,
// biome-ignore lint/suspicious/noConfusingVoidType: <Prisma returns void if no data is returned>
): Promise<{ callback: UserEntity | void; status: DatabaseStatus }>;
update(user: User): Promise<UserEntity>;
delete(user: User): Promise<UserEntity>;
Expand Down
2 changes: 2 additions & 0 deletions src/modules/events/Events.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Module, type OnApplicationBootstrap } from "@nestjs/common";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { EventEmitter2, EventEmitterModule } from "@nestjs/event-emitter";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { REST } from "discord.js";
import * as EventsMap from "./index";
const Events = Object.values(EventsMap);
Expand Down
1 change: 1 addition & 0 deletions src/modules/events/Gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Config } from "@/modules/config/types";
import type { IDatabaseService } from "@/modules/database/interfaces/IDatabaseService";
import { Services } from "@/types/Constants";
import { Inject, Injectable, Logger } from "@nestjs/common";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { ConfigService } from "@nestjs/config";
import { OnEvent } from "@nestjs/event-emitter";
import { RESTJSONErrorCodes } from "discord-api-types/v10";
Expand Down
1 change: 1 addition & 0 deletions src/modules/events/Guild.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IDatabaseService } from "@/modules/database/interfaces/IDatabaseService";
import { Services } from "@/types/Constants";
import { Inject, Injectable } from "@nestjs/common";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { Client } from "discord.js";
import { Context, type ContextOf, On } from "necord";

Expand Down
2 changes: 1 addition & 1 deletion src/modules/events/NDC.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from "@nestjs/common";
import { Context, ContextOf, On } from "necord";
import { Context, type ContextOf, On } from "necord";

@Injectable()
export class NDCEvents {
Expand Down
2 changes: 2 additions & 0 deletions src/modules/events/NotQuiteNitro.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {
LOCALIZATION_ADAPTER,
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
NestedLocalizationAdapter,
} from "@necord/localization";
import { Inject, Injectable } from "@nestjs/common";
import { OnEvent } from "@nestjs/event-emitter";
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
import { Client, Message, TextChannel } from "discord.js";

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/events/Thread.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from "@nestjs/common";
import { Context, ContextOf, On } from "necord";
import { Context, type ContextOf, On } from "necord";

@Injectable()
export class ThreadEvents {
Expand Down
3 changes: 2 additions & 1 deletion src/modules/events/VoiceStateUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Injectable } from "@nestjs/common";
import {
ChannelType,
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
Client,
GuildMember,
PermissionResolvable,
} from "discord.js";
import { Context, ContextOf, On } from "necord";
import { Context, type ContextOf, On } from "necord";

@Injectable()
export class VoiceStateUpdateEvents {
Expand Down
9 changes: 6 additions & 3 deletions src/modules/music/Music.embeds.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import {
LOCALIZATION_ADAPTER,
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
NestedLocalizationAdapter,
} from "@necord/localization";
import { Inject, Injectable } from "@nestjs/common";
import {
// biome-ignore lint/style/useImportType: <Cannot useImportType in Injected classes>
Client,
EmbedBuilder,
Guild,
VoiceChannel,
type Guild,
type VoiceChannel,
channelMention,
} from "discord.js";
import { IMusicEmbeds } from "./interfaces";
import type { IMusicEmbeds } from "./interfaces";

@Injectable()
export class MusicEmbeds implements IMusicEmbeds {
Expand Down
Loading

0 comments on commit 9bde5d0

Please sign in to comment.