Skip to content

Commit

Permalink
fix(): update linter file
Browse files Browse the repository at this point in the history
  • Loading branch information
NarHakobyan committed Jun 24, 2024
1 parent 9391b89 commit 79ed159
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 340 deletions.
639 changes: 325 additions & 314 deletions .eslintrc.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-canonical": "^4.18.0",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-import-helpers": "^1.3.1",
"eslint-plugin-n": "^16.6.1",
Expand Down
23 changes: 11 additions & 12 deletions src/guards/roles.guard.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
import {
type CanActivate,
type ExecutionContext,
Injectable,
} from '@nestjs/common';
import type { CanActivate, ExecutionContext } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import _ from 'lodash';

import { type RoleType } from '../constants';
import { type UserEntity } from '../modules/user/user.entity';
import type { RoleType } from '../constants';
import type { UserEntity } from '../modules/user/user.entity';

@Injectable()
export class RolesGuard implements CanActivate {
constructor(private readonly reflector: Reflector) {}

canActivate(context: ExecutionContext): boolean {
const roles = this.reflector.get<RoleType[]>('roles', context.getHandler());
const roles = this.reflector.get<RoleType[] | undefined>(
'roles',
context.getHandler(),
);

if (_.isEmpty(roles)) {
if (!roles?.length) {
return true;
}

const request = context.switchToHttp().getRequest();
const user = <UserEntity>request.user;
const request = context.switchToHttp().getRequest<{ user: UserEntity }>();
const user = request.user;

return roles.includes(user.role);
}
Expand Down
3 changes: 2 additions & 1 deletion src/modules/user/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { AbstractEntity } from '../../common/abstract.entity';
import { RoleType } from '../../constants';
import { UseDto } from '../../decorators';
import { PostEntity } from '../post/post.entity';
import { UserDto, type UserDtoOptions } from './dtos/user.dto';
import type { UserDtoOptions } from './dtos/user.dto';
import { UserDto } from './dtos/user.dto';
import { UserSettingsEntity } from './user-settings.entity';

@Entity({ name: 'users' })
Expand Down
1 change: 0 additions & 1 deletion tsconfig.build.tsbuildinfo

This file was deleted.

9 changes: 4 additions & 5 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"extends": "./tsconfig.json",
"include": [
"src/**/*.ts",
"*.ts",
"test/**/*.ts"
"src/**/*",
"*.{ts,js,mts}",
"test/**/*"
],
"exclude": [
"node_modules",
"dist",
".eslintrc.js"
"dist"
]
}
21 changes: 14 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
{
"compilerOptions": {
"rootDir": "src",
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"noImplicitAny": true,
"removeComments": true,
"noLib": false,
"skipLibCheck": true,
"importHelpers": true,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"allowUnreachableCode": false,
"noImplicitReturns": true,
"exactOptionalPropertyTypes": true,
"noImplicitThis": true,
"noPropertyAccessFromIndexSignature": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"strictPropertyInitialization": true,
"target": "ES2022",
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"noEmitHelpers": true,
"noUncheckedIndexedAccess": true,
"outDir": "./dist",
"baseUrl": "./src",
"incremental": true,
"strictNullChecks": true,
"skipLibCheck": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"strict": true
"strictNullChecks": true
},
"include": [
"src/**/*"
Expand Down
76 changes: 76 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2737,6 +2737,14 @@
"@typescript-eslint/types" "6.4.1"
"@typescript-eslint/visitor-keys" "6.4.1"

"@typescript-eslint/[email protected]":
version "7.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.13.1.tgz#c08041206904bf36f0e6997efdb0ca775e0c452e"
integrity sha512-adbXNVEs6GmbzaCpymHQ0MB6E4TqoiVbC0iqG3uijR8ZYfpAXMGttouQzF4Oat3P2GxDVIrg7bMI/P65LiQZdg==
dependencies:
"@typescript-eslint/types" "7.13.1"
"@typescript-eslint/visitor-keys" "7.13.1"

"@typescript-eslint/[email protected]":
version "6.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.17.0.tgz#5febad3f523e393006614cbda28b826925b728d5"
Expand All @@ -2757,6 +2765,11 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.4.1.tgz#b2c61159f46dda210fed9f117f5d027f65bb5c3b"
integrity sha512-zAAopbNuYu++ijY1GV2ylCsQsi3B8QvfPHVqhGdDcbx/NK5lkqMnCGU53amAjccSpk+LfeONxwzUhDzArSfZJg==

"@typescript-eslint/[email protected]":
version "7.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.13.1.tgz#787db283bd0b58751094c90d5b58bbf5e9fc9bd8"
integrity sha512-7K7HMcSQIAND6RBL4kDl24sG/xKM13cA85dc7JnmQXw2cBDngg7c19B++JzvJHRG3zG36n9j1i451GBzRuHchw==

"@typescript-eslint/[email protected]":
version "6.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.17.0.tgz#b913d19886c52d8dc3db856903a36c6c64fd62aa"
Expand Down Expand Up @@ -2784,6 +2797,20 @@
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/[email protected]":
version "7.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.13.1.tgz#3412841b130e070db2f675e3d9b8cb1ae49e1c3f"
integrity sha512-uxNr51CMV7npU1BxZzYjoVz9iyjckBduFBP0S5sLlh1tXYzHzgZ3BR9SVsNed+LmwKrmnqN3Kdl5t7eZ5TS1Yw==
dependencies:
"@typescript-eslint/types" "7.13.1"
"@typescript-eslint/visitor-keys" "7.13.1"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
minimatch "^9.0.4"
semver "^7.6.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/[email protected]":
version "6.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.17.0.tgz#f2b16d4c9984474656c420438cdede7eccd4079e"
Expand All @@ -2810,6 +2837,16 @@
"@typescript-eslint/typescript-estree" "6.4.1"
semver "^7.5.4"

"@typescript-eslint/utils@^7.0.0":
version "7.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.13.1.tgz#611083379caa0d3a2c09d126c65065a3e4337ba2"
integrity sha512-h5MzFBD5a/Gh/fvNdp9pTfqJAbuQC4sCN2WzuXme71lqFJsZtLbjxfSk4r3p02WIArOF9N94pdsLiGutpDbrXQ==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
"@typescript-eslint/scope-manager" "7.13.1"
"@typescript-eslint/types" "7.13.1"
"@typescript-eslint/typescript-estree" "7.13.1"

"@typescript-eslint/[email protected]":
version "6.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.17.0.tgz#3ed043709c39b43ec1e58694f329e0b0430c26b6"
Expand All @@ -2826,6 +2863,14 @@
"@typescript-eslint/types" "6.4.1"
eslint-visitor-keys "^3.4.1"

"@typescript-eslint/[email protected]":
version "7.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.13.1.tgz#9c229a795a919db61f2d7f2337ef584ac05fbe96"
integrity sha512-k/Bfne7lrP7hcb7m9zSsgcBmo+8eicqqfNAJ7uUY+jkTFpKeH2FSkWpFRtimBxgkyvqfu9jTPRbYOvud6isdXA==
dependencies:
"@typescript-eslint/types" "7.13.1"
eslint-visitor-keys "^3.4.3"

"@ungap/structured-clone@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406"
Expand Down Expand Up @@ -5000,6 +5045,15 @@ eslint-plugin-canonical@^4.18.0:
ts-unused-exports "^9.0.3"
xregexp "^5.1.1"

eslint-plugin-deprecation@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-deprecation/-/eslint-plugin-deprecation-3.0.0.tgz#c0b6bce543c2a01f231d39a1c54fdfebf3560d48"
integrity sha512-JuVLdNg/uf0Adjg2tpTyYoYaMbwQNn/c78P1HcccokvhtRphgnRjZDKmhlxbxYptppex03zO76f97DD/yQHv7A==
dependencies:
"@typescript-eslint/utils" "^7.0.0"
ts-api-utils "^1.3.0"
tslib "^2.3.1"

eslint-plugin-es-x@^7.5.0:
version "7.5.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-es-x/-/eslint-plugin-es-x-7.5.0.tgz#d08d9cd155383e35156c48f736eb06561d07ba92"
Expand Down Expand Up @@ -7515,6 +7569,11 @@ locate-path@^6.0.0:
dependencies:
p-locate "^5.0.0"

lodash-es@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee"
integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==

lodash.capitalize@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/lodash.capitalize/-/lodash.capitalize-4.2.1.tgz#f826c9b4e2a8511d84e3aca29db05e1a4f3b72a9"
Expand Down Expand Up @@ -7834,6 +7893,13 @@ minimatch@^8.0.2:
dependencies:
brace-expansion "^2.0.1"

minimatch@^9.0.4:
version "9.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51"
integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==
dependencies:
brace-expansion "^2.0.1"

minimist@^1.2.0, minimist@^1.2.6:
version "1.2.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
Expand Down Expand Up @@ -9275,6 +9341,11 @@ semver@^6.0.0, semver@^6.3.0, semver@^6.3.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

semver@^7.6.0:
version "7.6.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.2.tgz#1e3b34759f896e8f14d6134732ce798aeb0c6e13"
integrity sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==

[email protected]:
version "0.18.0"
resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be"
Expand Down Expand Up @@ -9988,6 +10059,11 @@ ts-api-utils@^1.0.1:
resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.0.2.tgz#7c094f753b6705ee4faee25c3c684ade52d66d99"
integrity sha512-Cbu4nIqnEdd+THNEsBdkolnOXhg0I8XteoHaEKgvsxpsbWda4IsUut2c187HxywQCvveojow0Dgw/amxtSKVkQ==

ts-api-utils@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.3.0.tgz#4b490e27129f1e8e686b45cc4ab63714dc60eea1"
integrity sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==

ts-jest@^29.1.1:
version "29.1.1"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.1.1.tgz#f58fe62c63caf7bfcc5cc6472082f79180f0815b"
Expand Down

0 comments on commit 79ed159

Please sign in to comment.