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

test: add linter to all packages and enable vitest #490

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"start": "pnpm --filter \"@ai16z/agent\" start --isRoot",
"start:client": "pnpm --dir client start --isRoot",
"dev": "bash ./scripts/dev.sh",
"lint": "pnpm --dir packages/core lint && pnpm --dir packages/agent lint",
"lint": "bash ./scripts/lint.sh",
"prettier-check": "npx prettier --check .",
"prettier": "npx prettier --write .",
"release": "pnpm build && pnpm prettier && npx lerna publish --no-private --force-publish",
Expand Down
66 changes: 66 additions & 0 deletions packages/adapter-postgres/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import eslint from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import typescript from "@typescript-eslint/parser";
import prettier from "eslint-config-prettier";
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin

export default [
// JavaScript and TypeScript files
{
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
languageOptions: {
parser: typescript,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
},
globals: {
// Add Node.js globals
NodeJS: "readonly",
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
module: "readonly",
require: "readonly",
},
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
...eslint.configs.recommended.rules,
...tseslint.configs.recommended.rules,
"prefer-const": "warn",
"no-constant-binary-expression": "error",

// Disable no-undef as TypeScript handles this better
"no-undef": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
// Customize TypeScript rules
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
// Vitest configuration
{
files: ["src/**/*.test.js", "src/**/*.test.ts", "src/**/*.spec.js", "src/**/*.spec.ts"],
plugins: {
vitest, // Register Vitest plugin
},
rules: {
...vitest.configs.recommended.rules,
},
},
// Add prettier as the last config to override other formatting rules
prettier,
];
7 changes: 6 additions & 1 deletion packages/adapter-postgres/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
"pg": "^8.13.1"
},
"devDependencies": {
"eslint": "9.13.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-vitest": "0.5.4",
"tsup": "^8.3.5"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch"
"dev": "tsup --format esm --dts --watch",
"lint": "eslint . --fix"
}
}
66 changes: 66 additions & 0 deletions packages/adapter-sqlite/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import eslint from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import typescript from "@typescript-eslint/parser";
import prettier from "eslint-config-prettier";
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin

export default [
// JavaScript and TypeScript files
{
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
languageOptions: {
parser: typescript,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
},
globals: {
// Add Node.js globals
NodeJS: "readonly",
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
module: "readonly",
require: "readonly",
},
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
...eslint.configs.recommended.rules,
...tseslint.configs.recommended.rules,
"prefer-const": "warn",
"no-constant-binary-expression": "error",

// Disable no-undef as TypeScript handles this better
"no-undef": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
// Customize TypeScript rules
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
// Vitest configuration
{
files: ["src/**/*.test.js", "src/**/*.test.ts", "src/**/*.spec.js", "src/**/*.spec.ts"],
plugins: {
vitest, // Register Vitest plugin
},
rules: {
...vitest.configs.recommended.rules,
},
},
// Add prettier as the last config to override other formatting rules
prettier,
];
7 changes: 6 additions & 1 deletion packages/adapter-sqlite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
"sqlite-vec": "0.1.4-alpha.2"
},
"devDependencies": {
"eslint": "9.13.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-vitest": "0.5.4",
"tsup": "^8.3.5"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch"
"dev": "tsup --format esm --dts --watch",
"lint": "eslint . --fix"
},
"peerDependencies": {
"whatwg-url": "7.1.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-sqlite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class SqliteDatabaseAdapter
}
const placeholders = params.roomIds.map(() => "?").join(", ");
let sql = `SELECT * FROM memories WHERE type = ? AND roomId IN (${placeholders})`;
let queryParams = [params.tableName, ...params.roomIds];
const queryParams = [params.tableName, ...params.roomIds];

if (params.agentId) {
sql += ` AND agentId = ?`;
Expand Down
66 changes: 66 additions & 0 deletions packages/adapter-sqljs/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import eslint from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import typescript from "@typescript-eslint/parser";
import prettier from "eslint-config-prettier";
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin

export default [
// JavaScript and TypeScript files
{
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
languageOptions: {
parser: typescript,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
},
globals: {
// Add Node.js globals
NodeJS: "readonly",
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
module: "readonly",
require: "readonly",
},
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
...eslint.configs.recommended.rules,
...tseslint.configs.recommended.rules,
"prefer-const": "warn",
"no-constant-binary-expression": "error",

// Disable no-undef as TypeScript handles this better
"no-undef": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
// Customize TypeScript rules
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
// Vitest configuration
{
files: ["src/**/*.test.js", "src/**/*.test.ts", "src/**/*.spec.js", "src/**/*.spec.ts"],
plugins: {
vitest, // Register Vitest plugin
},
rules: {
...vitest.configs.recommended.rules,
},
},
// Add prettier as the last config to override other formatting rules
prettier,
];
7 changes: 6 additions & 1 deletion packages/adapter-sqljs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
"uuid": "11.0.2"
},
"devDependencies": {
"eslint": "9.13.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-vitest": "0.5.4",
"tsup": "^8.3.5"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --watch"
"dev": "tsup --watch",
"lint": "eslint . --fix"
},
"peerDependencies": {
"whatwg-url": "7.1.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-sqljs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export declare class Database {

close(): void;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
create_function(name: string, func: (...args: any[]) => any): Database;

each(
Expand Down
66 changes: 66 additions & 0 deletions packages/adapter-supabase/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import eslint from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import typescript from "@typescript-eslint/parser";
import prettier from "eslint-config-prettier";
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin

export default [
// JavaScript and TypeScript files
{
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
languageOptions: {
parser: typescript,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
},
globals: {
// Add Node.js globals
NodeJS: "readonly",
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
module: "readonly",
require: "readonly",
},
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
...eslint.configs.recommended.rules,
...tseslint.configs.recommended.rules,
"prefer-const": "warn",
"no-constant-binary-expression": "error",

// Disable no-undef as TypeScript handles this better
"no-undef": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
// Customize TypeScript rules
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
// Vitest configuration
{
files: ["src/**/*.test.js", "src/**/*.test.ts", "src/**/*.spec.js", "src/**/*.spec.ts"],
plugins: {
vitest, // Register Vitest plugin
},
rules: {
...vitest.configs.recommended.rules,
},
},
// Add prettier as the last config to override other formatting rules
prettier,
];
7 changes: 6 additions & 1 deletion packages/adapter-supabase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
"@supabase/supabase-js": "2.46.1"
},
"devDependencies": {
"eslint": "9.13.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-vitest": "0.5.4",
"tsup": "^8.3.5"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --watch"
"dev": "tsup --watch",
"lint": "eslint . --fix"
},
"peerDependencies": {
"whatwg-url": "7.1.0"
Expand Down
Loading