Skip to content

Commit 57f8f00

Browse files
chore: reuse the shared biome config (#7763)
**Motivation** Use consistent linting rules for all projects. **Description** - Reuse the `@chainsafe/biome-config` package to have consistent **Steps to test or reproduce** Run CI --------- Co-authored-by: Cayman <caymannava@gmail.com>
1 parent 2ff1784 commit 57f8f00

File tree

6 files changed

+23
-93
lines changed

6 files changed

+23
-93
lines changed

biome.jsonc

Lines changed: 11 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
{
22
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"extends": [
4+
"@chainsafe/biomejs-config",
5+
"@chainsafe/biomejs-config/recommended",
6+
"@chainsafe/biomejs-config/nodejs",
7+
"@chainsafe/biomejs-config/esm"
8+
],
39
"vcs": {
4-
"clientKind": "git",
5-
"enabled": true,
6-
"useIgnoreFile": true,
710
"defaultBranch": "unstable"
811
},
912
"files": {
1013
"include": ["packages/*/src/**/*.ts", "packages/*/test/**/*.ts", "configs/**/*.ts", "./vitest.config.ts"]
1114
},
1215
"formatter": {
13-
"enabled": true,
14-
"formatWithErrors": true,
15-
"useEditorconfig": true,
16-
"lineWidth": 120,
17-
"attributePosition": "auto",
18-
"bracketSpacing": false,
1916
"ignore": ["**/lib", "**/.nyc_output", "./packages/*/spec-tests", "**/node_modules", "./packages/*/node_modules/**"]
2017
},
2118
"organizeImports": {
2219
"enabled": true
2320
},
2421
"linter": {
25-
"enabled": true,
2622
"rules": {
27-
"recommended": true,
2823
"correctness": {
29-
"noUnusedVariables": "error",
3024
"useImportExtensions": {
3125
"level": "error",
3226
"options": {
@@ -37,11 +31,7 @@
3731
}
3832
}
3933
}
40-
},
41-
"useArrayLiterals": "error",
42-
"noUndeclaredVariables": "error",
43-
// TODO: We want this rule but it's not working properly with mono repos
44-
"noUndeclaredDependencies": "off"
34+
}
4535
},
4636
"performance": {
4737
// This rule should be enabled but with considerations and careful review
@@ -58,24 +48,16 @@
5848
"deniedGlobals": ["fetch"]
5949
}
6050
},
61-
// We prefer to use `Math.pow` over `**` operator
62-
"useExponentiationOperator": "off",
6351
// In some cases the enums are initialized with values of other enums
6452
"useLiteralEnumMembers": "off",
65-
// We prefer to have multiple declarations lines
66-
"useSingleVarDeclarator": "off",
6753
// We use `+` operator for string concatenation a lot
6854
"useTemplate": "off",
6955
// We use to export types and object without differentiating
7056
"useExportType": "off",
7157
// We use to import types and object without differentiating
7258
"useImportType": "off",
73-
// It's nice to use `Number` namespace but should be done in a separate PR
74-
"useNumberNamespace": "off",
7559
// We prefer to auto-initialize enums
7660
"useEnumInitializers": "off",
77-
// Namespaces are deprecated way to organize modules in TS
78-
"noNamespace": "error",
7961
"useNamingConvention": {
8062
"level": "error",
8163
"options": {
@@ -101,12 +83,6 @@
10183
},
10284
"formats": ["camelCase", "snake_case", "PascalCase", "CONSTANT_CASE"]
10385
},
104-
{
105-
"selector": {
106-
"kind": "enum"
107-
},
108-
"formats": ["PascalCase"]
109-
},
11086
{
11187
"selector": {
11288
"kind": "objectLiteralProperty"
@@ -167,77 +143,23 @@
167143
}
168144
},
169145
"suspicious": {
170-
// `void` as type is useful in our case when used as generic constraint e.g. K extends number | void
171-
"noConfusingVoidType": "off",
172146
// There is a lot of empty code blocks, should be enabled and clean up separately.
173-
"noEmptyBlockStatements": "off",
174-
"noConsoleLog": "error"
147+
"noEmptyBlockStatements": "off"
175148
},
176149
"nursery": {
177-
"useConsistentMemberAccessibility": {
178-
"level": "error",
179-
"options": {
180-
"accessibility": "noPublic"
181-
}
182-
},
183-
"noCommonJs": "error",
184-
"noRestrictedImports": {
185-
"level": "error",
186-
"options": {
187-
"paths": {
188-
"child_process": "Please use node:child_process instead.",
189-
"crypto": "Please use node:crypto instead.",
190-
"fs": "Please use node:fs instead.",
191-
"http": "Please use node:https instead.",
192-
"net": "Please use node:net instead.",
193-
"os": "Please use node:os instead.",
194-
"path": "Please use node:path instead.",
195-
"stream": "Please use node:stream instead.",
196-
"util": "Please use node:util instead.",
197-
"url": "Please use node:url instead.",
198-
"worker_threads": "Please use node:worker_threads instead."
199-
}
200-
}
201-
},
202-
"noDuplicateElseIf": "error",
203-
"noUselessEscapeInRegex": "error",
204-
"noIrregularWhitespace": "error",
205-
"noOctalEscape": "error",
206150
// Need to enable this rule with exception to anonymous functions
207-
"useExplicitType": "off",
208-
"useGuardForIn": "error",
209-
"noDuplicateProperties": "error",
210-
"useAtIndex": "error",
211-
"useCollapsedIf": "error"
151+
"useExplicitType": "off"
212152
}
213153
}
214154
},
215-
"javascript": {
216-
"formatter": {
217-
"jsxQuoteStyle": "double",
218-
"quoteProperties": "asNeeded",
219-
"trailingCommas": "es5",
220-
"semicolons": "always",
221-
"arrowParentheses": "always",
222-
"bracketSpacing": false,
223-
"bracketSameLine": false,
224-
"quoteStyle": "double",
225-
"attributePosition": "auto",
226-
"enabled": true
227-
},
228-
"linter": {
229-
"enabled": true
230-
},
231-
"globals": ["BigInt"]
232-
},
233155
"overrides": [
234156
// Code using console output
235157
{
236158
"include": ["packages/cli/src/", "packages/test-utils/src", "packages/flare/src"],
237159
"linter": {
238160
"rules": {
239161
"suspicious": {
240-
"noConsoleLog": "off"
162+
"noConsole": "off"
241163
}
242164
}
243165
}
@@ -257,7 +179,7 @@
257179
// During testing we use `any` type for quick assignments
258180
"noExplicitAny": "off",
259181
// Console logging is often used in tests
260-
"noConsoleLog": "off"
182+
"noConsole": "off"
261183
}
262184
}
263185
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"devDependencies": {
4444
"@actions/core": "^1.10.1",
4545
"@chainsafe/benchmark": "^1.2.3",
46+
"@chainsafe/biomejs-config": "^0.1.2",
4647
"@biomejs/biome": "^1.9.4",
4748
"@types/node": "^20.12.8",
4849
"@vitest/browser": "^3.0.6",

packages/logger/src/browser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class BrowserConsole extends Transport {
7171

7272
if (val <= this.levels[this.level as LogLevel]) {
7373
// @ts-expect-error
74+
// biome-ignore lint/suspicious/noConsole: We want the explicit usage of console
7475
console[mappedMethod](message);
7576
}
7677

packages/prover/src/cli/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ void prover
1313
if (msg?.includes("Not enough non-option arguments")) {
1414
// Show command help message when no command is provided
1515
yarg.showHelp();
16-
// biome-ignore lint/suspicious/noConsoleLog: This code will run only in browser so console will be available.
16+
// biome-ignore lint/suspicious/noConsole: This code will run only in browser so console will be available.
1717
console.log("\n");
1818
}
1919

2020
const errorMessage =
2121
err !== undefined ? (err instanceof YargsError ? err.message : err.stack) : msg || "Unknown error";
2222

23+
// biome-ignore lint/suspicious/noConsole: We want to explicitly want to log error to console
2324
console.error(` ✖ ${errorMessage}\n`);
2425
process.exit(1);
2526
})

packages/utils/src/diff.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ export function getDiffs(val1: Diffable, val2: Diffable, objectPath: string): Di
202202
*/
203203
export function diff(val1: unknown, val2: unknown, outputValues = false, filename?: string): void {
204204
if (!isDiffable(val1)) {
205-
// biome-ignore lint/suspicious/noConsoleLog: <explanation>
205+
// biome-ignore lint/suspicious/noConsole: <explanation>
206206
console.log("val1 is not Diffable");
207207
return;
208208
}
209209
if (!isDiffable(val2)) {
210-
// biome-ignore lint/suspicious/noConsoleLog: <explanation>
210+
// biome-ignore lint/suspicious/noConsole: <explanation>
211211
console.log("val2 is not Diffable");
212212
return;
213213
}
@@ -227,7 +227,7 @@ export function diff(val1: unknown, val2: unknown, outputValues = false, filenam
227227
if (filename) {
228228
fs.writeFileSync(filename, output);
229229
} else {
230-
// biome-ignore lint/suspicious/noConsoleLog: <explanation>
230+
// biome-ignore lint/suspicious/noConsole: <explanation>
231231
console.log(output);
232232
}
233233
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,11 @@
473473
yaml "^2.7.0"
474474
yargs "^17.7.2"
475475

476+
"@chainsafe/biomejs-config@^0.1.2":
477+
version "0.1.2"
478+
resolved "https://registry.yarnpkg.com/@chainsafe/biomejs-config/-/biomejs-config-0.1.2.tgz#e31c9a7f719a932ccf7b9b78bb5d8401a65587f7"
479+
integrity sha512-WveZrCiFC+XxiUnzN2YH9pKxFOAUs3W0YxLDY8emktGR9U/Pa9pfQl4ZiZCD0uwRBQKZdWLKc0yoAtkVYqU9Jg==
480+
476481
"@chainsafe/bls-hd-key@^0.3.0":
477482
version "0.3.0"
478483
resolved "https://registry.npmjs.org/@chainsafe/bls-hd-key/-/bls-hd-key-0.3.0.tgz"

0 commit comments

Comments
 (0)