Skip to content

Commit 94d6d0a

Browse files
VIDSOL-211-chores adding paths aliases and config updates
- adding paths aliases - removing eslint redundant rules - adding type check on dev mode for both backend and frontend - pre-commit husky now type-check, lint-check, run-prettier - removed lint-staged totally unnecessary with husky
1 parent c5e0e3a commit 94d6d0a

File tree

9 files changed

+201
-185
lines changed

9 files changed

+201
-185
lines changed

.husky/pre-commit

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn lint-staged
4+
# Exit on error and unset variables
5+
set -eu
6+
7+
yarn --silent quality-check

.lintstagedrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

backend/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"main": "index.js",
66
"type": "module",
77
"scripts": {
8-
"dev": "tsx watch index.ts",
9-
"start": "node --import tsx index.ts",
10-
"debug": "node --inspect --watch --import tsx index.ts",
8+
"dev": "nodemon --watch . --ext ts,tsx,json --ignore dist --exec \"sh -c 'yarn ts-check && node --import tsx index.ts'\"",
9+
"start": "yarn ts-check && node --import tsx index.ts",
10+
"debug": "nodemon --watch . --ext ts,tsx,json --ignore dist --exec \"sh -c 'yarn ts-check && node --inspect --import tsx index.ts'\"",
1111
"test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest --maxWorkers=1 --coverage",
1212
"test:watch": "yarn test --watch",
13-
"ts-check": "tsc -p tsconfig.json"
13+
"ts-check": "tsc --noEmit -p tsconfig.json --pretty true"
1414
},
1515
"author": "",
1616
"license": "MIT",
@@ -41,6 +41,7 @@
4141
"@types/supertest": "^6.0.2",
4242
"@types/validator": "^13.15.2",
4343
"jest": "^29.7.0",
44+
"nodemon": "^3.1.10",
4445
"supertest": "^7.0.0",
4546
"ts-jest": "^29.1.2"
4647
}

frontend/.eslintrc.cjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,22 @@ module.exports = {
1919
'jsx-a11y/no-static-element-interactions': 'off',
2020
'jsx-a11y/click-events-have-key-events': 'off',
2121
'react/require-default-props': 'off',
22+
23+
'jsdoc/require-jsdoc': 'off', // to keep code base consistency since const functions are not required to have jsdoc,
24+
25+
/*
26+
* Functions and classes are hoisted, so they can be used before their declaration.
27+
*/
28+
'@typescript-eslint/no-use-before-define': ['error', {
29+
functions: false,
30+
classes: false,
31+
variables: true,
32+
}],
33+
34+
'no-redeclare': 'off', // duplicate rule, typescript already checks for this
35+
'@typescript-eslint/no-shadow': 'off', // duplicate rule, typescript already checks for this
36+
'consistent-return': 'off', // this rule goes against standard useEffect patterns,
37+
'tailwindcss/classnames-order': 'off', // this rule forces the changes to be more disruptive than beneficial and prevent grouping classes logically
38+
'no-dupe-class-members': 'off', // duplicate rule, typescript already checks for this
2239
},
2340
};

frontend/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
"version": "1.2.3",
66
"type": "module",
77
"scripts": {
8-
"build": "vite build && yarn cp-build",
8+
"build": "yarn --silent ts-check && vite build && yarn cp-build",
99
"cp-build": "mkdir -p ../backend/dist && cp -r dist ../backend",
10-
"dev": "vite --host",
10+
"dev": "concurrently 'yarn --silent ts-check:watch' 'vite --host'",
1111
"docs": "typedoc",
1212
"docs:watch": "typedoc --watch",
1313
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1414
"preview": "vite preview",
1515
"test": "vitest run --coverage",
1616
"test:watch": "vitest",
17-
"ts-check": "tsc -p tsconfig.json"
17+
"ts-check": "tsc -p tsconfig.json --pretty true",
18+
"ts-check:watch": "yarn --silent ts-check --noEmit --watch --preserveWatchOutput"
1819
},
1920
"dependencies": {
2021
"@emotion/css": "^11.11.2",
@@ -64,6 +65,7 @@
6465
"@types/uuid": "^9.0.8",
6566
"@vitest/coverage-v8": "^1.3.0",
6667
"@vitest/ui": "^1.3",
67-
"jsdom": "^22.1.0"
68+
"jsdom": "^22.1.0",
69+
"vite-plugin-checker": "^0.11.0"
6870
}
6971
}

frontend/tsconfig.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,19 @@
1717
"strict": true,
1818
"noUnusedLocals": false,
1919
"noUnusedParameters": false,
20-
"noFallthroughCasesInSwitch": true
20+
"noFallthroughCasesInSwitch": true,
21+
"paths": {
22+
"@api/*": ["./src/api/*"],
23+
"@components/*": ["./src/components/*"],
24+
"@Context/*": ["./src/Context/*"],
25+
"@hooks/*": ["./src/hooks/*"],
26+
"@locales/*": ["./src/locales/*"],
27+
"@pages/*": ["./src/pages/*"],
28+
"@tests/*": ["./src/tests/*"],
29+
"@app-types/*": ["./src/types/*"],
30+
"@utils/*": ["./src/utils/*"],
31+
"@test/*": ["./src/test/*"]
32+
}
2133
},
2234
"include": [
2335
"./src",

frontend/vite.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { UserConfig as VitestUserConfigInterface } from 'vitest/config';
44
import { defineConfig as defineVitestConfig } from 'vitest/config';
55
import react from '@vitejs/plugin-react';
66
import replace from '@rollup/plugin-replace';
7+
import checker from 'vite-plugin-checker';
78

89
const vitestConfig: VitestUserConfigInterface = defineVitestConfig({
910
test: {
@@ -43,6 +44,24 @@ export default defineConfig(({ mode }) => {
4344
'process.env.CI': process.env.CI,
4445
preventAssignment: true,
4546
}),
47+
checker({
48+
typescript: true,
49+
terminal: true,
50+
}),
4651
],
52+
resolve: {
53+
alias: {
54+
'@api': '/src/api',
55+
'@components': '/src/components',
56+
'@Context': '/src/Context',
57+
'@hooks': '/src/hooks',
58+
'@locales': '/src/locales',
59+
'@pages': '/src/pages',
60+
'@tests': '/src/tests',
61+
'@app-types': '/src/types',
62+
'@utils': '/src/utils',
63+
'@test': '/src/test',
64+
},
65+
},
4766
});
4867
});

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@
1313
"npm": "9.x"
1414
},
1515
"scripts": {
16+
"quality-check": "yarn --silent ts-check && yarn --silent lint:fix",
1617
"build": "yarn workspace frontend build",
1718
"deploy-vcr": "vcr deploy",
18-
"dev": "yarn && concurrently 'yarn workspace frontend dev' 'yarn workspace backend dev'",
19+
"dev:frontend": "yarn workspace frontend dev",
20+
"dev:backend": "yarn workspace backend dev",
21+
"dev": "yarn && concurrently 'yarn dev:frontend' 'yarn dev:backend'",
1922
"docs": "yarn workspace frontend docs",
2023
"docs:watch": "yarn workspace frontend docs:watch",
2124
"lint": "ESLINT_USE_FLAT_CONFIG=false yarn eslint . --ext .ts,.tsx",
2225
"lint:filenames": "./scripts/lintFileNames.sh",
23-
"lint:fix": "yarn prettier --write . && yarn lint --fix",
24-
"postinstall": "husky",
26+
"lint:fix": "prettier --log-level warn --write \"**/*.{ts,tsx,js,json,md,yml,yaml}\" && yarn lint --fix",
27+
"prepare": "husky install",
2528
"run-server": "yarn workspace backend start",
2629
"start": "yarn workspace frontend build && yarn workspace backend start",
2730
"start:backend": "yarn workspace backend dev",
@@ -33,10 +36,10 @@
3336
"test:frontend": "yarn workspace frontend test",
3437
"test:frontend:watch": "yarn workspace frontend test:watch",
3538
"test:integration": "yarn workspace integration-tests test",
36-
"ts-check": "yarn ts-check:backend && yarn ts-check:frontend",
39+
"ts-check": "yarn --silent ts-check:backend && yarn --silent ts-check:frontend",
3740
"test:integrationUpdateScreenshots": "yarn workspace integration-tests updateScreenshots",
38-
"ts-check:backend": "yarn workspace backend ts-check",
39-
"ts-check:frontend": "yarn workspace frontend ts-check"
41+
"ts-check:backend": "yarn --silent workspace backend ts-check",
42+
"ts-check:frontend": "yarn --silent workspace frontend ts-check"
4043
},
4144
"repository": {
4245
"type": "git",
@@ -68,7 +71,6 @@
6871
"eslint-plugin-tailwindcss": "^3.18.0",
6972
"husky": "^9.0.11",
7073
"license-checker": "^25.0.1",
71-
"lint-staged": "^15.2.2",
7274
"concurrently": "^9.1.2",
7375
"prettier": "^3.2.5",
7476
"typescript": "^5.8.3"

0 commit comments

Comments
 (0)