diff --git a/.gitattributes b/.gitattributes index a32b9f86..a03b251e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,62 +1,7 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### +# Normalize Line Endings * text=auto eol=lf -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain + +# LFS File Listing project/assets/database/locations/interchange/looseLoot.json filter=lfs diff=lfs merge=lfs -text project/assets/database/locations/lighthouse/looseLoot.json filter=lfs diff=lfs merge=lfs -text project/assets/database/locations/shoreline/looseLoot.json filter=lfs diff=lfs merge=lfs -text diff --git a/.gitea/workflows/run-lint.yaml b/.gitea/workflows/run-lint.yaml index 4870b564..fabc8634 100644 --- a/.gitea/workflows/run-lint.yaml +++ b/.gitea/workflows/run-lint.yaml @@ -53,6 +53,7 @@ jobs: - name: Fix Instructions if: failure() && steps.run-tests.outcome == 'failure' run: | - echo -e "Code linting has failed. The linter has been configured to look for coding errors, defects, and questionable patterns. Please look into resolving these errors. The linter may be able to resolve some of these issues automatically. You can launch the automatic fixer by running the following command from within the 'project' directory. Anything not resolved by running this command must be resolved manually.\n\nnpm run lint:fix\n" + echo -e "Code linting has failed. The linter has been configured to look for coding errors, defects, questionable patterns, and code formatting issues. Please look into resolving these errors. The linter may be able to resolve some of these issues automatically. You can launch the automatic fixer by running the following command from within the 'project' directory. Anything not resolved by running this command must be resolved manually.\n\nnpm run lint:fix\n" + echo -e "To automatically format code on-save in your IDE, please install the recommended VSCode plugins listed within the 'project/Server.code-workspace' file.\n" echo -e "Consistency is professionalism.™" shell: bash diff --git a/.gitea/workflows/run-style.yaml b/.gitea/workflows/run-style.yaml deleted file mode 100644 index cdc20708..00000000 --- a/.gitea/workflows/run-style.yaml +++ /dev/null @@ -1,59 +0,0 @@ -name: Check Code Style - -on: - push: - branches: '*' - pull_request: - branches: '*' - -jobs: - dprint: - runs-on: ubuntu-latest - container: - image: refringe/spt-build-node:1.0.7 - steps: - - name: Clone - run: | - rm -rf /workspace/SPT-AKI/Build/server - git clone https://dev.sp-tarkov.com/${GITHUB_REPOSITORY}.git --branch master /workspace/SPT-AKI/Build/server - - cd /workspace/SPT-AKI/Build/server - git checkout ${GITHUB_SHA} - shell: bash - - - name: Pull LFS Files - run: | - cd /workspace/SPT-AKI/Build/server - git lfs pull - git lfs ls-files - shell: bash - - - name: Cache NPM Dependencies - id: cache-npm-dependencies - uses: actions/cache@v4 - with: - path: /workspace/SPT-AKI/Build/server/project/node_modules - key: npm-dependencies-${{ hashFiles('/workspace/SPT-AKI/Build/server/project/package.json') }} - - - name: Install NPM Dependencies - if: steps.cache-npm-dependencies.outputs.cache-hit != 'true' - run: | - cd /workspace/SPT-AKI/Build/server/project - rm -rf node_modules - npm install - shell: bash - - - name: Check Code Style - id: check-code-style - run: | - cd /workspace/SPT-AKI/Build/server/project - npm run style - shell: bash - - - name: Fix Instructions - if: failure() && steps.check-code-style.outcome == 'failure' - run: | - echo -e "The code style check has failed. To fix this, please ensure your code adheres to the project's style guidelines. You can automatically format the project code by running the following command from within the 'project' directory.\n\nnpm run style:fix\n" - echo -e "To automatically format code on-save in your IDE, please install the recommended VSCode plugins listed within the 'project/Server.code-workspace' file.\n" - echo -e "Thank you for keeping our house clean. ♥" - shell: bash diff --git a/README.md b/README.md index de26217d..b1cebba3 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,7 @@ This project has been built in [Visual Studio Code](https://code.visualstudio.co There are a number of VSC extensions that we recommended for this project. VSC will prompt you to install these when you open the workspace file. If you do not see the prompt, you can install them manually: - [EditorConfig](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) - Editor Settings Synchronization -- [Dprint Code Formatter](https://marketplace.visualstudio.com/items?itemName=dprint.dprint) - Formatting on Save - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - Linting for Coding Issues & Naming Conventions -- [Biome](https://marketplace.visualstudio.com/items?itemName=biomejs.biome) - Linting for Coding Standards - [Vitest](https://marketplace.visualstudio.com/items?itemName=vitest.explorer) - Debugging Tests - [SPT ID Highlighter](https://marketplace.visualstudio.com/items?itemName=refringe.spt-id-highlighter) - Converts IDs to Names @@ -54,26 +52,24 @@ 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 | Description | -|--------------------------|----------------------------------------------------------------------| -| `check:circular` | Check for circular dependencies in the project. | -| `lint` | Lint the project for coding standards. | -| `lint:fix` | Attempt to automatically fix coding standard issues. | -| `style` | Check the project for style/formatting issues. | -| `style:fix` | Attempt to automatically fix style/formatting issues. | -| `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 and style/formatting issues. | +| `lint:fix` | Automatically fix coding standard issues and style/formatting issues. | +| `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. | ### Debugging @@ -83,7 +79,7 @@ To debug the project in Visual Studio Code, you can select the `Run` tab and the To debug a server mod in Visual Studio Code, you can copy the mod files into the `user/mods` folder and then start the server in [debug mode](#debugging). You should now be able to set breakpoints in the mod's Typescript files and they will be hit when the server runs the mod files. -## Contributing +## Contributing We're really excited that you're interested in contributing! Before submitting your contribution, please consider the following: @@ -111,7 +107,7 @@ We're really excited that you're interested in contributing! Before submitting y ### Style Guide -We use Dprint to enforce a consistent code style. Please run `npm run style` and/or `npm run style:fix` before submitting your changes. This is made easier by using the recommended VSC extensions to automatically format your code whenever you save a file. +We use ESLint Stylistic to enforce a consistent code style. Please run `npm run lint` and/or `npm run lint:fix` before submitting your changes. This is made easier by using the recommended VSC extensions to automatically format your code whenever you save a file. ### Tests diff --git a/project/.editorconfig b/project/.editorconfig index a3284cad..04dc276e 100644 --- a/project/.editorconfig +++ b/project/.editorconfig @@ -7,3 +7,6 @@ charset = utf-8 indent_style = space indent_size = 4 max_line_length = 120 + +[*.md] +trim_trailing_whitespace = false diff --git a/project/.eslintignore b/project/.eslintignore index 0761328e..607008c7 100644 --- a/project/.eslintignore +++ b/project/.eslintignore @@ -1,5 +1,5 @@ # Exclude these folders from linting -node_modules +node_modules/ out/ obj/ build/ @@ -12,4 +12,4 @@ user/mods/ *.ico *.jpg *.txt -*.exe \ No newline at end of file +*.exe diff --git a/project/.eslintrc.json b/project/.eslintrc.json index 72de65ff..2923eff8 100644 --- a/project/.eslintrc.json +++ b/project/.eslintrc.json @@ -1,23 +1,34 @@ { - "root": true, - "parser": "@typescript-eslint/parser", - "plugins": [ - "@typescript-eslint" - ], - "env": { - "node": true - }, "extends": [ - "plugin:@typescript-eslint/eslint-recommended" + "plugin:@typescript-eslint/recommended", + "plugin:@stylistic/recommended-extends", + "plugin:import/recommended", + "plugin:import/typescript" ], + "plugins": [ + "@typescript-eslint", + "@stylistic", + "import" + ], + "settings": { + "import/resolver": { + "typescript": { + "project": "tsconfig.json" + }, + "node": { + "extensions": [".ts", ".mjs"] + } + } + }, "rules": { - "brace-style": ["error", "allman"], - "@typescript-eslint/no-namespace": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-dynamic-delete": "off", + "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-empty-interface": "off", - "@typescript-eslint/no-explicit-any": "off", // We use a bunch of these. - "@typescript-eslint/no-unused-vars": "off", // Typescript compiler already checks--Will grey out variable. "@typescript-eslint/no-var-requires": "error", - "@typescript-eslint/explicit-module-boundary-types": ["error", { "allowArgumentsExplicitlyTypedAsAny": true }], + "@typescript-eslint/explicit-module-boundary-types": ["error", { + "allowArgumentsExplicitlyTypedAsAny": true + }], "@typescript-eslint/naming-convention": ["error", { "selector": "default", "format": ["camelCase"], @@ -40,24 +51,63 @@ "selector": "property", "modifiers": ["readonly", "static"], "format": ["UPPER_CASE"] + }], + "@stylistic/indent": ["error", 4, { "MemberExpression": 1, "SwitchCase": 1 }], + "@stylistic/brace-style": ["error", "allman", { "allowSingleLine": false }], + "@stylistic/semi": ["error", "always"], + "@stylistic/quotes": ["error", "double", { "avoidEscape": true }], + "@stylistic/linebreak-style": ["error", "unix"], + "@stylistic/max-len": ["error", { + "code": 120, + "tabWidth": 4, + "ignoreComments": true, + "ignoreTrailingComments": true, + "ignoreUrls": true, + "ignoreStrings": true, + "ignoreTemplateLiterals": true, + "ignoreRegExpLiterals": true + }], + "@stylistic/multiline-ternary": ["error", "always-multiline"], + "@stylistic/no-extra-parens": ["error", "all"], + "@stylistic/new-parens": "error", + "@stylistic/newline-per-chained-call": ["error", { "ignoreChainWithDepth": 3 }], + "@stylistic/no-extra-semi": "error", + "@stylistic/no-floating-decimal": "error", + "@stylistic/no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1 }], + "@stylistic/switch-colon-spacing": "error", + "@stylistic/type-annotation-spacing": "error", + "@stylistic/type-generic-spacing": ["error"], + "@stylistic/type-named-tuple-spacing": ["error"], + "@stylistic/wrap-regex": "error", + "@stylistic/yield-star-spacing": ["error", "both"], + "import/order": ["error", { + "groups": ["builtin", "external", "internal", "parent", "sibling", "index"], + "pathGroups": [ + { + "pattern": "tsyringe", + "group": "builtin", + "position": "before" + } + ], + "newlines-between": "never", + "alphabetize": { + "order": "asc", + "caseInsensitive": true + } }] }, - "overrides": [{ - "files": [ - "src/loaders/**/*.ts" - ], - "rules": { - "@typescript-eslint/no-var-requires": "off" + "overrides": [ + { + "files": ["src/di/**/*.ts"], + "rules": { + "@typescript-eslint/no-extraneous-class": "off" + } + }, + { + "files": ["src/loaders/**/*.ts"], + "rules": { + "@typescript-eslint/no-var-requires": "off" + } } - }, { - "files": [ - "**/vitest.config.ts" - ], - "rules": { - "@typescript-eslint/naming-convention": ["error", { - "selector": "objectLiteralProperty", - "format": null - }] - } - }] + ] } diff --git a/project/.vscode/extensions.json b/project/.vscode/extensions.json index 49f98cc2..547ba280 100644 --- a/project/.vscode/extensions.json +++ b/project/.vscode/extensions.json @@ -1,10 +1,8 @@ { "recommendations": [ "EditorConfig.EditorConfig", - "dprint.dprint", - "dbaeumer.vscode-eslint", - "biomejs.biome", "vitest.explorer", - "refringe.spt-id-highlighter" + "refringe.spt-id-highlighter", + "dbaeumer.vscode-eslint" ] } diff --git a/project/Server.code-workspace b/project/Server.code-workspace index 5ab13e4e..a47cd254 100644 --- a/project/Server.code-workspace +++ b/project/Server.code-workspace @@ -7,9 +7,11 @@ "settings": { "window.title": "SPT-AKI Server", "editor.formatOnSave": true, - "editor.defaultFormatter": "dprint.dprint", - "editor.codeActionsOnSave": [ - "source.organizeImports.biome" - ] + "editor.defaultFormatter": "dbaeumer.vscode-eslint", + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, + "eslint.debug": true, + "eslint.experimental.useFlatConfig": false } } diff --git a/project/biome.json b/project/biome.json deleted file mode 100644 index 0577bbda..00000000 --- a/project/biome.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", - "javascript": { - "parser": { - "unsafeParameterDecoratorsEnabled": true - } - }, - "organizeImports": { - "enabled": true - }, - "linter": { - "enabled": true, - "rules": { - "recommended": true, - "style": { - "useImportType": "off", - "noImplicitBoolean": "off", - "noParameterAssign": "warn", - "useTemplate": "warn", - "useSingleVarDeclarator": "warn" - }, - "a11y": { - "useKeyWithClickEvents": "off", - "useValidAnchor": "warn" - }, - "suspicious": { - "noExplicitAny": "off", - "noDoubleEquals": "warn", - "noShadowRestrictedNames": "warn", - "noEmptyInterface": "off" - }, - "performance": { - "noDelete": "off" - }, - "correctness": { - "noUnnecessaryContinue": "warn" - }, - "complexity": { - "noStaticOnlyClass": "off", - "useSimplifiedLogicExpression": "warn", - "useOptionalChain": "warn" - } - } - }, - "formatter": { - "enabled": false - }, - "files": { - "ignore": [ - "**/*.js", - "**/*.json", - "**/*.d.ts", - "**/Dockerfile.*", - "**/.git/**/*", - "**/.vscode/**/*", - "**/node_modules/**/*", - "**/build/**/*", - "**/obj/**/*", - "**/dist/**/*", - "**/user/**/*", - "**/logs/**/*", - "**/assets/**/*", - "**/Aki_Data/**/*", - "**/types/**/*", - "**/tests/__cache__/**/*", - "**/tests/__coverage__/**/*" - ] - } -} diff --git a/project/dprint.json b/project/dprint.json deleted file mode 100644 index 96405138..00000000 --- a/project/dprint.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "incremental": false, - "lineWidth": 120, - "indentWidth": 4, - "newLineKind": "lf", - "useTabs": false, - "typescript": { - "semiColons": "always", - "quoteStyle": "alwaysDouble", - "quoteProps": "asNeeded", - "useBraces": "always", - "bracePosition": "nextLine", - "singleBodyPosition": "maintain", - "nextControlFlowPosition": "nextLine", - "trailingCommas": "onlyMultiLine", - "operatorPosition": "nextLine", - "preferHanging": false, - "preferSingleLine": true, - "arrowFunction.useParentheses": "force", - "binaryExpression.linePerExpression": false, - "memberExpression.linePerExpression": false, - "typeLiteral.separatorKind": "semiColon", - "enumDeclaration.memberSpacing": "newLine", - "spaceAround": false, - "spaceSurroundingProperties": true, - "objectExpression.spaceSurroundingProperties": true, - "objectPattern.spaceSurroundingProperties": true, - "typeLiteral.spaceSurroundingProperties": true, - "binaryExpression.spaceSurroundingBitwiseAndArithmeticOperator": true, - "commentLine.forceSpaceAfterSlashes": true, - "constructor.spaceBeforeParentheses": false, - "constructorType.spaceAfterNewKeyword": false, - "constructSignature.spaceAfterNewKeyword": false, - "doWhileStatement.spaceAfterWhileKeyword": true, - "module.sortImportDeclarations": "maintain", - "module.sortExportDeclarations": "maintain", - "exportDeclaration.sortNamedExports": "maintain", - "importDeclaration.sortNamedImports": "maintain", - "exportDeclaration.spaceSurroundingNamedExports": false, - "forInStatement.spaceAfterForKeyword": true, - "forOfStatement.spaceAfterForKeyword": true, - "forStatement.spaceAfterForKeyword": true, - "forStatement.spaceAfterSemiColons": true, - "functionDeclaration.spaceBeforeParentheses": false, - "functionExpression.spaceBeforeParentheses": false, - "functionExpression.spaceAfterFunctionKeyword": false, - "getAccessor.spaceBeforeParentheses": false, - "ifStatement.spaceAfterIfKeyword": true, - "importDeclaration.spaceSurroundingNamedImports": true, - "method.spaceBeforeParentheses": false, - "setAccessor.spaceBeforeParentheses": false, - "taggedTemplate.spaceBeforeLiteral": false, - "typeAnnotation.spaceBeforeColon": false, - "typeAssertion.spaceBeforeExpression": false, - "whileStatement.spaceAfterWhileKeyword": true - }, - "json": { - "trailingCommas": "never", - "preferSingleLine": false - }, - "markdown": { - "textWrap": "always", - "emphasisKind": "underscores", - "strongKind": "asterisks" - }, - "dockerfile": {}, - "excludes": [ - "**/*.js", - "**/*.d.ts", - "**/*-lock.json", - "**/.git/**/*", - "**/node_modules/**/*", - "**/build/**/*", - "**/obj/**/*", - "**/dist/**/*", - "**/user/**/*", - "**/logs/**/*", - "**/assets/**/*", - "**/Aki_Data/**/*", - "**/types/**/*", - "**/tests/__cache__/**/*", - "**/tests/__coverage__/**/*" - ], - "plugins": [ - "https://plugins.dprint.dev/typescript-0.88.3.wasm", - "https://plugins.dprint.dev/json-0.19.0.wasm", - "https://plugins.dprint.dev/markdown-0.16.2.wasm", - "https://plugins.dprint.dev/dockerfile-0.3.0.wasm" - ] -} diff --git a/project/package.json b/project/package.json index 6052b048..ac482b37 100644 --- a/project/package.json +++ b/project/package.json @@ -12,10 +12,8 @@ }, "scripts": { "check:circular": "madge --circular --ts-config tsconfig.json --extensions ts ./src/", - "lint": "biome ci src --formatter-enabled=false --max-diagnostics=200", - "lint:fix": "biome check --apply-unsafe --max-diagnostics=200 . && dprint fmt --incremental=false", - "style": "dprint check --incremental=false", - "style:fix": "dprint fmt --incremental=false", + "lint": "eslint src", + "lint:fix": "eslint src --fix", "test": "vitest run", "test:watch": "vitest", "test:coverage": "vitest run --coverage", @@ -32,7 +30,7 @@ }, "dependencies": { "atomically": "~1.7", - "buffer-crc32": "^1.0.0", + "buffer-crc32": "~1.0", "date-fns": "~2.30", "date-fns-tz": "~2.0", "i18n": "~0.15", @@ -51,8 +49,9 @@ "ws": "~8.16" }, "devDependencies": { - "@biomejs/biome": "~1.6", + "@eslint/js": "~9.2", "@pnpm/exe": "8.15.4", + "@stylistic/eslint-plugin": "~1.8", "@swc/cli": "~0.3", "@swc/core": "~1.4", "@types/i18n": "~0.13", @@ -60,15 +59,16 @@ "@types/proper-lockfile": "~4.1", "@types/semver": "~7.5", "@types/ws": "~8.5", - "@typescript-eslint/eslint-plugin": "~7.2", - "@typescript-eslint/parser": "~7.2", + "@typescript-eslint/eslint-plugin": "~7.8", + "@typescript-eslint/parser": "~7.8", "@vitest/coverage-istanbul": "~1.3", "@vitest/ui": "~1.3", "@yao-pkg/pkg": "5.11.5", "@yao-pkg/pkg-fetch": "3.5.9", "cross-env": "~7.0", - "dprint": "~0.45", "eslint": "~8.57", + "eslint-import-resolver-typescript": "~3.6", + "eslint-plugin-import": "~2.29", "fs-extra": "~11.2", "gulp": "~4.0", "gulp-decompress": "~3.0", @@ -82,6 +82,7 @@ "tsconfig-paths": "~4.2", "typedoc": "~0.25", "typemoq": "~2.1", + "typescript-eslint": "~7.8", "vitest": "~1.3" }, "targets": {