Skip to content

Commit

Permalink
run prettier and add back format action (#13722)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner authored Sep 4, 2024
1 parent 5108e3e commit cd67857
Show file tree
Hide file tree
Showing 673 changed files with 1,413 additions and 1,412 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: format

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && inputs.run-id || github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
inputs:
run-id:
type: string
description: The workflow ID to download artifacts (skips the build step)
pull_request:
paths:
- "**/*.{ts,js,json,md,toml,yml,yaml,tsx,jsx}"

jobs:
format:
if: ${{ !inputs.run-id }}
name: Run format
uses: ./.github/workflows/run-format.yml
secrets: inherit
with:
zig-version: 0.13.0
9 changes: 5 additions & 4 deletions .github/workflows/run-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ jobs:
uses: actions/checkout@v4
with:
sparse-checkout: |
.prettierrc-ci
.github
src
scripts
packages
test
bench
package.json
bun.lockb
.vscode
- name: Setup Bun
uses: ./.github/actions/setup-bun
with:
bun-version: "1.1.20"
bun-version: "1.1.26"
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
Expand All @@ -43,9 +47,6 @@ jobs:
- name: Format Zig
run: |
bun fmt:zig
- name: Generate submodule versions
run: |
bash ./scripts/write-versions.sh
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ test/js/deno
test/node.js
src/react-refresh.js
*.min.js
test/js/node/test/fixtures
test/js/node/test/common
test/snippets
31 changes: 31 additions & 0 deletions .prettierrc-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"arrowParens": "avoid",
"printWidth": 120,
"trailingComma": "all",
"useTabs": false,
"quoteProps": "preserve",
"plugins": [
"prettier-plugin-organize-imports"
],
"overrides": [
{
"files": [
".vscode/*.json"
],
"options": {
"parser": "jsonc",
"quoteProps": "preserve",
"singleQuote": false,
"trailingComma": "all"
}
},
{
"files": [
"*.md"
],
"options": {
"printWidth": 80
}
}
]
}
2 changes: 1 addition & 1 deletion bench/async/bun.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { run, bench } from "mitata";
import { bench, run } from "mitata";

bench("sync", () => {});
bench("async", async () => {});
Expand Down
2 changes: 1 addition & 1 deletion bench/async/deno.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { run, bench } from "../node_modules/mitata/src/cli.mjs";
import { bench, run } from "../node_modules/mitata/src/cli.mjs";

bench("sync", () => {});
bench("async", async () => {});
Expand Down
2 changes: 1 addition & 1 deletion bench/async/node.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { run, bench } from "mitata";
import { bench, run } from "mitata";

bench("sync", () => {});
bench("async", async () => {});
Expand Down
2 changes: 1 addition & 1 deletion bench/copyfile/node.mitata.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { copyFileSync, writeFileSync, readFileSync, statSync } from "node:fs";
import { bench, run } from "mitata";
import { copyFileSync, statSync, writeFileSync } from "node:fs";

function runner(ready) {
for (let size of [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) {
Expand Down
2 changes: 1 addition & 1 deletion bench/deepEqual/map.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, run } from "mitata";
import { expect } from "bun:test";
import { bench, run } from "mitata";

const MAP_SIZE = 10_000;

Expand Down
2 changes: 1 addition & 1 deletion bench/deepEqual/set.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, run } from "mitata";
import { expect } from "bun:test";
import { bench, run } from "mitata";

const SET_SIZE = 10_000;

Expand Down
1 change: 0 additions & 1 deletion bench/emitter/implementations.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import EventEmitter3 from "eventemitter3";
import { group } from "mitata";
import EventEmitterNative from "node:events";

Expand Down
2 changes: 1 addition & 1 deletion bench/expect-to-equal/expect-to-equal.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// bun:test automatically rewrites this import to bun:test when run in bun
import { test, expect } from "@jest/globals";
import { expect, test } from "@jest/globals";

const N = parseInt(process.env.RUN_COUNT || "10000", 10);
if (!Number.isSafeInteger(N)) {
Expand Down
2 changes: 1 addition & 1 deletion bench/expect-to-equal/expect-to-equal.vitest.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from "vitest";
import { expect, test } from "vitest";

const N = parseInt(process.env.RUN_COUNT || "10000", 10);
if (!Number.isSafeInteger(N)) {
Expand Down
4 changes: 2 additions & 2 deletions bench/ffi/bun.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ptr, dlopen, CString, toBuffer } from "bun:ffi";
import { run, bench, group } from "mitata";
import { CString, dlopen, ptr } from "bun:ffi";
import { bench, group, run } from "mitata";

const { napiNoop, napiHash, napiString } = require(import.meta.dir + "/src/ffi_napi_bench.node");

Expand Down
2 changes: 1 addition & 1 deletion bench/ffi/deno.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { run, bench, group } from "../node_modules/mitata/src/cli.mjs";
import { bench, group, run } from "../node_modules/mitata/src/cli.mjs";

const extension = "darwin" !== Deno.build.os ? "so" : "dylib";
const path = new URL("src/target/release/libffi_napi_bench." + extension, import.meta.url).pathname;
Expand Down
2 changes: 1 addition & 1 deletion bench/ffi/node.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { run, bench, group } from "mitata";
import { bench, group, run } from "mitata";
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);
Expand Down
2 changes: 1 addition & 1 deletion bench/glob/braces.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import braces from "braces";
import { group, bench, run } from "mitata";
import { bench, group, run } from "mitata";

// const iterations = 1000;
const iterations = 100;
Expand Down
2 changes: 1 addition & 1 deletion bench/glob/scan.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { run, bench, group } from "mitata";
import fg from "fast-glob";
import { fdir } from "fdir";
import { bench, group, run } from "mitata";

const normalPattern = "*.ts";
const recursivePattern = "**/*.ts";
Expand Down
4 changes: 2 additions & 2 deletions bench/gzip/bun.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { run, bench, group } from "mitata";
import { gzipSync, gunzipSync } from "bun";
import { gunzipSync, gzipSync } from "bun";
import { bench, group, run } from "mitata";

const data = await Bun.file(require.resolve("@babel/standalone/babel.min.js")).arrayBuffer();

Expand Down
2 changes: 1 addition & 1 deletion bench/gzip/deno.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { run, bench } from "../node_modules/mitata/src/cli.mjs";
import { bench, run } from "../node_modules/mitata/src/cli.mjs";

const data = new TextEncoder().encode("Hello World!".repeat(9999));

Expand Down
6 changes: 3 additions & 3 deletions bench/gzip/node.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { run, bench } from "mitata";
import { gzipSync, gunzipSync } from "zlib";
import { createRequire } from "module";
import { readFileSync } from "fs";
import { bench, run } from "mitata";
import { createRequire } from "module";
import { gunzipSync, gzipSync } from "zlib";

const require = createRequire(import.meta.url);
const data = readFileSync(require.resolve("@babel/standalone/babel.min.js"));
Expand Down
3 changes: 1 addition & 2 deletions bench/hot-module-reloading/css-stress-test/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Main } from "./main";
import classNames from "classnames";
import ReactDOM from "react-dom";
import { Main } from "./main";

const Base = ({}) => {
const name = typeof location !== "undefined" ? decodeURIComponent(location.search.substring(1)) : null;
Expand Down
2 changes: 1 addition & 1 deletion bench/install/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* For more information, see https://remix.run/docs/en/main/file-conventions/entry.server
*/

import { PassThrough } from "node:stream";
import type { EntryContext } from "@remix-run/node";
import { Response } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import isbot from "isbot";
import { PassThrough } from "node:stream";
import { renderToPipeableStream } from "react-dom/server";

const ABORT_DELAY = 5_000;
Expand Down
10 changes: 5 additions & 5 deletions bench/modules/node_os/bun.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { bench, run } from "mitata";
import {
arch,
cpus,
endianness,
arch,
uptime,
networkInterfaces,
getPriority,
totalmem,
freemem,
getPriority,
homedir,
hostname,
loadavg,
networkInterfaces,
platform,
release,
setPriority,
tmpdir,
totalmem,
type,
uptime,
userInfo,
version,
} from "node:os";
Expand Down
10 changes: 5 additions & 5 deletions bench/modules/node_os/node.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { bench, run } from "mitata";
import {
arch,
cpus,
endianness,
arch,
uptime,
networkInterfaces,
getPriority,
totalmem,
freemem,
getPriority,
homedir,
hostname,
loadavg,
networkInterfaces,
platform,
release,
setPriority,
tmpdir,
totalmem,
type,
uptime,
userInfo,
version,
} from "node:os";
Expand Down
2 changes: 1 addition & 1 deletion bench/react-hello-world/react-hello-world.deno.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { renderToReadableStream } from "https://esm.run/react-dom/server";
import * as React from "https://esm.run/react";
import { renderToReadableStream } from "https://esm.run/react-dom/server";

const App = () => (
<html>
Expand Down
2 changes: 1 addition & 1 deletion bench/react-hello-world/react-hello-world.node.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// react-ssr.tsx
import { renderToPipeableStream } from "react-dom/server.node";
import React from "react";
import { renderToPipeableStream } from "react-dom/server.node";
const http = require("http");
const App = () => (
<html>
Expand Down
2 changes: 1 addition & 1 deletion bench/scanner/remix-route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ActionFunction, LoaderFunction } from "remix";
import { useParams } from "remix";
import type { LoaderFunction, ActionFunction } from "remix";

export const loader: LoaderFunction = async ({ params }) => {
console.log(params.postId);
Expand Down
2 changes: 1 addition & 1 deletion bench/snippets/assert.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, group, run } from "./runner.mjs";
import * as assert from "assert";
import { bench, run } from "./runner.mjs";

bench("deepEqual", () => {
assert.deepEqual({ foo: "123", bar: "baz" }, { foo: "123", bar: "baz" });
Expand Down
4 changes: 2 additions & 2 deletions bench/snippets/buffer-create.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @runtime bun,node,deno
import { bench, run } from "./runner.mjs";
import process from "node:process";
import { Buffer } from "node:buffer";
import process from "node:process";
import { bench, run } from "./runner.mjs";

const N = parseInt(process.env.RUN_COUNTER ?? "10000", 10);
var isBuffer = new Buffer(0);
Expand Down
2 changes: 1 addition & 1 deletion bench/snippets/buffer-to-string.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { bench, run } from "./runner.mjs";
import { Buffer } from "node:buffer";
import crypto from "node:crypto";
import { bench, run } from "./runner.mjs";

const bigBuffer = Buffer.from("hello world".repeat(10000));
const converted = bigBuffer.toString("base64");
Expand Down
4 changes: 2 additions & 2 deletions bench/snippets/concat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { bench, group, run } from "./runner.mjs";
import { readFileSync } from "fs";
import { allocUnsafe } from "bun";
import { readFileSync } from "fs";
import { bench, group, run } from "./runner.mjs";

function polyfill(chunks) {
var size = 0;
Expand Down
2 changes: 1 addition & 1 deletion bench/snippets/crypto.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// so it can run in environments without node module resolution
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
import crypto from "node:crypto";
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
var foo = new Uint8Array(65536);
bench("crypto.getRandomValues(65536)", () => {
crypto.getRandomValues(foo);
Expand Down
2 changes: 1 addition & 1 deletion bench/snippets/deep-equals.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, group, run } from "./runner.mjs";
import fastDeepEquals from "fast-deep-equal/es6/index";
import { bench, group, run } from "./runner.mjs";
// const Date = globalThis.Date;

function func1() {}
Expand Down
2 changes: 1 addition & 1 deletion bench/snippets/dns.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dns } from "bun";
import { bench, run, group } from "./runner.mjs";
import { bench, group, run } from "./runner.mjs";

async function forEachBackend(name, fn) {
group(name, () => {
Expand Down
2 changes: 1 addition & 1 deletion bench/snippets/encode-into.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { run, bench } from "../node_modules/mitata/src/cli.mjs";
import { bench, run } from "../node_modules/mitata/src/cli.mjs";

const encoder = new TextEncoder();

Expand Down
5 changes: 1 addition & 4 deletions bench/snippets/escapeHTML.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { group } from "./runner.mjs";
import { bench, run } from "./runner.mjs";
import { encode as htmlEntityEncode } from "html-entities";
import { escape as heEscape } from "he";
import { bench, group, run } from "./runner.mjs";

var bunEscapeHTML = globalThis.escapeHTML || Bun.escapeHTML;

Expand Down
2 changes: 1 addition & 1 deletion bench/snippets/ffi-overhead.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { viewSource, dlopen, CString, ptr, toBuffer, toArrayBuffer, FFIType, callback } from "bun:ffi";
import { dlopen } from "bun:ffi";
import { bench, group, run } from "./runner.mjs";

const types = {
Expand Down
2 changes: 1 addition & 1 deletion bench/snippets/new-incomingmessage.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, run } from "./runner.mjs";
import { IncomingMessage } from "node:http";
import { bench, run } from "./runner.mjs";

const headers = {
date: "Mon, 06 Nov 2023 05:12:49 GMT",
Expand Down
Loading

0 comments on commit cd67857

Please sign in to comment.