Skip to content
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

feat: Add prettier formatter #394

Open
wants to merge 5 commits into
base: v2-astro
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Format Check

on:
push:
pull_request:

jobs:
check_format:
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4

- name: Setup Node Formatting
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: Check Formatting
run: |
npm ci --ignore-scripts
npm run format
git diff --exit-code --name-only
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public/grainc.bc.mjs
grain-language-server/
src/content/docs/
12 changes: 12 additions & 0 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import("prettier").Config} */
export default {
plugins: ["prettier-plugin-astro"],
overrides: [
{
files: "*.astro",
options: {
parser: "astro",
},
},
],
};
27 changes: 15 additions & 12 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ import rehypeTableWrapper from "./src/rehype/rehype-table-wrapper";

const require = createRequire(import.meta.url);

const grainLang = JSON.parse(fs.readFileSync("./grain-language-server/editor-extensions/vscode/syntaxes/grain.json"));
const theme = JSON.parse(fs.readFileSync("./themes/github-dark-modified-lighter.json"));
const grainLang = JSON.parse(
fs.readFileSync(
"./grain-language-server/editor-extensions/vscode/syntaxes/grain.json",
),
);
const theme = JSON.parse(
fs.readFileSync("./themes/github-dark-modified-lighter.json"),
);

// https://astro.build/config
export default defineConfig({
Expand Down Expand Up @@ -48,23 +54,20 @@ export default defineConfig({
},
build: {
target: "esnext",
}
},
},

integrations: [tailwind(), svelte()],

redirects: {
"/docs": "/docs/intro",
"/docs/guide": "/docs/guide/basics"
"/docs/guide": "/docs/guide/basics",
},

markdown: {
rehypePlugins: [
rehypeSlug,
[
rehypeAutolinkHeadings,
rehypeAutolinkHeadingsConfig,
],
[rehypeAutolinkHeadings, rehypeAutolinkHeadingsConfig],
rehypeContentIntroTextTransformer,
rehypeTableWrapper,
],
Expand All @@ -75,10 +78,10 @@ export default defineConfig({
code(node) {
// Hack to distinguish block code from inline code in tailwind-typography
node.properties["data-block"] = "true";
}
}
},
},
],
langs: [{...grainLang, name: "grain"}]
}
langs: [{ ...grainLang, name: "grain" }],
},
},
});
41 changes: 28 additions & 13 deletions netlify/functions/mailing-list-unsubscribe.mts
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,47 @@ export default async (req: Request, context: Context) => {
}

try {
const allForms = await fetch(`https://api.netlify.com/api/v1/sites/${siteId}/forms`, {
headers: { Authorization: `Bearer ${apiKey}` },
}).then(res => res.json());
const allForms = await fetch(
`https://api.netlify.com/api/v1/sites/${siteId}/forms`,
{
headers: { Authorization: `Bearer ${apiKey}` },
},
).then((res) => res.json());

const eligibleMailingListForms = allForms.filter((form: any) => form.name === MAILING_LIST_FORM_NAME);
const eligibleMailingListForms = allForms.filter(
(form: any) => form.name === MAILING_LIST_FORM_NAME,
);
if (eligibleMailingListForms.length !== 1) {
console.log(`Found ${eligibleMailingListForms.length} mailing list forms`);
return new Response("Unexpectedly found multiple mailing list sign up forms", { status: 500 });
console.log(
`Found ${eligibleMailingListForms.length} mailing list forms`,
);
return new Response(
"Unexpectedly found multiple mailing list sign up forms",
{ status: 500 },
);
}

const mailingListFormId = eligibleMailingListForms[0].id;

const mailingListSubmissions = await fetch(`https://api.netlify.com/api/v1/forms/${mailingListFormId}/submissions`, {
headers: { Authorization: `Bearer ${apiKey}` },
}).then(res => res.json());
const mailingListSubmissions = await fetch(
`https://api.netlify.com/api/v1/forms/${mailingListFormId}/submissions`,
{
headers: { Authorization: `Bearer ${apiKey}` },
},
).then((res) => res.json());

const matchedSubmissions = mailingListSubmissions
.filter((submission: any) => submission.data.email?.trim()?.toUpperCase() === email);
const matchedSubmissions = mailingListSubmissions.filter(
(submission: any) =>
submission.data.email?.trim()?.toUpperCase() === email,
);

await Promise.all(
matchedSubmissions.map((submission: any) =>
fetch(`https://api.netlify.com/api/v1/submissions/${submission.id}`, {
method: "DELETE",
headers: { Authorization: `Bearer ${apiKey}` },
})
)
}),
),
);

return new Response("Success");
Expand Down
49 changes: 46 additions & 3 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
"astro": "astro",
"format": "prettier . --write"
},
"dependencies": {
"@astrojs/check": "^0.9.4",
Expand Down Expand Up @@ -55,6 +56,8 @@
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.12",
"@types/ramda": "^0.30.2"
"@types/ramda": "^0.30.2",
"prettier": "^3.4.2",
"prettier-plugin-astro": "^0.14.1"
}
}
57 changes: 25 additions & 32 deletions public/fonts/LeagueMono/OFL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@

Version 1.1 - 26 February 2007

----
---

SIL Open Font License
=====================
# SIL Open Font License


Preamble
--------
## Preamble

The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
Expand All @@ -23,15 +20,14 @@ with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

Definitions
-----------
## Definitions

`"Font Software"` refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
Expand All @@ -51,49 +47,46 @@ new environment.
`"Author"` refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

Permission & Conditions
-----------------------
## Permission & Conditions

Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1. Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
in Original or Modified Versions, may be sold by itself.

2. Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3. No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4. The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5. The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

Termination
-----------
## Termination

This license becomes null and void if any of the above conditions are
not met.

Disclaimer
----------
## Disclaimer

THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
Expand Down
2 changes: 1 addition & 1 deletion scripts/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function collectGrainFiles(...segments) {
dirent.name.replace(".gr", ""),
];
const contents = await fs.readFile(
path.join(stdlibDir, ...segments, dirent.name)
path.join(stdlibDir, ...segments, dirent.name),
);
const importIdent = contents.toString().match(/.*?^module\s+(\w+)/m)[1];
const filepathSegment = importPathSegments.join("/");
Expand Down
Loading