diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c73a105aa..bff883416 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -5,6 +5,7 @@ "stylelint.vscode-stylelint", "streetsidesoftware.code-spell-checker", "dbaeumer.vscode-eslint", - "esbenp.prettier-vscode" + "esbenp.prettier-vscode", + "biomejs.biome" ] } diff --git a/biome.json b/biome.json new file mode 100644 index 000000000..ddc8cd40c --- /dev/null +++ b/biome.json @@ -0,0 +1,26 @@ +{ + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "organizeImports": { + "enabled": false + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentSize": 2, + "lineWidth": 240, + "ignore": ["dist", "dist_electron", "release", "*.ejs", "index.html"] + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "complexity": { "useLiteralKeys": "off" } + }, + "ignore": ["dist", "dist_electron", "release", "*.ejs", "index.html"] + }, + "javascript": { + "formatter": { + "quoteStyle": "double" + } + } +} diff --git a/package.json b/package.json index 5ff44bcc6..2bd01121c 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "tga": "^1.0.7" }, "devDependencies": { + "@biomejs/biome": "1.2.2", "@intlify/unplugin-vue-i18n": "^1.2.0", "@types/archiver": "^5.3.3", "@types/auto-launch": "^5.0.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 33077f036..6fef1a7f5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,6 +22,9 @@ dependencies: version: 1.0.7 devDependencies: + '@biomejs/biome': + specifier: 1.2.2 + version: 1.2.2 '@intlify/unplugin-vue-i18n': specifier: ^1.2.0 version: 1.2.0(vue-i18n@9.4.1) @@ -577,6 +580,74 @@ packages: to-fast-properties: 2.0.0 dev: true + /@biomejs/biome@1.2.2: + resolution: {integrity: sha512-fXwXi56ZdaKO/N3rTmhWw41UxstoviODk+wia4WWNSlm23r8xJ/NxjaZ88scV2IsmsFHqc8rmwb2dkrStAdIEw==} + engines: {node: '>=14.*'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@biomejs/cli-darwin-arm64': 1.2.2 + '@biomejs/cli-darwin-x64': 1.2.2 + '@biomejs/cli-linux-arm64': 1.2.2 + '@biomejs/cli-linux-x64': 1.2.2 + '@biomejs/cli-win32-arm64': 1.2.2 + '@biomejs/cli-win32-x64': 1.2.2 + dev: true + + /@biomejs/cli-darwin-arm64@1.2.2: + resolution: {integrity: sha512-Fx1IURKhoqH6wPawtKLT6wcfMSjRRcNK8+VWau0iDOjXvNtjJpSmICbU89B7Vt/gZRwPqkfDMBkFwm6V5vFTSQ==} + engines: {node: '>=14.*'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-darwin-x64@1.2.2: + resolution: {integrity: sha512-JNaAFOI/ZisnmzvcFNd73geJxaFaN2L4YsWM6cgBeKyLY/ycl9C/PBTFfEmeB1c7f5XIIal8P2cj47kLJpN5Ig==} + engines: {node: '>=14.*'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-linux-arm64@1.2.2: + resolution: {integrity: sha512-JHXRnfhOLx8UO/Fcyn2c5pFRri0XKqRZm2wf5oH5GSfLVpckDw2X15dYGbu3nmfM/3pcAaTV46pUpjrCnaAieg==} + engines: {node: '>=14.*'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-linux-x64@1.2.2: + resolution: {integrity: sha512-5Zr+iM7lUKsw81p9PkXRESuH2/AhRZ6RCWkgE+FSLcxMhXy/4RDR+o2YQDsJM6cWKIzOJM05vDHTGrDq7vXE4A==} + engines: {node: '>=14.*'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-win32-arm64@1.2.2: + resolution: {integrity: sha512-HvUcG2p++RvYP0zfOqh+DgiUUH+JI/uETr0kzWlOJ9F3lsG525pkywg4RSd4OvJd7Wpd3wt3UpN/A4IEJaVmbA==} + engines: {node: '>=14.*'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-win32-x64@1.2.2: + resolution: {integrity: sha512-bfaFJwqJ9ApFga2o88OaROSd3pasYRzRGXHJWAE9VUUKdSNSTYxHOqVrNvV54yYPtL6Kt9xkuZa4HNu9it3TaA==} + engines: {node: '>=14.*'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@csstools/css-parser-algorithms@2.3.1(@csstools/css-tokenizer@2.2.0): resolution: {integrity: sha512-xrvsmVUtefWMWQsGgFffqWSK03pZ1vfDki4IVIIUxxDKnGBzqNgv0A7SB1oXtVNEkcVO8xi1ZrTL29HhSu5kGA==} engines: {node: ^14 || ^16 || >=18} diff --git a/src/libs/gif2tga.ts b/src/libs/gif2tga.ts index 7e569a11c..9a46097d1 100644 --- a/src/libs/gif2tga.ts +++ b/src/libs/gif2tga.ts @@ -32,18 +32,20 @@ function calculateBestSize(width, height, count) { } function calculateFileSize( - width, - height, - pages, - scaling, - useSkipFrames, - skipFrames, + _width: number, + _height: number, + _pages: number, + scaling: number, + useSkipFrames: boolean, + skipFrames: number, ) { + let pages = _pages; + if (useSkipFrames) { - pages = Math.floor(pages * (1 - 1 / skipFrames)); + pages = Math.floor(_pages * (1 - 1 / skipFrames)); } - width = Math.round(width * scaling); - height = Math.round(height * scaling); + const width = Math.round(_width * scaling); + const height = Math.round(_height * scaling); const cols = calculateBestSize(width, height, pages); const rows = Math.ceil(pages / cols); return { @@ -69,9 +71,11 @@ async function convert( useSkipFrames, skipFrames, destination, - fileBuffer, + _fileBuffer, ) { try { + let fileBuffer = _fileBuffer; + if (fileBuffer === undefined) { fileBuffer = await fs.promises.readFile(filename); } diff --git a/src/libs/stopmotion.ts b/src/libs/stopmotion.ts index 3d372af1f..3a8682827 100644 --- a/src/libs/stopmotion.ts +++ b/src/libs/stopmotion.ts @@ -264,6 +264,7 @@ const serializationMapping: SerializationMapping = [ function replaceNonASCIICharacters(inputString: string): string { // eslint-disable-next-line no-control-regex + // biome-ignore lint/suspicious/noControlCharactersInRegex: return inputString.replace(/[^\x00-\x7F]/g, "?"); } @@ -277,16 +278,19 @@ function applySerializationMapping(inputString: string): string { return result; } -function serializeValue(value: any, serializedArray: string[]): void { +function serializeValue( + value: string | number, + serializedArray: string[], +): void { const valueType = typeof value; if (valueType === "string") { const processedValue = applySerializationMapping( - replaceNonASCIICharacters(value), + replaceNonASCIICharacters(value as string), ); serializedArray.push("^S", processedValue); } else if (valueType === "number") { - serializedArray.push(`^N${value}`); + serializedArray.push(`^N${value.toString()}`); } else if (valueType === "boolean") { serializedArray.push(value ? "^B" : "^b"); } else if (valueType === "object" || Array.isArray(value)) { @@ -304,7 +308,7 @@ function serializeValue(value: any, serializedArray: string[]): void { } } -function serialize(input: any): string { +function serialize(input: string | number): string { const serializedArray: string[] = ["^1"]; serializeValue(input, serializedArray); return `${serializedArray.join("")}^^`; diff --git a/src/libs/wago-push-handler.ts b/src/libs/wago-push-handler.ts index d413dadcb..6c9abd183 100644 --- a/src/libs/wago-push-handler.ts +++ b/src/libs/wago-push-handler.ts @@ -7,6 +7,7 @@ import type { ConfigState, Version } from "@/stores/config"; interface WagoApiResponse { data: string; status: number; + // biome-ignore lint/suspicious/noExplicitAny: [Symbol.iterator](): Iterator; }