From 8ec69ff2a4f2f2e4d3f9c26f8de7710df4c264e4 Mon Sep 17 00:00:00 2001 From: Ege Akman Date: Wed, 3 Apr 2024 09:26:30 +0300 Subject: [PATCH] Add pre-commit checks and fix its complaints (#547) Closes #497 We can change the ``maxkb`` argument to our needs. Added some handy checks as well. Since we are using [``pre-commit``](https://pypi.org/p/pre-commit), we might want to add that to a ``requirements-dev.txt``. --- .pre-commit-config.yaml | 21 +++ README.md | 14 ++ src/components/form/label.tsx | 5 +- src/components/form/select.tsx | 11 +- src/components/icons/award.astro | 1 - src/components/icons/headhunt.astro | 1 - src/components/icons/network.astro | 1 - src/components/icons/rocket.astro | 1 - src/components/icons/target.astro | 1 - src/components/icons/transfer.astro | 1 - src/components/keynoters/keynoters.tsx | 1 - src/components/note/note.tsx | 4 +- .../session-summary/session-summary.tsx | 8 +- .../sponsor-tiers/sponsor-tiers.tsx | 1 - src/components/typography/title.tsx | 2 +- src/consts.ts | 4 +- src/content/config.ts | 2 +- src/content/deadlines/00_cfp.mdx | 2 +- src/data/home/intro.md | 6 +- src/data/sponsors.json | 21 +-- tailwind.config.mjs | 162 +++++++++--------- tsconfig.json | 2 +- vercel.json | 4 +- 23 files changed, 157 insertions(+), 119 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..3a39c4805 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-added-large-files + args: ["--maxkb", "5000"] + - id: check-case-conflict + - id: check-merge-conflict + - id: check-yaml + - id: end-of-file-fixer + exclude_types: ["svg"] + - id: trailing-whitespace + exclude_types: ["svg"] + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.1.0 + hooks: + - id: prettier + args: ["--tab-width", "2", "--trailing-comma", "es5"] + exclude_types: ["mdx"] + exclude: "pnpm-lock.yaml" diff --git a/README.md b/README.md index d2dcc017a..c5fa514f6 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,20 @@ dependencies. Then, use `pnpm run dev` to start the development server. The website will be available at `http://localhost:4321`. +### Pre-commit Setup + +To ensure code quality and consistency, we use `pre-commit` hooks. Follow these +steps to set up `pre-commit` on your local environment: + +1. Install `pre-commit`. You can follow the instructions from + [pre-commit.com](https://pre-commit.com/#install). +2. Run `pre-commit install` in the root of your local repository. +3. Now, `pre-commit` will run automatically on `git commit`. You can also run it + manually on all files using `pre-commit run --all-files`. + +This will help maintain a consistent coding style and catch common issues before +submission. + ### Docker If you want to run this in docker, run: diff --git a/src/components/form/label.tsx b/src/components/form/label.tsx index 793e8cf84..3e37d629b 100644 --- a/src/components/form/label.tsx +++ b/src/components/form/label.tsx @@ -6,7 +6,10 @@ export const Label = ({ htmlFor: string; }) => { return ( -