Skip to content

Commit 89810d3

Browse files
committed
Run eslint in codebase
1 parent 3497802 commit 89810d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+432
-474
lines changed

.eslintrc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ module.exports = {
1111
},
1212
ignorePatterns: ['./node_modules/*'],
1313
rules: {
14-
'no-error-on-unmatched-pattern': 'off'
14+
'no-error-on-unmatched-pattern': 'off',
15+
'@typescript-eslint/no-explicit-any': 'off', // TODO: Remove this.
16+
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }]
1517
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
16-
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
18+
// e.g. '@typescript-eslint/explicit-function-return-type': 'off',
1719
}
1820
};

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.json

babel.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
module.exports = {
2-
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript', 'backpack-core/babel']
2+
presets: [
3+
'backpack-core/babel',
4+
'@babel/preset-typescript',
5+
['@babel/preset-env', { targets: { node: 'current' } }]
6+
]
37
};

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@
3838
}
3939
},
4040
"lint-staged": {
41-
"*.{ts, js}": [
42-
"tslint --fix src/**/*.{ts,js} test/**/*.{ts,js}",
43-
"prettier --single-quote --parser typescript --print-width 120 --write scripts/*.ts src/**/*.{ts,js} test/**/*.{ts,js}",
44-
"git add"
41+
"*.{ts,json}": [
42+
"eslint --fix {src,scripts,test}/**/*.{ts,json} --no-error-on-unmatched-pattern"
4543
]
4644
},
4745
"private": true,
@@ -61,6 +59,7 @@
6159
"bookshelf-case-converter-plugin": "^1.0.0",
6260
"chalk": "^2.4.2",
6361
"cors": "^2.8.5",
62+
"date-fns": "^2.11.1",
6463
"dotenv": "^8.2.0",
6564
"express": "^4.17.1",
6665
"helmet": "^3.21.2",
@@ -104,10 +103,10 @@
104103
"eslint-plugin-prettier": "^3.1.2",
105104
"faker": "^4.1.0",
106105
"fork-ts-checker-webpack-plugin": "^2.0.0",
107-
"husky": "^3.0.9",
106+
"husky": "^4.2.3",
108107
"jest": "^24.9.0",
109108
"json-loader": "^0.5.7",
110-
"lint-staged": "^9.4.2",
109+
"lint-staged": "^10.0.9",
111110
"npm-run-all": "^4.1.5",
112111
"prettier": "^2.0.2",
113112
"rimraf": "^3.0.0",

scripts/fake-loader.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import * as factories from '../src/database/factories';
55

66
const { info } = console;
77

8-
(async () => {
8+
function print<T>(data: T): void {
9+
const jsonData = JSON.stringify(data, null, ' ');
10+
11+
info(chalk.green(jsonData));
12+
}
13+
14+
(async (): Promise<void> => {
915
try {
1016
const table = process.argv[2];
1117
const total = +process.argv[3] || 1;
@@ -20,9 +26,3 @@ const { info } = console;
2026
process.exit(1);
2127
}
2228
})();
23-
24-
function print<T>(data: T): void {
25-
const jsonData = JSON.stringify(data, null, ' ');
26-
27-
info(chalk.green(jsonData));
28-
}

scripts/mail-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as mail from '../src/utils/mail';
22

3-
(async () => {
3+
(async (): Promise<void> => {
44
try {
55
await mail.send({
66
to: 'sgr.raee@gmail.com',

src/config/config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export default {
1616
host: process.env.APP_HOST || '127.0.0.1',
1717
environment: process.env.NODE_ENV || 'development',
1818
appUrl: process.env.APP_URL || 'http://localhost:8888',
19-
port: (isTestEnvironment ? process.env.TEST_APP_PORT : process.env.APP_PORT) || '8000',
19+
port:
20+
(isTestEnvironment ? process.env.TEST_APP_PORT : process.env.APP_PORT) ||
21+
'8000',
2022
pagination: {
2123
page: 1,
2224
maxRows: 20
@@ -26,8 +28,10 @@ export default {
2628
accessTokenDuration: process.env.ACCESS_TOKEN_DURATION || '10m',
2729
refreshTokenDuration: process.env.REFRESH_TOKEN_DURATION || '24h',
2830
emailVerificationDuration: process.env.EMAIL_VERIFICATION_DURATION || 24,
29-
accessTokenSecretKey: process.env.ACCESS_TOKEN_SECRET_KEY || '<ACCESS_TOKEN_SECRET_KEY>',
30-
refreshTokenSecretKey: process.env.REFRESH_TOKEN_SECRET_KEY || '<REFRESH_TOKEN_SECRET_KEY>'
31+
accessTokenSecretKey:
32+
process.env.ACCESS_TOKEN_SECRET_KEY || '<ACCESS_TOKEN_SECRET_KEY>',
33+
refreshTokenSecretKey:
34+
process.env.REFRESH_TOKEN_SECRET_KEY || '<REFRESH_TOKEN_SECRET_KEY>'
3135
},
3236
logging: {
3337
dir: process.env.LOGGING_DIR || 'logs',

src/config/knex.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ const dbConfig: Knex.Config = {
1010
timezone: 'UTC',
1111
host: process.env.DB_HOST,
1212
port: +(process.env.DB_PORT || '5432'),
13-
database: process.env.NODE_ENV === 'test' ? process.env.TEST_DB_NAME : process.env.DB_NAME,
13+
database:
14+
process.env.NODE_ENV === 'test'
15+
? process.env.TEST_DB_NAME
16+
: process.env.DB_NAME,
1417
user: process.env.DB_USER,
1518
password: process.env.DB_PASSWORD
1619
}

src/controllers/auth.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ const { messages } = config;
1414
* @param {Response} res
1515
* @param {NextFunction} next
1616
*/
17-
export async function login(req: Request, res: Response, next: NextFunction) {
17+
export async function login(
18+
req: Request,
19+
res: Response,
20+
next: NextFunction
21+
): Promise<void> {
1822
try {
1923
const data = await authService.login(req.body);
2024

@@ -35,7 +39,11 @@ export async function login(req: Request, res: Response, next: NextFunction) {
3539
* @param {Response} res
3640
* @param {NextFunction} next
3741
*/
38-
export async function refresh(_: Request, res: Response, next: NextFunction) {
42+
export async function refresh(
43+
_: Request,
44+
res: Response,
45+
next: NextFunction
46+
): Promise<void> {
3947
try {
4048
const token = String(res.locals.refreshToken);
4149
const jwtPayload = res.locals.jwtPayload as JWTPayload;
@@ -58,7 +66,11 @@ export async function refresh(_: Request, res: Response, next: NextFunction) {
5866
* @param {Response} res
5967
* @param {NextFunction} next
6068
*/
61-
export async function logout(_: Request, res: Response, next: NextFunction) {
69+
export async function logout(
70+
_: Request,
71+
res: Response,
72+
next: NextFunction
73+
): Promise<void> {
6274
try {
6375
const token = String(res.locals.refreshToken);
6476
await authService.logout(token);

src/controllers/home.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import * as HttpStatus from 'http-status-codes';
66
*
77
* @param {Request} req
88
* @param {Response} res
9+
* @returns {void}
910
*/
10-
export function index(req: Request, res: Response) {
11+
export function index(req: Request, res: Response): void {
1112
res.status(HttpStatus.OK).json({
1213
name: req.app.locals.name,
1314
version: req.app.locals.version

0 commit comments

Comments
 (0)