fix: improve CI/CD quality checks and fix test/lint configuration
Backend fixes: - Add eslint.config.js with proper ES6 module configuration - Add jest.config.js to support ES modules - Update package.json with @eslint/js dependency - Configure npm test script with NODE_OPTIONS for ES modules - Update Jenkinsfile to block deployments on failed lint/tests This ensures: 1. ESLint works correctly with ES6 modules 2. Jest can run tests with ES6 imports 3. Deployments are blocked if quality checks fail 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
caff01fc4b
commit
9330c68e5c
19
Jenkinsfile
vendored
19
Jenkinsfile
vendored
|
|
@ -77,11 +77,20 @@ pipeline {
|
|||
}
|
||||
steps {
|
||||
echo "🧪 Lancement des tests et analyse..."
|
||||
sh '''
|
||||
npm ci
|
||||
npm run lint || echo "⚠️ Erreurs de lint détectées"
|
||||
npm test || echo "⚠️ Tests échoués — ignorés pour le déploiement"
|
||||
'''
|
||||
script {
|
||||
def lintStatus = sh(script: 'npm ci && npm run lint', returnStatus: true)
|
||||
def testStatus = sh(script: 'npm test', returnStatus: true)
|
||||
|
||||
if (lintStatus != 0) {
|
||||
error "❌ ESLint a échoué - Le déploiement est bloqué"
|
||||
}
|
||||
|
||||
if (testStatus != 0) {
|
||||
error "❌ Les tests ont échoué - Le déploiement est bloqué"
|
||||
}
|
||||
|
||||
echo "✅ Tests et lint passés avec succès"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
36
eslint.config.js
Normal file
36
eslint.config.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import js from '@eslint/js';
|
||||
|
||||
export default [
|
||||
js.configs.recommended,
|
||||
{
|
||||
languageOptions: {
|
||||
ecmaVersion: 2022,
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
// Node.js globals
|
||||
console: 'readonly',
|
||||
process: 'readonly',
|
||||
Buffer: 'readonly',
|
||||
__dirname: 'readonly',
|
||||
__filename: 'readonly',
|
||||
global: 'readonly',
|
||||
module: 'readonly',
|
||||
require: 'readonly',
|
||||
exports: 'writable',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
||||
'no-console': 'off',
|
||||
'no-undef': 'error',
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: [
|
||||
'node_modules/**',
|
||||
'dist/**',
|
||||
'coverage/**',
|
||||
'*.config.js',
|
||||
],
|
||||
},
|
||||
];
|
||||
37
jest.config.js
Normal file
37
jest.config.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
export default {
|
||||
// Use Node's experimental ESM support
|
||||
testEnvironment: 'node',
|
||||
|
||||
// Transform ES modules
|
||||
transform: {},
|
||||
|
||||
// Extensions to consider
|
||||
extensionsToTreatAsEsm: ['.js'],
|
||||
|
||||
// Module name mapper for ES modules
|
||||
moduleNameMapper: {
|
||||
'^(\\.{1,2}/.*)\\.js$': '$1',
|
||||
},
|
||||
|
||||
// Test match patterns
|
||||
testMatch: [
|
||||
'**/test/**/*.test.js',
|
||||
'**/__tests__/**/*.js',
|
||||
],
|
||||
|
||||
// Coverage configuration
|
||||
collectCoverageFrom: [
|
||||
'src/**/*.js',
|
||||
'!src/**/*.test.js',
|
||||
'!**/node_modules/**',
|
||||
],
|
||||
|
||||
// Ignore patterns
|
||||
testPathIgnorePatterns: [
|
||||
'/node_modules/',
|
||||
'/dist/',
|
||||
],
|
||||
|
||||
// Verbose output
|
||||
verbose: true,
|
||||
};
|
||||
|
|
@ -8,8 +8,8 @@
|
|||
"start": "node index.js",
|
||||
"dev": "nodemon index.js",
|
||||
"lint": "eslint .",
|
||||
"test": "jest",
|
||||
"test:integration": "jest --config jest.integration.config.js",
|
||||
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
||||
"test:integration": "NODE_OPTIONS=--experimental-vm-modules jest --config jest.integration.config.js",
|
||||
"db:schema": "psql -h 51.75.24.29 -U postgres -d thetiptop_dev -p 5433 -f database/schema.sql",
|
||||
"db:create": "node scripts/create-tables.js",
|
||||
"db:seed": "node database/seed.js",
|
||||
|
|
@ -42,6 +42,7 @@
|
|||
"zod": "^4.1.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.0",
|
||||
"eslint": "^9.39.0",
|
||||
"jest": "^30.2.0",
|
||||
"nodemon": "^3.1.10",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user