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

Convert project to Node.js v20 and many more updates ✨ #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

29 changes: 0 additions & 29 deletions .eslintrc.js

This file was deleted.

41 changes: 10 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,28 @@ on:
branches:
- main

env:
HUSKY: 0

jobs:
format-check-lint-type-check-test:
runs-on: 'ubuntu-latest'
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3

- name: Install Node.js 18
- name: Install Node.js 20
uses: actions/setup-node@v3
with:
node-version: 18.x

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8.6.12
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
node-version: 20.x

- name: Install dependencies
run: pnpm install

- name: Format Check
run: pnpm format --check
run: npm install

- name: Lint
run: pnpm lint
run: npm run lint

- name: Type Check
run: pnpm type-check
run: npm run type-check

- name: Test
run: pnpm test -- --disable-coverage --allow-empty-coverage # Disable coverage reporting for CI
run: npm run test
5 changes: 1 addition & 4 deletions .husky/pre-commit
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm lint-staged
npx lint-staged
4 changes: 2 additions & 2 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
'*': 'pnpm prettier --ignore-unknown --write',
};
'*': 'eslint',
}
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierrc.js

This file was deleted.

33 changes: 8 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,34 @@ npm i @arrowood.dev/socket

Requirements:

- Node.js v18.x
- pnpm v8.6.12 (recommend using corepack)

The formatting, linting, and typechecking of this repo are based off of [@vercel/style-guide](https://github.com/vercel/style-guide).
- Node.js v20.x

### Building

This project uses [TypeScript](https://www.typescriptlang.org/) for building. This must be manually executed using:

```sh
pnpm build
npm run build
```

Output will be in the `dist` folder.

### Formatting

This project uses [prettier](https://prettier.io/) for formatting. Code is formatted automatically when you commit, and you can run the formatter manually using:

```sh
pnpm format
```

All files (except those listed in [.prettierignore](./.prettierignore)) will be formatted.

Prettier is configured by [.prettierrc.js](./.prettierrc.js). It is based on [@vercel/style-guide/prettier](https://github.com/vercel/style-guide#prettier).

### Linting

This project uses [eslint](https://eslint.org/) for linting. Code is linted automatically when you commit, and you can run the linter manually using:

```sh
pnpm lint
npm run lint
```

All files (except those listed in [.eslintignore](./.eslintignore)) will be linted.

ESLint is configured by [.eslintrc.js](./.eslintrc.js). It is based on [@vercel/style-guide/eslint/node](https://github.com/vercel/style-guide#eslint)
ESLint is configured by [eslint.config.mjs](./eslint.config.mjs).

### Testing

This project uses [node-tap](https://node-tap.org/) for testing. Run tests using:
This project uses the Node.js [Test Runner](https://nodejs.org/docs/latest-v20.x/api/test.html) for testing. Run tests using:

```sh
pnpm test
npm run test
```

Only test files matching the pattern `test/*.test.ts` will be executed.
Expand All @@ -72,13 +55,13 @@ Testing utility functions should be stored in `test/utils.ts` and be well docume
To manually type-check the repo without producing a build, use:

```sh
pnpm type-check
npm run type-check
```

This project uses [TypeScript](https://www.typescriptlang.org/). There exists multiple TypeScript config files; each serves a different purpose.

- [tsconfig.base.json](./tsconfig.base.json)
- The base configuration, itself based on [@vercel/style-guide/typescript](https://github.com/vercel/style-guide#typescript).
- The base configuration, itself based on [@tsconfig/node20](https://github.com/tsconfig/bases/blob/main/bases/node20.json).
- It does **not** _include_ any files as it is meant to be extended from.
- [tsconfig.json](./tsconfig.json)
- The default configuration.
Expand Down
7 changes: 7 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import neostandard, { plugins } from 'neostandard'

export default [
{ ignores: ['dist/*', 'node_modules/*', 'package-lock.json'] },
...neostandard(),
...plugins['typescript-eslint'].configs.recommended,
]
Loading
Loading