Skip to content

chore: replace eslint with biome #14263

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 26 commits into from
Aug 15, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab

[*.{md,json,yaml,yml,tf,tfvars,nix}]
[*.{md,yaml,yml,tf,tfvars,nix}]
indent_style = space
indent_size = 2

Expand Down
18 changes: 6 additions & 12 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,13 @@ result
# by Prettier.
helm/**/templates/*.yaml

# Terraform state files used in tests, these are automatically generated.
# Example: provisioner/terraform/testdata/instance-id/instance-id.tfstate.json
**/testdata/**/*.tf*.json

# Testdata shouldn't be formatted.
scripts/apitypings/testdata/**/*.ts
enterprise/tailnet/testdata/*.golden.html
tailnet/testdata/*.golden.html

# Generated files shouldn't be formatted.
site/e2e/provisionerGenerated.ts
testdata/

# Ignore generated files
**/pnpm-lock.yaml

# Ignore generated JSON (e.g. examples/examples.gen.json).
**/*.gen.json

# Everything in site/ is formatted by Biome. For the rest of the repo though, we
# need broader language support.
site/
18 changes: 6 additions & 12 deletions .prettierignore.include
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@
# by Prettier.
helm/**/templates/*.yaml

# Terraform state files used in tests, these are automatically generated.
# Example: provisioner/terraform/testdata/instance-id/instance-id.tfstate.json
**/testdata/**/*.tf*.json

# Testdata shouldn't be formatted.
scripts/apitypings/testdata/**/*.ts
enterprise/tailnet/testdata/*.golden.html
tailnet/testdata/*.golden.html

# Generated files shouldn't be formatted.
site/e2e/provisionerGenerated.ts
testdata/

# Ignore generated files
**/pnpm-lock.yaml

# Ignore generated JSON (e.g. examples/examples.gen.json).
**/*.gen.json

# Everything in site/ is formatted by Biome. For the rest of the repo though, we
# need broader language support.
site/
4 changes: 2 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"zxh404.vscode-proto3",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker",
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig"
"EditorConfig.EditorConfig",
"biomejs.biome"
]
}
14 changes: 12 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@
}
]
},
"eslint.workingDirectories": ["./site"],
"search.exclude": {
"**.pb.go": true,
"**/*.gen.json": true,
Expand Down Expand Up @@ -224,5 +223,16 @@
// with VS Code.
"typescript.tsdk": "./site/node_modules/typescript/lib",
// Playwright tests in VSCode will open a browser to live "view" the test.
"playwright.reuseBrowser": true
"playwright.reuseBrowser": true,

"[javascript][javascriptreact][json][jsonc][typescript][typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
// "editor.codeActionsOnSave": {
// "source.organizeImports.biome": "explicit"
// }
},

"[css][html][markdown][yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
80 changes: 13 additions & 67 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ BOLD := $(shell tput bold 2>/dev/null)
GREEN := $(shell tput setaf 2 2>/dev/null)
RESET := $(shell tput sgr0 2>/dev/null)

fmt: fmt/eslint fmt/prettier fmt/terraform fmt/shfmt fmt/go
fmt: fmt/ts fmt/go fmt/terraform fmt/shfmt fmt/prettier
.PHONY: fmt

fmt/go:
Expand All @@ -401,15 +401,19 @@ fmt/go:
go run mvdan.cc/gofumpt@v0.4.0 -w -l .
.PHONY: fmt/go

Copy link
Member

@matifali matifali Aug 15, 2024

Choose a reason for hiding this comment

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

I used to do fmt/prettier when formatting markdown files.
Can you extract a fmt/docs or fmt/md to make docs formatting easier?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, we still need prettier for basically everything it was doing before outside of site/, so I'll just put that job back.

fmt/eslint:
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/eslint$(RESET)"
fmt/ts:
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/ts$(RESET)"
cd site
pnpm run lint:fix
.PHONY: fmt/eslint
# Avoid writing files in CI to reduce file write activity
ifdef CI
pnpm run check --linter-enabled=false
else
pnpm run check:fix
endif
.PHONY: fmt/ts

fmt/prettier:
fmt/prettier: .prettierignore
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/prettier$(RESET)"
cd site
# Avoid writing files in CI to reduce file write activity
ifdef CI
pnpm run format:check
Expand Down Expand Up @@ -442,7 +446,7 @@ lint/site-icons:

lint/ts:
cd site
pnpm i && pnpm lint
pnpm lint
.PHONY: lint/ts

lint/go:
Expand Down Expand Up @@ -495,9 +499,6 @@ gen: \
.prettierignore.include \
.prettierignore \
provisioner/terraform/testdata/version \
site/.prettierrc.yaml \
site/.prettierignore \
site/.eslintignore \
site/e2e/provisionerGenerated.ts \
site/src/theme/icons.json \
examples/examples.gen.json \
Expand Down Expand Up @@ -526,9 +527,6 @@ gen/mark-fresh:
coderd/apidoc/swagger.json \
.prettierignore.include \
.prettierignore \
site/.prettierrc.yaml \
site/.prettierignore \
site/.eslintignore \
site/e2e/provisionerGenerated.ts \
site/src/theme/icons.json \
examples/examples.gen.json \
Expand Down Expand Up @@ -603,7 +601,6 @@ provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
site/src/api/typesGenerated.ts: $(wildcard scripts/apitypings/*) $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
go run ./scripts/apitypings/ > $@
./scripts/pnpm_install.sh
pnpm exec prettier --write "$@"

site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisionersdk/proto/provisioner.pb.go
cd site
Expand All @@ -613,7 +610,7 @@ site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisio
site/src/theme/icons.json: $(wildcard scripts/gensite/*) $(wildcard site/static/icon/*)
go run ./scripts/gensite/ -icons "$@"
./scripts/pnpm_install.sh
pnpm exec prettier --write "$@"
pnpm -C site/ exec biome format --write src/theme/icons.json

examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates)
go run ./scripts/examplegen/main.go > examples/examples.gen.json
Expand Down Expand Up @@ -702,23 +699,6 @@ scripts/ci-report/testdata/.gen-golden: $(wildcard scripts/ci-report/testdata/*)
go test ./scripts/ci-report -run=TestOutputMatchesGoldenFile -update
touch "$@"

# Generate a prettierrc for the site package that uses relative paths for
# overrides. This allows us to share the same prettier config between the
# site and the root of the repo.
site/.prettierrc.yaml: .prettierrc.yaml
. ./scripts/lib.sh
dependencies yq

echo "# Code generated by Makefile (../$<). DO NOT EDIT." > "$@"
echo "" >> "$@"

# Replace all listed override files with relative paths inside site/.
# - ./ -> ../
# - ./site -> ./
yq \
'.overrides[].files |= map(. | sub("^./"; "") | sub("^"; "../") | sub("../site/"; "./") | sub("../!"; "!../"))' \
"$<" >> "$@"

# Combine .gitignore with .prettierignore.include to generate .prettierignore.
.prettierignore: .gitignore .prettierignore.include
echo "# Code generated by Makefile ($^). DO NOT EDIT." > "$@"
Expand All @@ -728,40 +708,6 @@ site/.prettierrc.yaml: .prettierrc.yaml
cat "$$f" >> "$@"
done

# Generate ignore files based on gitignore into the site directory. We turn all
# rules into relative paths for the `site/` directory (where applicable),
# following the pattern format defined by git:
# https://git-scm.com/docs/gitignore#_pattern_format
#
# This is done for compatibility reasons, see:
# https://github.com/prettier/prettier/issues/8048
# https://github.com/prettier/prettier/issues/8506
# https://github.com/prettier/prettier/issues/8679
site/.eslintignore site/.prettierignore: .prettierignore Makefile
rm -f "$@"
touch "$@"
# Skip generated by header, inherit `.prettierignore` header as-is.
while read -r rule; do
# Remove leading ! if present to simplify rule, added back at the end.
tmp="$${rule#!}"
ignore="$${rule%"$$tmp"}"
rule="$$tmp"
case "$$rule" in
# Comments or empty lines (include).
\#*|'') ;;
# Generic rules (include).
\*\**) ;;
# Site prefixed rules (include).
site/*) rule="$${rule#site/}";;
./site/*) rule="$${rule#./site/}";;
# Rules that are non-generic and don't start with site (rewrite).
/*) rule=.."$$rule";;
*/?*) rule=../"$$rule";;
*) ;;
esac
echo "$${ignore}$${rule}" >> "$@"
done < "$<"

test:
$(GIT_FLAGS) gotestsum --format standard-quiet -- -v -short -count=1 ./...
.PHONY: test
Expand Down
3 changes: 1 addition & 2 deletions offlinedocs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"@chakra-ui/react": "2.8.2",
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.5",
"@types/lodash": "4.14.196",
"archiver": "6.0.2",
"framer-motion": "^10.17.6",
"front-matter": "4.0.2",
Expand All @@ -36,7 +35,7 @@
"@types/react-dom": "18.3.0",
"eslint": "8.56.0",
"eslint-config-next": "14.0.1",
"prettier": "3.1.0",
"prettier": "3.3.3",
"typescript": "5.3.2"
},
"engines": {
Expand Down
Loading
Loading