diff --git a/eslint.config.js b/eslint.config.js index b2e2883..0f0ea2c 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -105,9 +105,31 @@ module.exports = [ '@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }] } }, - // Test files (JavaScript and TypeScript) + // Test files (JavaScript) { - files: ['test/**/*.js', '**/*.test.js', 'test/**/*.ts', '**/*.test.ts'], + files: ['test/**/*.js', '**/*.test.js'], + languageOptions: { + ecmaVersion: 'latest', + sourceType: 'commonjs', + globals: { + jest: 'readonly', + describe: 'readonly', + test: 'readonly', + it: 'readonly', + expect: 'readonly', + beforeEach: 'readonly', + afterEach: 'readonly', + beforeAll: 'readonly', + afterAll: 'readonly' + } + }, + rules: { + 'no-console': 'off' + } + }, + // Test files (TypeScript) + { + files: ['test/**/*.ts', '**/*.test.ts'], languageOptions: { parser: tsparser, parserOptions: { @@ -127,6 +149,9 @@ module.exports = [ afterAll: 'readonly' } }, + plugins: { + '@typescript-eslint': tseslint + }, rules: { 'no-console': 'off', '@typescript-eslint/no-explicit-any': 'off' // Allow any in tests for mocking diff --git a/jest.config.js b/jest.config.js index 9c0ac89..575f4b0 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,9 +8,7 @@ module.exports = { '**/test/e2e/scenarios/**/*.test.{js,ts}' ], transform: { - '^.+\\.ts$': ['ts-jest', { - isolatedModules: true - }], + '^.+\\.ts$': 'ts-jest', '^.+\\.js$': 'babel-jest' }, moduleFileExtensions: ['ts', 'js', 'json'], diff --git a/src/controllers/githubController.ts b/src/controllers/githubController.ts index 2d255dc..4cde922 100644 --- a/src/controllers/githubController.ts +++ b/src/controllers/githubController.ts @@ -117,7 +117,7 @@ export const handleWebhook: WebhookHandler = async (req, res) => { // Validate request body structure for webhook processing // Use Object.prototype.toString for secure type checking to prevent bypass const bodyType = Object.prototype.toString.call(req.body); - if (bodyType !== '[object Object]' || req.body === null || req.body === undefined) { + if (bodyType !== '[object Object]') { logger.error('Webhook request missing or invalid body structure'); return res.status(400).json({ error: 'Missing or invalid request body' }); } diff --git a/tsconfig.json b/tsconfig.json index 0042c95..c0082ae 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,6 +28,7 @@ "allowUnreachableCode": false, "noFallthroughCasesInSwitch": true, "noErrorTruncation": true, + "isolatedModules": true, "types": ["node", "jest"] }, "include": [