Skip to content

Commit 0b7f606

Browse files
committed
build: use biome as formatter
1 parent 468b152 commit 0b7f606

File tree

21 files changed

+2359
-40
lines changed

21 files changed

+2359
-40
lines changed

.eslintrc.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,7 @@ module.exports = {
133133
// https://eslint.org/docs/rules/
134134
'accessor-pairs': 'error',
135135
'array-callback-return': 'error',
136-
'arrow-parens': 'error',
137-
'arrow-spacing': 'error',
138136
'block-scoped-var': 'error',
139-
'block-spacing': 'error',
140-
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
141137
'capitalized-comments': ['error', 'always', {
142138
line: {
143139
// Ignore all lines that have less characters than 20 and all lines that
@@ -150,49 +146,20 @@ module.exports = {
150146
ignorePattern: '.*',
151147
},
152148
}],
153-
'comma-dangle': ['error', 'always-multiline'],
154-
'comma-spacing': 'error',
155-
'comma-style': 'error',
156-
'computed-property-spacing': 'error',
157149
'default-case-last': 'error',
158-
'dot-location': ['error', 'property'],
159150
'dot-notation': 'error',
160151
'eol-last': 'error',
161152
'eqeqeq': ['error', 'smart'],
162153
'func-call-spacing': 'error',
163154
'func-name-matching': 'error',
164155
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
165-
'indent': ['error', 2, {
166-
ArrayExpression: 'first',
167-
CallExpression: { arguments: 'first' },
168-
FunctionDeclaration: { parameters: 'first' },
169-
FunctionExpression: { parameters: 'first' },
170-
MemberExpression: 'off',
171-
ObjectExpression: 'first',
172-
SwitchCase: 1,
173-
}],
174-
'key-spacing': 'error',
175-
'keyword-spacing': 'error',
176156
'linebreak-style': 'error',
177-
'max-len': ['error', {
178-
code: 120,
179-
ignorePattern: '^// Flags:',
180-
ignoreRegExpLiterals: true,
181-
ignoreTemplateLiterals: true,
182-
ignoreUrls: true,
183-
tabWidth: 2,
184-
}],
185-
'new-parens': 'error',
186-
'no-confusing-arrow': 'error',
187157
'no-constant-condition': ['error', { checkLoops: false }],
188158
'no-constructor-return': 'error',
189159
'no-duplicate-imports': 'error',
190160
'no-else-return': 'error',
191-
'no-extra-parens': ['error', 'functions'],
192161
'no-lonely-if': 'error',
193162
'no-mixed-requires': 'error',
194-
'no-multi-spaces': ['error', { ignoreEOLComments: true }],
195-
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0, maxBOF: 0 }],
196163
'no-new-require': 'error',
197164
'no-path-concat': 'error',
198165
'no-proto': 'error',
@@ -257,10 +224,8 @@ module.exports = {
257224
},
258225
],
259226
'no-self-compare': 'error',
260-
'no-tabs': 'error',
261227
'no-template-curly-in-string': 'error',
262228
'no-throw-literal': 'error',
263-
'no-trailing-spaces': 'error',
264229
'no-undef': ['error', { typeof: true }],
265230
'no-undef-init': 'error',
266231
'no-unused-expressions': ['error', { allowShortCircuit: true }],
@@ -276,7 +241,6 @@ module.exports = {
276241
'no-useless-return': 'error',
277242
'no-var': 'error',
278243
'no-void': 'error',
279-
'no-whitespace-before-property': 'error',
280244
'object-curly-newline': 'error',
281245
'object-curly-spacing': ['error', 'always'],
282246
'one-var': ['error', { initialized: 'never' }],
@@ -288,11 +252,8 @@ module.exports = {
288252
],
289253
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
290254
'prefer-object-has-own': 'error',
291-
'quotes': ['error', 'single', { avoidEscape: true }],
292255
'quote-props': ['error', 'consistent'],
293256
'rest-spread-spacing': 'error',
294-
'semi': 'error',
295-
'semi-spacing': 'error',
296257
'space-before-blocks': ['error', 'always'],
297258
'space-before-function-paren': ['error', {
298259
anonymous: 'never',
@@ -308,7 +269,6 @@ module.exports = {
308269
}],
309270
'strict': ['error', 'global'],
310271
'symbol-description': 'error',
311-
'template-curly-spacing': 'error',
312272
'unicode-bom': 'error',
313273
'valid-typeof': ['error', { requireStringLiterals: true }],
314274

.github/workflows/tools.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717
- acorn-walk
1818
- ada
1919
- base64
20+
- biome
2021
- brotli
2122
- c-ares
2223
- cjs-module-lexer
@@ -87,6 +88,14 @@ jobs:
8788
cat temp-output
8889
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
8990
rm temp-output
91+
- id: biome
92+
subsystem: tools
93+
label: tools
94+
run: |
95+
./tools/dep_updaters/update-biome.sh > temp-output
96+
cat temp-output
97+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
98+
rm temp-output
9099
- id: brotli
91100
subsystem: deps
92101
label: dependencies

biome.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"$schema": "./tools/node_modules/@biomejs/biome/configuration_schema.json",
3+
"files": {
4+
"ignore": [
5+
"out",
6+
"compile_commands.json",
7+
"tools/node_modules",
8+
"tools/**/*.json",
9+
"typings",
10+
".devcontainer"
11+
],
12+
"include": [
13+
"test/**/*.{js,mjs,json}",
14+
"lib/**/*.{js,mjs,json}",
15+
"tools/**/*.{js,mjs,json}"
16+
],
17+
"ignoreUnknown": true
18+
},
19+
"formatter": {
20+
"enabled": true,
21+
"indentStyle": "space",
22+
"indentWidth": 2,
23+
"lineWidth": 120
24+
},
25+
"linter": {
26+
"enabled": false
27+
},
28+
"organizeImports": {
29+
"enabled": false
30+
},
31+
"javascript": {
32+
"formatter": {
33+
"enabled": true,
34+
"arrowParentheses": "always",
35+
"trailingComma": "all",
36+
"quoteStyle": "single",
37+
"semicolons": "always"
38+
}
39+
},
40+
"json": {
41+
"formatter": {
42+
"enabled": true
43+
}
44+
}
45+
}

tools/dep_updaters/update-biome.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/sh
2+
3+
# Shell script to update @biomejs/biome in the source tree to the latest release.
4+
5+
# This script must be in the tools directory when it runs because it uses the
6+
# script source file path to determine directories to work in.
7+
8+
set -ex
9+
10+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
11+
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
12+
[ -x "$NODE" ] || NODE=$(command -v node)
13+
NPM="$BASE_DIR/deps/npm/bin/npm-cli.js"
14+
NODE_MODULES_DIR="$BASE_DIR/tools/node_modules"
15+
16+
# shellcheck disable=SC1091
17+
. "$BASE_DIR/tools/dep_updaters/utils.sh"
18+
19+
NEW_VERSION=$("$NODE" "$NPM" view @biomejs/biome dist-tags.latest)
20+
# CURRENT_VERSION=$("$NODE" "$NPM" --prefix './tools/node_modules/@biomejs/biome/' pkg get version)
21+
22+
# This function exit with 0 if new version and current version are the same
23+
# compare_dependency_version "@biomejs/biome" "$NEW_VERSION" "$CURRENT_VERSION"
24+
25+
cd "$( dirname "$0" )/../.." || exit
26+
27+
echo "Making temporary workspace..."
28+
29+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
30+
31+
cleanup () {
32+
EXIT_CODE=$?
33+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
34+
exit $EXIT_CODE
35+
}
36+
37+
trap cleanup INT TERM EXIT
38+
39+
cd "$WORKSPACE"
40+
41+
echo "Fetching @biomejs/biome source archive..."
42+
43+
"$NODE" "$NPM" pack "@biomejs/biome@$NEW_VERSION"
44+
45+
BIOME_TGZ="biomejs-biome-$NEW_VERSION.tgz"
46+
47+
log_and_verify_sha256sum "@biomejs/biome" "$BIOME_TGZ"
48+
49+
rm -r "$NODE_MODULES_DIR/@biomejs/biome"/*
50+
51+
tar -xf "$BIOME_TGZ"
52+
53+
mv package/* "$NODE_MODULES_DIR/@biomejs/biome"
54+
55+
# Biome has optional dependencies that are not installed by default.
56+
# - @biomejs/cli-win32-x64
57+
# - @biomejs/cli-win32-arm64
58+
# - @biomejs/cli-darwin-x64
59+
# - @biomejs/cli-darwin-arm64
60+
# - @biomejs/cli-linux-x64
61+
# - @biomejs/cli-linux-arm64
62+
PLATFORM_DEPS=(
63+
"cli-win32-x64"
64+
"cli-win32-arm64"
65+
"cli-darwin-x64"
66+
"cli-darwin-arm64"
67+
"cli-linux-x64"
68+
"cli-linux-arm64"
69+
)
70+
71+
for PLATFORM_DEP in "${PLATFORM_DEPS[@]}"; do
72+
echo "Fetching @biomejs/$PLATFORM_DEP source archive..."
73+
74+
"$NODE" "$NPM" pack "@biomejs/$PLATFORM_DEP@$NEW_VERSION"
75+
76+
PLATFORM_DEP_TGZ="biomejs-$PLATFORM_DEP-$NEW_VERSION.tgz"
77+
78+
log_and_verify_sha256sum "@biomejs/$PLATFORM_DEP" "$PLATFORM_DEP_TGZ"
79+
80+
rm -rf "$NODE_MODULES_DIR/@biomejs/biome/node_modules/@biomejs/$PLATFORM_DEP"
81+
mkdir -p "$NODE_MODULES_DIR/@biomejs/biome/node_modules/@biomejs/$PLATFORM_DEP"
82+
83+
tar -xf "$PLATFORM_DEP_TGZ" -C "$NODE_MODULES_DIR/@biomejs/biome/node_modules/@biomejs/$PLATFORM_DEP" --strip-components=1
84+
done
85+
86+
chmod +x "$NODE_MODULES_DIR/@biomejs/biome/bin/biome"
87+
88+
echo "All done!"
89+
echo ""
90+
echo "Please git add @biomejs/biome, commit the new version:"
91+
echo ""
92+
echo "$ git add -A tools/node_modules/@biomejs/biome"
93+
echo "$ git commit -m \"deps: update @biomejs/biome to $NEW_VERSION\""
94+
echo ""
95+
96+
# Update the version number on maintaining-dependencies.md
97+
# and print the new version as the last line of the script as we need
98+
# to add it to $GITHUB_ENV variable
99+
finalize_version_update "@biomejs/biome" "$NEW_VERSION"

tools/node_modules/@biomejs/biome/README.md

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)