Skip to content

Commit

Permalink
feat: update eslint dependencies and add eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
SmartNetAR committed Feb 6, 2022
1 parent 51eac50 commit 89d3921
Show file tree
Hide file tree
Showing 66 changed files with 238 additions and 324 deletions.
15 changes: 13 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ module.exports = {
],
'rules': {
indent: 'off',
'@typescript-eslint/indent': ['error', 4],
'@typescript-eslint/indent': ['error', 4,
{
"ignoredNodes": [
"FunctionExpression > .params[decorators.length > 0]",
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
]
}
],
'quotes': ['warn', 'single'],
'semi': ['warn', 'always'],
'semi-spacing': ['warn', {'before': false, 'after': true}],
Expand All @@ -43,6 +51,8 @@ module.exports = {
'space-before-function-paren': ['warn', 'never'],
'keyword-spacing': ['warn', {'before': true}],
'linebreak-style': ['error', 'unix'],
"padded-blocks": ["error", "never"],
"eol-last": ["error","always"],
'brace-style': ['error', 'allman'],
'prefer-const': ['warn'],
'max-len': [
Expand Down Expand Up @@ -133,7 +143,8 @@ module.exports = {
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-unsafe-call': 0,
'@typescript-eslint/require-await': 0,
"@typescript-eslint/type-annotation-spacing": "warn",
"@typescript-eslint/no-unsafe-argument": "warn",
'no-mixed-spaces-and-tabs': 0
}
};

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"envalid": "^7.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-prefer-arrow": "^1.2.3",
"express": "^4.17.1",
"express-handlebars": "^5.3.0",
Expand Down Expand Up @@ -156,11 +156,11 @@
"@types/uuid": "^8.3.0",
"@types/validator": "^13.7.0",
"@types/web-push": "^3.3.0",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"concurrently": "^6.3.0",
"cpy-cli": "^3.1.1",
"eslint": "^7.32.0",
"eslint": "^8.8.0",
"husky": "^7.0.4",
"jest": "^27.4.5",
"lint-staged": "^11.2.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ class RedisCacheRepository implements ICacheRepository
}
}

export default RedisCacheRepository;
export default RedisCacheRepository;
4 changes: 2 additions & 2 deletions src/App/InterfaceAdapters/IByOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { PopulateOptions } from 'mongoose';

interface IByOptions
{
initThrow? : boolean | undefined;
initThrow?: boolean | undefined;
populate?: string | PopulateOptions | PopulateOptions[] | undefined;
}

export default IByOptions;
export default IByOptions;
2 changes: 1 addition & 1 deletion src/App/InterfaceAdapters/IId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ interface IId
_id?: string | any;
}

export default IId;
export default IId;
2 changes: 1 addition & 1 deletion src/App/InterfaceAdapters/IKind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ interface IKind
king: string;
}

export default IKind;
export default IKind;
6 changes: 3 additions & 3 deletions src/App/Presentation/Shared/ErrorHttpException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ErrorHttpException extends Error
this._metadata = metadata;
}

public get statusCode() : IStatusCode
public get statusCode(): IStatusCode
{
return this._statusCode;
}
Expand All @@ -28,7 +28,7 @@ class ErrorHttpException extends Error
this._statusCode = value;
}

public get errors() : ValidationError[]
public get errors(): ValidationError[]
{
return this._errors;
}
Expand All @@ -38,7 +38,7 @@ class ErrorHttpException extends Error
this._errors = err;
}

public get metadata() : Record<string, any>
public get metadata(): Record<string, any>
{
return this._metadata;
}
Expand Down
3 changes: 0 additions & 3 deletions src/App/Tests/index.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ describe('Start Index Test', () =>

request = configServer.request;
dbConnection = configServer.dbConnection;

});

afterAll((async() =>
{
await dbConnection.drop();
await dbConnection.close();

}));

describe('#get', () =>
Expand All @@ -29,7 +27,6 @@ describe('Start Index Test', () =>
{
const response: any = await request.get('/');
expect(response.statusCode).toStrictEqual(200);

});
});
});
22 changes: 0 additions & 22 deletions src/App/Tests/whiteList.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ describe('White list routes Test', () =>

request = configServer.request;
dbConnection = configServer.dbConnection;

});

afterAll((async() =>
{
await dbConnection.drop();
await dbConnection.close();

}));

describe('all', () =>
Expand All @@ -29,35 +27,30 @@ describe('White list routes Test', () =>
{
const response: any = await request.get('/test/all/12345678');
expect(response.statusCode).toStrictEqual(200);

});

test('post', async() =>
{
const response: any = await request.post('/test/all/hello/world');
expect(response.statusCode).toStrictEqual(200);

});

test('put', async() =>
{
const response: any = await request.put('/test/all/numeric/123');
expect(response.statusCode).toStrictEqual(200);

});

test('delete', async() =>
{
const response: any = await request.delete('/test/all/12345678/delete');
expect(response.statusCode).toStrictEqual(200);

});

test('query', async() =>
{
const response: any = await request.get('/test/all/query?hola=mundo&hello=world');
expect(response.statusCode).toStrictEqual(200);

});
});

Expand All @@ -67,48 +60,40 @@ describe('White list routes Test', () =>
{
const response: any = await request.get('/test/countries');
expect(response.statusCode).toStrictEqual(200);

});

test('query', async() =>
{
const response: any = await request.get('/test/countries?status=true');
expect(response.statusCode).toStrictEqual(200);

});
});

describe('dynamic', () =>
{

test('equal', async() =>
{
const response: any = await request.get('/test/countries/12345678');
expect(response.statusCode).toStrictEqual(200);

});

test('one', async() =>
{
const response: any = await request.get('/test/countries/12345678/states');
expect(response.statusCode).toStrictEqual(200);

});

test('two', async() =>
{
const response: any = await request.get('/test/countries/12345678/states/12345678/cities');
expect(response.statusCode).toStrictEqual(200);

});

test('query', async() =>
{
const response: any = await request.get('/test/countries/12345678/states?status=true');
expect(response.statusCode).toStrictEqual(200);

});

});

describe('untidy', () =>
Expand All @@ -119,16 +104,13 @@ describe('White list routes Test', () =>
{
const response: any = await request.get('/test/12345678/hello/all');
expect(response.statusCode).toStrictEqual(403);

});

test('query', async() =>
{
const response: any = await request.get('/test/12345678/hello/all?status=true');
expect(response.statusCode).toStrictEqual(403);

});

});

describe('dynamic', () =>
Expand All @@ -137,17 +119,13 @@ describe('White list routes Test', () =>
{
const response: any = await request.get('/test/cities/12345678/countries/12345678/states');
expect(response.statusCode).toStrictEqual(403);

});

test('query', async() =>
{
const response: any = await request.get('/test/cities/12345678/countries/12345678/states?status=true');
expect(response.statusCode).toStrictEqual(403);

});

});

});
});
2 changes: 1 addition & 1 deletion src/Auth/Domain/Services/AuthService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import MainConfig from '../../../Config/mainConfig';
class AuthService
{
@containerFactory(REPOSITORIES.IUserRepository)
private userRepository: IUserRepository
private userRepository: IUserRepository;

private config = MainConfig.getInstance();

Expand Down
2 changes: 1 addition & 1 deletion src/Auth/Domain/Types/TypeAuth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

declare type TypeAuth = 'authUser' | 'tokenDecode';

export default TypeAuth;
export default TypeAuth;
2 changes: 1 addition & 1 deletion src/Auth/InterfaceAdapters/IGroupPermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ interface IGroupPermission
permissions: string[];
}

export default IGroupPermission;
export default IGroupPermission;
2 changes: 1 addition & 1 deletion src/Auth/Presentation/Controllers/AuthController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AuthController
return await useCase.handle(request, authUser);
}

public async logout(tokenDecode:ITokenDecode): Promise<ILocaleMessage>
public async logout(tokenDecode: ITokenDecode): Promise<ILocaleMessage>
{
const useCase = new LogoutUseCase();
return await useCase.handle(tokenDecode);
Expand Down
1 change: 0 additions & 1 deletion src/Auth/Tests/forgotPassword.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('Start ForgotPassword Test', () =>
{
await dbConnection.drop();
await dbConnection.close();

}));

describe('ForgotPassword Success', () =>
Expand Down
4 changes: 0 additions & 4 deletions src/Auth/Tests/keepAlive.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ describe('Start Keep Alive Test', () =>

request = configServer.request;
dbConnection = configServer.dbConnection;

});

afterAll((async() =>
{
await dbConnection.drop();
await dbConnection.close();

}));

describe('Keep Alive Success', () =>
Expand All @@ -41,7 +39,6 @@ describe('Start Keep Alive Test', () =>
const { body: { data } } = response;

token = data.token;

});

test.skip('Keep Alive POST /', async() =>
Expand All @@ -59,7 +56,6 @@ describe('Start Keep Alive Test', () =>
expect(statusCode).toStrictEqual('HTTP_CREATED');

token = refreshToken;

});
});
});
Expand Down
5 changes: 0 additions & 5 deletions src/Auth/Tests/login.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('Start Login Test', () =>

request = configServer.request;
dbConnection = configServer.dbConnection;

});

afterAll((async() =>
Expand Down Expand Up @@ -42,7 +41,6 @@ describe('Start Login Test', () =>

expect(data.user.email).toStrictEqual('[email protected]');
expect(data.user.firstName).toStrictEqual('user');

});

test('Login SuperAdmin Success', async() =>
Expand All @@ -65,7 +63,6 @@ describe('Start Login Test', () =>

expect(data.user.email).toStrictEqual('[email protected]');
expect(data.user.firstName).toStrictEqual('Super');

});

test('Login SuperAdmin Wrong Credentials', async() =>
Expand All @@ -87,7 +84,6 @@ describe('Start Login Test', () =>
expect(statusCode).toStrictEqual('HTTP_FORBIDDEN');

expect(message).toStrictEqual('Error credentials.');

});

test('Login Operator unverified', async() =>
Expand Down Expand Up @@ -130,6 +126,5 @@ describe('Start Login Test', () =>
expect(statusCode).toStrictEqual('HTTP_FORBIDDEN');

expect(message).toStrictEqual('Your role is disable.');

});
});
Loading

0 comments on commit 89d3921

Please sign in to comment.