From 117ffe9b169470e6b3c4f2fb5f3a5f3294bab34e Mon Sep 17 00:00:00 2001 From: muriukialex Date: Fri, 16 Feb 2024 01:04:40 +0300 Subject: [PATCH] introduce prettier, format code using prettier --- .github/workflows/preview.yaml | 12 + .github/workflows/production.yaml | 12 + .prettierrc | 11 + app/api/labs/[id]/route.ts | 2 +- app/globals.css | 4 +- app/home/page.tsx | 10 +- app/layout.tsx | 2 +- app/page.tsx | 6 +- components/UI/Divider.tsx | 2 +- components/UI/Lab.tsx | 16 +- components/UI/UserLabs.tsx | 41 +-- components/index.ts | 4 +- cypress/e2e/1-getting-started/todo.cy.js | 78 +++--- cypress/e2e/2-advanced-examples/actions.cy.js | 246 +++++++++--------- .../e2e/2-advanced-examples/aliasing.cy.js | 32 ++- .../e2e/2-advanced-examples/assertions.cy.js | 123 +++++---- .../e2e/2-advanced-examples/connectors.cy.js | 62 +++-- cypress/e2e/2-advanced-examples/cookies.cy.js | 120 ++++----- .../e2e/2-advanced-examples/cypress_api.cy.js | 192 +++++++------- cypress/e2e/2-advanced-examples/files.cy.js | 60 ++--- .../e2e/2-advanced-examples/location.cy.js | 30 ++- cypress/e2e/2-advanced-examples/misc.cy.js | 73 +++--- .../e2e/2-advanced-examples/navigation.cy.js | 40 +-- .../network_requests.cy.js | 164 ++++++------ .../e2e/2-advanced-examples/querying.cy.js | 84 +++--- .../spies_stubs_clocks.cy.js | 111 ++++---- cypress/e2e/2-advanced-examples/storage.cy.js | 106 ++++---- .../e2e/2-advanced-examples/traversal.cy.js | 119 ++++----- .../e2e/2-advanced-examples/utilities.cy.js | 65 ++--- .../e2e/2-advanced-examples/viewport.cy.js | 38 +-- cypress/e2e/2-advanced-examples/waiting.cy.js | 22 +- cypress/e2e/2-advanced-examples/window.cy.js | 16 +- cypress/fixtures/profile.json | 2 +- cypress/fixtures/users.json | 2 +- cypress/support/commands.ts | 2 +- cypress/support/e2e.ts | 4 +- lib/const.ts | 1 - lib/labs.ts | 2 +- lib/metadata-options.ts | 13 +- package-lock.json | 107 ++++++++ package.json | 3 + postcss.config.js | 2 +- service/requests.ts | 2 +- tailwind.config.ts | 6 +- 44 files changed, 1131 insertions(+), 918 deletions(-) create mode 100644 .prettierrc diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 41726ff..4b19eeb 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -7,6 +7,18 @@ on: branches-ignore: - main jobs: + Code Format: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: 18.12.1 + - name: Format + run: npm run format + Run Tests: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/production.yaml b/.github/workflows/production.yaml index 9cb880a..1b04906 100644 --- a/.github/workflows/production.yaml +++ b/.github/workflows/production.yaml @@ -7,6 +7,18 @@ on: branches: - main jobs: + Code Format: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: 18.12.1 + - name: Format + run: npm run format + Run Tests: runs-on: ubuntu-latest steps: diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..190bea8 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,11 @@ +{ + "plugins": [ + "prettier-plugin-organize-imports", + "prettier-plugin-tailwindcss" + ], + "trailingComma": "all", + "semi": false, + "singleQuote": false, + "useTabs": false, + "tabWidth": 2 +} diff --git a/app/api/labs/[id]/route.ts b/app/api/labs/[id]/route.ts index 11e1621..d5085b3 100644 --- a/app/api/labs/[id]/route.ts +++ b/app/api/labs/[id]/route.ts @@ -1,6 +1,6 @@ -import { NextResponse } from "next/server" import Lab from "@/models/Lab" import { LabRequestType } from "@/types/Requests" +import { NextResponse } from "next/server" export async function PUT( req: Request, diff --git a/app/globals.css b/app/globals.css index 3c93daf..753a5fc 100644 --- a/app/globals.css +++ b/app/globals.css @@ -33,9 +33,9 @@ body { } h1 { - @apply text-2xl sm:text-4xl font-bold mt-4 mb-4 dark:text-white text-gray-500; + @apply mb-4 mt-4 text-2xl font-bold text-gray-500 sm:text-4xl dark:text-white; } h2 { - @apply sm:text-xl text-lg mt-2 mb-2; + @apply mb-2 mt-2 text-lg sm:text-xl; } diff --git a/app/home/page.tsx b/app/home/page.tsx index d97d3e5..5ecbd10 100644 --- a/app/home/page.tsx +++ b/app/home/page.tsx @@ -1,10 +1,10 @@ "use client" +import { UserLabs } from "@/components" +import { useUserLabsData } from "@/hooks" +import { ButtonStatusType } from "@/types/Common" import { signOut, useSession } from "next-auth/react" import { useState } from "react" -import { ButtonStatusType } from "@/types/Common" -import { useUserLabsData } from "@/hooks" -import { UserLabs } from "@/components" const HomePage = () => { const { data: userData } = useSession() @@ -32,7 +32,7 @@ const HomePage = () => { } return ( -
+

AWS r/Start Labs

@@ -40,7 +40,7 @@ const HomePage = () => {
@@ -41,7 +53,7 @@ const UserLabs = ({ return (
-
+

Week 1

{weekOne.map((lab) => ( -
+

Week 2

{weekTwo.map((lab) => ( -
+

Week 3

{weekThree.map((lab) => ( -
+

Week 4

{weekFour.map((lab) => ( -
+

Week 5

{weekFive.map((lab) => ( -
+

Week 6

{weekSix.map((lab) => ( -
+

Week 7

{weekSeven.map((lab) => ( -
+

Week 8

{weekEight.map((lab) => ( -
+

Week 9

{weekNine.map((lab) => ( -
+

Week 10

{weekTen.map((lab) => ( -
+

Week 11

{weekEleven.map((lab) => ( ))}
-
) } diff --git a/components/index.ts b/components/index.ts index 97e3e3f..aa3b87e 100644 --- a/components/index.ts +++ b/components/index.ts @@ -1,4 +1,4 @@ -import { GoogleIcon, CheckMark } from "./Icons" +import { CheckMark, GoogleIcon } from "./Icons" import { Divider, UserLabs } from "./UI" -export { GoogleIcon, Divider, CheckMark, UserLabs } +export { CheckMark, Divider, GoogleIcon, UserLabs } diff --git a/cypress/e2e/1-getting-started/todo.cy.js b/cypress/e2e/1-getting-started/todo.cy.js index 4768ff9..d4516b2 100644 --- a/cypress/e2e/1-getting-started/todo.cy.js +++ b/cypress/e2e/1-getting-started/todo.cy.js @@ -11,32 +11,32 @@ // please read our getting started guide: // https://on.cypress.io/introduction-to-cypress -describe('example to-do app', () => { +describe("example to-do app", () => { beforeEach(() => { // Cypress starts out with a blank slate for each test // so we must tell it to visit our website with the `cy.visit()` command. // Since we want to visit the same URL at the start of all our tests, // we include it in our beforeEach function so that it runs before each test - cy.visit('https://example.cypress.io/todo') + cy.visit("https://example.cypress.io/todo") }) - it('displays two todo items by default', () => { + it("displays two todo items by default", () => { // We use the `cy.get()` command to get all elements that match the selector. // Then, we use `should` to assert that there are two matched items, // which are the two default items. - cy.get('.todo-list li').should('have.length', 2) + cy.get(".todo-list li").should("have.length", 2) // We can go even further and check that the default todos each contain // the correct text. We use the `first` and `last` functions // to get just the first and last matched elements individually, // and then perform an assertion with `should`. - cy.get('.todo-list li').first().should('have.text', 'Pay electric bill') - cy.get('.todo-list li').last().should('have.text', 'Walk the dog') + cy.get(".todo-list li").first().should("have.text", "Pay electric bill") + cy.get(".todo-list li").last().should("have.text", "Walk the dog") }) - it('can add new todo items', () => { + it("can add new todo items", () => { // We'll store our item text in a variable so we can reuse it - const newItem = 'Feed the cat' + const newItem = "Feed the cat" // Let's get the input element and use the `type` command to // input our new list item. After typing the content of our item, @@ -44,29 +44,29 @@ describe('example to-do app', () => { // This input has a data-test attribute so we'll use that to select the // element in accordance with best practices: // https://on.cypress.io/selecting-elements - cy.get('[data-test=new-todo]').type(`${newItem}{enter}`) + cy.get("[data-test=new-todo]").type(`${newItem}{enter}`) // Now that we've typed our new item, let's check that it actually was added to the list. // Since it's the newest item, it should exist as the last element in the list. // In addition, with the two default items, we should have a total of 3 elements in the list. // Since assertions yield the element that was asserted on, // we can chain both of these assertions together into a single statement. - cy.get('.todo-list li') - .should('have.length', 3) + cy.get(".todo-list li") + .should("have.length", 3) .last() - .should('have.text', newItem) + .should("have.text", newItem) }) - it('can check off an item as completed', () => { + it("can check off an item as completed", () => { // In addition to using the `get` command to get an element by selector, // we can also use the `contains` command to get an element by its contents. // However, this will yield the