Skip to content

Commit

Permalink
chore: add knip package (#25)
Browse files Browse the repository at this point in the history
* chore: add knip package

* ci: test listing

* ci: test listing

* revert: prior info command

* ci: test knip

* ci: show warnings instead of errors

* ci: test showing knip error

* ci: test showing knip error

* ci: test showing knip error

* revert: prior plain state

* chore: change script name

* ci: remove on push main
  • Loading branch information
uigywnkiub authored Jul 30, 2024
1 parent 858c448 commit c5a2c9c
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 42 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
${{ runner.os }}-

- if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }}
name: List the state of node modules
name: Info the state of node modules
continue-on-error: true
run: yarn list
run: yarn info --name-only

- name: Install Dependencies
run: yarn install --immutable
Expand Down Expand Up @@ -75,9 +75,9 @@ jobs:
${{ runner.os }}-
- if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }}
name: List the state of node modules
name: Info the state of node modules
continue-on-error: true
run: yarn list
run: yarn info --name-only

- name: Install Dependencies
run: yarn install --immutable
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Find unused files, dependencies and exports in JavaScript and TypeScript projects.
name: Knip

on:
workflow_dispatch:
pull_request:
types:
- opened
- synchronize

env:
CACHE_NAME: cache-node-modules

jobs:
knip:
name: Knip
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache node modules
id: cache-yarn
uses: actions/cache@v4
with:
# Below is an another cache folder on ubuntu
# path: ~/.cache/yarn
path: ${{ steps.yarn-cache-dir-path.outputs.yarn_cache_dir }}
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}\
-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-
${{ runner.os }}-build-
${{ runner.os }}-

- if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }}
name: Info the state of node modules
continue-on-error: true
run: yarn info --name-only

- name: Install Dependencies
run: yarn install --immutable

- name: Run Knip
# continue-on-error: true
run: yarn knip
2 changes: 1 addition & 1 deletion app/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export type TBalanceProjection = ['amount', 'isIncome']

export type TGroupedTransactions = Record<string, TTransaction[]>

export type TTotals = {
type TTotals = {
income: number
expense: number
}
Expand Down
2 changes: 1 addition & 1 deletion app/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Spinner } from '@nextui-org/spinner'
import { Spinner } from '@nextui-org/react'

export default function Loading() {
return (
Expand Down
2 changes: 1 addition & 1 deletion app/sign-in/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NAV_TITLE } from '@/config/constants/navigation'
import SignIn from '@/app/ui/sign-in/sign-in'

export const metadata: Metadata = {
title: NAV_TITLE.SIGNOUT,
title: NAV_TITLE.SIGNIN,
}

export default function Page() {
Expand Down
2 changes: 1 addition & 1 deletion app/ui/pagination/pagination-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useCallback, useEffect } from 'react'

import { usePathname, useRouter, useSearchParams } from 'next/navigation'

import { Pagination } from '@nextui-org/pagination'
import { Pagination } from '@nextui-org/react'

import { SEARCH_PARAM } from '@/config/constants/navigation'

Expand Down
15 changes: 0 additions & 15 deletions app/ui/skeletons.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions config/constants/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export const enum NAV_TITLE {
FEEDBACK = 'Give Feedback',
ISSUE = 'Report Issue',
SIGNIN = 'Sign In',
SIGNOUT = 'Sign Out',
MOBILE_TEMPORARILY_NOT_ALLOWED = 'Mobile Temporarily Not Allowed',
}

export const enum SEARCH_PARAM {
Expand Down
2 changes: 0 additions & 2 deletions config/constants/routes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
export const enum ROUTE {
HOME = '/',
SIGNIN = '/sign-in',
SIGNOUT = '/sign-out',
MONTHLY_REPORT = '/monthly-report',
CHART = '/chart',
CATEGORIES = '/categories',
SETTINGS = '/settings',
FEEDBACK = '/feedback',
ISSUE = '/issue',
MOBILE_TEMPORARILY_NOT_ALLOWED = '/mobile-temporarily-not-allowed',
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"test:cov": "vitest --coverage",
"prettier": "prettier --c .",
"prettier:fix": "prettier --w .",
"prepare": "husky"
"prepare": "husky",
"knip": "knip"
},
"dependencies": {
"@ducanh2912/next-pwa": "^10.2.8",
Expand Down Expand Up @@ -49,7 +50,7 @@
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.0.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20.14.13",
"@types/node": "^22.0.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-is": "^18.3.0",
Expand All @@ -60,6 +61,7 @@
"eslint-config-prettier": "^9.1.0",
"husky": "^9.1.3",
"jsdom": "^24.1.1",
"knip": "^5.27.0",
"lint-staged": "^15.2.7",
"postcss": "^8.4.40",
"prettier": "^3.3.3",
Expand Down
Loading

0 comments on commit c5a2c9c

Please sign in to comment.