Skip to content

Commit

Permalink
Add Biome
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanzilla committed Oct 5, 2023
1 parent 9ba26ed commit a5ac9b8
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"stylelint.vscode-stylelint",
"streetsidesoftware.code-spell-checker",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"biomejs.biome"
]
}
26 changes: 26 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
71 changes: 71 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions src/libs/gif2tga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down
12 changes: 8 additions & 4 deletions src/libs/stopmotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ const serializationMapping: SerializationMapping = [

function replaceNonASCIICharacters(inputString: string): string {
// eslint-disable-next-line no-control-regex
// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
return inputString.replace(/[^\x00-\x7F]/g, "?");
}

Expand All @@ -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)) {
Expand All @@ -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("")}^^`;
Expand Down
1 change: 1 addition & 0 deletions src/libs/wago-push-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { ConfigState, Version } from "@/stores/config";
interface WagoApiResponse {
data: string;
status: number;
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
[Symbol.iterator](): Iterator<any>;
}

Expand Down

0 comments on commit a5ac9b8

Please sign in to comment.