Format codebase to ensure consistent style

Ce commit applique un formatage uniforme au code en utilisant des guillemets doubles. Cela améliore la lisibilité et maintient une style cohérente à travers tous les fichiers. De plus, une configuration Biome a été ajoutée pour automatiser ce processus à l'avenir.
This commit is contained in:
Mathis H (Avnyr) 2024-08-21 13:51:53 +02:00
parent 3b8f3565d4
commit 0bb8185247
No known key found for this signature in database
GPG Key ID: FF69BF8BF95CDD58
26 changed files with 232 additions and 149 deletions

View File

@ -1,19 +1,19 @@
/* eslint-disable */
export default {
displayName: 'backend-e2e',
preset: '../../jest.preset.js',
globalSetup: '<rootDir>/src/support/global-setup.ts',
globalTeardown: '<rootDir>/src/support/global-teardown.ts',
setupFiles: ['<rootDir>/src/support/test-setup.ts'],
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/backend-e2e',
displayName: "backend-e2e",
preset: "../../jest.preset.js",
globalSetup: "<rootDir>/src/support/global-setup.ts",
globalTeardown: "<rootDir>/src/support/global-teardown.ts",
setupFiles: ["<rootDir>/src/support/test-setup.ts"],
testEnvironment: "node",
transform: {
"^.+\\.[tj]s$": [
"ts-jest",
{
tsconfig: "<rootDir>/tsconfig.spec.json",
},
],
},
moduleFileExtensions: ["ts", "js", "html"],
coverageDirectory: "../../coverage/backend-e2e",
};

View File

@ -1,10 +1,10 @@
import axios from 'axios';
import axios from "axios";
describe('GET /api', () => {
it('should return a message', async () => {
const res = await axios.get(`/api`);
describe("GET /api", () => {
it("should return a message", async () => {
const res = await axios.get(`/api`);
expect(res.status).toBe(200);
expect(res.data).toEqual({ message: 'Hello API' });
});
expect(res.status).toBe(200);
expect(res.data).toEqual({ message: "Hello API" });
});
});

View File

@ -1,10 +1,10 @@
/* eslint-disable */
var __TEARDOWN_MESSAGE__: string;
module.exports = async function () {
// Start services that that the app needs to run (e.g. database, docker-compose, etc.).
console.log('\nSetting up...\n');
module.exports = async () => {
// Start services that that the app needs to run (e.g. database, docker-compose, etc.).
console.log("\nSetting up...\n");
// Hint: Use `globalThis` to pass variables to global teardown.
globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n';
// Hint: Use `globalThis` to pass variables to global teardown.
globalThis.__TEARDOWN_MESSAGE__ = "\nTearing down...\n";
};

View File

@ -1,7 +1,7 @@
/* eslint-disable */
module.exports = async function () {
// Put clean up logic here (e.g. stopping services, docker-compose, etc.).
// Hint: `globalThis` is shared between setup and teardown.
console.log(globalThis.__TEARDOWN_MESSAGE__);
module.exports = async () => {
// Put clean up logic here (e.g. stopping services, docker-compose, etc.).
// Hint: `globalThis` is shared between setup and teardown.
console.log(globalThis.__TEARDOWN_MESSAGE__);
};

View File

@ -1,10 +1,10 @@
/* eslint-disable */
import axios from 'axios';
import axios from "axios";
module.exports = async function () {
// Configure axios for tests to use.
const host = process.env.HOST ?? 'localhost';
const port = process.env.PORT ?? '3000';
axios.defaults.baseURL = `http://${host}:${port}`;
module.exports = async () => {
// Configure axios for tests to use.
const host = process.env.HOST ?? "localhost";
const port = process.env.PORT ?? "3000";
axios.defaults.baseURL = `http://${host}:${port}`;
};

View File

@ -1,11 +1,11 @@
/* eslint-disable */
export default {
displayName: 'backend',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/backend',
displayName: "backend",
preset: "../../jest.preset.js",
testEnvironment: "node",
transform: {
"^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }],
},
moduleFileExtensions: ["ts", "js", "html"],
coverageDirectory: "../../coverage/apps/backend",
};

View File

@ -1,22 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';
import { Test, TestingModule } from "@nestjs/testing";
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
describe('AppController', () => {
let app: TestingModule;
describe("AppController", () => {
let app: TestingModule;
beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
});
beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
});
describe('getData', () => {
it('should return "Hello API"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getData()).toEqual({ message: 'Hello API' });
});
});
describe("getData", () => {
it('should return "Hello API"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getData()).toEqual({ message: "Hello API" });
});
});
});

View File

@ -1,13 +1,13 @@
import { Controller, Get } from '@nestjs/common';
import { Controller, Get } from "@nestjs/common";
import { AppService } from './app.service';
import { AppService } from "./app.service";
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
constructor(private readonly appService: AppService) {}
@Get()
getData() {
return this.appService.getData();
}
@Get()
getData() {
return this.appService.getData();
}
}

View File

@ -1,11 +1,12 @@
import { Module } from '@nestjs/common';
import { Module } from "@nestjs/common";
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
import { DbModule } from "./db/db.module";
@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
imports: [DbModule],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}

View File

@ -1,21 +1,21 @@
import { Test } from '@nestjs/testing';
import { Test } from "@nestjs/testing";
import { AppService } from './app.service';
import { AppService } from "./app.service";
describe('AppService', () => {
let service: AppService;
describe("AppService", () => {
let service: AppService;
beforeAll(async () => {
const app = await Test.createTestingModule({
providers: [AppService],
}).compile();
beforeAll(async () => {
const app = await Test.createTestingModule({
providers: [AppService],
}).compile();
service = app.get<AppService>(AppService);
});
service = app.get<AppService>(AppService);
});
describe('getData', () => {
it('should return "Hello API"', () => {
expect(service.getData()).toEqual({ message: 'Hello API' });
});
});
describe("getData", () => {
it('should return "Hello API"', () => {
expect(service.getData()).toEqual({ message: "Hello API" });
});
});
});

View File

@ -1,8 +1,8 @@
import { Injectable } from '@nestjs/common';
import { Injectable } from "@nestjs/common";
@Injectable()
export class AppService {
getData(): { message: string } {
return { message: 'Hello API' };
}
getData(): { message: string } {
return { message: "Hello API" };
}
}

View File

@ -0,0 +1,7 @@
import { Module } from "@nestjs/common";
import { DbService } from "./db.service";
@Module({
providers: [DbService],
})
export class DbModule {}

View File

@ -0,0 +1,18 @@
import { Test, TestingModule } from "@nestjs/testing";
import { DbService } from "./db.service";
describe("DbService", () => {
let service: DbService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [DbService],
}).compile();
service = module.get<DbService>(DbService);
});
it("should be defined", () => {
expect(service).toBeDefined();
});
});

View File

@ -0,0 +1,4 @@
import { Injectable } from "@nestjs/common";
@Injectable()
export class DbService {}

View File

@ -3,20 +3,20 @@
* This is only a minimal backend to get started.
*/
import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { Logger } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";
import { AppModule } from './app/app.module';
import { AppModule } from "./app/app.module";
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const globalPrefix = 'api';
app.setGlobalPrefix(globalPrefix);
const port = process.env.PORT || 3000;
await app.listen(port);
Logger.log(
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`
);
const app = await NestFactory.create(AppModule);
const globalPrefix = "api";
app.setGlobalPrefix(globalPrefix);
const port = process.env.PORT || 3000;
await app.listen(port);
Logger.log(
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`,
);
}
bootstrap();

View File

@ -1,14 +1,14 @@
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { nxE2EPreset } from "@nx/cypress/plugins/cypress-preset";
import { defineConfig } from 'cypress';
import { defineConfig } from "cypress";
export default defineConfig({
e2e: {
...nxE2EPreset(__filename, {
cypressDir: 'src',
webServerCommands: { default: 'nx run frontend:start' },
ciWebServerCommand: 'nx run frontend:serve-static',
}),
baseUrl: 'http://localhost:3000',
},
e2e: {
...nxE2EPreset(__filename, {
cypressDir: "src",
webServerCommands: { default: "nx run frontend:start" },
ciWebServerCommand: "nx run frontend:serve-static",
}),
baseUrl: "http://localhost:3000",
},
});

View File

@ -1,13 +1,13 @@
import { getGreeting } from '../support/app.po';
import { getGreeting } from "../support/app.po";
describe('frontend-e2e', () => {
beforeEach(() => cy.visit('/'));
describe("frontend-e2e", () => {
beforeEach(() => cy.visit("/"));
it('should display welcome message', () => {
// Custom command example, see `../support/commands.ts` file
cy.login('my-email@something.com', 'myPassword');
it("should display welcome message", () => {
// Custom command example, see `../support/commands.ts` file
cy.login("my-email@something.com", "myPassword");
// Function helper example, see `../support/app.po.ts` file
getGreeting().contains(/Welcome/);
});
// Function helper example, see `../support/app.po.ts` file
getGreeting().contains(/Welcome/);
});
});

View File

@ -1 +1 @@
export const getGreeting = () => cy.get('h1');
export const getGreeting = () => cy.get("h1");

View File

@ -12,15 +12,15 @@
// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
Cypress.Commands.add("login", (email, password) => {
console.log("Custom command example: Login", email, password);
});
//
// -- This is a child command --

View File

@ -14,4 +14,4 @@
// ***********************************************************
// Import commands.ts using ES2015 syntax:
import './commands';
import "./commands";

View File

@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
declare module '*.svg' {
const content: any;
export const ReactComponent: any;
export default content;
declare module "*.svg" {
const content: any;
export const ReactComponent: any;
export default content;
}

View File

@ -1,11 +1,11 @@
/* eslint-disable */
export default {
displayName: 'frontend',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/next/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/frontend',
displayName: "frontend",
preset: "../../jest.preset.js",
transform: {
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nx/react/plugins/jest",
"^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nx/next/babel"] }],
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
coverageDirectory: "../../coverage/apps/frontend",
};

View File

@ -1,3 +1,3 @@
export async function GET(request: Request) {
return new Response('Hello, from API!');
return new Response("Hello, from API!");
}

44
biome.json Normal file
View File

@ -0,0 +1,44 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
"organizeImports": {
"enabled": true
},
"files": {
"include": [
"./apps/**/*.ts"
]
},
"vcs": {
"enabled": true,
"clientKind": "git"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"performance": {
"recommended": true,
"noDelete": "off"
},
"suspicious": {
"noExplicitAny": "warn"
},
"complexity": {
"useLiteralKeys": "off"
},
"style": {
"useImportType": "off"
}
}
},
"formatter": {
"indentStyle": "tab",
"indentWidth": 2,
"lineWidth": 80
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
}
}
}

View File

@ -2,11 +2,14 @@
"name": "@app/source",
"version": "0.0.0",
"license": "MIT",
"scripts": {},
"scripts": {
"check": "biome check --skip-errors --apply apps"
},
"private": true,
"dependencies": {
"@nestjs/common": "^10.4.1",
"@nestjs/core": "^10.4.1",
"@nestjs/mapped-types": "*",
"@nestjs/platform-express": "^10.4.1",
"axios": "^1.7.4",
"next": "14.2.3",

View File

@ -10,11 +10,17 @@
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2020", "dom"],
"lib": [
"es2020",
"dom"
],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {}
},
"exclude": ["node_modules", "tmp"]
"exclude": [
"node_modules",
"tmp"
]
}