-
Notifications
You must be signed in to change notification settings - Fork 584
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: experiment with wasm-fmt/biome
- Loading branch information
Showing
10 changed files
with
110 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,7 @@ | |
"@types/jsdom": "20.0.1", | ||
"@typescript-eslint/eslint-plugin": "5.55.0", | ||
"@typescript-eslint/parser": "5.55.0", | ||
"@wasm-fmt/biome_fmt": "^0.1.12", | ||
"async": "3.2.4", | ||
"concurrently": "7.0.0", | ||
"decomment": "0.9.5", | ||
|
@@ -138,11 +139,7 @@ | |
} | ||
}, | ||
"lint-staged": { | ||
"{lib,packages}/**/src/**/*.ts": [ | ||
"eslint --fix", | ||
"prettier --write" | ||
], | ||
"**/*.{ts,js,md,json}": "prettier --write" | ||
"**/*.{md,json}": "prettier --write" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import init, { format } from "@wasm-fmt/biome_fmt"; | ||
import { promises } from "node:fs"; | ||
import path, { join } from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
|
||
import walk from "./utils/walk.js"; | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
await init(); | ||
|
||
const prettifyCode = async (dir) => { | ||
for await (const file of walk(dir, ["node_modules"])) { | ||
if (file.endsWith(".ts") || file.endsWith(".js")) { | ||
if (file.endsWith("ruleset.ts")) { | ||
continue; | ||
} | ||
promises.readFile(file, "utf-8").then((contents) => { | ||
promises.writeFile( | ||
file, | ||
format(contents, file, { | ||
indent_style: "space", | ||
indent_width: 2, | ||
line_width: 120, | ||
line_ending: "lf", | ||
quote_properties: "as-needed", | ||
arrow_parentheses: "always", | ||
semicolons: "always", | ||
bracket_spacing: true, | ||
bracket_same_line: false, | ||
quote_style: "double", | ||
trailing_comma: "all", | ||
}), | ||
"utf-8" | ||
); | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
prettifyCode(join(__dirname, "..", "clients", "client-s3")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import init from "@wasm-fmt/biome_fmt"; | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
|
||
import { runWasmFmtBiome } from "./run-wasm-fmt-biome.mjs"; | ||
|
||
export const prettifyCode = async (dir) => { | ||
await init(); | ||
|
||
for (const subdirectory of fs.readdirSync(dir)) { | ||
const targets = [path.join(subdirectory, "typescript-codegen"), path.join(subdirectory, "typescript-ssdk-codegen")]; | ||
|
||
for (const target of targets) { | ||
if (fs.existsSync(target) && fs.lstatSync(target).isDirectory()) { | ||
runWasmFmtBiome(target); | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import init, { format } from "@wasm-fmt/biome_fmt"; | ||
import { promises } from "node:fs"; | ||
|
||
import walk from "../utils/walk.js"; | ||
|
||
await init(); | ||
|
||
export const runWasmFmtBiome = async (dir) => { | ||
for await (const file of walk(dir)) { | ||
if (file.endsWith(".ts") || file.endsWith(".js")) { | ||
if (file.endsWith("ruleset.ts")) { | ||
continue; | ||
} | ||
promises.readFile(file, "utf-8").then((contents) => { | ||
promises.writeFile( | ||
file, | ||
format(contents, file, { | ||
indent_style: "space", | ||
indent_width: 2, | ||
line_width: 120, | ||
line_ending: "lf", | ||
quote_properties: "as-needed", | ||
arrow_parentheses: "always", | ||
semicolons: "always", | ||
bracket_spacing: true, | ||
bracket_same_line: false, | ||
quote_style: "double", | ||
trailing_comma: "all", | ||
}), | ||
"utf-8" | ||
); | ||
}); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4016,6 +4016,11 @@ | |
loupe "^2.3.6" | ||
pretty-format "^29.5.0" | ||
|
||
"@wasm-fmt/biome_fmt@^0.1.12": | ||
version "0.1.12" | ||
resolved "https://registry.yarnpkg.com/@wasm-fmt/biome_fmt/-/biome_fmt-0.1.12.tgz#11f239b03b19be9a755006c77183722246c8dfbc" | ||
integrity sha512-2t7UdDh9sQ4JCXLXHfJeeqmeRcijbbgmLQ69sREWuYU7nMp8R/4F9g4bIEvJVvWmA4sNmPRvPJW/i3s5lDS11A== | ||
|
||
"@webassemblyjs/[email protected]": | ||
version "1.11.1" | ||
resolved "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz" | ||
|