diff --git a/.gitattributes b/.gitattributes index 982110c0..a32b9f86 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,7 @@ ############################################################################### # Set default behavior to automatically normalize line endings. ############################################################################### -* text=auto +* text=auto eol=lf ############################################################################### # Set default behavior for command prompt diff. # 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..a389b7d3 100644 --- a/project/.eslintrc.json +++ b/project/.eslintrc.json @@ -1,91 +1,65 @@ { - "root": true, - "parser": "@typescript-eslint/parser", - "plugins": [ - "@typescript-eslint" - ], - "env": { - "node": true - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-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" + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": [ + "@typescript-eslint" ], - "@typescript-eslint/naming-convention": [ - "error", - { - "selector": "default", - "format": [ - "camelCase" + "env": { + "node": true + }, + "extends": [ + "plugin:@typescript-eslint/eslint-recommended" + ], + "rules": { + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-empty-interface": "off", + "@typescript-eslint/no-namespace": "off", + "@typescript-eslint/no-unused-vars": "error", + "@typescript-eslint/no-var-requires": "error", + "@typescript-eslint/explicit-module-boundary-types": ["error", { "allowArgumentsExplicitlyTypedAsAny": true }], + "@typescript-eslint/naming-convention": ["error", { + "selector": "import", + "format": ["camelCase", "PascalCase", "UPPER_CASE"] + }, { + "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/callbacks/**/*.js", + "src/controllers/**/*.js" ], - "leadingUnderscore": "allow" - }, - { - "selector": "typeLike", - "format": [ - "PascalCase" - ] - }, - { - "selector": "objectLiteralProperty", - "format": [ - "PascalCase", - "camelCase" + "rules": { + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": "off" + } + }, { + "files": [ + "src/loaders/**/*.ts" ], - "leadingUnderscore": "allow" - }, - { - "selector": "typeProperty", - "format": [ - "PascalCase", - "camelCase" - ], - "leadingUnderscore": "allow" - }, - { - "selector": "enumMember", - "format": [ - "UPPER_CASE" - ] - } - ], - "@typescript-eslint/indent": [ - "error", - 4 - ], - "@typescript-eslint/no-unused-expressions": [ - "error", - { - "allowShortCircuit": false, - "allowTernary": false - } - ], - "@typescript-eslint/keyword-spacing": [ - "error", - { - "before": true, - "after": true - } - ], - "@typescript-eslint/explicit-module-boundary-types": [ - "warn", - { - "allowArgumentsExplicitlyTypedAsAny": true - } - ] - } -} \ No newline at end of file + "rules": { + "no-var-requires": "off", + "@typescript-eslint/no-var-requires": "off", + } + }] +} diff --git a/project/.vscode/settings.json b/project/.vscode/settings.json deleted file mode 100644 index 02965ef3..00000000 --- a/project/.vscode/settings.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "editor.defaultFormatter": "dbaeumer.vscode-eslint", - "eslint.format.enable": true, - "editor.codeActionsOnSave": { - "source.fixAll.eslint": true - }, - "[json]": { - "editor.defaultFormatter": "vscode.json-language-features", - "editor.detectIndentation": false, - "editor.tabSize": 4, - "editor.insertSpaces": true - }, - "cSpell.words": [ - "Baseclass", - "IIIA", - "medkit", - "Superfors", - "ULACH" - ] -} diff --git a/project/Server.code-workspace b/project/Server.code-workspace index 12291d34..9e60789a 100644 --- a/project/Server.code-workspace +++ b/project/Server.code-workspace @@ -5,18 +5,27 @@ } ], "extensions": { - "recommendations": ["dbaeumer.vscode-eslint"], + "recommendations": [ + "EditorConfig.EditorConfig", + "Jota0222.multi-formatter", + "dbaeumer.vscode-eslint", + "dprint.dprint", + "biomejs.biome" + ] }, "settings": { "window.title": "SPT-AKI Server", + "editor.formatOnSave": true, + "editor.defaultFormatter": "dprint.dprint", + "multiFormatter.formatterList": [ + "dprint.dprint", + "biomejs.biome" + ], "[typescript]": { - "editor.formatOnSave": true, - "editor.defaultFormatter": "dbaeumer.vscode-eslint" - }, - "eslint.validate": ["typescript"], - "editor.codeActionsOnSave": { - "source.organizeImports": false, - "source.fixAll.eslint": true + "editor.codeActionsOnSave": { + "quickfix.biome": false, + "source.organizeImports.biome": true + } } - }, + } } diff --git a/project/biome.json b/project/biome.json index 60e00327..8316dc82 100644 --- a/project/biome.json +++ b/project/biome.json @@ -6,7 +6,7 @@ } }, "organizeImports": { - "enabled": false + "enabled": true }, "linter": { "enabled": true, @@ -26,7 +26,7 @@ "noExplicitAny": "off", "noDoubleEquals": "warn", "noShadowRestrictedNames": "warn", - "noEmptyInterface":"off" + "noEmptyInterface": "off" }, "performance": { "noDelete": "off" @@ -39,13 +39,30 @@ "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..8853221a --- /dev/null +++ b/project/dprint.json @@ -0,0 +1,87 @@ +{ + "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": "sameLine", + "preferHanging": false, + "preferSingleLine": false, + "arrowFunction.useParentheses": "force", + "binaryExpression.linePerExpression": false, + "memberExpression.linePerExpression": false, + "typeLiteral.separatorKind": "semiColon", + "enumDeclaration.memberSpacing": "newLine", + "spaceAround": false, + "spaceSurroundingProperties": false, + "objectExpression.spaceSurroundingProperties": false, + "objectPattern.spaceSurroundingProperties": false, + "typeLiteral.spaceSurroundingProperties": false, + "binaryExpression.spaceSurroundingBitwiseAndArithmeticOperator": true, + "commentLine.forceSpaceAfterSlashes": true, + "constructor.spaceBeforeParentheses": false, + "constructorType.spaceAfterNewKeyword": false, + "constructSignature.spaceAfterNewKeyword": false, + "doWhileStatement.spaceAfterWhileKeyword": true, + "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", + "**/*.swcrc", + "**/*-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 fda52be9..1893e3d4 100644 --- a/project/package.json +++ b/project/package.json @@ -14,6 +14,8 @@ "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/**", + "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",