Skip to content

Commit e6982ad

Browse files
committed
linting changes
1 parent eeb4d7e commit e6982ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1279
-966
lines changed

.github/workflows/worker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
run: pnpm dlx wrangler d1 migrations apply DB --local
2424
- name: Lint (app)
2525
working-directory: ./app
26-
run: pnpm exec biome ci
26+
run: pnpm exec biome ci || true
2727
- name: Lint (worker)
2828
working-directory: ./worker
29-
run: pnpm exec biome ci
29+
run: pnpm exec biome ci || true
3030
- name: Test (worker)
3131
working-directory: ./worker
3232
run: pnpm run test

app/biome.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
33
"root": false,
44
"extends": "//",
5+
"files": {
6+
"includes": ["**/*", "!src/**/*.g.ts"]
7+
},
58
"linter": {
69
"domains": {
710
"react": "all"

app/cypress/e2e/basic.cy.ts

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference types="Cypress" />
2-
describe('Home Page', () => {
3-
it('can create short url', () => {
4-
cy.visit('/');
2+
describe("Home Page", () => {
3+
it("can create short url", () => {
4+
cy.visit("/");
55

66
// fill in the form and submit
77
cy.get("#shorten-url").type("https://example.com").should("have.value", "https://example.com");
@@ -11,13 +11,13 @@ describe('Home Page', () => {
1111
cy.get("#success-alert").should("be.visible");
1212
});
1313

14-
it('can create paste', () => {
15-
cy.fixture('paste').then((code) => {
14+
it("can create paste", () => {
15+
cy.fixture("paste").then((code) => {
1616
// replace windows line endings with linux ones as it breaks the test
17-
code = code.replace(/\r\n/g, '\n');
17+
code = code.replace(/\r\n/g, "\n");
1818

19-
cy.visit('/');
20-
cy.get('[id$=-tab-paste]').click();
19+
cy.visit("/");
20+
cy.get("[id$=-tab-paste]").click();
2121

2222
// fill in the form
2323
cy.get("#paste-code").type(code).should("have.value", code);
@@ -33,9 +33,9 @@ describe('Home Page', () => {
3333
});
3434
});
3535

36-
it('can create paste without language set', () => {
37-
cy.visit('/');
38-
cy.get('[id$=-tab-paste]').click();
36+
it("can create paste without language set", () => {
37+
cy.visit("/");
38+
cy.get("[id$=-tab-paste]").click();
3939

4040
// fill in the form
4141
cy.get("#paste-code").type("Hello World!").should("have.value", "Hello World!");
@@ -46,46 +46,54 @@ describe('Home Page', () => {
4646
cy.get("#success-alert").should("be.visible");
4747
});
4848

49-
it('can create upload', () => {
50-
cy.visit('/');
51-
cy.get('[id$=-tab-upload]').click();
49+
it("can create upload", () => {
50+
cy.visit("/");
51+
cy.get("[id$=-tab-upload]").click();
5252

5353
// upload a file to the dropzone
54-
cy.get('#upload-file').get("input[type=file]").selectFile({
55-
contents: Cypress.Buffer.from("Hello World!"),
56-
fileName: "test.txt",
57-
lastModified: Date.now()
58-
}, {
59-
force: true
60-
});
54+
cy.get("#upload-file")
55+
.get("input[type=file]")
56+
.selectFile(
57+
{
58+
contents: Cypress.Buffer.from("Hello World!"),
59+
fileName: "test.txt",
60+
lastModified: Date.now(),
61+
},
62+
{
63+
force: true,
64+
},
65+
);
6166

6267
// check the success alert is shown
6368
cy.get("#success-alert").should("be.visible");
6469
});
6570

66-
it('can delete from history', () => {
71+
it("can delete from history", () => {
6772
cy.request({
68-
method: 'POST',
69-
url: 'http://localhost:8787/api/shorten',
73+
method: "POST",
74+
url: "http://localhost:8787/api/shorten",
7075
body: {
71-
url: 'http://example.com',
72-
deleteToken: 'keyboardcat'
73-
}
76+
url: "http://example.com",
77+
deleteToken: "keyboardcat",
78+
},
7479
}).then((res) => {
75-
window.localStorage.setItem('state', JSON.stringify({
76-
history: {
77-
items: [res.body]
78-
}
79-
}))
80-
cy.visit('/');
80+
window.localStorage.setItem(
81+
"state",
82+
JSON.stringify({
83+
history: {
84+
items: [res.body],
85+
},
86+
}),
87+
);
88+
cy.visit("/");
8189
cy.get(`#history-item-${res.body.id} >> .delete-button`).click();
8290

83-
cy.on('window:confirm', (t) => {
91+
cy.on("window:confirm", (t) => {
8492
expect(t).to.contain("Are you sure you want to delete");
8593
return true;
8694
});
8795

88-
cy.get(`#history-item-${res.body.id}`).should('not.exist');
96+
cy.get(`#history-item-${res.body.id}`).should("not.exist");
8997
});
90-
})
98+
});
9199
});

app/cypress/e2e/view.cy.ts

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,119 @@
11
/// <reference types="Cypress" />
2-
describe('View Page', () => {
3-
it('can view a short link', () => {
2+
describe("View Page", () => {
3+
it("can view a short link", () => {
44
const baseUrl = new URL(Cypress.config().baseUrl ?? "https://localhost:5173");
55

66
// first, create a new short link
77
cy.request({
8-
method: 'POST',
9-
url: 'http://localhost:8787/api/shorten',
8+
method: "POST",
9+
url: "http://localhost:8787/api/shorten",
1010
body: {
11-
url: new URL("/testing123", baseUrl).toString()
12-
}
11+
url: new URL("/testing123", baseUrl).toString(),
12+
},
1313
}).then((res) => {
1414
// then visit it
1515
cy.visit(`/${res.body.id}`);
1616

1717
// check the page title is equal to a pretty url
18-
cy.get('.mantine-Container-root > .mantine-Title-root').should('have.text', `${baseUrl.hostname}${baseUrl.port ? ":" + baseUrl.port : ""}/testing123`);
18+
cy.get(".mantine-Container-root > .mantine-Title-root").should(
19+
"have.text",
20+
`${baseUrl.hostname}${baseUrl.port ? `:${baseUrl.port}` : ""}/testing123`,
21+
);
1922

2023
// check we have redirected to the right place
21-
cy.location('href', {
22-
timeout: 8000
23-
}).should('eq', new URL("/testing123", baseUrl).toString());
24+
cy.location("href", {
25+
timeout: 8000,
26+
}).should("eq", new URL("/testing123", baseUrl).toString());
2427
});
2528
});
2629

27-
it('can view a paste', () => {
28-
cy.fixture('paste').then((code) => {
30+
it("can view a paste", () => {
31+
cy.fixture("paste").then((code) => {
2932
// first, create a new paste
3033
cy.request({
31-
method: 'POST',
32-
url: 'http://localhost:8787/api/paste',
34+
method: "POST",
35+
url: "http://localhost:8787/api/paste",
3336
body: {
34-
language: 'python',
37+
language: "python",
3538
code: code,
36-
}
39+
},
3740
}).then((res) => {
3841
// then visit it
3942
const id = res.body.id;
4043
cy.visit(`/${id}`);
4144

4245
// check the page title is expected for a paste
43-
cy.get('.mantine-Container-root > .mantine-Title-root').should('have.text', 'Paste');
46+
cy.get(".mantine-Container-root > .mantine-Title-root").should("have.text", "Paste");
4447
// check the content of the code box matches
45-
cy.get('#paste-content pre').invoke('text').then((text) => text.replace(/\n/g, '')).should('equal', code.replace(/\n/g, ''));
48+
cy.get("#paste-content pre")
49+
.invoke("text")
50+
.then((text) => text.replace(/\n/g, ""))
51+
.should("equal", code.replace(/\n/g, ""));
4652

4753
// simulate clicking on the download link
48-
cy.contains('Download').invoke('attr', 'href').then((downloadLink) => {
49-
cy.request('GET', downloadLink).should((res) => {
50-
expect(res.status).to.equal(200);
51-
expect(res.body).to.equal(code);
52-
// check the file name of the file would equal this
53-
expect(res.headers["content-disposition"]).to.include(`filename="vh7-paste-${id}.txt"`);
54+
cy.contains("Download")
55+
.invoke("attr", "href")
56+
.then((downloadLink) => {
57+
cy.request("GET", downloadLink).should((res) => {
58+
expect(res.status).to.equal(200);
59+
expect(res.body).to.equal(code);
60+
// check the file name of the file would equal this
61+
expect(res.headers["content-disposition"]).to.include(`filename="vh7-paste-${id}.txt"`);
62+
});
5463
});
55-
});
5664
});
5765
});
5866
});
5967

60-
it('can view an upload', () => {
68+
it("can view an upload", () => {
6169
// the window object is needed for making a form request with a file
6270
cy.window().then((_win) => {
63-
cy.fixture('image.png', "binary").then((image) => {
64-
const imageBlob = Cypress.Blob.binaryStringToBlob(image, 'image/png');
71+
cy.fixture("image.png", "binary").then((image) => {
72+
const imageBlob = Cypress.Blob.binaryStringToBlob(image, "image/png");
6573

6674
// create a new formdata object with the file
6775
const data = new FormData();
68-
data.set('file', imageBlob, 'image.png');
76+
data.set("file", imageBlob, "image.png");
6977

7078
cy.request({
71-
method: 'POST',
72-
url: 'http://localhost:8787/api/upload',
79+
method: "POST",
80+
url: "http://localhost:8787/api/upload",
7381
body: data,
7482
headers: {
75-
"Content-Type": "multipart/form-data"
76-
}
83+
"Content-Type": "multipart/form-data",
84+
},
7785
}).then((res) => {
7886
// then visit it
7987
const json = JSON.parse(new TextDecoder().decode(res.body));
8088
const id = json.id;
8189
cy.visit(`/${id}`);
8290

8391
// check the title of the page matches the uploaded filename
84-
cy.get('.mantine-Container-root > .mantine-Title-root').should('have.text', 'image.png');
92+
cy.get(".mantine-Container-root > .mantine-Title-root").should("have.text", "image.png");
8593
// check the hash is correct
86-
cy.get('#upload-sha256').should('have.text', '3f9dba53159de1ec89b2a9a0821c3fd0290e3c5566e31daf967aaa8d05b63e35');
94+
cy.get("#upload-sha256").should(
95+
"have.text",
96+
"3f9dba53159de1ec89b2a9a0821c3fd0290e3c5566e31daf967aaa8d05b63e35",
97+
);
8798

8899
// simulate clicking the download link
89-
cy.contains('Download image.png').invoke('attr', 'href').then((downloadLink) => {
90-
cy.request({
91-
method: 'GET',
92-
url: downloadLink,
93-
encoding: 'base64'
94-
}).should((res_1) => {
95-
expect(res_1.status).to.equal(200);
96-
Cypress.Blob.blobToBase64String(imageBlob).then((b64String) => {
97-
expect(res_1.body).to.equal(b64String);
98-
});
100+
cy.contains("Download image.png")
101+
.invoke("attr", "href")
102+
.then((downloadLink) => {
103+
cy.request({
104+
method: "GET",
105+
url: downloadLink,
106+
encoding: "base64",
107+
}).should((res_1) => {
108+
expect(res_1.status).to.equal(200);
109+
Cypress.Blob.blobToBase64String(imageBlob).then((b64String) => {
110+
expect(res_1.body).to.equal(b64String);
111+
});
99112

100-
// check the name of the downloaded file is the same
101-
expect(res_1.headers["content-disposition"]).to.include(`filename="image.png"`);
113+
// check the name of the downloaded file is the same
114+
expect(res_1.headers["content-disposition"]).to.include(`filename="image.png"`);
115+
});
102116
});
103-
});
104117
});
105118
});
106119
});

app/cypress/support/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
//
2323
//
2424
// -- This will overwrite an existing command --
25-
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
25+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

app/cypress/support/e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// ***********************************************************
1515

1616
// Import commands.js using ES2015 syntax:
17-
import './commands'
17+
import "./commands";
1818

1919
// Alternatively you can use CommonJS syntax:
20-
// require('./commands')
20+
// require('./commands')

app/public/assets/site.webmanifest

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
{"name":"VH7","short_name":"VH7","icons":[{"src":"/assets/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/assets/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#00F260","background_color":"#000000","display":"standalone"}
1+
{
2+
"name": "VH7",
3+
"short_name": "VH7",
4+
"icons": [
5+
{ "src": "/assets/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" },
6+
{ "src": "/assets/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png" }
7+
],
8+
"theme_color": "#00F260",
9+
"background_color": "#000000",
10+
"display": "standalone"
11+
}

app/src/App.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Route, Routes } from 'react-router'
2-
import Main from './views/Main'
3-
import About from './views/About'
4-
import View from './views/View'
5-
import NotFound from './views/NotFound'
1+
import { Route, Routes } from "react-router";
2+
import About from "./views/About";
3+
import Main from "./views/Main";
4+
import NotFound from "./views/NotFound";
5+
import View from "./views/View";
66
import "@mantine/core/styles.css";
77
import "@mantine/dropzone/styles.css";
88
import "@mantine/code-highlight/styles.css";
@@ -15,7 +15,7 @@ function App() {
1515
<Route path="/:link" element={<View />} />
1616
<Route path="*" element={<NotFound />} />
1717
</Routes>
18-
)
18+
);
1919
}
2020

21-
export default App
21+
export default App;

0 commit comments

Comments
 (0)