Skip to content

Commit

Permalink
feat: use biomejs (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
9renpoto authored Jan 21, 2024
1 parent e6c2ceb commit 150d370
Show file tree
Hide file tree
Showing 32 changed files with 522 additions and 312 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ jobs:
node-version: [lts/*, latest]
steps:
- uses: actions/checkout@v3
- uses: biomejs/setup-biome@v2
with:
version: latest
- run: biome ci .
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand All @@ -25,7 +29,6 @@ jobs:
${{ runner.OS }}-
- run: npm ci
- run: npm run build
- run: npm run lint
- run: npm test
- name: Coverage
uses: coverallsapp/[email protected]
Expand Down
25 changes: 25 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$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
}
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
}
}
}
42 changes: 21 additions & 21 deletions example/__tests__/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Test, TestingModule } from '@nestjs/testing';
import request from 'supertest';
import { INestApplication } from '@nestjs/common';
import { ApolloServer } from '@apollo/server';
import gql from 'graphql-tag';
import { GraphQLError } from 'graphql';
import { AppModule } from './../src/app.module';
import { GraphQLModule } from '@nestjs/graphql';
import { ApolloDriver } from '@nestjs/apollo';

describe('AppModule', () => {
import { ApolloServer } from "@apollo/server";
import { ApolloDriver } from "@nestjs/apollo";
import { INestApplication } from "@nestjs/common";
import { GraphQLModule } from "@nestjs/graphql";
import { Test, TestingModule } from "@nestjs/testing";
import { GraphQLError } from "graphql";
import gql from "graphql-tag";
import request from "supertest";
import { AppModule } from "./../src/app.module";

describe("AppModule", () => {
let app: INestApplication;
let apolloClient: ApolloServer;

Expand All @@ -26,14 +26,14 @@ describe('AppModule', () => {

afterAll(() => app.close());

it('defined', () => expect(app).toBeDefined());
it("defined", () => expect(app).toBeDefined());

it('/ (GET)', () => request(app.getHttpServer()).get('/').expect(500));
it("/ (GET)", () => request(app.getHttpServer()).get("/").expect(500));

it('/graphql (GET)', () =>
request(app.getHttpServer()).get('/graphql').expect(400));
it("/graphql (GET)", () =>
request(app.getHttpServer()).get("/graphql").expect(400));

it('/graphql(POST) forbiddenError warning', async () => {
it("/graphql(POST) forbiddenError warning", async () => {
const result = await apolloClient.executeOperation({
query: gql`
query {
Expand All @@ -43,11 +43,11 @@ describe('AppModule', () => {
variables: {},
});
expect(
result.body.kind === 'single' && result.body.singleResult.errors,
).toEqual([new GraphQLError('Unauthorized')]);
result.body.kind === "single" && result.body.singleResult.errors,
).toEqual([new GraphQLError("Unauthorized")]);
});

it('/graphql(POST) forbiddenError', async () => {
it("/graphql(POST) forbiddenError", async () => {
const result = await apolloClient.executeOperation({
query: gql`
query {
Expand All @@ -57,7 +57,7 @@ describe('AppModule', () => {
variables: {},
});
expect(
result.body.kind === 'single' && result.body.singleResult.errors,
).toEqual([new GraphQLError('Forbidden')]);
result.body.kind === "single" && result.body.singleResult.errors,
).toEqual([new GraphQLError("Forbidden")]);
});
});
6 changes: 3 additions & 3 deletions example/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller, Get, UseInterceptors } from '@nestjs/common';
import { AppService } from './app.service';
import { RavenInterceptor } from '../../lib';
import { Controller, Get, UseInterceptors } from "@nestjs/common";
import { RavenInterceptor } from "../../lib";
import { AppService } from "./app.service";

@Controller()
@UseInterceptors(new RavenInterceptor())
Expand Down
16 changes: 8 additions & 8 deletions example/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { GraphQLModule } from '@nestjs/graphql';
import { RavenInterceptor } from '../../lib';
import { GqlModule } from './gql/gql.module';
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
import { ApolloDriver, ApolloDriverConfig } from "@nestjs/apollo";
import { Module } from "@nestjs/common";
import { APP_INTERCEPTOR } from "@nestjs/core";
import { GraphQLModule } from "@nestjs/graphql";
import { RavenInterceptor } from "../../lib";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
import { GqlModule } from "./gql/gql.module";

@Module({
imports: [
Expand Down
4 changes: 2 additions & 2 deletions example/src/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable, InternalServerErrorException } from '@nestjs/common';
import { Injectable, InternalServerErrorException } from "@nestjs/common";

@Injectable()
export class AppService {
getHello(): string {
throw new InternalServerErrorException('This is not good?');
throw new InternalServerErrorException("This is not good?");
}
}
4 changes: 2 additions & 2 deletions example/src/gql/gql.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Module } from '@nestjs/common';
import { GqlResolver } from './gql.resolver';
import { Module } from "@nestjs/common";
import { GqlResolver } from "./gql.resolver";

@Module({
providers: [GqlResolver],
Expand Down
12 changes: 6 additions & 6 deletions example/src/gql/gql.resolver.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { GqlResolver } from './gql.resolver';
import { Test, TestingModule } from "@nestjs/testing";
import { GqlResolver } from "./gql.resolver";

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

beforeEach(async () => {
Expand All @@ -12,14 +12,14 @@ describe('GqlResolver', () => {
resolver = module.get<GqlResolver>(GqlResolver);
});

it('should be defined', () => expect(resolver).toBeDefined());
it("should be defined", () => expect(resolver).toBeDefined());

it('UnauthorizedException', () =>
it("UnauthorizedException", () =>
expect(
resolver.unauthorizedException(),
).rejects.toThrowErrorMatchingInlineSnapshot(`"Unauthorized"`));

it('@nestjs/common (Forbidden)', () =>
it("@nestjs/common (Forbidden)", () =>
expect(
resolver.forbiddenException(),
).rejects.toThrowErrorMatchingInlineSnapshot(`"Forbidden"`));
Expand Down
10 changes: 5 additions & 5 deletions example/src/gql/gql.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import {
ForbiddenException,
UnauthorizedException,
UseInterceptors,
} from '@nestjs/common';
import { Query, Resolver } from '@nestjs/graphql';
import { RavenInterceptor } from '../../../lib';
} from "@nestjs/common";
import { Query, Resolver } from "@nestjs/graphql";
import { RavenInterceptor } from "../../../lib";

@Resolver('Gql')
@Resolver("Gql")
export class GqlResolver {
@Query(() => Boolean)
async forbiddenException() {
throw new ForbiddenException();
}

@UseInterceptors(new RavenInterceptor({ level: 'warning' }))
@UseInterceptors(new RavenInterceptor({ level: "warning" }))
@Query(() => Boolean)
async unauthorizedException() {
throw new UnauthorizedException();
Expand Down
8 changes: 4 additions & 4 deletions example/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as Sentry from '@sentry/node';
import { config } from 'dotenv';
import { NestFactory } from "@nestjs/core";
import * as Sentry from "@sentry/node";
import { config } from "dotenv";
import { AppModule } from "./app.module";

async function bootstrap() {
config();
Expand Down
8 changes: 4 additions & 4 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './raven.decorators';
export * from './raven.interceptor';
export * from './raven.interfaces';
export * from './raven.module';
export * from "./raven.decorators";
export * from "./raven.interceptor";
export * from "./raven.interfaces";
export * from "./raven.module";
6 changes: 3 additions & 3 deletions lib/raven.decorators.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IRavenScopeTransformerFunction } from './raven.interfaces';
import { SetMetadata } from '@nestjs/common';
import { SetMetadata } from "@nestjs/common";
import { IRavenScopeTransformerFunction } from "./raven.interfaces";

export const RAVEN_LOCAL_TRANSFORMERS_METADATA = 'raven-local-transformers';
export const RAVEN_LOCAL_TRANSFORMERS_METADATA = "raven-local-transformers";

export const RavenTransformer = (
...transformers: IRavenScopeTransformerFunction[]
Expand Down
Loading

0 comments on commit 150d370

Please sign in to comment.