Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ensdomains/ens-app-v3 into …
Browse files Browse the repository at this point in the history
…usecapsule-integration-two
  • Loading branch information
LeonmanRolls committed Sep 2, 2024
2 parents c25c67f + fdd6460 commit abce894
Show file tree
Hide file tree
Showing 47 changed files with 237 additions and 1,903 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/knip.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Knip

on: [push]

jobs:
knip:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install pnpm
run: corepack enable pnpm

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'

- run: pnpm install --frozen-lockfile

- run: pnpm knip
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,3 +507,62 @@ Our testing philosophy is user-centric, meaning we want to write out tests so th
A user generally clicks, types and swipes, and so most tests should include one of these actions. A user may also load a page in a specific state (by clicking, typing or swiping outside of the app) so sometimes we just want to check a page renders correctly. The vast majority of our tests will be of these kinds.

For deeper parts of the codebase that aren't directly related to a user interaction, such as utility functions, the user is the developer. So simply test the code in the way a developer would use it.

## Knip Configuration Guide

### 1. Install Knip:

Install Knip as a development dependency in your project:

```bash
pnpm add -D knip
```

### 2. Add a knip script to your package.json:

Add a script to your package.json for easy access to Knip:

```json
{
"scripts": {
...,
"knip": "knip",
"knip:fix": "knip --fix --allow-remove-files"
}
}
```

### 3. Create Knip Configuration File:

Create a `knip.config.ts` file at the root of your project. For more detail of configuration options, refer to the [knip.config.ts file](knip.config.ts) in the ENSDomains repository.

### 4. Run Knip:

To analyze your project, run Knip using the following command:

```bash
pnpm knip
```
Knip will exit with code `1` if any issues are found, such as unused files, dependencies, or exports that need to be removed.

### 5. Review and Remove Unused Files

After Knip completes its analysis, review the results. Manually remove any unused files that are safe to delete, or let Knip handle it automatically with the following command:

```bash
pnpm knip:fix
```

Ensure you carefully examine any files marked for removal to avoid accidentally deleting necessary code.

### 6. Run Unit Tests and E2E Tests:

After removing files, it's important to run your unit and end-to-end tests to ensure that everything is still functioning correctly:

```bash
pnpm test:coverage
```

```bash
pnpm e2e
```
30 changes: 30 additions & 0 deletions knip.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { KnipConfig } from 'knip'

const config: KnipConfig = {
project: ['src/**/*.{js,jsx,ts,tsx,mjs,mts}'],
include: ['files', 'duplicates'],
exclude: ['types', 'exports', 'unlisted'],
next: {
entry: ['next.config.{js,ts,cjs,mjs}', 'src/pages/**/*.{js,jsx,ts,tsx}'],
},
playwright: {
config: ['playwright.config.{js,ts}'],
entry: ['e2e/**/*.@(spec|test).?(c|m)[jt]s?(x)'],
},
vitest: {
config: ['vitest.config.{js,mjs,ts,cjs,mts,cts}'],
entry: ['src/**/*.test.{js,ts,jsx,tsx}'],
},
ignore: [
// Duplicate exports. Removal is currently blocked due to potential E2E test failures.
'src/transaction-flow/input/EditResolver/EditResolver-flow.tsx',
'src/utils/metamask/firefox.ts',
// We still need the `test-d` files
'src/hooks/ensjs/public/useRecords.test-d.ts',
'src/utils/query/match/matchExactOrNullParamItem.test-d.ts',
'src/utils/query/match/matchQueryKeyMeta.test-d.ts',
'src/utils/query/match/queryKeyToInternalParams.test-d.ts',
],
}

export default config
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
"generate:sitemaps": "node ./scripts/generate-site-map.mjs",
"generate:coinMapper": "ts-node ./scripts/coin-mapper.ts",
"compose": "cp ./node_modules/@ensdomains/ens-test-env/src/docker-compose.yml ./docker-compose.yml",
"subgraph:update": "ens-test-env subgraph --var NEXT_PUBLIC_DEPLOYMENT_ADDRESSES"
"subgraph:update": "ens-test-env subgraph --var NEXT_PUBLIC_DEPLOYMENT_ADDRESSES",
"knip": "npx knip",
"knip:fix": "npx knip --fix --allow-remove-files"
},
"dependencies": {
"@ensdomains/address-encoder": "1.1.1",
Expand Down Expand Up @@ -162,6 +164,7 @@
"husky": "^7.0.4",
"isows": "^1.0.3",
"jsdom": "^24.0.0",
"knip": "^5.27.2",
"lokijs": "^1.5.12",
"msw": "^1.2.3",
"multiformats": "^12.0.1",
Expand Down
Loading

0 comments on commit abce894

Please sign in to comment.