From c4604179da3aba21013a0e479443f2848ae94cbb Mon Sep 17 00:00:00 2001 From: Nishant Kohli Date: Mon, 12 Feb 2024 03:47:43 +0530 Subject: [PATCH] upgrade @nish1896/eslint-config to 1.0.4 (#7) --- apps/express-server/.eslintrc.js | 2 +- .../src/app-constants/env_vars.ts | 4 +--- apps/express-server/src/app.ts | 2 +- apps/express-server/src/middleware/guard.ts | 8 ++++---- .../src/middleware/request-logger.ts | 2 +- .../src/middleware/winston-logger.ts | 10 +++++----- .../src/routes/auth/controller.ts | 12 +++++------ .../express-server/src/routes/auth/service.ts | 6 +++--- apps/express-server/src/routes/auth/types.ts | 2 +- apps/frontend/.eslintrc.js | 9 ++++++--- apps/frontend/package.json | 2 +- apps/frontend/src/react-app-env.d.ts | 2 +- apps/frontend/src/redux-store/index.ts | 2 +- apps/frontend/src/redux-store/types.ts | 2 +- apps/nestjs-server/.eslintrc.js | 4 +--- apps/nestjs-server/package.json | 2 +- apps/nestjs-server/src/main.ts | 2 +- apps/nestjs-server/src/routes/home/module.ts | 2 +- apps/next-client/.eslintrc.js | 2 +- apps/next-client/package.json | 2 +- packages/core-lib/package.json | 2 +- yarn.lock | 20 +++++++++---------- 22 files changed, 50 insertions(+), 51 deletions(-) diff --git a/apps/express-server/.eslintrc.js b/apps/express-server/.eslintrc.js index 2849e72..8471e60 100644 --- a/apps/express-server/.eslintrc.js +++ b/apps/express-server/.eslintrc.js @@ -1,3 +1,3 @@ module.exports = { extends: ['@nish1896'] -} \ No newline at end of file +}; diff --git a/apps/express-server/src/app-constants/env_vars.ts b/apps/express-server/src/app-constants/env_vars.ts index 70d6fdd..95767de 100644 --- a/apps/express-server/src/app-constants/env_vars.ts +++ b/apps/express-server/src/app-constants/env_vars.ts @@ -5,6 +5,4 @@ const env = process.env; -export const ENV_VARS = Object.freeze({ - port: env.port ?? 5000, -}); +export const ENV_VARS = Object.freeze({ port: env.port ?? 5000 }); diff --git a/apps/express-server/src/app.ts b/apps/express-server/src/app.ts index 645b2c3..809b44f 100644 --- a/apps/express-server/src/app.ts +++ b/apps/express-server/src/app.ts @@ -15,7 +15,7 @@ app.get('/', (_: Request, response: Response) => { response.status(200).send('Api is up & running!!!'); }); -app.use(`/api/auth`, Routes.authRouter); +app.use('/api/auth', Routes.authRouter); /* 404 Handler - To be written at last */ app.get('*', (req: Request, response: Response) => { diff --git a/apps/express-server/src/middleware/guard.ts b/apps/express-server/src/middleware/guard.ts index a947eed..e4aae12 100644 --- a/apps/express-server/src/middleware/guard.ts +++ b/apps/express-server/src/middleware/guard.ts @@ -4,10 +4,10 @@ import { winstonLogger } from './winston-logger'; export function validateAuthHeader( req: Request, res: Response, - next: NextFunction + next: NextFunction, ) { /* Check presence of jwt and refresh-token */ - let token: string | undefined = req.cookies?.['jwt']; + const token: string | undefined = req.cookies?.jwt; if (!token) { const errorMsg = 'Unauthorized request'; @@ -22,7 +22,7 @@ export function validateAuthHeader( export function authenticateAdmin( _: Request, res: Response, - next: NextFunction + next: NextFunction, ) { if (res.locals?.user?.role === 'Admin') { next(); @@ -37,7 +37,7 @@ export function checkTokenMismatchInReqParams( /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ req: Request, res: Response, - next: NextFunction + next: NextFunction, ) { if (res.locals?.user?._id !== req.params.id) { return res.status(406).send('Token Mismatch').end(); diff --git a/apps/express-server/src/middleware/request-logger.ts b/apps/express-server/src/middleware/request-logger.ts index e626aad..746134b 100644 --- a/apps/express-server/src/middleware/request-logger.ts +++ b/apps/express-server/src/middleware/request-logger.ts @@ -4,7 +4,7 @@ import { winstonLogger } from './winston-logger'; export function requestLogger( request: Request, response: Response, - next: NextFunction + next: NextFunction, ) { winstonLogger.info(`${request.method} ${request.url}`); response.on('finish', () => { diff --git a/apps/express-server/src/middleware/winston-logger.ts b/apps/express-server/src/middleware/winston-logger.ts index 645f2f4..bf6b95b 100644 --- a/apps/express-server/src/middleware/winston-logger.ts +++ b/apps/express-server/src/middleware/winston-logger.ts @@ -11,19 +11,19 @@ const customLevels = { warn: 1, info: 2, http: 3, - success: 4 + success: 4, }, colors: { error: 'bold red blackBG', warn: 'italic yellow', info: 'blue', http: 'magenta', - success: 'green' + success: 'green', }, }; const myFormat = printf( - ({ level, message, timestamp }) => `[ ${level} ]:: ${timestamp} - ${message}` + ({ level, message, timestamp }) => `[ ${level} ]:: ${timestamp} - ${message}`, ); /** @@ -46,7 +46,7 @@ const winstonLogger = createLogger({ /* Aligns in a tabular format */ // format.align(), - myFormat + myFormat, ), // defaultMeta: { service: 'log-service' }, transports: [ @@ -71,7 +71,7 @@ addColors(customLevels.colors); if (process.env.NODE_ENV !== 'production') { winstonLogger.add( - new transports.Console({ format: format.colorize({ all: true }) }) + new transports.Console({ format: format.colorize({ all: true }) }), ); } diff --git a/apps/express-server/src/routes/auth/controller.ts b/apps/express-server/src/routes/auth/controller.ts index e87974f..8aa7792 100644 --- a/apps/express-server/src/routes/auth/controller.ts +++ b/apps/express-server/src/routes/auth/controller.ts @@ -6,21 +6,21 @@ const authRouter = Router(); authRouter.get( '/test', - async function printHello(_, res: Response) { + function printHello(_, res: Response) { return res.status(200).send('Hello World !!').end(); - } + }, ); /* Login user */ authRouter.post( '/login', - async function loginUser( + function loginUser( req: Request, - res: Response + res: Response, ) { const { email, password } = req.body; - return await authService.loginUser(res, email, password); - } + return authService.loginUser(res, email, password); + }, ); export { authRouter }; diff --git a/apps/express-server/src/routes/auth/service.ts b/apps/express-server/src/routes/auth/service.ts index f87e7ad..2128d41 100644 --- a/apps/express-server/src/routes/auth/service.ts +++ b/apps/express-server/src/routes/auth/service.ts @@ -1,12 +1,12 @@ import { Response } from 'express'; class AuthService { - async loginUser(res: Response, email: string, password: string) { + loginUser(res: Response, email: string, password: string) { try { - res.send({ + res.status(200).send({ email, password, - }); + }).end(); } catch (err) { res.status(500).send('Internal Server Error'); } diff --git a/apps/express-server/src/routes/auth/types.ts b/apps/express-server/src/routes/auth/types.ts index 558d659..6f31cc6 100644 --- a/apps/express-server/src/routes/auth/types.ts +++ b/apps/express-server/src/routes/auth/types.ts @@ -1,4 +1,4 @@ export interface UserLoginBody { email: string; password: string; -} \ No newline at end of file +} diff --git a/apps/frontend/.eslintrc.js b/apps/frontend/.eslintrc.js index 817637d..9a44c18 100644 --- a/apps/frontend/.eslintrc.js +++ b/apps/frontend/.eslintrc.js @@ -1,3 +1,6 @@ -// module.exports = { -// extends: ['@nish1896'] -// } +module.exports = { + extends: ['@nish1896'], + rules: { + '@typescript-eslint/no-non-null-assertion': 'off', + } +}; diff --git a/apps/frontend/package.json b/apps/frontend/package.json index b3e56b5..de5de36 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -27,7 +27,7 @@ "web-vitals": "^3.5.2" }, "devDependencies": { - "@nish1896/eslint-config": "^1.0.3", + "@nish1896/eslint-config": "^1.0.4", "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^14.2.1", "@testing-library/user-event": "^14.5.2", diff --git a/apps/frontend/src/react-app-env.d.ts b/apps/frontend/src/react-app-env.d.ts index 6431bc5..30da896 100644 --- a/apps/frontend/src/react-app-env.d.ts +++ b/apps/frontend/src/react-app-env.d.ts @@ -1 +1 @@ -/// +// / diff --git a/apps/frontend/src/redux-store/index.ts b/apps/frontend/src/redux-store/index.ts index fc4c3dc..2bb2180 100644 --- a/apps/frontend/src/redux-store/index.ts +++ b/apps/frontend/src/redux-store/index.ts @@ -2,4 +2,4 @@ export * from './hooks'; export * from './reducers'; export * from './services'; export * from './store'; -export * from './types'; \ No newline at end of file +export * from './types'; diff --git a/apps/frontend/src/redux-store/types.ts b/apps/frontend/src/redux-store/types.ts index a25fdfc..ee00638 100644 --- a/apps/frontend/src/redux-store/types.ts +++ b/apps/frontend/src/redux-store/types.ts @@ -1,4 +1,4 @@ import { store } from './store'; export type RootState = ReturnType; -export type AppDispatch = typeof store.dispatch; \ No newline at end of file +export type AppDispatch = typeof store.dispatch; diff --git a/apps/nestjs-server/.eslintrc.js b/apps/nestjs-server/.eslintrc.js index 562bca3..639376f 100644 --- a/apps/nestjs-server/.eslintrc.js +++ b/apps/nestjs-server/.eslintrc.js @@ -4,9 +4,7 @@ module.exports = { tsconfigRootDir: __dirname, sourceType: 'module', }, - extends: [ - '@nish1896' - ], + extends: ['@nish1896'], rules: { '@typescript-eslint/interface-name-prefix': 'off', '@typescript-eslint/explicit-function-return-type': 'off', diff --git a/apps/nestjs-server/package.json b/apps/nestjs-server/package.json index edd5e74..29c72a4 100644 --- a/apps/nestjs-server/package.json +++ b/apps/nestjs-server/package.json @@ -29,7 +29,7 @@ "@nestjs/cli": "^10.3.2", "@nestjs/schematics": "^10.1.1", "@nestjs/testing": "^10.3.2", - "@nish1896/eslint-config": "^1.0.3", + "@nish1896/eslint-config": "^1.0.4", "@types/express": "^4.17.21", "@types/jest": "^29.5.12", "@types/node": "^20.11.17", diff --git a/apps/nestjs-server/src/main.ts b/apps/nestjs-server/src/main.ts index cb769e6..171672d 100644 --- a/apps/nestjs-server/src/main.ts +++ b/apps/nestjs-server/src/main.ts @@ -18,7 +18,7 @@ async function bootstrap() { new FastifyAdapter({ ignoreTrailingSlash: true, caseSensitive: false, - }) + }), ); await app.listen(4000); } diff --git a/apps/nestjs-server/src/routes/home/module.ts b/apps/nestjs-server/src/routes/home/module.ts index d2f7e76..ec14661 100644 --- a/apps/nestjs-server/src/routes/home/module.ts +++ b/apps/nestjs-server/src/routes/home/module.ts @@ -6,4 +6,4 @@ import { HomeService } from './service'; controllers: [HomeController], providers: [HomeService], }) -export class HomeModule {} \ No newline at end of file +export class HomeModule {} diff --git a/apps/next-client/.eslintrc.js b/apps/next-client/.eslintrc.js index d90a3de..3d8aff9 100644 --- a/apps/next-client/.eslintrc.js +++ b/apps/next-client/.eslintrc.js @@ -1,6 +1,6 @@ module.exports = { extends: [ 'next/core-web-vitals', - // '@nish1896' + '@nish1896' ], } diff --git a/apps/next-client/package.json b/apps/next-client/package.json index 7c54827..e339e0e 100644 --- a/apps/next-client/package.json +++ b/apps/next-client/package.json @@ -18,7 +18,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@nish1896/eslint-config": "^1.0.3", + "@nish1896/eslint-config": "^1.0.4", "@types/node": "^20.11.17", "@types/react": "^18.2.55", "@types/react-dom": "^18.2.19", diff --git a/packages/core-lib/package.json b/packages/core-lib/package.json index 3536aef..e09b68a 100644 --- a/packages/core-lib/package.json +++ b/packages/core-lib/package.json @@ -14,7 +14,7 @@ "typescript": "^5.3.3" }, "devDependencies": { - "@nish1896/eslint-config": "^1.0.3", + "@nish1896/eslint-config": "^1.0.4", "eslint": "^8.56.0" } } diff --git a/yarn.lock b/yarn.lock index 66329c4..ce40738 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2315,14 +2315,14 @@ dependencies: eslint-scope "5.1.1" -"@nish1896/eslint-config@^1.0.3": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@nish1896/eslint-config/-/eslint-config-1.0.3.tgz#cdaa3e7772ec276fb66a533d41ab7acfdf869de0" - integrity sha512-9L1Ul4S4hW4FpN8WwmrtLT92PY4ph+dTa8kM2fLU6H02j3/qosPQw+hVlBOI2ktlRe5iTxgS/3AXTpCQLKarVQ== +"@nish1896/eslint-config@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@nish1896/eslint-config/-/eslint-config-1.0.4.tgz#ab9669ea5cbbd762b95bf17cb3163762c6e6e997" + integrity sha512-QmWgufEAoS4bZEAPgYzq7yA2DHCIG9A5TcYLGITsuNVuhmXuzzeWJA6iQIxm+9OotVrL1rvTHg1gBLzg4Mi5sw== dependencies: - "@stylistic/eslint-plugin" "^1.5.4" - "@typescript-eslint/eslint-plugin" "^6.19.0" - "@typescript-eslint/parser" "^6.19.0" + "@stylistic/eslint-plugin" "^1.6.1" + "@typescript-eslint/eslint-plugin" "^6.21.0" + "@typescript-eslint/parser" "^6.21.0" eslint-plugin-jsx-a11y "^6.8.0" eslint-plugin-react "^7.33.2" eslint-plugin-react-hooks "^4.6.0" @@ -2511,7 +2511,7 @@ "@stylistic/eslint-plugin-js" "1.6.1" "@typescript-eslint/utils" "^6.20.0" -"@stylistic/eslint-plugin@^1.5.4": +"@stylistic/eslint-plugin@^1.6.1": version "1.6.1" resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin/-/eslint-plugin-1.6.1.tgz#011e408ad9a1dddfe9517ace9dd3b6ce9ef4b17b" integrity sha512-De7Sw86OtIf7SsMgjLCf4bTeI3085Plyh4l0Rg1V42BTFo/Q6Pz7Cbu31rEk/UHFiEna/YO8Hxj80jFP3ObrQw== @@ -3154,7 +3154,7 @@ semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/eslint-plugin@^6.19.0": +"@typescript-eslint/eslint-plugin@^6.21.0": version "6.21.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz#30830c1ca81fd5f3c2714e524c4303e0194f9cd3" integrity sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA== @@ -3178,7 +3178,7 @@ dependencies: "@typescript-eslint/utils" "5.62.0" -"@typescript-eslint/parser@^5.4.2 || ^6.0.0", "@typescript-eslint/parser@^6.19.0": +"@typescript-eslint/parser@^5.4.2 || ^6.0.0", "@typescript-eslint/parser@^6.21.0": version "6.21.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.21.0.tgz#af8fcf66feee2edc86bc5d1cf45e33b0630bf35b" integrity sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==