From 91f813e8a60a7640b87ee9faf739e7f1b664a24a Mon Sep 17 00:00:00 2001 From: Des Hartman Date: Thu, 22 Jan 2026 11:24:24 +1100 Subject: [PATCH 1/2] chore: add ESLint configuration to catch code quality issues Adds comprehensive ESLint setup to proactively catch common code quality issues flagged by GitHub Copilot during PR reviews, including: - Implicit any types and unsafe type operations - Floating promises and misused promises - Unused variables - Jest best practices The configuration is tuned for this TypeScript monorepo and includes lenient rules for test files where stricter typing is less critical. This change helps prevent issues like those caught in #546 where Copilot identified type safety and promise handling concerns. Co-Authored-By: Claude --- .eslintrc.js | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 9 ++++- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..135c3704 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,93 @@ +module.exports = { + root: true, + env: { + node: true, + es6: true, + }, + plugins: ['@typescript-eslint', 'jest'], + extends: ['eslint:recommended', 'plugin:jest/recommended'], + rules: { + // Best practices + 'no-console': 'off', // CLI tool, console is expected + 'prefer-const': 'error', + 'no-var': 'error', + + // Jest best practices + 'jest/expect-expect': 'warn', + 'jest/no-disabled-tests': 'warn', + 'jest/no-focused-tests': 'error', + }, + overrides: [ + { + // TypeScript files with type checking + files: ['**/*.ts', '**/*.tsx'], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + project: ['./tsconfig.base.json', './packages/*/tsconfig.json'], + tsconfigRootDir: __dirname, + }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + 'plugin:jest/recommended', + ], + rules: { + // Catch implicit any (would catch Issue #1) + '@typescript-eslint/no-explicit-any': 'warn', // Warn, not error (any is sometimes needed) + '@typescript-eslint/no-unsafe-assignment': 'warn', + '@typescript-eslint/no-unsafe-member-access': 'warn', + '@typescript-eslint/no-unsafe-call': 'warn', + + // Catch promise issues + '@typescript-eslint/no-floating-promises': 'error', + '@typescript-eslint/no-misused-promises': 'error', + + // General code quality + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + }, + ], + + // Best practices + 'no-console': 'off', + 'prefer-const': 'error', + 'no-var': 'error', + + // Jest best practices + 'jest/expect-expect': 'warn', + 'jest/no-disabled-tests': 'warn', + 'jest/no-focused-tests': 'error', + }, + }, + { + // More lenient rules for test files + files: ['**/__tests__/**', '**/*.test.ts', '**/*.test.js'], + env: { + jest: true, + }, + rules: { + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + }, + }, + ], + ignorePatterns: [ + 'node_modules/', + 'dist/', + 'build/', + 'coverage/', + '*.config.js', + '.eslintrc.js', + 'jest.config.js', + 'jest.config.base.js', + '.changeset/', + ], +}; diff --git a/package.json b/package.json index dcd4a4e7..b5908fb1 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,9 @@ "docs": "npm run docs --workspaces --if-present", "prepare": "husky install", "pre-commit": "lint-staged", - "reset": "npm exec --workspaces -- npx rimraf node_modules && npx rimraf node_modules" + "reset": "npm exec --workspaces -- npx rimraf node_modules && npx rimraf node_modules", + "lint": "eslint . --ext .ts,.js,.tsx,.jsx", + "lint:fix": "eslint . --ext .ts,.js,.tsx,.jsx --fix" }, "devDependencies": { "@changesets/changelog-github": "^0.4.8", @@ -28,11 +30,15 @@ "@commitlint/config-conventional": "^19.1.0", "@twilio/test-dep": "npm:twilio@4.22.0", "@types/jest": "^29.2.4", + "@typescript-eslint/eslint-plugin": "^6.21.0", + "@typescript-eslint/parser": "^6.21.0", "all-contributors-cli": "^6.1.2", "commitizen": "^4.2.4", "commitlint-plugin-workspace-scopes": "^1.1.0", "conventional-changelog-cli": "^2.1.0", "cz-conventional-changelog": "^2.1.0", + "eslint": "^8.57.1", + "eslint-plugin-jest": "^27.9.0", "husky": "^8.0.2", "jest": "^29.7.0", "jest-express": "^1.10.1", @@ -47,6 +53,7 @@ }, "lint-staged": { "*.{js,jsx,ts,tsx}": [ + "eslint --fix", "prettier --write", "git add" ] From 001fdda9f58b7ef9414f0d2915b39144f1275b0a Mon Sep 17 00:00:00 2001 From: Des Hartman Date: Thu, 22 Jan 2026 13:42:16 +1100 Subject: [PATCH 2/2] chore: add changeset for ESLint configuration Add empty changeset to satisfy changeset-bot. This is a dev-tooling change that doesn't require version bumps. Co-Authored-By: Claude --- .changeset/add-eslint-configuration.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .changeset/add-eslint-configuration.md diff --git a/.changeset/add-eslint-configuration.md b/.changeset/add-eslint-configuration.md new file mode 100644 index 00000000..bfc0fc19 --- /dev/null +++ b/.changeset/add-eslint-configuration.md @@ -0,0 +1,12 @@ +--- +--- + +Add ESLint configuration for code quality and consistency + +Adds repository-wide ESLint configuration to catch common code quality issues. This is a development-only change that adds linting tooling without affecting any package functionality or APIs. + +**Configuration includes:** +- TypeScript-specific rules for type safety and promise handling +- Basic JavaScript rules for code consistency +- Lenient rules for test files +- Integration with lint-staged for pre-commit linting