From f283a2e6a35d600baf0d33ac75432dc23c82575c Mon Sep 17 00:00:00 2001 From: Refringe Date: Wed, 15 Nov 2023 20:33:45 -0500 Subject: [PATCH] Pre-merge Formatting Updates These are the basic config changes that enable auto-formatting. This is being run directly within this branch to prevent a plethora of merge conflicts when `fix/linting-errors` is merged into this branch. --- project/.editorconfig | 9 +++ project/.eslintrc.json | 129 +++++++++++++--------------------- project/Server.code-workspace | 23 +++--- project/biome.json | 36 ++++++++-- project/dprint.json | 90 ++++++++++++++++++++++++ project/package.json | 7 +- 6 files changed, 197 insertions(+), 97 deletions(-) create mode 100644 project/.editorconfig create mode 100644 project/dprint.json diff --git a/project/.editorconfig b/project/.editorconfig new file mode 100644 index 00000000..a3284cad --- /dev/null +++ b/project/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 4 +max_line_length = 120 diff --git a/project/.eslintrc.json b/project/.eslintrc.json index 3653c8e7..1d631e74 100644 --- a/project/.eslintrc.json +++ b/project/.eslintrc.json @@ -2,90 +2,61 @@ "root": true, "parser": "@typescript-eslint/parser", "plugins": [ - "@typescript-eslint" + "@typescript-eslint" ], "env": { - "node": true + "node": true }, "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended" + "plugin:@typescript-eslint/eslint-recommended" ], "rules": { - "semi": [1, "always"], - "@typescript-eslint/no-explicit-any": 0, - "@typescript-eslint/no-unused-vars": 1, - "@typescript-eslint/no-empty-interface": 0, - "@typescript-eslint/no-namespace": 0, - "@typescript-eslint/comma-dangle": 1, - "@typescript-eslint/func-call-spacing": 2, - "@typescript-eslint/quotes": 1, - "@typescript-eslint/brace-style": [ - "error", - "allman" - ], - "@typescript-eslint/naming-convention": [ - "error", - { - "selector": "default", - "format": [ - "camelCase" - ], - "leadingUnderscore": "allow" - }, - { - "selector": "typeLike", - "format": [ - "PascalCase" - ] - }, - { - "selector": "objectLiteralProperty", - "format": [ - "PascalCase", - "camelCase" - ], - "leadingUnderscore": "allow" - }, - { - "selector": "typeProperty", - "format": [ - "PascalCase", - "camelCase" - ], - "leadingUnderscore": "allow" - }, - { - "selector": "enumMember", - "format": [ - "UPPER_CASE" - ] + "@typescript-eslint/no-namespace": "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/naming-convention": ["error", { + "selector": "default", + "format": ["camelCase"], + "leadingUnderscore": "allow" + }, { + "selector": "typeLike", + "format": ["PascalCase"] + }, { + "selector": "objectLiteralProperty", + "format": ["PascalCase", "camelCase", "snake_case"], + "leadingUnderscore": "allow" + }, { + "selector": "typeProperty", + "format": ["PascalCase", "camelCase"], + "leadingUnderscore": "allow" + }, { + "selector": "enumMember", + "format": ["UPPER_CASE"] + }, { + "selector": "property", + "modifiers": ["readonly", "static"], + "format": ["UPPER_CASE"] + }] + }, + "overrides": [{ + "files": [ + "src/loaders/**/*.ts" + ], + "rules": { + "@typescript-eslint/no-var-requires": "off" } - ], - "@typescript-eslint/indent": [ - "error", - 4 - ], - "@typescript-eslint/no-unused-expressions": [ - "error", - { - "allowShortCircuit": false, - "allowTernary": false + }, { + "files": [ + "**/vitest.config.ts" + ], + "rules": { + "@typescript-eslint/naming-convention": ["error", { + "selector": "objectLiteralProperty", + "format": null + }] } - ], - "@typescript-eslint/keyword-spacing": [ - "error", - { - "before": true, - "after": true - } - ], - "@typescript-eslint/explicit-module-boundary-types": [ - "warn", - { - "allowArgumentsExplicitlyTypedAsAny": true - } - ] - } -} \ No newline at end of file + }] +} diff --git a/project/Server.code-workspace b/project/Server.code-workspace index 12291d34..1758f080 100644 --- a/project/Server.code-workspace +++ b/project/Server.code-workspace @@ -5,18 +5,19 @@ } ], "extensions": { - "recommendations": ["dbaeumer.vscode-eslint"], + "recommendations": [ + "EditorConfig.EditorConfig", + "dprint.dprint", + "dbaeumer.vscode-eslint", + "biomejs.biome" + ] }, "settings": { "window.title": "SPT-AKI Server", - "[typescript]": { - "editor.formatOnSave": true, - "editor.defaultFormatter": "dbaeumer.vscode-eslint" - }, - "eslint.validate": ["typescript"], - "editor.codeActionsOnSave": { - "source.organizeImports": false, - "source.fixAll.eslint": true - } - }, + "editor.formatOnSave": true, + "editor.defaultFormatter": "dprint.dprint", + "editor.codeActionsOnSave": [ + "source.organizeImports.biome" + ] + } } diff --git a/project/biome.json b/project/biome.json index ded78fca..8316dc82 100644 --- a/project/biome.json +++ b/project/biome.json @@ -1,5 +1,13 @@ { "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "javascript": { + "parser": { + "unsafeParameterDecoratorsEnabled": true + } + }, + "organizeImports": { + "enabled": true + }, "linter": { "enabled": true, "rules": { @@ -18,7 +26,7 @@ "noExplicitAny": "off", "noDoubleEquals": "warn", "noShadowRestrictedNames": "warn", - "noEmptyInterface":"off" + "noEmptyInterface": "off" }, "performance": { "noDelete": "off" @@ -27,16 +35,34 @@ "noUnnecessaryContinue": "warn" }, "complexity": { + "noStaticOnlyClass": "off", "useSimplifiedLogicExpression": "warn", "useOptionalChain": "warn" } - }, + } + }, + "formatter": { + "enabled": false + }, + "files": { "ignore": [ "**/*.js", "**/*.json", - "**/*.mjs", + "**/*.d.ts", "**/Dockerfile.*", - "**/node_modules/**/*" + "**/.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 new file mode 100644 index 00000000..96405138 --- /dev/null +++ b/project/dprint.json @@ -0,0 +1,90 @@ +{ + "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 f6f37803..bb904aba 100644 --- a/project/package.json +++ b/project/package.json @@ -11,9 +11,11 @@ "node": "18.15.0" }, "scripts": { - "check:circular": "madge --circular --extensions ts ./src/", + "check:circular": "madge --circular --ts-config tsconfig.json --extensions ts ./src/", "lint": "biome ci src --formatter-enabled=false --max-diagnostics=200", - "lint:fix": "eslint --fix --ext .ts src/**", + "lint:fix": "biome check --apply-unsafe --max-diagnostics=200 . && dprint fmt --incremental=false", + "style": "dprint check --incremental=false", + "style:fix": "dprint fmt --incremental=false", "test": "vitest run", "test:watch": "vitest", "test:coverage": "vitest run --coverage", @@ -61,6 +63,7 @@ "@vitest/coverage-istanbul": "1.0.0-beta.3", "@vitest/ui": "1.0.0-beta.3", "cross-env": "7.0.3", + "dprint": "0.42.5", "eslint": "8.51.0", "gulp": "4.0.2", "gulp-execa": "5.0.1",