aboutsummaryrefslogtreecommitdiff
path: root/test/snippets
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-03-02 19:02:10 -0800
committerGravatar GitHub <noreply@github.com> 2023-03-02 19:02:10 -0800
commit9388b3f8257bc2e580deaece4cd2677928104fc6 (patch)
tree3f6aff2009cef69897f599fe51305b894f81a376 /test/snippets
parentb469e5035161286abeb1a7726518d1afcc163a51 (diff)
downloadbun-9388b3f8257bc2e580deaece4cd2677928104fc6.tar.gz
bun-9388b3f8257bc2e580deaece4cd2677928104fc6.tar.zst
bun-9388b3f8257bc2e580deaece4cd2677928104fc6.zip
Add a zig fmt action (#2277)
* Add a zig fmt action * add failing file * Setup prettier better * Update prettier-fmt.yml * Fail on error * Update prettier-fmt.yml * boop * boop2 * tar.gz * Update zig-fmt.yml * Update zig-fmt.yml * Update zig-fmt.yml * Update zig-fmt.yml * Update zig-fmt.yml * boop * Update prettier-fmt.yml * tag * newlines * multiline * fixup * Update zig-fmt.yml * update it * fixup * both * w * Update prettier-fmt.yml * prettier all the things * Update package.json * zig fmt * ❌ ✅ * bump * . * quotes * fix prettier ignore * once more * Update prettier-fmt.yml * Update fallback.ts * consistentcy --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test/snippets')
-rw-r--r--test/snippets/code-simplification-neql-define.js20
-rw-r--r--test/snippets/export.js5
-rw-r--r--test/snippets/jsx-entities.jsx5
-rw-r--r--test/snippets/latin1-chars-in-regexp.js34
-rw-r--r--test/snippets/optional-chain-with-function.js8
-rw-r--r--test/snippets/react-context-value-func.tsx2
-rw-r--r--test/snippets/simple-lit-example.ts8
-rw-r--r--test/snippets/spread_with_key.tsx7
-rw-r--r--test/snippets/string-escapes.js34
-rw-r--r--test/snippets/styledcomponents-output.js20
-rw-r--r--test/snippets/template-literal.js15
-rw-r--r--test/snippets/type-only-imports.ts3
12 files changed, 44 insertions, 117 deletions
diff --git a/test/snippets/code-simplification-neql-define.js b/test/snippets/code-simplification-neql-define.js
index c7676dc9b..bd7ab9207 100644
--- a/test/snippets/code-simplification-neql-define.js
+++ b/test/snippets/code-simplification-neql-define.js
@@ -2,7 +2,7 @@ var testFailed = false;
const invariant = () => {
testFailed = true;
};
-var $$m = (arg) => {
+var $$m = arg => {
var module = { exports: {} },
exports = module.exports;
return arg(module, exports);
@@ -12,31 +12,19 @@ var size = 100,
export var $f332019d = $$m(
{
- "relay-runtime/lib/network/RelayQueryResponseCache.js": (
- module,
- exports,
- ) => {
+ "relay-runtime/lib/network/RelayQueryResponseCache.js": (module, exports) => {
var RelayQueryResponseCache = function () {
var foo = function RelayQueryResponseCache(_ref) {
var size = _ref.size,
ttl = _ref.ttl;
!(size > 0)
? process.env.NODE_ENV !== "production"
- ? invariant(
- false,
- "RelayQueryResponseCache: Expected the max cache size to be > 0, got " +
- "`%s`.",
- size,
- )
+ ? invariant(false, "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + "`%s`.", size)
: invariant(false)
: void 0;
!(ttl > 0)
? process.env.NODE_ENV !== "production"
- ? invariant(
- false,
- "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.",
- ttl,
- )
+ ? invariant(false, "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", ttl)
: invariant(false)
: void 0;
};
diff --git a/test/snippets/export.js b/test/snippets/export.js
index 2a757269f..bf334f025 100644
--- a/test/snippets/export.js
+++ b/test/snippets/export.js
@@ -21,9 +21,6 @@ export function test() {
if (where.default !== "hi") {
throw new Error(`_auth import is incorrect.`);
}
- console.assert(
- powerLevel.description === "9001",
- "Symbol is not exported correctly",
- );
+ console.assert(powerLevel.description === "9001", "Symbol is not exported correctly");
return testDone(import.meta.url);
}
diff --git a/test/snippets/jsx-entities.jsx b/test/snippets/jsx-entities.jsx
index ac5d32225..7123fd674 100644
--- a/test/snippets/jsx-entities.jsx
+++ b/test/snippets/jsx-entities.jsx
@@ -926,10 +926,7 @@ export function test() {
key = txt.value;
}
- console.assert(
- elements[rawKey] === key.codePointAt(0),
- `${key} is not ${elements[rawKey]}`,
- );
+ console.assert(elements[rawKey] === key.codePointAt(0), `${key} is not ${elements[rawKey]}`);
}
return testDone(import.meta.url);
diff --git a/test/snippets/latin1-chars-in-regexp.js b/test/snippets/latin1-chars-in-regexp.js
index 1a533b1e1..0ba85d100 100644
--- a/test/snippets/latin1-chars-in-regexp.js
+++ b/test/snippets/latin1-chars-in-regexp.js
@@ -10,40 +10,24 @@
export var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
export var re_btou = new RegExp(
- [
- "[\xC0-\xDF][\x80-\xBF]",
- "[\xE0-\xEF][\x80-\xBF]{2}",
- "[\xF0-\xF7][\x80-\xBF]{3}",
- ].join("|"),
+ ["[\xC0-\xDF][\x80-\xBF]", "[\xE0-\xEF][\x80-\xBF]{2}", "[\xF0-\xF7][\x80-\xBF]{3}"].join("|"),
"g",
);
const encoder = new TextEncoder();
-const realLines = [
- "[\xC0-\xDF][\x80-\xBF]",
- "[\xE0-\xEF][\x80-\xBF]{2}",
- "[\xF0-\xF7][\x80-\xBF]{3}",
-];
-const real = realLines.map((input) => Array.from(encoder.encode(input)));
+const realLines = ["[\xC0-\xDF][\x80-\xBF]", "[\xE0-\xEF][\x80-\xBF]{2}", "[\xF0-\xF7][\x80-\xBF]{3}"];
+const real = realLines.map(input => Array.from(encoder.encode(input)));
const expected = [
[91, 195, 128, 45, 195, 159, 93, 91, 194, 128, 45, 194, 191, 93],
- [
- 91, 195, 160, 45, 195, 175, 93, 91, 194, 128, 45, 194, 191, 93, 123, 50,
- 125,
- ],
- [
- 91, 195, 176, 45, 195, 183, 93, 91, 194, 128, 45, 194, 191, 93, 123, 51,
- 125,
- ],
+ [91, 195, 160, 45, 195, 175, 93, 91, 194, 128, 45, 194, 191, 93, 123, 50, 125],
+ [91, 195, 176, 45, 195, 183, 93, 91, 194, 128, 45, 194, 191, 93, 123, 51, 125],
];
const newlinePreserved = `\n`;
export function test() {
- if (
- !real.every((point, i) => point.every((val, j) => val === expected[i][j]))
- ) {
+ if (!real.every((point, i) => point.every((val, j) => val === expected[i][j]))) {
throw new Error(
`test failed
${JSON.stringify({ expected, real }, null, 2)}`,
@@ -55,11 +39,7 @@ ${JSON.stringify({ expected, real }, null, 2)}`,
}
const decoder = new TextDecoder("utf8");
- if (
- !realLines.every(
- (line, i) => decoder.decode(Uint8Array.from(expected[i])) === line,
- )
- ) {
+ if (!realLines.every((line, i) => decoder.decode(Uint8Array.from(expected[i])) === line)) {
throw new Error(
`test failed. Lines did not match.
${JSON.stringify({ expected, real }, null, 2)}`,
diff --git a/test/snippets/optional-chain-with-function.js b/test/snippets/optional-chain-with-function.js
index 82ad51d46..841c8a584 100644
--- a/test/snippets/optional-chain-with-function.js
+++ b/test/snippets/optional-chain-with-function.js
@@ -3,10 +3,10 @@ export function test() {
const multipleSecondaryValues = undefined;
const ratings = ["123"];
- var bar = multipleSecondaryValues?.map((value) => false);
- bar = bar?.multipleSecondaryValues?.map((value) => false);
- bar = bar?.bar?.multipleSecondaryValues?.map((value) => false);
- bar = {}?.bar?.multipleSecondaryValues?.map((value) => false);
+ var bar = multipleSecondaryValues?.map(value => false);
+ bar = bar?.multipleSecondaryValues?.map(value => false);
+ bar = bar?.bar?.multipleSecondaryValues?.map(value => false);
+ bar = {}?.bar?.multipleSecondaryValues?.map(value => false);
} catch (e) {
throw e;
}
diff --git a/test/snippets/react-context-value-func.tsx b/test/snippets/react-context-value-func.tsx
index e7ced1292..800ad428d 100644
--- a/test/snippets/react-context-value-func.tsx
+++ b/test/snippets/react-context-value-func.tsx
@@ -12,7 +12,7 @@ const ContextProvider = ({ children }) => {
const ContextValue = ({}) => (
<Context.Consumer>
- {(foo) => {
+ {foo => {
if (foo) {
return <div>Worked!</div>;
}
diff --git a/test/snippets/simple-lit-example.ts b/test/snippets/simple-lit-example.ts
index 3c53f03ab..1b10b61db 100644
--- a/test/snippets/simple-lit-example.ts
+++ b/test/snippets/simple-lit-example.ts
@@ -3,7 +3,7 @@ import { LitElement, html, css } from "lit";
import { customElement, property, eventOptions } from "lit/decorators.js";
var loadedResolve;
-var loadedPromise = new Promise((resolve) => {
+var loadedPromise = new Promise(resolve => {
loadedResolve = resolve;
});
@@ -35,11 +35,7 @@ export class MyElement extends LitElement {
@property() planet = "Earth";
render() {
- return html`
- <span @click=${this.togglePlanet} class="planet" id="planet-id"
- >${this.planet}</span
- >
- `;
+ return html` <span @click=${this.togglePlanet} class="planet" id="planet-id">${this.planet}</span> `;
}
@eventOptions({ once: true })
diff --git a/test/snippets/spread_with_key.tsx b/test/snippets/spread_with_key.tsx
index d9f842d27..2dc0c7072 100644
--- a/test/snippets/spread_with_key.tsx
+++ b/test/snippets/spread_with_key.tsx
@@ -4,12 +4,7 @@ import React from "react";
export function SpreadWithTheKey({ className }: Props) {
const rest = {};
return (
- <div
- className={className}
- key="spread-with-the-key"
- {...rest}
- onClick={() => console.log("click")}
- >
+ <div className={className} key="spread-with-the-key" {...rest} onClick={() => console.log("click")}>
Rendered component containing warning
</div>
);
diff --git a/test/snippets/string-escapes.js b/test/snippets/string-escapes.js
index 436140939..5fbc8da6c 100644
--- a/test/snippets/string-escapes.js
+++ b/test/snippets/string-escapes.js
@@ -30,31 +30,23 @@ const encoder = new TextEncoder();
const encodedObj = encoder.encode(JSON.stringify(obj));
// ------------------------------------------------------------
const correctEncodedObj = [
- 123, 34, 92, 114, 92, 110, 34, 58, 34, 92, 114, 92, 110, 34, 44, 34, 92, 110,
- 34, 58, 34, 92, 110, 34, 44, 34, 92, 116, 34, 58, 34, 92, 116, 34, 44, 34, 92,
- 102, 34, 58, 34, 92, 102, 34, 44, 34, 92, 117, 48, 48, 48, 98, 34, 58, 34, 92,
- 117, 48, 48, 48, 98, 34, 44, 34, 226, 128, 168, 34, 58, 34, 226, 128, 168, 34,
- 44, 34, 226, 128, 169, 34, 58, 34, 226, 128, 169, 34, 44, 34, 92, 117, 48, 48,
- 48, 48, 34, 58, 34, 92, 117, 48, 48, 48, 48, 194, 160, 110, 117, 108, 108, 32,
- 98, 121, 116, 101, 34, 44, 34, 240, 159, 152, 138, 34, 58, 34, 240, 159, 152,
- 138, 34, 44, 34, 240, 159, 152, 131, 34, 58, 34, 240, 159, 152, 131, 34, 44,
- 34, 240, 159, 149, 181, 240, 159, 143, 189, 226, 128, 141, 226, 153, 130, 239,
- 184, 143, 34, 58, 34, 240, 159, 149, 181, 240, 159, 143, 189, 226, 128, 141,
- 226, 153, 130, 239, 184, 143, 34, 44, 34, 227, 139, 161, 34, 58, 34, 227, 139,
- 161, 34, 44, 34, 226, 152, 186, 34, 58, 34, 226, 152, 186, 34, 44, 34, 227,
- 130, 183, 34, 58, 34, 227, 130, 183, 34, 44, 34, 240, 159, 145, 139, 34, 58,
- 34, 240, 159, 145, 139, 34, 44, 34, 102, 34, 58, 34, 226, 130, 135, 34, 44,
- 34, 226, 152, 185, 34, 58, 34, 226, 152, 185, 34, 44, 34, 226, 152, 187, 34,
- 58, 34, 226, 152, 187, 34, 44, 34, 99, 104, 105, 108, 100, 114, 101, 110, 34,
- 58, 49, 50, 51, 125,
+ 123, 34, 92, 114, 92, 110, 34, 58, 34, 92, 114, 92, 110, 34, 44, 34, 92, 110, 34, 58, 34, 92, 110, 34, 44, 34, 92,
+ 116, 34, 58, 34, 92, 116, 34, 44, 34, 92, 102, 34, 58, 34, 92, 102, 34, 44, 34, 92, 117, 48, 48, 48, 98, 34, 58, 34,
+ 92, 117, 48, 48, 48, 98, 34, 44, 34, 226, 128, 168, 34, 58, 34, 226, 128, 168, 34, 44, 34, 226, 128, 169, 34, 58, 34,
+ 226, 128, 169, 34, 44, 34, 92, 117, 48, 48, 48, 48, 34, 58, 34, 92, 117, 48, 48, 48, 48, 194, 160, 110, 117, 108, 108,
+ 32, 98, 121, 116, 101, 34, 44, 34, 240, 159, 152, 138, 34, 58, 34, 240, 159, 152, 138, 34, 44, 34, 240, 159, 152, 131,
+ 34, 58, 34, 240, 159, 152, 131, 34, 44, 34, 240, 159, 149, 181, 240, 159, 143, 189, 226, 128, 141, 226, 153, 130, 239,
+ 184, 143, 34, 58, 34, 240, 159, 149, 181, 240, 159, 143, 189, 226, 128, 141, 226, 153, 130, 239, 184, 143, 34, 44, 34,
+ 227, 139, 161, 34, 58, 34, 227, 139, 161, 34, 44, 34, 226, 152, 186, 34, 58, 34, 226, 152, 186, 34, 44, 34, 227, 130,
+ 183, 34, 58, 34, 227, 130, 183, 34, 44, 34, 240, 159, 145, 139, 34, 58, 34, 240, 159, 145, 139, 34, 44, 34, 102, 34,
+ 58, 34, 226, 130, 135, 34, 44, 34, 226, 152, 185, 34, 58, 34, 226, 152, 185, 34, 44, 34, 226, 152, 187, 34, 58, 34,
+ 226, 152, 187, 34, 44, 34, 99, 104, 105, 108, 100, 114, 101, 110, 34, 58, 49, 50, 51, 125,
];
export const jsxVariants = (
<>
- "\r\n": "\r\n", "\n": "\n", "\t": "\t", "\f": "\f", "\v": "\v", "\u2028":
- "\u2028", "\u2029": "\u2029", "😊": "😊", "😃": "😃", "🕵🏽‍♂️": "🕵🏽‍♂️", "㋡":
- "㋡", "☺": "☺", シ: "シ", "👋": "👋", f: f, "☹": "☹", "☻": "☻", children:
- 123,
+ "\r\n": "\r\n", "\n": "\n", "\t": "\t", "\f": "\f", "\v": "\v", "\u2028": "\u2028", "\u2029": "\u2029", "😊": "😊",
+ "😃": "😃", "🕵🏽‍♂️": "🕵🏽‍♂️", "㋡": "㋡", "☺": "☺", シ: "シ", "👋": "👋", f: f, "☹": "☹", "☻": "☻", children: 123,
<div data="\r\n" />
<div data="\n" />
<div data="\t" />
diff --git a/test/snippets/styledcomponents-output.js b/test/snippets/styledcomponents-output.js
index fca6e8407..91c871770 100644
--- a/test/snippets/styledcomponents-output.js
+++ b/test/snippets/styledcomponents-output.js
@@ -3,8 +3,7 @@ import React from "react";
import ReactDOM from "react-dom";
const ErrorScreenRoot = styled.div`
- font-family: "Muli", -apple-system, BlinkMacSystemFont, Helvetica, Arial,
- sans-serif;
+ font-family: "Muli", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
position: fixed;
top: 0;
left: 0;
@@ -18,8 +17,7 @@ const ErrorScreenRoot = styled.div`
text-align: center;
background-color: #0b2988;
color: #fff;
- font-family: "Muli", -apple-system, BlinkMacSystemFont, Helvetica, Arial,
- sans-serif;
+ font-family: "Muli", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
line-height: 1.5em;
& > p {
@@ -35,23 +33,15 @@ export function test() {
if (typeof window !== "undefined") {
const reactEl = document.createElement("div");
document.body.appendChild(reactEl);
- ReactDOM.render(
- <ErrorScreenRoot id="error-el">
- The react child should have this text
- </ErrorScreenRoot>,
- reactEl,
- );
+ ReactDOM.render(<ErrorScreenRoot id="error-el">The react child should have this text</ErrorScreenRoot>, reactEl);
const style = document.querySelector("style[data-styled]");
console.assert(style, "style tag should exist");
console.assert(
- style.textContent.split("").every((a) => a.codePointAt(0) < 128),
+ style.textContent.split("").every(a => a.codePointAt(0) < 128),
"style tag should not contain invalid unicode codepoints",
);
- console.assert(
- document.querySelector("#error-el").textContent ===
- "The react child should have this text",
- );
+ console.assert(document.querySelector("#error-el").textContent === "The react child should have this text");
ReactDOM.unmountComponentAtNode(reactEl);
reactEl.remove();
diff --git a/test/snippets/template-literal.js b/test/snippets/template-literal.js
index a5749a555..8d8f64917 100644
--- a/test/snippets/template-literal.js
+++ b/test/snippets/template-literal.js
@@ -1,4 +1,4 @@
-const css = (templ) => templ.toString();
+const css = templ => templ.toString();
const fooNoBracesUTF8 = css`
before
@@ -25,8 +25,7 @@ const fooUTF16 = css`
`;
-const templateLiteralWhichDefinesAFunction = ((...args) =>
- args[args.length - 1]().toString())`
+const templateLiteralWhichDefinesAFunction = ((...args) => args[args.length - 1]().toString())`
before
🙃 ${() => true}
after
@@ -35,17 +34,11 @@ const templateLiteralWhichDefinesAFunction = ((...args) =>
export function test() {
for (let foo of [fooNoBracesUT16, fooNoBracesUTF8, fooUTF16, fooUTF8]) {
- console.assert(
- foo.includes("before"),
- `Expected ${foo} to include "before"`,
- );
+ console.assert(foo.includes("before"), `Expected ${foo} to include "before"`);
console.assert(foo.includes("after"), `Expected ${foo} to include "after"`);
}
- console.assert(
- templateLiteralWhichDefinesAFunction.includes("true"),
- "Expected fooFunction to include 'true'",
- );
+ console.assert(templateLiteralWhichDefinesAFunction.includes("true"), "Expected fooFunction to include 'true'");
return testDone(import.meta.url);
}
diff --git a/test/snippets/type-only-imports.ts b/test/snippets/type-only-imports.ts
index c43fcf278..38d02c743 100644
--- a/test/snippets/type-only-imports.ts
+++ b/test/snippets/type-only-imports.ts
@@ -3,8 +3,7 @@ import type Bacon from "tree";
import type { SilentSymbolCollisionsAreOkayInTypeScript } from "./app";
export const baconator: Bacon = true;
-export const SilentSymbolCollisionsAreOkayInTypeScript: SilentSymbolCollisionsAreOkayInTypeScript =
- true;
+export const SilentSymbolCollisionsAreOkayInTypeScript: SilentSymbolCollisionsAreOkayInTypeScript = true;
export function test() {
console.assert(SilentSymbolCollisionsAreOkayInTypeScript);