Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cleanup lint warning #1109

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/attachments/attachments.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const mockAttachment: Attachment = {

describe("AttachmentsService", () => {
let service: AttachmentsService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let attachmentModel: Model<Attachment>;

beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from "@nestjs/common";
import { Injectable } from "@nestjs/common";
import { UserPayload } from "../interfaces/userPayload.interface";
import { AccessGroupService } from "./access-group.service";

Expand All @@ -11,10 +11,7 @@ export class AccessGroupFromMultipleProvidersService extends AccessGroupService
super();
}

async getAccessGroups(
//idpPayload: Record<string, unknown>,
userPayload: UserPayload,
): Promise<string[]> {
async getAccessGroups(userPayload: UserPayload): Promise<string[]> {
const accessGroups: string[] = [];

for (const accessGroupProvider of this.accessGroupProviders) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from "@nestjs/common";
import { Injectable } from "@nestjs/common";
import { AccessGroupService } from "./access-group.service";

/**
Expand All @@ -11,10 +11,6 @@ export class AccessGroupFromStaticValuesService extends AccessGroupService {
}

async getAccessGroups(): Promise<string[]> {
// Logger.log(
// "Static access group getAccessGroups : " +
// this.staticAccessGroups.join(","),
// );
return this.staticAccessGroups;
}
}
6 changes: 3 additions & 3 deletions src/auth/auth.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { AuthService } from "./auth.service";
import { ConfigService } from "@nestjs/config";

class AuthServiceMock {
login(req: Record<string, unknown>) {
login() {
return { username: "Test User", email: "[email protected]" };
}

adLogin(req: Record<string, unknown>) {
adLogin() {
return { username: "Test User", email: "[email protected]" };
}

whoami(req: Record<string, unknown>) {
whoami() {
return { username: "Test User", email: "[email protected]" };
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/auth/guards/jwt-auth.guard.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ExecutionContext,
Injectable,
UnauthorizedException,
} from "@nestjs/common";
import { ExecutionContext, Injectable } from "@nestjs/common";
import { Reflector } from "@nestjs/core";
import { AuthGuard } from "@nestjs/passport";

Expand All @@ -26,8 +22,6 @@ export class JwtAuthGuard extends AuthGuard("jwt") {
err: unknown,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
user: any,
info: unknown,
context: ExecutionContext,
) {
// const allowAny = this.reflector.get<string[]>(
// "allow-any",
Expand Down
2 changes: 1 addition & 1 deletion src/auth/strategies/ldap.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class LdapStrategy extends PassportStrategy(Strategy, "ldap") {

const foundUser = await this.usersService.findOne(userFilter);
const jsonUser = JSON.parse(JSON.stringify(foundUser));
const { password, ...user } = jsonUser;
const { ...user } = jsonUser;
user.userId = user._id;

// update user identity if needed
Expand Down
2 changes: 1 addition & 1 deletion src/auth/strategies/oidc.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class OidcStrategy extends PassportStrategy(Strategy, "oidc") {
}

const jsonUser = JSON.parse(JSON.stringify(user));
const { password, ...returnUser } = jsonUser;
const { ...returnUser } = jsonUser;
returnUser.userId = returnUser._id;

return returnUser;
Expand Down
10 changes: 5 additions & 5 deletions src/common/pipes/filter.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PipeTransform, Injectable, ArgumentMetadata } from "@nestjs/common";
import { PipeTransform, Injectable } from "@nestjs/common";

@Injectable()
export class FilterPipe
Expand All @@ -8,10 +8,10 @@ export class FilterPipe
{ filter?: string; fields?: string }
>
{
transform(
inValue: { filter?: string; fields?: string },
metadata: ArgumentMetadata,
): { filter?: string; fields?: string } {
transform(inValue: { filter?: string; fields?: string }): {
filter?: string;
fields?: string;
} {
/*
* intercept filter and make sure to convert loopback operators to mongo operators
*/
Expand Down
15 changes: 0 additions & 15 deletions src/config/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Logger } from "@nestjs/common";
import * as fs from "fs";
import { merge } from "lodash";
import localconfiguration from "./localconfiguration";
Expand Down Expand Up @@ -58,20 +57,6 @@ const configuration = () => {
}
});

// Logger.log("Config SETUP");
// Logger.log("- Access groups statisc values : " + accessGroupsStaticValues);
// Logger.log("- Admin groups : " + adminGroups);
// Logger.log("- Delete groups : " + deleteGroups );
// Logger.log("- Create dataset groups : " + createDatasetGroups);
// Logger.log(
// "- Create dataset with pid groups : " + createDatasetWithPidGroups,
// );
// Logger.log(
// "- Create dataset privileged groups : " + createDatasetPrivilegedGroups,
// );
// Logger.log("- Create job groups : " + createJobGroups);
// Logger.log("- Update job groups : " + updateJobGroups);

const config = {
loggerConfigs: jsonConfigMap.loggers || [defaultLogger],
adminGroups: adminGroups.split(",").map((v) => v.trim()) ?? [],
Expand Down
1 change: 1 addition & 0 deletions src/datablocks/datablocks.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const mockDatablock: Datablock = {

describe("DatablocksService", () => {
let service: DatablocksService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let model: Model<Datablock>;

beforeEach(async () => {
Expand Down
23 changes: 8 additions & 15 deletions src/datasets/datasets.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
InternalServerErrorException,
ConflictException,
BadRequestException,
Header,
} from "@nestjs/common";
import { MongoError } from "mongodb";
import {
Expand Down Expand Up @@ -97,7 +96,6 @@ import { TechniqueClass } from "./schemas/technique.schema";
import { RelationshipClass } from "./schemas/relationship.schema";
import { JWTUser } from "src/auth/interfaces/jwt-user.interface";
import { LogbooksService } from "src/logbooks/logbooks.service";
import { Logbook } from "src/logbooks/schemas/logbook.schema";
import configuration from "src/config/configuration";
import { DatasetType } from "./dataset-type.enum";

Expand Down Expand Up @@ -548,10 +546,7 @@ export class DatasetsController {
@Req() request: Request,
@Body() createDatasetDto: CreateRawDatasetDto | CreateDerivedDatasetDto,
): Promise<{ valid: boolean }> {
const datasetDTO = await this.checkPermissionsForDatasetCreate(
request,
createDatasetDto,
);
await this.checkPermissionsForDatasetCreate(request, createDatasetDto);

const dtoTestRawCorrect = plainToInstance(
CreateRawDatasetDto,
Expand Down Expand Up @@ -923,8 +918,6 @@ export class DatasetsController {
@Headers() headers: Record<string, string>,
@Query(new FilterPipe()) queryFilter: { filter?: string },
): Promise<DatasetClass | null> {
const user: JWTUser = request.user as JWTUser;

const mergedFilters = replaceLikeOperator(
this.updateMergedFiltersForList(
request,
Expand Down Expand Up @@ -1343,7 +1336,7 @@ export class DatasetsController {
@Req() request: Request,
@Param("pid") pid: string,
): Promise<Partial<Attachment>> {
const dataset = await this.checkPermissionsForDatasetExtended(
await this.checkPermissionsForDatasetExtended(
request,
pid,
Action.DatasetRead,
Expand Down Expand Up @@ -1439,7 +1432,7 @@ export class DatasetsController {
@Req() request: Request,
@Param("pid") pid: string,
): Promise<Attachment[]> {
const dataset = await this.checkPermissionsForDatasetExtended(
await this.checkPermissionsForDatasetExtended(
request,
pid,
Action.DatasetAttachmentRead,
Expand Down Expand Up @@ -1483,7 +1476,7 @@ export class DatasetsController {
@Param("aid") aid: string,
@Body() updateAttachmentDto: UpdateAttachmentDto,
): Promise<Attachment | null> {
const dataset = await this.checkPermissionsForDatasetExtended(
await this.checkPermissionsForDatasetExtended(
request,
pid,
Action.DatasetAttachmentUpdate,
Expand Down Expand Up @@ -1527,7 +1520,7 @@ export class DatasetsController {
@Param("pid") pid: string,
@Param("aid") aid: string,
): Promise<unknown> {
const dataset = await this.checkPermissionsForDatasetExtended(
await this.checkPermissionsForDatasetExtended(
request,
pid,
Action.DatasetAttachmentDelete,
Expand Down Expand Up @@ -1637,7 +1630,7 @@ export class DatasetsController {
@Param("pid") pid: string,
@Body() createOrigDatablock: unknown,
): Promise<{ valid: boolean; errors: ValidationError[] }> {
const dataset = await this.checkPermissionsForDatasetExtended(
await this.checkPermissionsForDatasetExtended(
request,
pid,
Action.DatasetOrigdatablockCreate,
Expand Down Expand Up @@ -1682,7 +1675,7 @@ export class DatasetsController {
@Req() request: Request,
@Param("pid") pid: string,
): Promise<OrigDatablock[]> {
const dataset = await this.checkPermissionsForDatasetExtended(
await this.checkPermissionsForDatasetExtended(
request,
pid,
Action.DatasetOrigdatablockRead,
Expand Down Expand Up @@ -1913,7 +1906,7 @@ export class DatasetsController {
@Req() request: Request,
@Param("pid") pid: string,
): Promise<Datablock[]> {
const dataset = await this.checkPermissionsForDatasetExtended(
await this.checkPermissionsForDatasetExtended(
request,
pid,
Action.DatasetDatablockRead,
Expand Down
1 change: 1 addition & 0 deletions src/datasets/datasets.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const mockDataset: DatasetClass = {

describe("DatasetsService", () => {
let service: DatasetsService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let model: Model<DatasetClass>;

beforeEach(async () => {
Expand Down
1 change: 0 additions & 1 deletion src/elastic-search/elastic-search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import { Client } from "@elastic/elasticsearch";
import { SearchQueryService } from "./providers/query-builder.service";
import {
SearchTotalHits,
SearchRequest,
AggregationsAggregate,
SortOrder,
Expand Down
1 change: 1 addition & 0 deletions src/initial-datasets/initial-datasets.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const mockInitialDataset: InitialDataset = {

describe("InitialDatasetsService", () => {
let service: InitialDatasetsService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let initialDatasetModel: Model<InitialDataset>;

beforeEach(async () => {
Expand Down
1 change: 1 addition & 0 deletions src/instruments/instruments.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const mockInstrument: Instrument = {

describe("InstrumentsService", () => {
let service: InstrumentsService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let model: Model<Instrument>;

beforeEach(async () => {
Expand Down
1 change: 1 addition & 0 deletions src/jobs/jobs.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class PoliciesServiceMock {}

describe("JobsService", () => {
let service: JobsService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let model: Model<JobClass>;

beforeEach(async () => {
Expand Down
1 change: 1 addition & 0 deletions src/origdatablocks/origdatablocks.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const mockOrigDatablock: OrigDatablock = {

describe("OrigdatablocksService", () => {
let service: OrigDatablocksService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let model: Model<OrigDatablock>;

beforeEach(async () => {
Expand Down
1 change: 1 addition & 0 deletions src/policies/policies.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const mockPolicy: Policy = {

describe("PoliciesService", () => {
let service: PoliciesService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let policyModel: Model<Policy>;

beforeEach(async () => {
Expand Down
1 change: 1 addition & 0 deletions src/proposals/proposals.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const mockProposal: ProposalClass = {

describe("ProposalsService", () => {
let service: ProposalsService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let model: Model<ProposalClass>;

beforeEach(async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/proposals/schemas/proposal.schema.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { ApiProperty, getSchemaPath } from "@nestjs/swagger";
import { ApiProperty } from "@nestjs/swagger";
import { Document } from "mongoose";
import {
Attachment,
AttachmentSchema,
} from "src/attachments/schemas/attachment.schema";

import { OwnableClass } from "src/common/schemas/ownable.schema";
import {
MeasurementPeriodClass,
Expand Down
3 changes: 1 addition & 2 deletions src/published-data/published-data.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,7 @@ export class PublishedDataController {
@Param("id") id: string,
@Body() data: UpdatePublishedDataDto,
): Promise<IRegister | null> {
// eslint-disable-next-line @typescript-eslint/naming-convention
const { doi, ...publishedData } = data;
const { ...publishedData } = data;

const OAIServerUri = this.configService.get<string>("oaiProviderRoute");

Expand Down
1 change: 1 addition & 0 deletions src/published-data/published-data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const mockPublishedData: PublishedData = {

describe("PublishedDataService", () => {
let service: PublishedDataService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let model: Model<PublishedData>;

beforeEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/published-data/published-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Inject, Injectable, Scope } from "@nestjs/common";
import { REQUEST } from "@nestjs/core";
import { Request } from "express";
import { InjectModel } from "@nestjs/mongoose";
import { FilterQuery, Model, QueryOptions } from "mongoose";
import { FilterQuery, Model } from "mongoose";
import {
parseLimitFilters,
addCreatedByFields,
Expand Down
1 change: 0 additions & 1 deletion src/samples/samples.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ import { Request } from "express";
import { JWTUser } from "src/auth/interfaces/jwt-user.interface";
import { IDatasetFields } from "src/datasets/interfaces/dataset-filters.interface";
import { CreateSubAttachmentDto } from "src/attachments/dto/create-sub-attachment.dto";
import { User } from "src/users/schemas/user.schema";

@ApiBearerAuth()
@ApiTags("samples")
Expand Down
1 change: 1 addition & 0 deletions src/samples/samples.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const mockSample: SampleClass = {

describe("SamplesService", () => {
let service: SamplesService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let sampleModel: Model<SampleClass>;

beforeEach(async () => {
Expand Down
1 change: 1 addition & 0 deletions src/samples/samples.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class SamplesService {
const createdSample = new this.sampleModel(
addCreatedByFields(createSampleDto, username),
);

return createdSample.save();
}

Expand Down
2 changes: 2 additions & 0 deletions src/users/roles.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const mockUserRole: UserRole = {

describe("RolesService", () => {
let service: RolesService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let roleModel: Model<Role>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let userRoleModel: Model<UserRole>;

beforeEach(async () => {
Expand Down
1 change: 1 addition & 0 deletions src/users/user-identities.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const mockUserIdentity: UserIdentity = {

describe("UserIdentitiesService", () => {
let service: UserIdentitiesService;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let userIdentityModel: Model<UserIdentity>;

beforeEach(async () => {
Expand Down
Loading