Skip to content

Commit 8655424

Browse files
regevbrRegev Brodyclaude
authored
chore: modernize testing & linting infrastructure (#49)
Co-authored-by: Regev Brody <regevbr@Regevs-MacBook-Pro.local> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 56c74c0 commit 8655424

15 files changed

Lines changed: 3626 additions & 2843 deletions

.github/workflows/ci.yml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,21 @@ jobs:
2828
with:
2929
ref: ${{ github.event.client_payload.ref || github.ref }}
3030

31+
- name: Install pnpm
32+
uses: pnpm/action-setup@v4
33+
with:
34+
version: 10
35+
3136
- name: Use Node.js ${{ matrix.node-version }}
3237
uses: actions/setup-node@v6
3338
with:
3439
node-version: ${{ matrix.node-version }}
35-
36-
- name: Get yarn cache directory
37-
id: yarn-cache-dir
38-
run: |
39-
echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
40-
41-
- uses: actions/cache@v4
42-
id: yarn-cache
43-
with:
44-
path: ${{ steps.yarn-cache-dir.outputs.dir }}
45-
key: ${{ matrix.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
46-
restore-keys: |
47-
${{ matrix.os }}-${{ matrix.node-version }}-yarn-
40+
cache: 'pnpm'
4841

4942
- name: Install dependencies and build
5043
run: |
51-
yarn install --ignore-engines
52-
yarn build
44+
pnpm install
45+
pnpm build
5346
5447
- name: Snyk security check
5548
if: matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS
@@ -60,11 +53,11 @@ jobs:
6053
- name: Run types tests
6154
if: matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS
6255
run: |
63-
yarn test:tsd
56+
pnpm test:tsd
6457
6558
- name: Run unit tests with coverage
6659
if: matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS
67-
run: yarn test:cover
60+
run: pnpm test:cover
6861

6962
- name: Upload coverage
7063
if: matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS
@@ -75,4 +68,4 @@ jobs:
7568

7669
- name: Run unit tests
7770
if: "!(matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS)"
78-
run: yarn test:unit
71+
run: pnpm test:unit

.github/workflows/publish.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,22 @@ jobs:
3131
run: |
3232
git fetch --prune --unshallow
3333
34+
- name: Install pnpm
35+
uses: pnpm/action-setup@v4
36+
with:
37+
version: 10
38+
3439
- name: Use Node.js ${{ env.NODE_VERSION }}
3540
uses: actions/setup-node@v6
3641
with:
3742
node-version: ${{ env.NODE_VERSION }}
3843
registry-url: ${{ env.REGISTRY }}
39-
40-
- name: Get yarn cache directory
41-
id: yarn-cache-dir
42-
run: |
43-
echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
44-
45-
- uses: actions/cache@v4
46-
id: yarn-cache
47-
with:
48-
path: ${{ steps.yarn-cache-dir.outputs.dir }}
49-
key: ubuntu-latest-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
50-
restore-keys: |
51-
ubuntu-latest-${{ env.NODE_VERSION }}-yarn-
44+
cache: 'pnpm'
5245

5346
- name: Install dependencies and build
5447
run: |
55-
yarn install --ignore-engines
56-
yarn build
48+
pnpm install
49+
pnpm build
5750
5851
- name: Publish
5952
run: |

.nycrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

CLAUDE.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Build & Test Commands
66

7-
- `yarn install` - Install dependencies
8-
- `yarn build` - Lint and compile TypeScript
9-
- `yarn compile` - Compile TypeScript only
10-
- `yarn test` - Run linting, type tests, and coverage tests
11-
- `yarn test:unit` - Run unit tests only
12-
- `yarn test:cover` - Run unit tests with coverage
13-
- `yarn test:tsd` - Run TypeScript definition tests
14-
- `yarn lint` - Run TSLint
15-
- `yarn ci` - Full CI pipeline (lint, compile, type tests, coverage)
7+
- `pnpm install` - Install dependencies
8+
- `pnpm run build` - Lint and compile TypeScript
9+
- `pnpm run compile` - Compile TypeScript only
10+
- `pnpm run test` - Run linting, type tests, and coverage tests
11+
- `pnpm run test:unit` - Run unit tests only
12+
- `pnpm run test:cover` - Run unit tests with coverage
13+
- `pnpm run test:tsd` - Run TypeScript definition tests
14+
- `pnpm run lint` - Run ESLint
15+
- `pnpm run ci` - Full CI pipeline (lint, compile, type tests, coverage)
1616

1717
Run a single test:
1818
```sh
19-
yarn test:unit --grep "test name pattern"
19+
pnpm run test:unit -- --grep "test name pattern"
2020
```
2121

2222
## Architecture
@@ -59,10 +59,12 @@ Right-hand side can be: literal value, `{ref: "path"}` to reference context, or
5959
## Code Style
6060

6161
- 4-space indentation, single quotes, semicolons required
62-
- Lines ~140 characters max
62+
- Lines ~120 characters max
6363
- 100% code coverage required
6464
- Type tests use TSD in `src/test/types/`
65+
- Linting via ESLint (flat config in `eslint.config.mjs`)
66+
- Testing via Vitest
6567

6668
## Node.js Support
6769

68-
Supports Node.js ^20, ^22, or ^24
70+
Supports Node.js ^20, ^22, or ^24

eslint.config.mjs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import js from '@eslint/js';
2+
import tsParser from '@typescript-eslint/parser';
3+
import tsPlugin from '@typescript-eslint/eslint-plugin';
4+
import globals from 'globals';
5+
6+
export default [
7+
js.configs.recommended,
8+
{
9+
files: ['src/**/*.ts'],
10+
languageOptions: {
11+
parser: tsParser,
12+
parserOptions: {
13+
ecmaVersion: 'latest',
14+
sourceType: 'module',
15+
},
16+
globals: {
17+
...globals.node,
18+
},
19+
},
20+
plugins: {
21+
'@typescript-eslint': tsPlugin,
22+
},
23+
rules: {
24+
// TypeScript recommended rules
25+
...tsPlugin.configs.recommended.rules,
26+
27+
// Single quotes with avoid-escape (matching TSLint quotemark)
28+
// Allow template literals as they're commonly used in the codebase
29+
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
30+
31+
// Max line length 120 with ignore patterns for imports/exports
32+
'max-len': ['error', {
33+
code: 120,
34+
ignorePattern: '^import |^export \\{(.*?)\\}|class [a-zA-Z]+ implements |//',
35+
ignoreUrls: true,
36+
ignoreStrings: true,
37+
ignoreTemplateLiterals: true,
38+
}],
39+
40+
// Trailing commas - disabled to match existing codebase style
41+
'comma-dangle': 'off',
42+
43+
// Disabled rules (matching TSLint config)
44+
'no-empty': 'off',
45+
'no-console': 'off',
46+
'no-unused-expressions': 'off',
47+
'@typescript-eslint/no-unused-expressions': 'off',
48+
49+
// Allow unused vars/params - matching TSLint which didn't enforce this strictly
50+
'@typescript-eslint/no-unused-vars': 'off',
51+
52+
// Other disabled TypeScript rules
53+
'@typescript-eslint/no-explicit-any': 'off',
54+
'@typescript-eslint/no-empty-function': 'off',
55+
'@typescript-eslint/ban-ts-comment': 'off',
56+
'@typescript-eslint/no-require-imports': 'off',
57+
'@typescript-eslint/no-empty-object-type': 'off',
58+
59+
// Disable rules that TypeScript handles
60+
'no-undef': 'off',
61+
'no-redeclare': 'off',
62+
63+
// Semicolons - disabled to match existing codebase style
64+
semi: 'off',
65+
66+
// Disable multiline check - TypeScript handles this
67+
'no-unexpected-multiline': 'off',
68+
},
69+
},
70+
{
71+
ignores: ['dist/**', 'node_modules/**'],
72+
},
73+
];

package.json

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
"node": "^20 || ^22 || ^24"
99
},
1010
"scripts": {
11-
"test": "yarn lint && yarn test:tsd && yarn test:cover",
11+
"test": "pnpm run lint && pnpm run test:tsd && pnpm run test:cover",
1212
"test:tsd": "tsd",
13-
"test:unit": "mocha --config src/test/.mocharc.json",
14-
"build": "yarn lint && yarn compile",
15-
"compile": "./node_modules/.bin/tsc",
16-
"test:cover": "nyc --reporter=lcov --reporter=text-summary mocha --config src/test/.mocharc.json",
17-
"lint": "tslint -c tslint.json 'src/**/*.ts' 'test/**/*.ts'",
18-
"ci": "yarn lint && yarn compile && yarn test:tsd && yarn test:cover"
13+
"test:unit": "vitest run",
14+
"build": "pnpm run lint && pnpm run compile",
15+
"compile": "tsc -p tsconfig.build.json",
16+
"test:cover": "vitest run --coverage",
17+
"lint": "eslint 'src/**/*.ts'",
18+
"ci": "pnpm run lint && pnpm run compile && pnpm run test:tsd && pnpm run test:cover"
1919
},
2020
"repository": {
2121
"type": "git",
@@ -48,22 +48,19 @@
4848
"directory": "src/test/types"
4949
},
5050
"devDependencies": {
51-
"@istanbuljs/nyc-config-typescript": "^1.0.2",
52-
"@types/chai": "4.3.20",
53-
"@types/chai-as-promised": "7.1.8",
54-
"@types/mocha": "^10.0.10",
51+
"@eslint/js": "^9.19.0",
5552
"@types/node": "^24.10.9",
5653
"@types/underscore": "^1.13.0",
57-
"chai": "4.5.0",
58-
"chai-as-promised": "7.1.2",
59-
"mocha": "^11.7.5",
54+
"@typescript-eslint/eslint-plugin": "^8.23.0",
55+
"@typescript-eslint/parser": "^8.23.0",
56+
"@vitest/coverage-v8": "^3.0.5",
57+
"eslint": "^9.19.0",
58+
"globals": "^16.0.0",
6059
"moment": "^2.30.1",
61-
"nyc": "^17.1.0",
62-
"source-map-support": "^0.5.21",
6360
"ts-node": "^10.9.2",
6461
"tsd": "^0.33.0",
65-
"tslint": "^6.1.3",
66-
"typescript": "^5.9.3"
62+
"typescript": "^5.9.3",
63+
"vitest": "^3.0.5"
6764
},
6865
"dependencies": {
6966
"ts-toolbelt": "^9.6.0"

0 commit comments

Comments
 (0)