Skip to content

Commit cc33679

Browse files
authored
Merge branch 'development' into Shravya/feature/Phase4/Tagged_Logs_for_Young_Learner_Support
2 parents 3b5d899 + 91f82fa commit cc33679

574 files changed

Lines changed: 59262 additions & 15266 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.

.babelrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"presets": ["@babel/preset-env"],
3+
"plugins": [
4+
"@babel/plugin-transform-async-to-generator",
5+
[
6+
"@babel/plugin-transform-runtime",
7+
{
8+
"corejs": false,
9+
"helpers": true,
10+
"regenerator": true,
11+
"useESModules": false
12+
}
13+
],
14+
[
15+
"module-resolver",
16+
{
17+
"root": "./src"
18+
}
19+
]
20+
],
21+
"ignore": ["**/*.test.js", "**/*.spec.js", "src/test/**"]
22+
}

.eslintrc

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"extends": ["eslint:recommended", "airbnb-base", "prettier"],
3+
"parser": "@babel/eslint-parser",
4+
"parserOptions": {
5+
"ecmaVersion": 8,
6+
"sourceType": "module",
7+
"requireConfigFile": false,
8+
"babelOptions": {
9+
"plugins": [
10+
[
11+
"module-resolver",
12+
{
13+
"root": ["./src"]
14+
}
15+
]
16+
]
17+
}
18+
},
19+
"env": { "es6": true, "node": true, "commonjs": true },
20+
"rules": {
21+
"global-require": "off",
22+
"func-names": "off",
23+
"no-underscore-dangle": "off",
24+
"no-param-reassign": "off",
25+
"max-len": "off",
26+
"no-continue": "warn",
27+
"no-await-in-loop": "warn",
28+
"template-curly-spacing": "off",
29+
"indent": "off",
30+
"linebreak-style": 0,
31+
"no-console": "off",
32+
"consistent-return": "off"
33+
},
34+
"settings": {
35+
"import/resolver": {
36+
"babel-module": {
37+
"root": ["./src"]
38+
},
39+
"node": {
40+
"paths": ["src"],
41+
"extensions": [".js", ".jsx"]
42+
}
43+
}
44+
},
45+
"overrides": [
46+
{
47+
"files": ["**/*.test.js", "**/*.spec.js", "src/test/*.js"],
48+
"env": {
49+
"jest": true
50+
}
51+
}
52+
]
53+
}

.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/

.gitignore

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/bower_components
1010

1111
# misc
12+
# /scripts
1213
/.sass-cache
1314
/connect.lock
1415
/coverage/*
@@ -24,4 +25,14 @@ testem.log
2425
/.vscode
2526

2627
# OS specific
27-
.DS_Store
28+
.DS_Store
29+
30+
# Documentation
31+
/docs
32+
.DS_Storescripts/
33+
.env
34+
patch-mongo.js
35+
skip-db.js
36+
stub-db.js
37+
stub-db-strong.js
38+
# scripts/

.husky/commit-msg

100755100644
File mode changed.

.husky/pre-commit

100755100644
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
echo "✅ Husky pre-commit is running..."
52
npx lint-staged --allow-empty
63

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lts/iron
1+
20

0 commit comments

Comments
 (0)