Skip to content

Commit

Permalink
chore: create new ESLint config
Browse files Browse the repository at this point in the history
  • Loading branch information
ijemmao committed Sep 26, 2024
1 parent 4bd21b3 commit 0addd11
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 123 deletions.
94 changes: 0 additions & 94 deletions .eslintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion @types/express.d.ts

This file was deleted.

13 changes: 13 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginReact from "eslint-plugin-react";


export default [
{files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"]},
{languageOptions: { globals: {...globals.browser, ...globals.node} }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
];
12 changes: 1 addition & 11 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,9 @@
"@types/string-similarity": "^4.0.0",
"@types/supertest": "^6.0.2",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^5.59.6",
"cross-env": "^7.0.2",
"cypress": "^12.14.0",
"eslint": "8.34.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-next": "^14.1.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-cypress": "2.12.1",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-react": "7.32.2",
"eslint": "9.11.1",
"husky": "^4.3.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^10.4.0",
Expand Down
18 changes: 6 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@eslint/js": "^9.11.1",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/git": "^9.0.0",
Expand All @@ -169,18 +170,10 @@
"@types/string-similarity": "^4.0.0",
"@types/supertest": "^6.0.2",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^5.59.6",
"cypress": "^12.14.0",
"eslint": "8.34.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-next": "^14.1.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-cypress": "2.12.1",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-react": "7.32.2",
"eslint": "^9.11.1",
"eslint-plugin-react": "^7.36.1",
"globals": "^15.9.0",
"husky": "^4.3.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^10.4.0",
Expand All @@ -190,7 +183,8 @@
"prettier": "3.2.5",
"supertest": "^6.3.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2"
"ts-node": "^10.9.2",
"typescript-eslint": "^8.7.0"
},
"standard-version": {
"skip": {
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/nsibidi.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { NextFunction, Response } from 'express';
import mongoose, { Connection } from 'mongoose';
import { handleQueries, packageResponse } from './utils';
import { IgboAPIRequest } from '../types/express';
import { IgboAPIRequest, MiddleWare } from '../types/express';
import { searchNsibidiCharactersQuery } from './utils/queries';
import { findNsibidiCharactersWithMatch } from './utils/buildDocs';
import { nsibidiCharacterSchema } from '../models/NsibidiCharacter';
import { NsibidiCharacter } from '../types/nsibidiCharacter';

export const getNsibidiCharacters = async (req: IgboAPIRequest, res: Response, next: NextFunction) => {
export const getNsibidiCharacters: MiddleWare = async (req, res, next) => {
try {
const { searchWord, version, skip, limit } = await handleQueries(req);

Expand All @@ -30,7 +30,7 @@ export const getNsibidiCharacters = async (req: IgboAPIRequest, res: Response, n
}
};

export const getNsibidiCharacter = async (req: IgboAPIRequest, res: Response, next: NextFunction) => {
export const getNsibidiCharacter: MiddleWare = async (req, res, next) => {
try {
const { id, version } = await handleQueries(req);

Expand Down
5 changes: 4 additions & 1 deletion src/middleware/errorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { NextFunction, Request, Response } from 'express';
import { ErrorMiddleWare } from '../types';

// eslint-disable-next-line no-unused-vars
export default (err: any, _: Request, res: Response, __: NextFunction) => {
const errorHandler: ErrorMiddleWare = (err: any, _, res, __) => {
res.status(400);
/* Depending on the nested error message the status code will change */
if (err.message.match(/No .{1,} exist(s)?/) || err.message.match(/doesn't exist(s)?/)) {
Expand All @@ -10,3 +11,5 @@ export default (err: any, _: Request, res: Response, __: NextFunction) => {
console.error(err?.stack);
return res.send({ error: err.message });
};

export default errorHandler
4 changes: 4 additions & 0 deletions src/types/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ export interface IgboAPIRequest extends ExpressRequest {
export interface MiddleWare {
(req: IgboAPIRequest, res: Response, next: NextFunction): void;
}

export interface ErrorMiddleWare {
(error: any, req: IgboAPIRequest, res: Response, next: NextFunction): void;
}
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type { MiddleWare, IgboAPIRequest, Query } from './express';
export type { MiddleWare, ErrorMiddleWare, IgboAPIRequest, Query } from './express';
export type { Developer, DeveloperDocument, DeveloperResponse } from './developer';
export type {
IncomingExample,
Expand Down

0 comments on commit 0addd11

Please sign in to comment.