Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(imports): 👷 organize in proper order #224

Merged
merged 8 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 74 additions & 7 deletions README-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ Development environment for the project.
- [Development](#development)
- [💻 Commands](#-commands)
- [Install dependencies](#install-dependencies)
- [Update outdated dependencies](#update-outdated-dependencies)
- [Manually](#manually)
- [Using `npm-check-updates` tool](#using-npm-check-updates-tool)
- [Update outdated dependencies](#update-outdated-dependencies)
- [Manually](#manually)
- [Using tool `npm-check-updates`](#using-tool-npm-check-updates)
- [💅 Prettier](#-prettier)
- [Imports Sorting Order](#imports-sorting-order)
- [Import Example](#import-example)

---

Expand All @@ -34,21 +36,21 @@ npm run dev

Open [http://localhost:3000](http://localhost:3000) to view project in browser.

### Update outdated dependencies
## Update outdated dependencies

There are 2 ways to do this.

#### Manually
### Manually

Find what packages are outdated and upgrade to latest version if possible.

```bash
npm outdated
```

#### Using `npm-check-updates` tool
### Using tool `npm-check-updates`

To update the outdated packages in package.json, you can use the [npm-check-updates](https://www.npmjs.com/package/npm-check-updates) (ncu) tool.
To update the outdated packages in package.json, you can use the NCU tool: [npm-check-updates](https://www.npmjs.com/package/npm-check-updates)

Install `npm-check-updates` globally.

Expand Down Expand Up @@ -93,3 +95,68 @@ Format the code via Prettier.
```bash
npm run prettier:fix
```

## Imports Sorting Order

Sorting order for imports in files:

1. Third-Party Library Imports
2. Custom Hooks
3. Components
4. Data
5. Utils
6. Interfaces and Helpers
7. Images
8. CSS

## Import Example

```ts
// Third-Party Library Imports
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import { ReactNode } from 'react'
```

```ts
// Custom Hooks
import { useScrollProgress } from '@/hooks/useScrollProgress'
```

```ts
// Components
import PageContainer from '@/components/layout/PageContainer'
import PageNavigation from '@/components/page-navigation/PageNavigation'
import Header from '@/components/header/Header'
import Footer from '@/components/footer/Footer'
```

```ts
// Data
import { mindset } from '@/data/expertise/mindset'
import { iconsSkills1 } from '@/data/skills/skillsMain'
```

```ts
// Utils
import { TEXT } from '@/localization/english'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
```

```ts
// Interfaces and Helpers
import { getGoBackLinkID } from '@/utils/helpers/getGoBackLink'
import { HeaderSectionProps } from '@/utils/interfaces/componentProps'
import { NavigationDirectionEnum } from '@/utils/interfaces/enums'
```

```ts
// Images
import logo from '@/public/images/webp/logo.webp'
```

```ts
// CSS
import '@/app/custom.css'
```
8 changes: 5 additions & 3 deletions __tests__/jest/generateIconsSkills.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getSkillsIcons, skillIcons, SkillKeys } from '@/utils/helpers/getSkillsIcons'

describe('getSkillsIcons', () => {
const expectedKeys: string[] = [
const expectedKeys: SkillKeys[] = [
'chakra',
'css',
'cypress',
Expand Down Expand Up @@ -36,8 +36,10 @@ describe('getSkillsIcons', () => {
const results = getSkillsIcons(skills)

results.forEach((resultIcon, index) => {
expect(resultIcon.name).toBe(skills[index])
expect(resultIcon.path).toBe(skillIcons[skills[index]])
const skill = skills[index]

expect(resultIcon.name).toBe(skill)
expect(resultIcon.path).toBe(skillIcons[skill])
})
})
})
3 changes: 1 addition & 2 deletions __tests__/jest/sitemap.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// FILEPATH: /Users/krsiak/github/personal/portfolio-website-krsiak-cz/__tests__/jest/sitemap.test.ts
import { MetadataRoute } from 'next'

import sitemap, { CHANGE_FREQUENCY_MONTHLY, URLS } from '@/app/sitemap'
import { MetadataRoute } from 'next'

describe('sitemap', () => {
let results: MetadataRoute.Sitemap
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/about-me/aboutMe.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { TEXT } from '@/localization/english'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('About Me Page - Tests', () => {
test('Heading + text', async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/breadcrumbs/aboutMe.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/breadcrumbs/personalProjects.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/breadcrumbs/resume.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/breadcrumbs/workExperience.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/footer/copyright.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { ID } from '@/utils/constants/ids/elementIds'
import { expect, test } from '@playwright/test'

test.describe('Footer - Copy', () => {
test('Copyright', async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/footer/pageLink.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { ID } from '@/utils/constants/ids/elementIds'
import { expect, test } from '@playwright/test'

const HOME_PAGE_PATH = '/'

Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/footer/scrollToTop.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { expect, test } from '@playwright/test'

test('should scroll to top when button is clicked', async ({ page }) => {
// Navigate to your page
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/footer/statusPageLink.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { ID } from '@/utils/constants/ids/elementIds'
import { expect, test } from '@playwright/test'

const STATUS_PAGE_URL = 'http://localhost:3000/status-page'

Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/header/headerLogo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { expect, test } from '@playwright/test'

test.describe('Header - Logo', () => {
test('Check link and text', async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/header/menu/desktop/linkAboutMe.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { TEXT } from '@/localization/english'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Header - Desktop Menu - About Me Link', () => {
test('should navigate to About Me page correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { TEXT } from '@/localization/english'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Header - Desktop Menu - Personal Projects Link', () => {
test('should navigate to Personal Projects page correctly', async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/header/menu/desktop/linkResume.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { TEXT } from '@/localization/english'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Header - Desktop Menu - Resume Link', () => {
test('should navigate to Resume page correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { TEXT } from '@/localization/english'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Header - Desktop Menu - Work Experience Link', () => {
test('should navigate to Work Experience page correctly', async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/homepage/heroLinks.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Browser, BrowserContext, Page, chromium, test } from '@playwright/test'

import { checkLink } from '@/__tests__/playwright/utils/helpers/checkLink'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { EXTERNAL_URL } from '@/utils/constants/urls/externalUrls'
import { Browser, BrowserContext, Page, chromium, test } from '@playwright/test'

let browser: Browser
let context: BrowserContext
Expand Down
3 changes: 2 additions & 1 deletion __tests__/playwright/homepage/heroTexts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Browser, BrowserContext, Page, chromium, expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { TEXT } from '@/localization/english'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { Browser, BrowserContext, Page, chromium, expect, test } from '@playwright/test'

let browser: Browser
let context: BrowserContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from '@playwright/test'

import { getDataTestId } from '@/__tests__/playwright/utils/helpers/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/constants/ids/dataTestIds'
import { PAGES_URL } from '@/utils/constants/urls/pageUrls'
import { expect, test } from '@playwright/test'

test.describe('Navigation - About Me', () => {
test('navigates to previous page - Home', async ({ page }) => {
Expand Down
Loading
Loading