Skip to content

Commit a8d6de6

Browse files
committed
feat: update dependencies
2 parents fa631f2 + 94ba54d commit a8d6de6

131 files changed

Lines changed: 7219 additions & 5023 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ module.exports = {
1111
},
1212
env: { es6: true, node: true, commonjs: true },
1313
rules: {
14+
// ===============================
15+
// KEEP EXISTING RELAXED RULES
16+
// ===============================
1417
'global-require': 'off',
1518
'func-names': 'off',
1619
'no-underscore-dangle': 'off',
@@ -21,8 +24,109 @@ module.exports = {
2124
'template-curly-spacing': 'off',
2225
indent: 'off',
2326
'linebreak-style': 0,
24-
'no-console': 'off',
27+
'no-console': 'warn',
2528
'consistent-return': 'off',
29+
30+
// ===============================
31+
// LIGHT ENTERPRISE ADDITIONS (MOSTLY WARNINGS)
32+
// ===============================
33+
34+
// Critical Error Prevention (errors only for breaking stuff)
35+
'no-undef': 'error',
36+
'no-unused-vars': [
37+
'warn',
38+
{
39+
vars: 'local',
40+
args: 'none',
41+
varsIgnorePattern: '^_',
42+
argsIgnorePattern: '^_',
43+
},
44+
],
45+
'no-unreachable': 'error',
46+
'no-dupe-keys': 'error',
47+
'no-duplicate-case': 'error',
48+
49+
// Security (light - just warnings to start awareness)
50+
'no-eval': 'warn',
51+
'no-implied-eval': 'warn',
52+
'no-new-func': 'warn',
53+
'no-script-url': 'warn',
54+
55+
// Code Quality (warnings only - gradual improvement)
56+
'no-var': 'warn', // Encourage let/const
57+
'prefer-const': 'warn', // Encourage immutability
58+
'no-magic-numbers': [
59+
'warn',
60+
{
61+
ignore: [-1, 0, 1, 2, 100, 200, 201, 400, 401, 403, 404, 500],
62+
ignoreArrayIndexes: true,
63+
},
64+
],
65+
'prefer-template': 'warn',
66+
'no-duplicate-imports': 'warn',
67+
'object-shorthand': 'warn',
68+
69+
// Async/Promise Best Practices (warnings)
70+
'no-return-await': 'warn',
71+
'prefer-promise-reject-errors': 'warn',
72+
'no-async-promise-executor': 'warn',
73+
74+
// Node.js Specific (warnings)
75+
'no-path-concat': 'warn',
76+
'no-process-exit': 'warn',
77+
'handle-callback-err': 'warn',
78+
'new-cap': 'warn',
79+
'no-lonely-if': 'warn',
80+
'no-nested-ternary': 'warn',
81+
camelcase: 'warn',
82+
radix: 'warn',
83+
'no-restricted-syntax': 'warn',
84+
85+
// Light Complexity Control (warnings with high thresholds)
86+
complexity: ['warn', { max: 15 }], // High threshold for lazy devs
87+
'max-depth': ['warn', { max: 5 }],
88+
'max-params': ['warn', { max: 4 }],
89+
'max-lines-per-function': [
90+
'warn',
91+
{
92+
max: 100,
93+
skipBlankLines: true,
94+
skipComments: true,
95+
},
96+
],
97+
98+
// Import Organization (warnings only)
99+
'import/order': [
100+
'warn',
101+
{
102+
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
103+
'newlines-between': 'never', // Keep it simple
104+
},
105+
],
106+
'import/newline-after-import': 'warn',
107+
'import/no-duplicates': 'warn',
108+
109+
// Performance Hints (warnings)
110+
'no-loop-func': 'warn',
111+
112+
// API Design (warnings for better practices)
113+
'no-throw-literal': 'warn',
114+
'prefer-rest-params': 'warn',
115+
'prefer-spread': 'warn',
116+
117+
// Database/Backend Specific (warnings)
118+
'no-eq-null': 'warn', // Encourage strict equality
119+
eqeqeq: ['warn', 'smart'], // Allow == null for lazy devs
120+
121+
// Documentation Encouragement (warnings)
122+
'spaced-comment': [
123+
'warn',
124+
'always',
125+
{
126+
markers: ['/', '!', '*'],
127+
exceptions: ['-', '+', '*'],
128+
},
129+
],
26130
},
27131
settings: {
28132
'import/resolver': {
@@ -32,9 +136,40 @@ module.exports = {
32136
},
33137
},
34138
overrides: [
139+
// Test Files - More Relaxed
35140
{
36141
files: ['**/*.test.js', '**/*.spec.js', 'src/test/**/*.js', 'src/__tests__/**/*.js'],
37142
env: { jest: true },
143+
rules: {
144+
// Relax rules for test files
145+
'no-magic-numbers': 'off',
146+
'max-lines-per-function': 'off',
147+
complexity: 'off',
148+
'max-params': 'off',
149+
'prefer-promise-reject-errors': 'off',
150+
'no-console': 'off',
151+
'import/no-extraneous-dependencies': 'off',
152+
},
153+
},
154+
155+
// Config Files - Super Relaxed
156+
{
157+
files: ['*.config.js', '.eslintrc.js', 'babel.config.js', 'webpack.config.js'],
158+
rules: {
159+
'no-console': 'off',
160+
'import/no-extraneous-dependencies': 'off',
161+
'global-require': 'off',
162+
},
163+
},
164+
165+
// Migration Files - Relaxed (if using DB migrations)
166+
{
167+
files: ['**/migrations/*.js', '**/seeders/*.js'],
168+
rules: {
169+
'no-console': 'off',
170+
'max-lines-per-function': 'off',
171+
'no-magic-numbers': 'off',
172+
},
38173
},
39174
],
40175
};

.github/workflows/node.js.yml

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,75 @@ on:
77
branches: [ development ]
88

99
jobs:
10-
build:
10+
lint:
11+
name: Lint Check
1112
runs-on: ubuntu-latest
1213
steps:
13-
- uses: actions/checkout@v4
14-
- name: Use Node.js 20.x
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Use Node.js 20.17.0
1518
uses: actions/setup-node@v4
1619
with:
17-
node-version: 20.x
20+
node-version: 20.17.0
1821
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Run lint
27+
run: npm run lint
1928

20-
- run: npm ci
21-
- name: Run email sender check
22-
run: node src/utilities/debugEmailSender.js
23-
- run: npm run test
24-
25-
29+
test:
30+
name: Tests with 10% Coverage Enforcement
31+
runs-on: ubuntu-latest
32+
needs: lint
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Use Node.js 20.17.0
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 20.17.0
41+
cache: 'npm'
42+
43+
- name: Install dependencies
44+
run: npm ci
45+
46+
- name: Run tests with coverage enforcement
47+
run: npm run test:ci
48+
49+
- name: Print detailed coverage report
50+
if: always()
51+
run: |
52+
echo "📊 COVERAGE ENFORCEMENT REPORT 📊"
53+
echo "=================================="
54+
echo "Minimum Required: Lines: 34%, Statements: 34%, Functions: 27%, Branches: 12%"
55+
echo "=================================="
56+
if [ -f coverage/coverage-summary.json ]; then
57+
node -e "
58+
const coverage = require('./coverage/coverage-summary.json');
59+
const { lines, statements, functions, branches } = coverage.total;
60+
61+
console.log('📈 CURRENT COVERAGE:');
62+
console.log(\`📄 Lines: \${lines.pct}% \${lines.pct >= 34 ? '✅ PASS' : '❌ FAIL'}\`);
63+
console.log(\`📝 Statements: \${statements.pct}% \${statements.pct >= 34 ? '✅ PASS' : '❌ FAIL'}\`);
64+
console.log(\`🔧 Functions: \${functions.pct}% \${functions.pct >= 27 ? '✅ PASS' : '❌ FAIL'}\`);
65+
console.log(\`🌿 Branches: \${branches.pct}% \${branches.pct >= 12 ? '✅ PASS' : '❌ FAIL'}\`);
66+
67+
const allPass = [lines, statements, functions, branches].every(metric => metric.pct >= 60);
68+
console.log('================================');
69+
console.log(\`🎯 OVERALL: \${allPass ? '✅ COVERAGE REQUIREMENTS MET' : '❌ COVERAGE REQUIREMENTS FAILED'}\`);
70+
console.log('================================');
71+
"
72+
else
73+
echo "❌ No coverage report generated"
74+
fi
75+
76+
- name: Upload coverage report
77+
if: always()
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: backend-coverage-report
81+
path: coverage/

create-tasks-for-current-user.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ async function createTasksForCurrentUser() {
1818

1919
console.log('✅ Connected to MongoDB');
2020

21-
const currentUserId = '68645a7c48658d005501e2f9';
21+
// add your user id here to create tasks for that user
22+
const currentUserId = '';
2223

2324
// Get existing data
2425
const subjects = await Subject.find({});

jest.config.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
module.exports = {
22
roots: ['<rootDir>/src'],
33
collectCoverageFrom: [
4-
'!<rootDir>/src/**/*.js', // need to collect coverage from all files that are involved in serving an API request
5-
'!<rootDir>/src/server.js',
6-
'!<rootDir>/src/models/**/*.js',
7-
'!<rootDir>/src/startup/**/*.js',
8-
'!<rootDir>/src/test/**/*.js',
9-
'!<rootDir>/src/utilities/**/*.js', // need to collect coverage from utilities after all unit tests have been created
4+
'src/**/*.js',
5+
'src/controllers/**/*.js',
6+
'src/routes/**/*.js',
7+
'src/utilities/**/*.js',
8+
'src/helpers/**/*.js',
9+
'src/models/**/*.js',
10+
'src/services/**/*.js',
11+
'src/middleware/**/*.js',
12+
// Exclude test files and mock data
13+
'!src/**/*.test.js',
14+
'!src/**/*.spec.js',
15+
'!src/**/*MockData.js',
16+
'!src/**/*MockData.jsx',
17+
'!src/test/**',
18+
'!src/__tests__/**',
19+
],
20+
// Coverage thresholds - Start light and increase gradually
21+
coverageThreshold: {
22+
global: {
23+
branches: 9,
24+
functions: 24,
25+
lines: 30,
26+
statements: 30,
27+
},
28+
},
29+
30+
// Coverage reporters - shows in terminal and generates reports
31+
coverageReporters: [
32+
'text', // Terminal output
33+
'text-summary', // Brief summary
34+
'lcov', // For CI/CD tools
35+
'html', // HTML report in coverage/ folder
36+
'json', // JSON report for parsing
1037
],
1138
testTimeout: 60000, // 1 minute for CI environments
1239
coverageDirectory: 'coverage',

0 commit comments

Comments
 (0)