mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-12 15:30:44 -05:00
Development Strict Mode (#1006)
- Enables TS strict mode - Adds script to check types - Adds workflow to run check-type script - Updates the code-checking workflows to share the same set-up job This updates the `tsconfig.json` option to enable strict mode. *However*, we use TSX for development and SWC for release, which do not type-check, so this option only gives additional linting/visual-feedback in VSCode. Additionally, I've added a NPM script `npm run lint:types` and a GitHub workflow that runs it. **This depends on #1005.** --------- Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com>
This commit is contained in:
parent
995a3d0c5a
commit
4afc2f5c96
10
.github/workflows/run-lint.yaml
vendored
10
.github/workflows/run-lint.yaml
vendored
@ -23,7 +23,17 @@ jobs:
|
||||
cache: "npm"
|
||||
cache-dependency-path: "project/package.json"
|
||||
|
||||
- name: Check NPM Cache
|
||||
id: cache-check
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('./project/package.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
if: steps.cache-check.outputs.cache-hit != 'true'
|
||||
run: npm install
|
||||
working-directory: ./project
|
||||
|
||||
|
10
.github/workflows/run-test.yaml
vendored
10
.github/workflows/run-test.yaml
vendored
@ -23,7 +23,17 @@ jobs:
|
||||
cache: "npm"
|
||||
cache-dependency-path: "project/package.json"
|
||||
|
||||
- name: Check NPM Cache
|
||||
id: cache-check
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('./project/package.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
if: steps.cache-check.outputs.cache-hit != 'true'
|
||||
run: npm install
|
||||
working-directory: ./project
|
||||
|
||||
|
42
.github/workflows/run-types.yaml
vendored
Normal file
42
.github/workflows/run-types.yaml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: Run Type Check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["*"]
|
||||
pull_request:
|
||||
branches: ["*"]
|
||||
|
||||
jobs:
|
||||
types:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: false
|
||||
|
||||
- name: Checkout LFS
|
||||
run: git lfs pull
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: "./project/.nvmrc"
|
||||
cache: "npm"
|
||||
cache-dependency-path: "./project/package.json"
|
||||
|
||||
- name: Check NPM Cache
|
||||
id: cache-check
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('./project/package.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
if: steps.cache-check.outputs.cache-hit != 'true'
|
||||
run: npm install
|
||||
working-directory: ./project
|
||||
|
||||
- name: Run Type Check
|
||||
run: npm run lint:types
|
||||
working-directory: ./project
|
45
README.md
45
README.md
@ -51,27 +51,30 @@ To prepare the project for development you will need to:
|
||||
|
||||
The following commands are available after the initial setup. Run them with `npm run <command>`.
|
||||
|
||||
| Command | Description |
|
||||
|-----------------------|---------------------------------------------------------------------------|
|
||||
| `check:circular` | Check for circular dependencies in the project. |
|
||||
| `lint` | Check the project for coding standards issues using Biome. |
|
||||
| `lint:fix` | Automatically fix coding standards issues using Biome. |
|
||||
| `style` | Check the project for formatting issues using Biome. |
|
||||
| `style:fix` | Automatically fix formatting issues using Biome. |
|
||||
| `format` | Automatically fix all coding standards and formatting issues using Biome. |
|
||||
| `test` | Run all tests. |
|
||||
| `test:watch` | Run tests in watch mode. Tests will re-run when files are changed. |
|
||||
| `test:coverage` | Run tests and generate a coverage report. |
|
||||
| `test:ui` | Run tests in UI mode. This will open a browser window to view tests. |
|
||||
| `build:release` | Build the project for release. |
|
||||
| `build:debug` | Build the project for debugging. |
|
||||
| `build:bleeding` | Build the project on the bleeding edge. |
|
||||
| `build:bleedingmods` | Build the project on the bleeding edge with mods. |
|
||||
| `run:build` | Run the project in build mode. |
|
||||
| `run:debug` | Run the project in debug mode. |
|
||||
| `run:profiler` | Run the project in profiler mode. |
|
||||
| `gen:types` | Generate types for the project. |
|
||||
| `gen:docs` | Generate documentation for the project. |
|
||||
| Command | Description |
|
||||
|------------------------|---------------------------------------------------------------------------|
|
||||
| `check:circular` | Check for circular dependencies in the project. |
|
||||
| `lint` | Check the project for coding standards issues using Biome. |
|
||||
| `lint:fix` | Automatically fix coding standards issues using Biome. |
|
||||
| `lint:types` | Check for TypeScript compile errors using TSC. |
|
||||
| `style` | Check the project for formatting issues using Biome. |
|
||||
| `style:fix` | Automatically fix formatting issues using Biome. |
|
||||
| `format` | Automatically fix all coding standards and formatting issues using Biome. |
|
||||
| `test` | Run all tests. |
|
||||
| `test:watch` | Run tests in watch mode. Tests will re-run when files are changed. |
|
||||
| `test:coverage` | Run tests and generate a coverage report. |
|
||||
| `test:ui` | Run tests in UI mode. This will open a browser window to view tests. |
|
||||
| `build:release` | Build the project for release. |
|
||||
| `build:debug` | Build the project for debugging. |
|
||||
| `build:bleeding` | Build the project on the bleeding edge. |
|
||||
| `build:bleedingmods` | Build the project on the bleeding edge with mods. |
|
||||
| `run:build` | Run the project in build mode. |
|
||||
| `run:debug` | Run the project in debug mode. |
|
||||
| `run:profiler` | Run the project in profiler mode. |
|
||||
| `gen:types` | Generate types for the project. |
|
||||
| `gen:docs` | Generate documentation for the project. |
|
||||
| `gen:items` | Dynamically generate ItemTpl and Weapons enums. |
|
||||
| `gen:productionquests` | Automatically update properties for production requirements. |
|
||||
|
||||
### Debugging
|
||||
|
||||
|
@ -14,13 +14,14 @@
|
||||
"check:circular": "madge --circular --ts-config tsconfig.json --extensions ts ./src/",
|
||||
"lint": "npx @biomejs/biome lint ./",
|
||||
"lint:fix": "npx @biomejs/biome lint --write ./",
|
||||
"lint:types": "tsc --noEmit",
|
||||
"style": "npx @biomejs/biome format ./",
|
||||
"style:fix": "npx @biomejs/biome format --write ./",
|
||||
"format": "npx @biomejs/biome check --write ./",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"test:ui": "vitest --ui --coverage",
|
||||
"test": "npx vitest run",
|
||||
"test:watch": "npx vitest",
|
||||
"test:coverage": "npx vitest run --coverage",
|
||||
"test:ui": "npx vitest --ui --coverage",
|
||||
"build:release": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:release",
|
||||
"build:debug": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:debug",
|
||||
"build:bleeding": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:bleeding",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"moduleDetection": "force",
|
||||
"module": "Preserve",
|
||||
"resolveJsonModule": true,
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"strict": false,
|
||||
"noEmit": false,
|
||||
"emitDeclarationOnly": true,
|
||||
"declaration": true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user