Implements dprint formatting library.

This commit is contained in:
Refringe 2023-11-10 11:29:56 -05:00
parent 8c8ccdc787
commit fe614670b7
No known key found for this signature in database
GPG Key ID: 64E03E5F892C6F9E
8 changed files with 202 additions and 123 deletions

2
.gitattributes vendored
View File

@ -1,7 +1,7 @@
############################################################################### ###############################################################################
# Set default behavior to automatically normalize line endings. # Set default behavior to automatically normalize line endings.
############################################################################### ###############################################################################
* text=auto * text=auto eol=lf
############################################################################### ###############################################################################
# Set default behavior for command prompt diff. # Set default behavior for command prompt diff.
# #

9
project/.editorconfig Normal file
View File

@ -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

View File

@ -1,91 +1,65 @@
{ {
"root": true, "root": true,
"parser": "@typescript-eslint/parser", "parser": "@typescript-eslint/parser",
"plugins": [ "plugins": [
"@typescript-eslint" "@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"
], ],
"@typescript-eslint/naming-convention": [ "env": {
"error", "node": true
{ },
"selector": "default", "extends": [
"format": [ "plugin:@typescript-eslint/eslint-recommended"
"camelCase" ],
"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" "rules": {
}, "no-unused-vars": "off",
{ "@typescript-eslint/no-unused-vars": "off"
"selector": "typeLike", }
"format": [ }, {
"PascalCase" "files": [
] "src/loaders/**/*.ts"
},
{
"selector": "objectLiteralProperty",
"format": [
"PascalCase",
"camelCase"
], ],
"leadingUnderscore": "allow" "rules": {
}, "no-var-requires": "off",
{ "@typescript-eslint/no-var-requires": "off",
"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
}
]
}
}

View File

@ -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"
]
}

View File

@ -5,18 +5,27 @@
} }
], ],
"extensions": { "extensions": {
"recommendations": ["dbaeumer.vscode-eslint"], "recommendations": [
"EditorConfig.EditorConfig",
"Jota0222.multi-formatter",
"dbaeumer.vscode-eslint",
"dprint.dprint",
"biomejs.biome"
]
}, },
"settings": { "settings": {
"window.title": "SPT-AKI Server", "window.title": "SPT-AKI Server",
"editor.formatOnSave": true,
"editor.defaultFormatter": "dprint.dprint",
"multiFormatter.formatterList": [
"dprint.dprint",
"biomejs.biome"
],
"[typescript]": { "[typescript]": {
"editor.formatOnSave": true, "editor.codeActionsOnSave": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint" "quickfix.biome": false,
}, "source.organizeImports.biome": true
"eslint.validate": ["typescript"], }
"editor.codeActionsOnSave": {
"source.organizeImports": false,
"source.fixAll.eslint": true
} }
}, }
} }

View File

@ -6,7 +6,7 @@
} }
}, },
"organizeImports": { "organizeImports": {
"enabled": false "enabled": true
}, },
"linter": { "linter": {
"enabled": true, "enabled": true,
@ -26,7 +26,7 @@
"noExplicitAny": "off", "noExplicitAny": "off",
"noDoubleEquals": "warn", "noDoubleEquals": "warn",
"noShadowRestrictedNames": "warn", "noShadowRestrictedNames": "warn",
"noEmptyInterface":"off" "noEmptyInterface": "off"
}, },
"performance": { "performance": {
"noDelete": "off" "noDelete": "off"
@ -39,13 +39,30 @@
"useSimplifiedLogicExpression": "warn", "useSimplifiedLogicExpression": "warn",
"useOptionalChain": "warn" "useOptionalChain": "warn"
} }
}, }
},
"formatter": {
"enabled": false
},
"files": {
"ignore": [ "ignore": [
"**/*.js", "**/*.js",
"**/*.json", "**/*.json",
"**/*.mjs", "**/*.d.ts",
"**/Dockerfile.*", "**/Dockerfile.*",
"**/node_modules/**/*" "**/.git/**/*",
"**/.vscode/**/*",
"**/node_modules/**/*",
"**/build/**/*",
"**/obj/**/*",
"**/dist/**/*",
"**/user/**/*",
"**/logs/**/*",
"**/assets/**/*",
"**/Aki_Data/**/*",
"**/types/**/*",
"**/tests/__cache__/**/*",
"**/tests/__coverage__/**/*"
] ]
} }
} }

87
project/dprint.json Normal file
View File

@ -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"
]
}

View File

@ -14,6 +14,8 @@
"check:circular": "madge --circular --ts-config tsconfig.json --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": "biome ci src --formatter-enabled=false --max-diagnostics=200",
"lint:fix": "eslint --fix --ext .ts src/**", "lint:fix": "eslint --fix --ext .ts src/**",
"style": "dprint check --incremental=false",
"style:fix": "dprint fmt --incremental=false",
"test": "vitest run", "test": "vitest run",
"test:watch": "vitest", "test:watch": "vitest",
"test:coverage": "vitest run --coverage", "test:coverage": "vitest run --coverage",
@ -61,6 +63,7 @@
"@vitest/coverage-istanbul": "1.0.0-beta.3", "@vitest/coverage-istanbul": "1.0.0-beta.3",
"@vitest/ui": "1.0.0-beta.3", "@vitest/ui": "1.0.0-beta.3",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"dprint": "0.42.5",
"eslint": "8.51.0", "eslint": "8.51.0",
"gulp": "4.0.2", "gulp": "4.0.2",
"gulp-execa": "5.0.1", "gulp-execa": "5.0.1",