Skip to content

Commit 30556b2

Browse files
feat: add comprehensive repository badges and improvements (#37)
* fix: migrate to ESLint v9 flat config format - Replace .eslintrc.js with eslint.config.js (ESLint v9 requirement) - Add 'type': 'module' to package.json for ES module support - Update Jest config to use ES module syntax - Fix rollup configuration for new @rollup/plugin-typescript version - Add proper globals configuration for Node.js and browser APIs - Install globals package for ESLint configuration - All tests and linting now working with new versions Resolves ESLint v9 migration issues from Renovate updates * chore: trigger CI to test ESLint v9 configuration - Add comment to TypeScript README to trigger CI - Test if ESLint v9 configuration works in CI environment * fix: convert prepare.js to ES module syntax - Convert CommonJS require() to ES module import syntax - Add __dirname and __filename polyfills for ES modules - Fixes TypeScript client CI failure due to ES module configuration * refactor: extract shared TypeScript rules in ESLint config - Extract duplicated TypeScript rules into sharedTypeScriptRules constant - Replace inline rule objects in both base and test configs with shared constant - Maintains all original rules and configurations unchanged - Improves maintainability by eliminating code duplication - Follows DRY principle for better code organization * refactor: convert dev.js to ES module syntax - Replace CommonJS require() calls with ES module import statements - Add __dirname and __filename polyfills using fileURLToPath and path.dirname - Import fileURLToPath from 'url' module for ES module compatibility - Maintains all original functionality while using modern ES module syntax - Consistent with prepare.js ES module conversion * feat: integrate ESLint with Prettier to avoid conflicting rules - Add eslint-config-prettier to devDependencies in package.json - Import eslint-config-prettier in ESLint configuration - Include prettier config in ESLint config array after js.configs.recommended - Disables Prettier-related ESLint rules to prevent conflicts - Ensures consistent code formatting between ESLint and Prettier - Maintains all existing ESLint rules while preventing style conflicts * refactor: extract shared globals in ESLint config - Extract duplicated global declarations into sharedGlobals constant - Include ...globals.node, ...globals.browser and readonly browser APIs - Replace base config globals with sharedGlobals reference - Replace test config globals with sharedGlobals + test-specific additions - Eliminates code duplication while maintaining all original functionality - Improves maintainability by centralizing global declarations * fix: update package-lock.json for eslint-config-prettier - Update package-lock.json to include eslint-config-prettier dependency - Resolves CI failure where npm ci couldn't install due to lock file mismatch - Ensures package.json and package-lock.json are in sync - Fixes TypeScript Client CI/CD workflow dependency installation * refactor: remove redundant global declarations from ESLint config - Remove explicit fetch, setTimeout, clearTimeout declarations from sharedGlobals - These globals are already included in globals.browser - Eliminates duplication and improves maintainability --------- Co-authored-by: Ben De Cock <[email protected]>
1 parent bff7688 commit 30556b2

File tree

13 files changed

+210
-137
lines changed

13 files changed

+210
-137
lines changed

clients/typescript/.eslintignore

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

clients/typescript/.eslintrc.js

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

clients/typescript/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
A robust TypeScript client library for the ContextForge Memory API with
44
comprehensive error handling, retry logic, and full type safety.
55

6+
<!-- Updated to trigger CI -->
7+
68
## Features
79

810
- **Full Type Safety**: Complete TypeScript definitions for all API types
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import js from '@eslint/js';
2+
import typescript from '@typescript-eslint/eslint-plugin';
3+
import typescriptParser from '@typescript-eslint/parser';
4+
import globals from 'globals';
5+
import prettier from 'eslint-config-prettier';
6+
7+
// Shared TypeScript rules used by both base and test configurations
8+
const sharedTypeScriptRules = {
9+
...typescript.configs.recommended.rules,
10+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
11+
'@typescript-eslint/explicit-function-return-type': ['error', {
12+
allowExpressions: true,
13+
allowTypedFunctionExpressions: true
14+
}],
15+
// Enforce explicit return types for exported/public APIs
16+
'@typescript-eslint/explicit-module-boundary-types': 'error',
17+
'@typescript-eslint/no-explicit-any': 'error',
18+
'@typescript-eslint/no-inferrable-types': 'off',
19+
'@typescript-eslint/strict-boolean-expressions': ['error', {
20+
allowNullableObject: true
21+
}],
22+
'prefer-const': 'error',
23+
'no-var': 'error',
24+
'no-unused-vars': 'off', // Turn off base rule as it can conflict with @typescript-eslint/no-unused-vars
25+
};
26+
27+
// Shared globals used by both base and test configurations
28+
const sharedGlobals = {
29+
...globals.node,
30+
...globals.browser,
31+
URL: 'readonly',
32+
Response: 'readonly',
33+
RequestInit: 'readonly',
34+
AbortController: 'readonly',
35+
};
36+
37+
export default [
38+
js.configs.recommended,
39+
prettier,
40+
{
41+
files: ['**/*.ts', '**/*.tsx'],
42+
languageOptions: {
43+
parser: typescriptParser,
44+
parserOptions: {
45+
ecmaVersion: 2020,
46+
sourceType: 'module',
47+
project: './tsconfig.json',
48+
},
49+
globals: sharedGlobals,
50+
},
51+
plugins: {
52+
'@typescript-eslint': typescript,
53+
},
54+
rules: sharedTypeScriptRules,
55+
},
56+
{
57+
files: ['tests/**/*.ts', '**/*.test.ts', '**/*.spec.ts'],
58+
languageOptions: {
59+
parser: typescriptParser,
60+
parserOptions: {
61+
ecmaVersion: 2020,
62+
sourceType: 'module',
63+
project: './tsconfig.test.json',
64+
},
65+
globals: {
66+
...sharedGlobals,
67+
...globals.jest,
68+
global: 'readonly',
69+
Headers: 'readonly',
70+
},
71+
},
72+
plugins: {
73+
'@typescript-eslint': typescript,
74+
},
75+
rules: sharedTypeScriptRules,
76+
},
77+
{
78+
ignores: [
79+
'dist/**',
80+
'node_modules/**',
81+
'coverage/**',
82+
'*.js',
83+
'*.mjs',
84+
],
85+
},
86+
];

clients/typescript/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
preset: 'ts-jest/presets/default-esm',
33
globals: {
44
'ts-jest': {

clients/typescript/package-lock.json

Lines changed: 32 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/typescript/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@contextforge/memory-client",
33
"version": "0.1.0",
4+
"type": "module",
45
"description": "TypeScript client for ContextForge Memory API with v0 and v1 support",
56
"main": "dist/index.js",
67
"module": "dist/index.esm.js",
@@ -60,7 +61,6 @@
6061
"engines": {
6162
"node": ">=18.0.0"
6263
},
63-
"peerDependencies": {},
6464
"devDependencies": {
6565
"@rollup/plugin-node-resolve": "^16.0.0",
6666
"@rollup/plugin-terser": "^0.4.4",
@@ -69,6 +69,8 @@
6969
"@typescript-eslint/eslint-plugin": "^8.0.0",
7070
"@typescript-eslint/parser": "^8.0.0",
7171
"eslint": "^9.0.0",
72+
"eslint-config-prettier": "^9.1.0",
73+
"globals": "^16.4.0",
7274
"husky": "^9.0.0",
7375
"jest": "^30.0.0",
7476
"prettier": "^3.1.0",

clients/typescript/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default defineConfig([
4141
tsconfig: './tsconfig.json',
4242
declaration: true,
4343
declarationMap: true,
44-
outDir: 'dist/types'
44+
declarationDir: 'dist/types'
4545
}),
4646
terser()
4747
],

clients/typescript/scripts/dev.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616
* node scripts/dev.js pre-publish - Run pre-publish checks/tasks
1717
*/
1818

19-
const { execSync } = require('child_process');
20-
const fs = require('fs');
21-
const path = require('path');
19+
import { execSync } from 'child_process';
20+
import fs from 'fs';
21+
import path from 'path';
22+
import { fileURLToPath } from 'url';
23+
24+
const __filename = fileURLToPath(import.meta.url);
25+
const __dirname = path.dirname(__filename);
2226

2327
// Validate we're in the package root
2428
const packageJsonPath = path.join(__dirname, '..', 'package.json');

clients/typescript/scripts/prepare.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
* Runs before npm install to ensure proper setup
66
*/
77

8+
import fs from 'fs';
9+
import path from 'path';
10+
import { fileURLToPath } from 'url';
11+
12+
const __filename = fileURLToPath(import.meta.url);
13+
const __dirname = path.dirname(__filename);
14+
815
console.log('Preparing TypeScript client...');
916

1017
// Ensure dist directory exists
11-
const fs = require('fs');
12-
const path = require('path');
13-
1418
const distDir = path.join(__dirname, '..', 'dist');
1519
if (!fs.existsSync(distDir)) {
1620
fs.mkdirSync(distDir, { recursive: true });

0 commit comments

Comments
 (0)