Skip to content

chore: install biomejs cli #7139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"files": {
"maxSize": 16000000,
"includes": ["{packages,lib,scripts,tests}/**/*.{mjs,js,ts,json}", "!**/dist-{cjs,es,types}/**", "!**/ruleset.ts"]
},
"formatter": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've turned many rules off initially because we need to establish that biome is runnable in our build systems before reintroducing rules that would lead to code changes.

"enabled": true,
"indentStyle": "space",
"lineWidth": 120,
"indentWidth": 2,
"lineEnding": "lf",
"bracketSpacing": true,
"bracketSameLine": false
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
},
"linter": {
"rules": {
"recommended": true,
"complexity": {
"noForEach": "off"
},
"correctness": {
"noUndeclaredVariables": "off",
"noUnusedVariables": "info",
"noInvalidBuiltinInstantiation": "error",
"noSwitchDeclarations": "info",
"noUnusedFunctionParameters": "info"
},
"style": {
"noNamespace": "error",
"useConsistentArrayType": {
"level": "info",
"options": {
"syntax": "shorthand"
}
},
"noParameterAssign": "info",
"useAsConstAssertion": "info",
"useDefaultParameterLast": "info",
"useEnumInitializers": "error",
"useSingleVarDeclarator": "error",
"noUnusedTemplateLiteral": "info",
"useNumberNamespace": "info",
"noInferrableTypes": "info",
"noUselessElse": "info"
},
"nursery": {
"useIterableCallbackReturn": "off"
},
"suspicious": {
"noEmptyBlockStatements": "info",
"noExplicitAny": "info",
"noImplicitAnyLet": "info",
"noEmptyBlock": "info",
"noEmptyInterface": "info",
"noAssignInExpressions": "info",
"noSparseArray": "info",
"noShadowRestrictedNames": "info"
}
}
},
"javascript": {
"formatter": {
"trailingCommas": "es5"
}
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
}
}
26 changes: 26 additions & 0 deletions clients/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"extends": "//",
"files": {
"maxSize": 16000000,
"includes": ["**/*.{mjs,js,ts,json}", "!**/dist-{cjs,es,types}/**", "!**/ruleset.ts"]
},
"linter": {
"rules": {
"recommended": true,
"complexity": {
"noForEach": "off"
},
"correctness": {
"noUndeclaredVariables": "off",
"noUnusedVariables": "off",
"noInvalidBuiltinInstantiation": "error",
"noSwitchDeclarations": "off",
"noUnusedFunctionParameters": "off"
},
"style": "off",
"nursery": "off",
"suspicious": "off"
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because biome requires that subconfiguration must also be named biome.json rather than allowing a pointer to a custom config file, and that it must sit in the folder it has control over, I had to edit several scripts that scan the clients folder to exclude this file.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
},
"license": "UNLICENSED",
"devDependencies": {
"@biomejs/biome": "2.0.0",
"@biomejs/cli-darwin-arm64": "2.0.0",
"@biomejs/cli-linux-x64-musl": "2.0.0",
"@commitlint/cli": "17.0.2",
"@commitlint/config-conventional": "17.0.2",
"@cucumber/cucumber": "8.5.3",
Expand Down
25 changes: 25 additions & 0 deletions private/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"extends": "//",
"files": {
"maxSize": 16000000,
"includes": ["**/*.{mjs,js,ts,json}", "!**/dist-{cjs,es,types}/**", "!**/ruleset.ts"]
},
"linter": {
"rules": {
"recommended": true,
"complexity": {
"noForEach": "off"
},
"correctness": {
"noUndeclaredVariables": "off",
"noUnusedVariables": "off",
"noInvalidBuiltinInstantiation": "error",
"noSwitchDeclarations": "off"
},
"style": "off",
"nursery": "off",
"suspicious": "off"
}
}
}
5 changes: 3 additions & 2 deletions scripts/byte-count/get-cjs-byte-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { readdirSync, statSync, rmSync, writeFileSync } = require("fs");
const { spawnProcess } = require("../utils/spawn-process");
const walk = require("../utils/walk");
const assert = require("assert");
const { listFolders } = require("../utils/list-folders");

/**
*
Expand All @@ -20,7 +21,7 @@ locations.clients = join(locations.root, "clients");
(async () => {
const packs = [];

for await (const clientFolderName of readdirSync(locations.clients)) {
for await (const clientFolderName of listFolders(locations.clients)) {
const clientLocation = join(locations.clients, clientFolderName);
const clientPkgJsonLocation = join(clientLocation, "package.json");
const pkg = require(clientPkgJsonLocation);
Expand Down Expand Up @@ -50,7 +51,7 @@ locations.clients = join(locations.root, "clients");
let bytes = 0;
const packFiles = [];

for await (file of walk(locations.clients)) {
for await (const file of walk(locations.clients)) {
if (file.includes("aws-sdk-client-") && file.endsWith(".tgz")) {
bytes += statSync(file).size;
packFiles.push(file);
Expand Down
11 changes: 6 additions & 5 deletions scripts/cli-dispatcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const readline = require("readline");
const findFolders = require("./lib/findFolders");
const findScripts = require("./lib/findScripts");
const Package = require("./lib/Package");
const { listFolders } = require("../utils/list-folders");

/**
* This script takes your command line arguments and infers the
Expand All @@ -21,16 +22,16 @@ async function main() {
const root = path.join(__dirname, "..", "..");
const argv = process.argv;

const clients = fs.readdirSync(path.join(root, "clients"));
const lib = fs.readdirSync(path.join(root, "lib"));
const packages = fs.readdirSync(path.join(root, "packages"));
const private = fs.readdirSync(path.join(root, "private"));
const clients = listFolders(path.join(root, "clients"));
const lib = listFolders(path.join(root, "lib"));
const packages = listFolders(path.join(root, "packages"));
const _private = listFolders(path.join(root, "private"));

const allPackages = [
...clients.map((c) => new Package(c, path.join(root, "clients", c))),
...lib.map((l) => new Package(l, path.join(root, "lib", l))),
...packages.map((p) => new Package(p, path.join(root, "packages", p))),
...private.map((p) => new Package(p, path.join(root, "private", p))),
..._private.map((p) => new Package(p, path.join(root, "private", p))),
];

const [node, dispatcher, ...rest] = argv;
Expand Down
11 changes: 6 additions & 5 deletions scripts/compilation/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
const fs = require("fs");
const path = require("path");
const Inliner = require("./Inliner");
const { listFolders } = require("../utils/list-folders");

const root = path.join(__dirname, "..", "..");

const package = process.argv[2];
const _package = process.argv[2];

if (!package) {
if (!_package) {
/**
* If no package is selected, this script sets build:cjs scripts to
* use this inliner script instead of only tsc.
*/
const packages = fs.readdirSync(path.join(root, "packages")).map((pkg) => ({
const packages = listFolders(path.join(root, "packages")).map((pkg) => ({
pkgJsonFilePath: path.join(root, "packages", pkg, "package.json"),
pkg,
}));
Expand All @@ -30,7 +31,7 @@ if (!package) {
);

packages.push(
...fs.readdirSync(path.join(root, "clients")).map((pkg) => ({
...listFolders(path.join(root, "clients")).map((pkg) => ({
pkgJsonFilePath: path.join(root, "clients", pkg, "package.json"),
pkg,
}))
Expand All @@ -43,7 +44,7 @@ if (!package) {
}
} else {
(async () => {
const inliner = new Inliner(package);
const inliner = new Inliner(_package);
await inliner.clean();
await inliner.tsc();
await inliner.discoverVariants();
Expand Down
9 changes: 5 additions & 4 deletions scripts/compilation/set-nocheck.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const fs = require("node:fs");
const path = require("node:path");
const { listFolders } = require("../utils/list-folders");

const root = path.join(__dirname, "..", "..");

for (const packageFolder of [
...fs.readdirSync(path.join(root, "lib")).map((f) => path.join(root, "lib", f)),
...fs.readdirSync(path.join(root, "packages")).map((f) => path.join(root, "packages", f)),
...fs.readdirSync(path.join(root, "clients")).map((f) => path.join(root, "clients", f)),
...fs.readdirSync(path.join(root, "private")).map((f) => path.join(root, "private", f)),
...listFolders(path.join(root, "lib"), false),
...listFolders(path.join(root, "packages"), false),
...listFolders(path.join(root, "clients"), false),
...listFolders(path.join(root, "private"), false),
]) {
console.log(packageFolder);

Expand Down
7 changes: 4 additions & 3 deletions scripts/npm-registry/mark-version-as-latest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
*/
//

import readline from "readline";
import { fileURLToPath } from "node:url";
import fs from "fs";
import path, { dirname } from "path";
import { fileURLToPath } from "node:url";
import readline from "readline";
import { listFolders } from "../utils/list-folders.js";
import { spawnProcessReturnValue } from "../utils/spawn-process.js";

const __dirname = dirname(fileURLToPath(import.meta.url));
Expand All @@ -34,7 +35,7 @@ const root = path.join(__dirname, "..", "..");
const packages = [];

function recordPackages(dir) {
const packageFolders = fs.readdirSync(dir);
const packageFolders = listFolders(dir);
for (const packageFolder of packageFolders) {
const pkgJson = JSON.parse(fs.readFileSync(path.join(dir, packageFolder, "package.json"), "utf-8"));
packages.push(pkgJson.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ const _private = path.join(root, "private");
const topLevelFolders = [packages, _private];
const packageFolders = [];
const walk = require("../utils/walk");
const { listFolders } = require("../utils/list-folders");

for (const topLevelFolder of topLevelFolders) {
packageFolders.push(...fs.readdirSync(topLevelFolder));
packageFolders.push(...listFolders(topLevelFolder));
}

const node_libraries = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,21 @@

const fs = require("fs");
const path = require("path");
const { listFolders } = require("../utils/list-folders");

const root = path.join(__dirname, "..", "..");

const clients = fs.readdirSync(path.join(root, "clients"));
const lib = fs.readdirSync(path.join(root, "lib"));
const packages = fs.readdirSync(path.join(root, "packages"));
const _private = fs.readdirSync(path.join(root, "private"));
const clients = listFolders(path.join(root, "clients"), false);
const lib = listFolders(path.join(root, "lib"), false);
const packages = listFolders(path.join(root, "packages"), false);
const _private = listFolders(path.join(root, "private"), false);

const setCanonicalVersion = process.argv.includes("--set-smithy-version");
const colocatedSmithy = fs.existsSync(path.join(root, "..", "smithy-typescript", "packages"));

const clientPackages = [
...clients.map((c) => path.join(root, "clients", c)),
..._private.filter((p) => !p.endsWith("-test")).map((p) => path.join(root, "private", p)),
];
const clientPackages = [...clients, ..._private.filter((p) => !p.endsWith("-test"))];

const nonClientPackages = [
...lib.map((l) => path.join(root, "lib", l)),
...packages.map((p) => path.join(root, "packages", p)),
..._private.filter((p) => p.endsWith("-test")).map((p) => path.join(root, "private", p)),
];
const nonClientPackages = [...lib, ...packages, ..._private.filter((p) => p.endsWith("-test"))];

const deps = {
/* @namespace/name: {
Expand Down
25 changes: 25 additions & 0 deletions scripts/utils/list-folders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const fs = require("node:fs");
const path = require("node:path");

/**
* @param dir - directory.
* @param basenameOnly - if true, return only the basename of the subdirectories
* @returns {string[]} list of full-paths of subdirectories (not files) in the given directory.
*/
function listFolders(dir, basenameOnly = true) {
const folders = [];
for (const fileSystemEntry of fs.readdirSync(dir, { withFileTypes: true })) {
if (fileSystemEntry.isDirectory()) {
if (basenameOnly) {
folders.push(fileSystemEntry.name);
} else {
folders.push(path.join(dir, fileSystemEntry.name));
}
}
}
return folders;
}

module.exports = {
listFolders,
};
11 changes: 4 additions & 7 deletions scripts/validation/package-graph-analyzer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require("node:fs");
const path = require("node:path");
const { listFolders } = require("../utils/list-folders");

const root = path.join(__dirname, "..", "..");
const packages = path.join(root, "packages");
Expand All @@ -26,7 +27,6 @@ const clients = path.join(root, "clients");

if (pkgJson.private !== true) {
throw new Error("package in reserved folder is not marked private:", folder);
} else {
}
}
}
Expand All @@ -36,16 +36,13 @@ const clients = path.join(root, "clients");
*/
{
const hasPkgJson = (subfolder, pkg) => fs.existsSync(path.join(subfolder, pkg, "package.json"));
const packagesData = fs
.readdirSync(packages)
const packagesData = listFolders(packages)
.filter(hasPkgJson.bind(null, "packages"))
.map((pkg) => require(path.join(packages, pkg, "package.json")));
const libsData = fs
.readdirSync(libs)
const libsData = listFolders(libs)
.filter(hasPkgJson.bind(null, "libs"))
.map((pkg) => require(path.join(libs, pkg, "package.json")));
const clientsData = fs
.readdirSync(clients)
const clientsData = listFolders(clients)
.filter(hasPkgJson.bind(null, "clients"))
.map((pkg) => require(path.join(clients, pkg, "package.json")));

Expand Down
Loading
Loading