Skip to content
Closed
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
17 changes: 0 additions & 17 deletions clients/typescript/.eslintignore

This file was deleted.

45 changes: 0 additions & 45 deletions clients/typescript/.eslintrc.js

This file was deleted.

103 changes: 103 additions & 0 deletions clients/typescript/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import js from '@eslint/js';
import typescript from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import globals from 'globals';

export default [
js.configs.recommended,
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: import.meta.dirname,
...
project: './tsconfig.test.json',
tsconfigRootDir: import.meta.dirname,
Comment on lines +12 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Malformed parserOptions with duplicate keys.

The parserOptions object contains duplicate project and tsconfigRootDir properties. Static analysis confirms line 14's tsconfigRootDir is overwritten by line 17. This configuration will only use the last values ('./tsconfig.test.json' and its tsconfigRootDir), breaking linting for non-test files.

The first config object (for general TS files) should reference './tsconfig.json', while the second config object (for test files at lines 48-92) should reference './tsconfig.test.json'. Remove the duplicate properties from lines 16-17 in the first config's parserOptions:

     languageOptions: {
       parser: typescriptParser,
       parserOptions: {
         project: './tsconfig.json',
         tsconfigRootDir: import.meta.dirname,
-        ...
-        project: './tsconfig.test.json',
-        tsconfigRootDir: import.meta.dirname,
+        ecmaVersion: 2020,
+        sourceType: 'module',
       },
       globals: {
🧰 Tools
🪛 Biome (2.1.2)

[error] 16-16: expected , but instead found :

Remove :

(parse)


[error] 14-14: This property is later overwritten by an object member with the same name.

Overwritten with this property.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property.

(lint/suspicious/noDuplicateObjectKeys)

🤖 Prompt for AI Agents
In clients/typescript/eslint.config.js around lines 12 to 17, the parserOptions
object has duplicate keys (project and tsconfigRootDir) that are being
overwritten by the test config values; remove the duplicate project and
tsconfigRootDir entries from the first parserOptions so it only references
'./tsconfig.json' and its tsconfigRootDir, and ensure the separate test
configuration (lines 48-92) retains './tsconfig.test.json' and its
tsconfigRootDir so linting for general and test files uses the correct tsconfig
files.

globals: {
...globals.node,
...globals.browser,
URL: 'readonly',
Response: 'readonly',
RequestInit: 'readonly',
AbortController: 'readonly',
fetch: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
},
},
plugins: {
'@typescript-eslint': typescript,
},
rules: {
// Optionally merge in typed presets for stronger checks:
// ...typescript.configs['recommended-type-checked']?.rules,
// ...typescript.configs['strict-type-checked']?.rules,
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/strict-boolean-expressions': ['error', {
allowNullableObject: true
}],
'prefer-const': 'error',
'no-var': 'error',
'no-unused-vars': 'off', // Turn off base rule as it can conflict with @typescript-eslint/no-unused-vars
},
},
{
files: ['tests/**/*.ts', '**/*.test.ts', '**/*.spec.ts'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: './tsconfig.test.json',
},
globals: {
...globals.node,
...globals.browser,
...globals.jest,
global: 'readonly',
URL: 'readonly',
Response: 'readonly',
RequestInit: 'readonly',
AbortController: 'readonly',
fetch: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
Headers: 'readonly',
},
},
plugins: {
'@typescript-eslint': typescript,
},
rules: {
...typescript.configs.recommended.rules,
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/explicit-function-return-type': ['error', {
allowExpressions: true,
allowTypedFunctionExpressions: true
}],
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/strict-boolean-expressions': ['error', {
allowNullableObject: true
}],
'prefer-const': 'error',
'no-var': 'error',
'no-unused-vars': 'off',
},
},
{
ignores: [
'dist/**',
'node_modules/**',
'coverage/**',
// Keep TS focused; optionally lint JS configs by removing these:
// '*.js',
// '*.mjs',
],
},
];
2 changes: 1 addition & 1 deletion clients/typescript/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
preset: 'ts-jest/presets/default-esm',
globals: {
'ts-jest': {
Expand Down
31 changes: 18 additions & 13 deletions clients/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions clients/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "@contextforge/memory-client",
"version": "0.1.0",
"type": "module",
"description": "TypeScript client for ContextForge Memory API with v0 and v1 support",
"main": "dist/index.js",
"main": "dist/index.cjs",
"module": "dist/index.esm.js",
"types": "dist/types/index.d.ts",
"sideEffects": false,
"exports": {
".": {
"import": "./dist/index.esm.js",
"require": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/types/index.d.ts"
},
"./package.json": "./package.json"
Expand Down Expand Up @@ -60,7 +61,6 @@
"engines": {
"node": ">=18.0.0"
},
"peerDependencies": {},
"devDependencies": {
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-terser": "^0.4.4",
Expand All @@ -69,6 +69,7 @@
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint": "^9.0.0",
"globals": "^16.4.0",
"husky": "^9.0.0",
"jest": "^30.0.0",
"prettier": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion clients/typescript/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default defineConfig([
tsconfig: './tsconfig.json',
declaration: true,
declarationMap: true,
outDir: 'dist/types'
declarationDir: 'dist/types'
}),
terser()
],
Expand Down
10 changes: 7 additions & 3 deletions clients/typescript/scripts/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
* node scripts/dev.js pre-publish - Run pre-publish checks/tasks
*/

const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// Validate we're in the package root
const packageJsonPath = path.join(__dirname, '..', 'package.json');
Expand Down
8 changes: 6 additions & 2 deletions clients/typescript/scripts/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
console.log('Preparing TypeScript client...');

// Ensure dist directory exists
const fs = require('fs');
const path = require('path');
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const distDir = path.join(__dirname, '..', 'dist');
if (!fs.existsSync(distDir)) {
Expand Down
Loading
Loading