ci: format files outside `src` folder
MODIFY
website/.eleventy.js
website/.eleventy.js
@@ -23,8 +23,7 @@ const grayMatter = require("gray-matter");
const isProduction = process.env.ELEVENTY_ENV === "production";
-module.exports =
- function (eleventyConfig) {
+module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy({ static: "." });
eleventyConfig.setUseGitIgnore(false);
@@ -32,10 +31,11 @@ module.exports =
eleventyConfig.addPlugin(syntaxHighlight);
- eleventyConfig.addPlugin(
- pluginTOC,
- { tags: ["h2", "h3", "h4"], wrapper: "div ", wrapperClass: "toc" },
- );
+ eleventyConfig.addPlugin(pluginTOC, {
+ tags: ["h2", "h3", "h4"],
+ wrapper: "div ",
+ wrapperClass: "toc",
+ });
eleventyConfig.addPlugin(eleventyNavigationPlugin);
@@ -47,9 +47,7 @@ module.exports =
md.use(markdownItFootnote);
- md.use(
- markdownItAnchor,
- {
+ md.use(markdownItAnchor, {
permalink: true,
permalinkSymbol: "",
permalinkAttrs: (slug) => ({ "aria-label": slug }),
@@ -61,22 +59,18 @@ module.exports =
).replace(/\s+/g, "-"),
);
},
- },
- );
+ });
eleventyConfig.setLibrary("md", md);
// Taken from https://github.com/11ty/eleventy-base-blog/blob/master/_11ty/getTagList.js
- eleventyConfig.addCollection(
- "tagList",
- function (collection) {
+ eleventyConfig.addCollection("tagList", function (collection) {
let tagSet = new Set();
collection.getAll().forEach(function (item) {
if ("tags" in item.data) {
let tags = item.data.tags;
- tags =
- tags.filter(function (item) {
+ tags = tags.filter(function (item) {
switch (item) {
// This list should match the `filter` list in tags.liquid
case "all":
@@ -87,24 +81,21 @@ module.exports =
}
return true;
- },);
+ });
for (const tag of tags) {
tagSet.add(tag);
}
}
- },);
+ });
// Returning an array in addCollection works in Eleventy 0.5.3
return [...tagSet];
- },
- );
+ });
// Used for including raw files without having them processed by liquid
const includerawCache = new Map();
- eleventyConfig.addFilter(
- "includeraw",
- function (loc) {
+ eleventyConfig.addFilter("includeraw", function (loc) {
const cached = includerawCache.get(loc);
if (cached !== undefined) {
return cached;
@@ -113,22 +104,16 @@ module.exports =
const file = fs.readFileSync(path.resolve(__dirname, loc), "utf8");
includerawCache.set(loc, file);
return file;
- },
- );
+ });
- eleventyConfig.addFilter(
- "toBase64",
- (content, ext) => {
+ eleventyConfig.addFilter("toBase64", (content, ext) => {
return base64Encode(new Buffer(content), ext);
- },
- );
+ });
const minCache = new Map();
// Minify JS in production
- eleventyConfig.addFilter(
- "jsmin",
- function (code) {
+ eleventyConfig.addFilter("jsmin", function (code) {
if (!isProduction) {
return code;
}
@@ -145,13 +130,10 @@ module.exports =
minCache.set(code, minified.code);
return minified.code;
- },
- );
+ });
// Minify CSS in production
- eleventyConfig.addFilter(
- "cssmin",
- function (code) {
+ eleventyConfig.addFilter("cssmin", function (code) {
if (!isProduction) {
return code;
}
@@ -164,52 +146,39 @@ module.exports =
const minified = new CleanCSS({}).minify(code).styles;
minCache.set(code, minified);
return minified;
- },
- );
+ });
// Minify HTML in production
- eleventyConfig.addTransform(
- "htmlmin",
- function (content, outputPath) {
+ eleventyConfig.addTransform("htmlmin", function (content, outputPath) {
if (isProduction && outputPath.endsWith(".html")) {
- return htmlmin.minify(
- content,
- {
+ return htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
conservativeCollapse: true,
collapseWhitespace: true,
- },
- );
+ });
}
return content;
- },
- );
+ });
- eleventyConfig.addFilter(
- "blogSummary",
- (val) => {
+ eleventyConfig.addFilter("blogSummary", (val) => {
const lines = val.split("<!-- DESCRIPTION_END -->")[0].split("\n");
return lines.filter((line) => {
return line.startsWith("<p>");
- },).join("\n");
- },
- );
-
- eleventyConfig.addFilter(
- "dateFormat",
- function (value) {
- return new Date(value).toLocaleDateString(
- undefined,
- { year: "numeric", month: "long", day: "numeric", timeZone: "UTC" },
- );
- },
- );
-
- eleventyConfig.addFilter(
- "titlify",
- function (title) {
+ }).join("\n");
+ });
+
+ eleventyConfig.addFilter("dateFormat", function (value) {
+ return new Date(value).toLocaleDateString(undefined, {
+ year: "numeric",
+ month: "long",
+ day: "numeric",
+ timeZone: "UTC",
+ });
+ });
+
+ eleventyConfig.addFilter("titlify", function (title) {
title = (title || "").trim();
if (!title.includes("Rome")) {
if (title !== "") {
@@ -218,22 +187,15 @@ module.exports =
title += "Rome Toolchain";
}
return title;
- },
- );
+ });
- eleventyConfig.addFilter(
- "kebabCase",
- function (string) {
+ eleventyConfig.addFilter("kebabCase", function (string) {
return string.toLowerCase().replace(/\s/g, "-");
- },
- );
+ });
- eleventyConfig.addShortcode(
- "romeVersion",
- function () {
+ eleventyConfig.addShortcode("romeVersion", function () {
return "?.?.?";
- },
- );
+ });
// Customize YAML engine so we can parse hard tabs lol...
eleventyConfig.setFrontMatterParsingOptions({
@@ -246,7 +208,7 @@ module.exports =
},
},
},
- },);
+ });
return {
dir: { input: "src", output: "build" },

MODIFY
website/api/constants.js
website/api/constants.js
-exports.stripeShippingCollection =
- {
+exports.stripeShippingCollection = {
// Stripe forces us to specify this enum so allow every country...
allowed_countries: [
"AC", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AT",

MODIFY
website/api/server.js
website/api/server.js
@@ -39,7 +39,10 @@ const tiers = [
metal: "bronze",
price: 25,
rewards: ["Sticker"],
- previousRewards: ["Cosmetic Discord role", "Cosmetic label on GitHub issues"],
+ previousRewards: [
+ "Cosmetic Discord role",
+ "Cosmetic label on GitHub issues",
+ ],
},
{
id: "advocate",
@@ -48,7 +51,10 @@ const tiers = [
metal: "silver",
price: 50,
rewards: ["Sticker pack"],
- previousRewards: ["Cosmetic Discord role", "Cosmetic label on GitHub issues"],
+ previousRewards: [
+ "Cosmetic Discord role",
+ "Cosmetic label on GitHub issues",
+ ],
},
{
id: "champion",
@@ -220,13 +226,11 @@ function wrapAsyncCallback(callback) {
app.use(morgan("tiny"));
-app.use(
- (req, res, next) => {
+app.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
next();
- },
-);
+});
async function getContributions(limit) {
const query = await db.query(
@@ -236,12 +240,13 @@ async function getContributions(limit) {
return query.rows.map((row) => {
return {
name: row.publicName,
- github: row.github === "" || row.publicName === "" ? undefined : row.github,
+ github:
+ row.github === "" || row.publicName === "" ? undefined : row.github,
comment: row.publicComment,
amount: Number(row.tierPrice) + Number(row.tip),
time: new Date(row.createdAt).valueOf(),
};
- },);
+ });
}
async function getTierStats() {
@@ -259,7 +264,7 @@ async function getTierStats() {
...tier,
count: query.rows.length === 0 ? 0 : Number(query.rows[0].count),
};
- },),
+ }),
);
}
@@ -269,12 +274,12 @@ async function getProgressStats() {
db.query(
`SELECT SUM("tierPrice") as "tierPrice", SUM("tip") as tip FROM contributions WHERE paid = true`,
),
- ],);
+ ]);
- const count = countQuery.rows.length === 0 ? 0 : Number(
- countQuery.rows[0].count,
- );
- let current = totalQuery.rows.length === 0 ? 0 : Number(
+ const count =
+ countQuery.rows.length === 0 ? 0 : Number(countQuery.rows[0].count);
+ let current =
+ totalQuery.rows.length === 0 ? 0 : Number(
totalQuery.rows[0].tierPrice,
) + Number(totalQuery.rows[0].tip);
@@ -310,15 +315,12 @@ function getAllContributions() {
}
async function getFreshStats() {
- const [
- { count, current, target },
- recentContributions,
- tiers,
- ] = await Promise.all([
+ const [{ count, current, target }, recentContributions, tiers] =
+ await Promise.all([
getProgressStats(),
getContributions(3),
getTierStats(),
- ],);
+ ]);
return { count, current, target, recentContributions, tiers };
}
@@ -327,14 +329,14 @@ app.get(
"/funding/stats",
wrapAsyncCallback(async (req, res) => {
res.json(await getStats());
- },),
+ }),
);
app.get(
"/funding/all",
wrapAsyncCallback(async (req, res) => {
res.json(await getAllContributions());
- },),
+ }),
);
function generateRewardsDescription(tier) {
@@ -376,7 +378,7 @@ app.post(
unit_amount: tierPrice * 100,
},
quantity: 1,
- },);
+ });
if (tip > 0) {
lineItems.push({
@@ -386,7 +388,7 @@ app.post(
unit_amount: tip * 100,
},
quantity: 1,
- },);
+ });
}
const session = await stripe.checkout.sessions.create({
@@ -402,7 +404,7 @@ app.post(
// Don't request shipping address for custom donators
shipping_address_collection:
tier.id !== "custom" && tierPrice > 10 ? constants.stripeShippingCollection : undefined,
- },);
+ });
const isPublic = ensureBoolean(body.public);
const publicName = ensureString(body.publicName, 100);
@@ -429,7 +431,7 @@ app.post(
);
res.json({ id: session.id });
- },),
+ }),
);
app.post(
@@ -457,9 +459,8 @@ app.post(
cachedAllContributions = undefined;
// Purge cache from Cloudflare
- await fetch(
- `https://api.cloudflare.com/client/v4/zones/${process.env.CF_ZONE_ID}/purge_cache`,
- {
+ await fetch(`https://api.cloudflare.com/client/v4/zones/${process.env
+ .CF_ZONE_ID}/purge_cache`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -470,18 +471,16 @@ app.post(
`${process.env.API_URL}/funding/stats`,
`${process.env.API_URL}/funding/all`,
],
- },),
- },
- );
+ }),
+ });
}
res.status(200);
res.end();
- },),
+ }),
);
-app.use(
- function (err, req, res, next) {
+app.use(function (err, req, res, next) {
// rome-ignore lint/js/preferOptionalChaining: netlify's node version does not support optional call expressions
if (Sentry !== undefined) {
Sentry.captureException(err);
@@ -490,20 +489,16 @@ app.use(
res.status(500);
res.end("Internal server error");
next;
- },
-);
+});
async function main() {
await db.connect();
const port = Number(process.env.API_PORT || 8_081);
- app.listen(
- port,
- () => {
+ app.listen(port, () => {
console.log(`API server listening on port ${port}!`);
- },
- );
+ });
}
main().catch((err) => {
@@ -513,4 +508,4 @@ main().catch((err) => {
}
console.error(err.stack);
process.exit(1);
-},);
+});

MODIFY
website/package.json
website/package.json
"start": "pnpm run --parallel watch:eleventy watch:sass build:styles",
"watch:eleventy": "eleventy --serve",
"watch:sass": "pnpm build:styles -- --watch",
- "format": "rome format --write src"
+ "format": "rome format --write ."
},
"devDependencies": {
"@11ty/eleventy": "^0.12.1",

MODIFY
website/playground/src/DesktopPlayground.tsx
website/playground/src/DesktopPlayground.tsx
@@ -153,7 +153,8 @@ export default function DesktopPlayground(
<pre className="h-screen overflow-scroll">{prettierOutput.ir}</pre>
</TabPanel>
<TabPanel>
- <div className="h-screen overflow-scroll whitespace-pre-wrap text-red-500 text-xs error-panel"
+ <div
+ className="h-screen overflow-scroll whitespace-pre-wrap text-red-500 text-xs error-panel"
dangerouslySetInnerHTML={{ __html: errors }}
/>
</TabPanel>

ci: format files outside `src` folder (#2829)