Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use biome #1781

Merged
merged 7 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ on:

jobs:
build:
timeout-minutes: 3
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [lts/*, latest]

steps:
- uses: actions/checkout@v4
uses: biomejs/setup-biome@v2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[actionlint] reported by reviewdog 🐶
key "uses" is duplicated in element of "steps" section. previously defined at line:15,col:9 [syntax-check]

with:
version: latest
9renpoto marked this conversation as resolved.
Show resolved Hide resolved
- name: Run Biome
run: biome ci .
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/biomejs/pre-commit
rev: "v0.1.0" # Use the sha / tag you want to point at
hooks:
- id: biome-check
additional_dependencies: ["@biomejs/[email protected]"]
28 changes: 28 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.2/schema.json",
"organizeImports": {
"enabled": true
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"formatter": {
"indentStyle": "space"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"useLiteralKeys": "off"
}
}
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
}
}
}
4 changes: 2 additions & 2 deletions example/__tests__/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Test, TestingModule } from "@nestjs/testing";
import { AppModule } from "../src/app.module";
import {
FastifyAdapter,
NestFastifyApplication,
} from "@nestjs/platform-fastify";
import { Test, TestingModule } from "@nestjs/testing";
import { AppModule } from "../src/app.module";

describe("app (e2e)", () => {
let app: NestFastifyApplication;
Expand Down
18 changes: 9 additions & 9 deletions example/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { join } from "path";
import { SlackModule } from "nestjs-slack-webhook";
import { FirebaseModule } from "nestjs-firebase";
import { ApolloDriver } from "@nestjs/apollo";
import { Module } from "@nestjs/common";
import { ConfigModule, ConfigService } from "@nestjs/config";
import { TypeOrmModule } from "@nestjs/typeorm";
import { GraphQLModule } from "@nestjs/graphql";
import { TypeOrmModule } from "@nestjs/typeorm";
import { FirebaseModule } from "nestjs-firebase";
import { SlackModule } from "nestjs-slack-webhook";
import { ZendeskModule } from "nestjs-zendesk";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
import slackConfig from "./config/slack";
import zendeskConfig from "./config/zendesk";
import { NodeModule } from "./node/node.module";
import { RecipesModule } from "./recipes/recipes.module";
import { NotifyModule } from "./notify/notify.module";
import { ZendeskModule } from "nestjs-zendesk";
import { RecipesModule } from "./recipes/recipes.module";
import { ZendeskModule as ZendeskWrapperModule } from "./zendesk/zendesk.module";
import { ApolloDriver } from "@nestjs/apollo";
import slackConfig from "./config/slack";
import zendeskConfig from "./config/zendesk";

@Module({
imports: [
Expand All @@ -36,7 +36,7 @@ import zendeskConfig from "./config/zendesk";
}),
GraphQLModule.forRoot({
installSubscriptionHandlers: true,
autoSchemaFile: join(__dirname, `./schema.gql`),
autoSchemaFile: join(__dirname, "./schema.gql"),
playground: true,
driver: ApolloDriver,
}),
Expand Down
13 changes: 9 additions & 4 deletions example/src/config/slack.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { SlackOptions } from "nestjs-slack-webhook";
import { registerAs } from "@nestjs/config";
import { SlackOptions } from "nestjs-slack-webhook";

export default registerAs(
"slack",
(): SlackOptions => ({
url: process.env.SLACK_WEBHOOK_URL!,
}),
(url = process.env["SLACK_WEBHOOK_URL"]): SlackOptions => {
if (!url) {
throw new Error("SLACK_WEBHOOK_URL is not defined");
}
return {
url,
};
},
);
2 changes: 1 addition & 1 deletion example/src/node/node.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { RecipesService } from "../recipes/recipes.service";
import { Recipe } from "../recipes/models/recipe";
import { RecipesService } from "../recipes/recipes.service";
import { NodeResolver } from "./node.resolver";

@Module({
Expand Down
18 changes: 11 additions & 7 deletions example/src/node/node.resolver.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { Test, TestingModule } from "@nestjs/testing";
import { RecipesService } from "../recipes/recipes.service";
import { NodeResolver } from "./node.resolver";
import { Recipe } from "../recipes/models/recipe";
import { getRepositoryToken } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { Recipe } from "../recipes/models/recipe";
import { RecipesService } from "../recipes/recipes.service";
import { NodeResolver } from "./node.resolver";

describe("NodeResolver", () => {
let resolver: NodeResolver;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [NodeResolver, RecipesService, {
provide: getRepositoryToken(Recipe),
useClass: Repository,
}],
providers: [
NodeResolver,
RecipesService,
{
provide: getRepositoryToken(Recipe),
useClass: Repository,
},
],
}).compile();

resolver = module.get<NodeResolver>(NodeResolver);
Expand Down
2 changes: 1 addition & 1 deletion example/src/node/node.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Args, ID, Query, Resolver } from "@nestjs/graphql";
import { fromGlobalId } from "graphql-relay";
import { RecipesService } from "../recipes/recipes.service";
import * as uuid from "uuid";
import { Node } from "../node/node";
import { RecipesService } from "../recipes/recipes.service";

@Resolver()
export class NodeResolver {
Expand Down
2 changes: 1 addition & 1 deletion example/src/notify/notify.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from "@nestjs/common";
import { NotifyService } from "./notify.service";
import { NotifyController } from "./notify.controller";
import { NotifyService } from "./notify.service";

@Module({
providers: [NotifyService],
Expand Down
6 changes: 2 additions & 4 deletions example/src/notify/notify.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Injectable } from "@nestjs/common";
import { InjectSlack } from "nestjs-slack-webhook";
import { IncomingWebhook, IncomingWebhookSendArguments } from "@slack/webhook";
import { InjectSlack } from "nestjs-slack-webhook";

@Injectable()
export class NotifyService {
constructor(
@InjectSlack() private readonly slack: IncomingWebhook,
) {}
constructor(@InjectSlack() private readonly slack: IncomingWebhook) {}

async notify(args: IncomingWebhookSendArguments) {
await this.slack.send(args);
Expand Down
2 changes: 1 addition & 1 deletion example/src/recipes/dto/recipes.input.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ConnectionArgs, OrderByInput } from "nestjs-graphql-relay";
import {
ArgsType,
Field,
InputType,
PartialType,
PickType,
} from "@nestjs/graphql";
import { ConnectionArgs, OrderByInput } from "nestjs-graphql-relay";
import { Recipe } from "../models/recipe";

@InputType()
Expand Down
2 changes: 1 addition & 1 deletion example/src/recipes/models/recipe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Field, ID, ObjectType } from "@nestjs/graphql";
import { toGlobalId } from "graphql-relay";
import { Column, Entity, PrimaryColumn } from "typeorm";
import { Field, ID, ObjectType } from "@nestjs/graphql";
import { Node } from "../../node/node";

@ObjectType({ implements: Node })
Expand Down
2 changes: 1 addition & 1 deletion example/src/recipes/recipes.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { Recipe } from "./models/recipe";
import { RecipesResolver } from "./recipes.resolver";
import { RecipesService } from "./recipes.service";
import { Recipe } from "./models/recipe";

@Module({
imports: [TypeOrmModule.forFeature([Recipe])],
Expand Down
6 changes: 3 additions & 3 deletions example/src/recipes/recipes.resolver.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Test, TestingModule } from "@nestjs/testing";
import { RecipesResolver } from "./recipes.resolver";
import { RecipesService } from "./recipes.service";
import { Recipe } from "./models/recipe";
import { getRepositoryToken } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { Recipe } from "./models/recipe";
import { RecipesResolver } from "./recipes.resolver";
import { RecipesService } from "./recipes.service";

describe("RecipesResolver", () => {
let resolver: RecipesResolver;
Expand Down
2 changes: 1 addition & 1 deletion example/src/recipes/recipes.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Args, Field, ObjectType, Query, Resolver } from "@nestjs/graphql";
import * as Relay from "graphql-relay";
import { PageInfo } from "nestjs-graphql-relay";
import { Recipe } from "./models/recipe";
import { RecipesConnectionArgs } from "./dto/recipes.input";
import { Recipe } from "./models/recipe";
import { RecipesService } from "./recipes.service";

@ObjectType({ isAbstract: true })
Expand Down
15 changes: 9 additions & 6 deletions example/src/recipes/recipes.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { Test, TestingModule } from "@nestjs/testing";
import { RecipesService } from "./recipes.service";
import { Recipe } from "./models/recipe";
import { getRepositoryToken } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { Recipe } from "./models/recipe";
import { RecipesService } from "./recipes.service";

describe("RecipesService", () => {
let service: RecipesService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [RecipesService, {
provide: getRepositoryToken(Recipe),
useClass: Repository,
}],
providers: [
RecipesService,
{
provide: getRepositoryToken(Recipe),
useClass: Repository,
},
],
}).compile();

service = module.get<RecipesService>(RecipesService);
Expand Down
Loading
Loading