Skip to content

Commit

Permalink
build: use biome as formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Nov 12, 2023
1 parent 468b152 commit c3e0525
Show file tree
Hide file tree
Showing 21 changed files with 2,339 additions and 40 deletions.
40 changes: 0 additions & 40 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ module.exports = {
// https://eslint.org/docs/rules/
'accessor-pairs': 'error',
'array-callback-return': 'error',
'arrow-parens': 'error',
'arrow-spacing': 'error',
'block-scoped-var': 'error',
'block-spacing': 'error',
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'capitalized-comments': ['error', 'always', {
line: {
// Ignore all lines that have less characters than 20 and all lines that
Expand All @@ -150,49 +146,20 @@ module.exports = {
ignorePattern: '.*',
},
}],
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': 'error',
'comma-style': 'error',
'computed-property-spacing': 'error',
'default-case-last': 'error',
'dot-location': ['error', 'property'],
'dot-notation': 'error',
'eol-last': 'error',
'eqeqeq': ['error', 'smart'],
'func-call-spacing': 'error',
'func-name-matching': 'error',
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
'indent': ['error', 2, {
ArrayExpression: 'first',
CallExpression: { arguments: 'first' },
FunctionDeclaration: { parameters: 'first' },
FunctionExpression: { parameters: 'first' },
MemberExpression: 'off',
ObjectExpression: 'first',
SwitchCase: 1,
}],
'key-spacing': 'error',
'keyword-spacing': 'error',
'linebreak-style': 'error',
'max-len': ['error', {
code: 120,
ignorePattern: '^// Flags:',
ignoreRegExpLiterals: true,
ignoreTemplateLiterals: true,
ignoreUrls: true,
tabWidth: 2,
}],
'new-parens': 'error',
'no-confusing-arrow': 'error',
'no-constant-condition': ['error', { checkLoops: false }],
'no-constructor-return': 'error',
'no-duplicate-imports': 'error',
'no-else-return': 'error',
'no-extra-parens': ['error', 'functions'],
'no-lonely-if': 'error',
'no-mixed-requires': 'error',
'no-multi-spaces': ['error', { ignoreEOLComments: true }],
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0, maxBOF: 0 }],
'no-new-require': 'error',
'no-path-concat': 'error',
'no-proto': 'error',
Expand Down Expand Up @@ -257,10 +224,8 @@ module.exports = {
},
],
'no-self-compare': 'error',
'no-tabs': 'error',
'no-template-curly-in-string': 'error',
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
'no-undef': ['error', { typeof: true }],
'no-undef-init': 'error',
'no-unused-expressions': ['error', { allowShortCircuit: true }],
Expand All @@ -276,7 +241,6 @@ module.exports = {
'no-useless-return': 'error',
'no-var': 'error',
'no-void': 'error',
'no-whitespace-before-property': 'error',
'object-curly-newline': 'error',
'object-curly-spacing': ['error', 'always'],
'one-var': ['error', { initialized: 'never' }],
Expand All @@ -288,11 +252,8 @@ module.exports = {
],
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
'prefer-object-has-own': 'error',
'quotes': ['error', 'single', { avoidEscape: true }],
'quote-props': ['error', 'consistent'],
'rest-spread-spacing': 'error',
'semi': 'error',
'semi-spacing': 'error',
'space-before-blocks': ['error', 'always'],
'space-before-function-paren': ['error', {
anonymous: 'never',
Expand All @@ -308,7 +269,6 @@ module.exports = {
}],
'strict': ['error', 'global'],
'symbol-description': 'error',
'template-curly-spacing': 'error',
'unicode-bom': 'error',
'valid-typeof': ['error', { requireStringLiterals: true }],

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- acorn-walk
- ada
- base64
- biome
- brotli
- c-ares
- cjs-module-lexer
Expand Down Expand Up @@ -87,6 +88,14 @@ jobs:
cat temp-output
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
rm temp-output
- id: biome
subsystem: tools
label: tools
run: |
./tools/dep_updaters/update-biome.sh > temp-output
cat temp-output
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
rm temp-output
- id: brotli
subsystem: deps
label: dependencies
Expand Down
27 changes: 27 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "./tools/node_modules/@biomejs/biome/configuration_schema.json",
"formatter": {
"include": [
"test/**/*.{js,mjs,json}",
"lib/**/*.{js,mjs,json}",
"tools/**/*.{js,mjs,json}"
],
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 120
},
"javascript": {
"formatter": {
"enabled": true,
"arrowParentheses": "always",
"trailingComma": "all",
"quoteStyle": "single",
"semicolons": "always",
}
},
"json": {
"formatter": {
"enabled": true
}
}
}
97 changes: 97 additions & 0 deletions tools/dep_updaters/update-biome.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/sh

# Shell script to update @biomejs/biome in the source tree to the latest release.

# This script must be in the tools directory when it runs because it uses the
# script source file path to determine directories to work in.

set -ex

BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
[ -x "$NODE" ] || NODE=$(command -v node)
NPM="$BASE_DIR/deps/npm/bin/npm-cli.js"
NODE_MODULES_DIR="$BASE_DIR/tools/node_modules"

# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION=$("$NODE" "$NPM" view @biomejs/biome dist-tags.latest)
# CURRENT_VERSION=$("$NODE" "$NPM" --prefix './tools/node_modules/@biomejs/biome/' pkg get version)

# This function exit with 0 if new version and current version are the same
# compare_dependency_version "@biomejs/biome" "$NEW_VERSION" "$CURRENT_VERSION"

cd "$( dirname "$0" )/../.." || exit

echo "Making temporary workspace..."

WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')

cleanup () {
EXIT_CODE=$?
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
exit $EXIT_CODE
}

trap cleanup INT TERM EXIT

cd "$WORKSPACE"

echo "Fetching @biomejs/biome source archive..."

"$NODE" "$NPM" pack "@biomejs/biome@$NEW_VERSION"

BIOME_TGZ="biomejs-biome-$NEW_VERSION.tgz"

log_and_verify_sha256sum "@biomejs/biome" "$BIOME_TGZ"

rm -r "$NODE_MODULES_DIR/@biomejs/biome"/*

tar -xf "$BIOME_TGZ"

mv package/* "$NODE_MODULES_DIR/@biomejs/biome"

# Biome has optional dependencies that are not installed by default.
# - @biomejs/cli-win32-x64
# - @biomejs/cli-win32-arm64
# - @biomejs/cli-darwin-x64
# - @biomejs/cli-darwin-arm64
# - @biomejs/cli-linux-x64
# - @biomejs/cli-linux-arm64
PLATFORM_DEPS=(
"cli-win32-x64"
"cli-win32-arm64"
"cli-darwin-x64"
"cli-darwin-arm64"
"cli-linux-x64"
"cli-linux-arm64"
)

for PLATFORM_DEP in "${PLATFORM_DEPS[@]}"; do
echo "Fetching @biomejs/$PLATFORM_DEP source archive..."

"$NODE" "$NPM" pack "@biomejs/$PLATFORM_DEP@$NEW_VERSION"

PLATFORM_DEP_TGZ="biomejs-$PLATFORM_DEP-$NEW_VERSION.tgz"

log_and_verify_sha256sum "@biomejs/$PLATFORM_DEP" "$PLATFORM_DEP_TGZ"

rm -rf "$NODE_MODULES_DIR/@biomejs/$PLATFORM_DEP"/*
mkdir -p "$NODE_MODULES_DIR/@biomejs/$PLATFORM_DEP"

tar -xf "$PLATFORM_DEP_TGZ" -C "$NODE_MODULES_DIR/@biomejs/$PLATFORM_DEP"
done

echo "All done!"
echo ""
echo "Please git add @biomejs/biome, commit the new version:"
echo ""
echo "$ git add -A tools/node_modules/@biomejs/biome"
echo "$ git commit -m \"deps: update @biomejs/biome to $NEW_VERSION\""
echo ""

# Update the version number on maintaining-dependencies.md
# and print the new version as the last line of the script as we need
# to add it to $GITHUB_ENV variable
finalize_version_update "@biomejs/biome" "$NEW_VERSION"
57 changes: 57 additions & 0 deletions tools/node_modules/@biomejs/biome/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions tools/node_modules/@biomejs/biome/bin/biome

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c3e0525

Please sign in to comment.