Skip to content

Commit

Permalink
Prettier config (#38)
Browse files Browse the repository at this point in the history
* Add prettier formatting

* apply prettier fixes

* add git-blame-ignore-revs

* add prettier to pre commit hood, add pre-commit local setup to readme

* add comments to .prettierignore explaining why files are ignored

* typo in README

* apply prettier to middleware.ts

* one more formatting commit to ignore with blame
  • Loading branch information
eriktaubeneck authored Jun 10, 2024
1 parent 72af906 commit 031145d
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Prettier formatting errors
32743cbd2f5dead77fd6ef7be25105f33c370f29
be76190dd8ca29e9e7b63a3cd1126386b2fe5917
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ repos:
files: ^server/
types_or: [javascript, jsx, ts, tsx]
pass_filenames: false
- id: prettier
name: prettier
entry: npx --prefix server prettier --config=server/.prettierrc --ignore-path=server/.prettierignore --check server
language: system
files: ^server/
types_or: [javascript, jsx, ts, tsx]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ Requirements:
3. [Supabase CLI](https://supabase.com/docs/guides/cli/getting-started)
4. Docker


#### Pre-commit Hooks

Github is set up to run pre-commit hooks specified in .pre-commit-config.yaml. If you want to use it locally, in the virtual environment, run `pre-commit install`.


#### macOS install prerequisites

```brew install python3```
Expand Down
13 changes: 13 additions & 0 deletions server/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Auto-generated file
data/supabaseTypes.ts
postcss.config.js
supabase/.temp*
tailwind.config.ts
.next/*

# Config files
next.config.js
tsconfig.json

# Not JS
README.md
1 change: 1 addition & 0 deletions server/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 3 additions & 1 deletion server/app/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export default function QueryStartedAlert({ queryId }: { queryId: string }) {
<div className="ml-3">
<p className="text-sm font-medium text-green-800">
Successfully started Query: {queryId}. Redirecting to
<Link href={`/query/view/${queryId}`}>/query/view/{queryId} </Link>.{" "}
<Link href={`/query/view/${queryId}`}>
/query/view/{queryId}{" "}
</Link>.{" "}
</p>
</div>
<div className="ml-auto pl-3">
Expand Down
20 changes: 11 additions & 9 deletions server/app/query/haikunator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ const haikunator = new Haikunator({
nouns: nouns,
});

function getCurrentTimestamp() {
const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
return `${year}-${month}-${day}T${hours}${minutes}`;
function getCurrentTimestamp() {
const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, "0");
const day = now.getDate().toString().padStart(2, "0");
const hours = now.getHours().toString().padStart(2, "0");
const minutes = now.getMinutes().toString().padStart(2, "0");
return `${year}-${month}-${day}T${hours}${minutes}`;
}

export default function NewQueryId(): string {
return encodeURIComponent(haikunator.haikunate({tokenLength: 0}) + getCurrentTimestamp());
return encodeURIComponent(
haikunator.haikunate({ tokenLength: 0 }) + getCurrentTimestamp(),
);
}
27 changes: 16 additions & 11 deletions server/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,31 @@ export async function middleware(request: NextRequest) {
},
);

if (process.env.NODE_ENV === "development" && process.env.BYPASS_AUTH === "true") {
if (
process.env.NODE_ENV === "development" &&
process.env.BYPASS_AUTH === "true"
) {
const dummyEmail: string = process.env.DUMMY_EMAIL!;
const dummyPassword:string = process.env.DUMMY_PASSWORD!;
const { data, error: signInError } = await supabase.auth.signInWithPassword({
email: dummyEmail,
password: dummyPassword,
})
const dummyPassword: string = process.env.DUMMY_PASSWORD!;
const { data, error: signInError } = await supabase.auth.signInWithPassword(
{
email: dummyEmail,
password: dummyPassword,
},
);

if (signInError) {
const { error: signUpError } = await supabase.auth.signUp({
email: dummyEmail,
password: dummyPassword
password: dummyPassword,
});
if (signUpError) {
console.error('Sign-in error:', signInError);
console.error('Sign-up error:', signUpError);
throw new Error('Failed to handle local development auth bypass.');
console.error("Sign-in error:", signInError);
console.error("Sign-up error:", signUpError);
throw new Error("Failed to handle local development auth bypass.");
}
}
return response
return response;
}
const {
data: { user },
Expand Down
16 changes: 16 additions & 0 deletions server/package-lock.json

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

1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"eslint": "^8",
"eslint-config-next": "14.0.3",
"postcss": "^8",
"prettier": "3.3.1",
"tailwindcss": "^3.3.0",
"typescript": "^5"
}
Expand Down

0 comments on commit 031145d

Please sign in to comment.