Skip to content

Commit 85810a4

Browse files
committed
chore: install biomejs cli
1 parent 0fd639b commit 85810a4

File tree

14 files changed

+292
-40
lines changed

14 files changed

+292
-40
lines changed

biome.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
3+
"files": {
4+
"maxSize": 16000000,
5+
"includes": ["{packages,lib,scripts,tests}/**/*.{mjs,js,ts,json}", "!**/dist-{cjs,es,types}/**", "!**/ruleset.ts"]
6+
},
7+
"formatter": {
8+
"enabled": true,
9+
"indentStyle": "space",
10+
"lineWidth": 120,
11+
"indentWidth": 2,
12+
"lineEnding": "lf",
13+
"bracketSpacing": true,
14+
"bracketSameLine": false
15+
},
16+
"assist": {
17+
"enabled": true,
18+
"actions": {
19+
"source": {
20+
"organizeImports": "on"
21+
}
22+
}
23+
},
24+
"linter": {
25+
"rules": {
26+
"recommended": true,
27+
"complexity": {
28+
"noForEach": "off"
29+
},
30+
"correctness": {
31+
"noUndeclaredVariables": "off",
32+
"noUnusedVariables": "info",
33+
"noInvalidBuiltinInstantiation": "error",
34+
"noSwitchDeclarations": "info",
35+
"noUnusedFunctionParameters": "info"
36+
},
37+
"style": {
38+
"noNamespace": "error",
39+
"useConsistentArrayType": {
40+
"level": "info",
41+
"options": {
42+
"syntax": "shorthand"
43+
}
44+
},
45+
"noParameterAssign": "info",
46+
"useAsConstAssertion": "info",
47+
"useDefaultParameterLast": "info",
48+
"useEnumInitializers": "error",
49+
"useSingleVarDeclarator": "error",
50+
"noUnusedTemplateLiteral": "info",
51+
"useNumberNamespace": "info",
52+
"noInferrableTypes": "info",
53+
"noUselessElse": "info"
54+
},
55+
"nursery": {
56+
"useIterableCallbackReturn": "off"
57+
},
58+
"suspicious": {
59+
"noEmptyBlockStatements": "info",
60+
"noExplicitAny": "info",
61+
"noImplicitAnyLet": "info",
62+
"noEmptyBlock": "info",
63+
"noEmptyInterface": "info",
64+
"noAssignInExpressions": "info",
65+
"noSparseArray": "info",
66+
"noShadowRestrictedNames": "info"
67+
}
68+
}
69+
},
70+
"javascript": {
71+
"formatter": {
72+
"trailingCommas": "es5"
73+
}
74+
},
75+
"vcs": {
76+
"enabled": true,
77+
"clientKind": "git",
78+
"useIgnoreFile": true
79+
}
80+
}

clients/biome.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
3+
"extends": "//",
4+
"files": {
5+
"maxSize": 16000000,
6+
"includes": ["**/*.{mjs,js,ts,json}", "!**/dist-{cjs,es,types}/**", "!**/ruleset.ts"]
7+
},
8+
"linter": {
9+
"rules": {
10+
"recommended": true,
11+
"complexity": {
12+
"noForEach": "off"
13+
},
14+
"correctness": {
15+
"noUndeclaredVariables": "off",
16+
"noUnusedVariables": "off",
17+
"noInvalidBuiltinInstantiation": "error",
18+
"noSwitchDeclarations": "off",
19+
"noUnusedFunctionParameters": "off"
20+
},
21+
"style": "off",
22+
"nursery": "off",
23+
"suspicious": "off"
24+
}
25+
}
26+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
},
6363
"license": "UNLICENSED",
6464
"devDependencies": {
65+
"@biomejs/biome": "^2.0.0",
66+
"@biomejs/cli-darwin-arm64": "^2.0.0",
67+
"@biomejs/cli-linux-x64-musl": "^2.0.0",
6568
"@commitlint/cli": "17.0.2",
6669
"@commitlint/config-conventional": "17.0.2",
6770
"@cucumber/cucumber": "8.5.3",

private/biome.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
3+
"extends": "//",
4+
"files": {
5+
"maxSize": 16000000,
6+
"includes": ["**/*.{mjs,js,ts,json}", "!**/dist-{cjs,es,types}/**", "!**/ruleset.ts"]
7+
},
8+
"linter": {
9+
"rules": {
10+
"recommended": true,
11+
"complexity": {
12+
"noForEach": "off"
13+
},
14+
"correctness": {
15+
"noUndeclaredVariables": "off",
16+
"noUnusedVariables": "off",
17+
"noInvalidBuiltinInstantiation": "error",
18+
"noSwitchDeclarations": "off"
19+
},
20+
"style": "off",
21+
"nursery": "off",
22+
"suspicious": "off"
23+
}
24+
}
25+
}

scripts/byte-count/get-cjs-byte-count.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { readdirSync, statSync, rmSync, writeFileSync } = require("fs");
55
const { spawnProcess } = require("../utils/spawn-process");
66
const walk = require("../utils/walk");
77
const assert = require("assert");
8+
const { listFolders } = require("../utils/list-folders");
89

910
/**
1011
*
@@ -20,7 +21,7 @@ locations.clients = join(locations.root, "clients");
2021
(async () => {
2122
const packs = [];
2223

23-
for await (const clientFolderName of readdirSync(locations.clients)) {
24+
for await (const clientFolderName of listFolders(locations.clients)) {
2425
const clientLocation = join(locations.clients, clientFolderName);
2526
const clientPkgJsonLocation = join(clientLocation, "package.json");
2627
const pkg = require(clientPkgJsonLocation);
@@ -50,7 +51,7 @@ locations.clients = join(locations.root, "clients");
5051
let bytes = 0;
5152
const packFiles = [];
5253

53-
for await (file of walk(locations.clients)) {
54+
for await (const file of walk(locations.clients)) {
5455
if (file.includes("aws-sdk-client-") && file.endsWith(".tgz")) {
5556
bytes += statSync(file).size;
5657
packFiles.push(file);

scripts/cli-dispatcher/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const readline = require("readline");
77
const findFolders = require("./lib/findFolders");
88
const findScripts = require("./lib/findScripts");
99
const Package = require("./lib/Package");
10+
const { listFolders } = require("../utils/list-folders");
1011

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

24-
const clients = fs.readdirSync(path.join(root, "clients"));
25-
const lib = fs.readdirSync(path.join(root, "lib"));
26-
const packages = fs.readdirSync(path.join(root, "packages"));
27-
const private = fs.readdirSync(path.join(root, "private"));
25+
const clients = listFolders(path.join(root, "clients"));
26+
const lib = listFolders(path.join(root, "lib"));
27+
const packages = listFolders(path.join(root, "packages"));
28+
const _private = listFolders(path.join(root, "private"));
2829

2930
const allPackages = [
3031
...clients.map((c) => new Package(c, path.join(root, "clients", c))),
3132
...lib.map((l) => new Package(l, path.join(root, "lib", l))),
3233
...packages.map((p) => new Package(p, path.join(root, "packages", p))),
33-
...private.map((p) => new Package(p, path.join(root, "private", p))),
34+
..._private.map((p) => new Package(p, path.join(root, "private", p))),
3435
];
3536

3637
const [node, dispatcher, ...rest] = argv;

scripts/compilation/inline.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
const fs = require("fs");
88
const path = require("path");
99
const Inliner = require("./Inliner");
10+
const { listFolders } = require("../utils/list-folders");
1011

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

13-
const package = process.argv[2];
14+
const _package = process.argv[2];
1415

15-
if (!package) {
16+
if (!_package) {
1617
/**
1718
* If no package is selected, this script sets build:cjs scripts to
1819
* use this inliner script instead of only tsc.
1920
*/
20-
const packages = fs.readdirSync(path.join(root, "packages")).map((pkg) => ({
21+
const packages = listFolders(path.join(root, "packages")).map((pkg) => ({
2122
pkgJsonFilePath: path.join(root, "packages", pkg, "package.json"),
2223
pkg,
2324
}));
@@ -30,7 +31,7 @@ if (!package) {
3031
);
3132

3233
packages.push(
33-
...fs.readdirSync(path.join(root, "clients")).map((pkg) => ({
34+
...listFolders(path.join(root, "clients")).map((pkg) => ({
3435
pkgJsonFilePath: path.join(root, "clients", pkg, "package.json"),
3536
pkg,
3637
}))
@@ -43,7 +44,7 @@ if (!package) {
4344
}
4445
} else {
4546
(async () => {
46-
const inliner = new Inliner(package);
47+
const inliner = new Inliner(_package);
4748
await inliner.clean();
4849
await inliner.tsc();
4950
await inliner.discoverVariants();

scripts/compilation/set-nocheck.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
const fs = require("node:fs");
22
const path = require("node:path");
3+
const { listFolders } = require("../utils/list-folders");
34

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

67
for (const packageFolder of [
7-
...fs.readdirSync(path.join(root, "lib")).map((f) => path.join(root, "lib", f)),
8-
...fs.readdirSync(path.join(root, "packages")).map((f) => path.join(root, "packages", f)),
9-
...fs.readdirSync(path.join(root, "clients")).map((f) => path.join(root, "clients", f)),
10-
...fs.readdirSync(path.join(root, "private")).map((f) => path.join(root, "private", f)),
8+
...listFolders(path.join(root, "lib"), false),
9+
...listFolders(path.join(root, "packages"), false),
10+
...listFolders(path.join(root, "clients"), false),
11+
...listFolders(path.join(root, "private"), false),
1112
]) {
1213
console.log(packageFolder);
1314

scripts/npm-registry/mark-version-as-latest.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
*/
99
//
1010

11-
import readline from "readline";
11+
import { fileURLToPath } from "node:url";
1212
import fs from "fs";
1313
import path, { dirname } from "path";
14-
import { fileURLToPath } from "node:url";
14+
import readline from "readline";
15+
import { listFolders } from "../utils/list-folders.js";
1516
import { spawnProcessReturnValue } from "../utils/spawn-process.js";
1617

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

3637
function recordPackages(dir) {
37-
const packageFolders = fs.readdirSync(dir);
38+
const packageFolders = listFolders(dir);
3839
for (const packageFolder of packageFolders) {
3940
const pkgJson = JSON.parse(fs.readFileSync(path.join(dir, packageFolder, "package.json"), "utf-8"));
4041
packages.push(pkgJson.name);

scripts/runtime-dependency-version-check/check-dependencies.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ const _private = path.join(root, "private");
1313
const topLevelFolders = [packages, _private];
1414
const packageFolders = [];
1515
const walk = require("../utils/walk");
16+
const { listFolders } = require("../utils/list-folders");
1617

1718
for (const topLevelFolder of topLevelFolders) {
18-
packageFolders.push(...fs.readdirSync(topLevelFolder));
19+
packageFolders.push(...listFolders(topLevelFolder));
1920
}
2021

2122
const node_libraries = [

scripts/runtime-dependency-version-check/runtime-dep-version-check.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,21 @@
2222

2323
const fs = require("fs");
2424
const path = require("path");
25+
const { listFolders } = require("../utils/list-folders");
2526

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

28-
const clients = fs.readdirSync(path.join(root, "clients"));
29-
const lib = fs.readdirSync(path.join(root, "lib"));
30-
const packages = fs.readdirSync(path.join(root, "packages"));
31-
const _private = fs.readdirSync(path.join(root, "private"));
29+
const clients = listFolders(path.join(root, "clients"), false);
30+
const lib = listFolders(path.join(root, "lib"), false);
31+
const packages = listFolders(path.join(root, "packages"), false);
32+
const _private = listFolders(path.join(root, "private"), false);
3233

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

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

41-
const nonClientPackages = [
42-
...lib.map((l) => path.join(root, "lib", l)),
43-
...packages.map((p) => path.join(root, "packages", p)),
44-
..._private.filter((p) => p.endsWith("-test")).map((p) => path.join(root, "private", p)),
45-
];
39+
const nonClientPackages = [...lib, ...packages, ..._private.filter((p) => p.endsWith("-test"))];
4640

4741
const deps = {
4842
/* @namespace/name: {

scripts/utils/list-folders.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const fs = require("node:fs");
2+
const path = require("node:path");
3+
4+
/**
5+
* @param dir - directory.
6+
* @param basenameOnly - if true, return only the basename of the subdirectories
7+
* @returns {string[]} list of full-paths of subdirectories (not files) in the given directory.
8+
*/
9+
function listFolders(dir, basenameOnly = true) {
10+
const folders = [];
11+
for (const fileSystemEntry of fs.readdirSync(dir, { withFileTypes: true })) {
12+
if (fileSystemEntry.isDirectory()) {
13+
if (basenameOnly) {
14+
folders.push(fileSystemEntry.name);
15+
} else {
16+
folders.push(path.join(dir, fileSystemEntry.name));
17+
}
18+
}
19+
}
20+
return folders;
21+
}
22+
23+
module.exports = {
24+
listFolders,
25+
};

scripts/validation/package-graph-analyzer.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const fs = require("node:fs");
22
const path = require("node:path");
3+
const { listFolders } = require("../utils/list-folders");
34

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

2728
if (pkgJson.private !== true) {
2829
throw new Error("package in reserved folder is not marked private:", folder);
29-
} else {
3030
}
3131
}
3232
}
@@ -36,16 +36,13 @@ const clients = path.join(root, "clients");
3636
*/
3737
{
3838
const hasPkgJson = (subfolder, pkg) => fs.existsSync(path.join(subfolder, pkg, "package.json"));
39-
const packagesData = fs
40-
.readdirSync(packages)
39+
const packagesData = listFolders(packages)
4140
.filter(hasPkgJson.bind(null, "packages"))
4241
.map((pkg) => require(path.join(packages, pkg, "package.json")));
43-
const libsData = fs
44-
.readdirSync(libs)
42+
const libsData = listFolders(libs)
4543
.filter(hasPkgJson.bind(null, "libs"))
4644
.map((pkg) => require(path.join(libs, pkg, "package.json")));
47-
const clientsData = fs
48-
.readdirSync(clients)
45+
const clientsData = listFolders(clients)
4946
.filter(hasPkgJson.bind(null, "clients"))
5047
.map((pkg) => require(path.join(clients, pkg, "package.json")));
5148

0 commit comments

Comments
 (0)