Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .clinerules
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Global Cline Rules

## 1. General Workflow
- Think step-by-step; ask for clarification if the request is ambiguous.
- Summarize plan before making changes; await approval on complex edits.

## 2. Response & Diff Formatting
- Use Markdown; wrap code in triple backticks with language tags.
- Present file modifications in Unified Diff (patch) format.
- Include a Conventional Commit–style message for each commit.

## 3. Documentation Practices
- Update `README.md` with any new setup or feature instructions.

## 4. Testing Standards
- Provide at least one unit test per new feature.
- Name tests to reflect behavior.

## 6. Error Handling & Logging
- Handle errors gracefully, logging only essential details.
- Use unique error codes or identifiers for easier debugging.
77 changes: 77 additions & 0 deletions javascriptapp/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// This file configures ESLint, which is a tool for identifying and reporting on patterns
// found in JavaScript code, with the goal of making code more consistent and avoiding bugs

module.exports = {
// The environment in which your code runs
env: {
// Node.js global variables and Node.js scoping
node: true,
// Browser global variables
browser: true,
// Adds all ECMAScript 2021 globals and automatically sets the ecmaVersion parser option to 12
es2021: true,
// Jest global variables
jest: true,
},
// Extends these configurations (recommended settings)
extends: [
// Use ESLint's recommended rules
'eslint:recommended',
// Use Prettier's recommended rules
'prettier',
// Use Jest plugin's recommended rules
'plugin:jest/recommended',
],
// Specifies the JavaScript language options to use
parserOptions: {
// Use ECMAScript 2021 syntax
ecmaVersion: 12,
// Use ECMAScript modules
sourceType: 'module',
},
// ESLint plugins to use
plugins: [
// Use Jest plugin
'jest',
],
// Custom rules
rules: {
// Disallow the use of console (error level)
// This helps catch debugging statements that might have been left in the code
'no-console': ['error', { allow: ['warn', 'error'] }],

// Require semicolons at the end of statements (error level)
semi: ['error', 'always'],

// Use single quotes for strings (warning level)
quotes: ['warn', 'single', { avoidEscape: true }],

// Disallow unused variables (warning level)
'no-unused-vars': ['warn'],

// Require consistent return statements in functions (error level)
'consistent-return': 'error',

// Require === and !== instead of == and != (error level)
eqeqeq: ['error', 'always'],

// Disallow the use of eval() (error level)
'no-eval': 'error',

// Disallow the use of alert, confirm, and prompt (error level)
'no-alert': 'error',

// Disallow the use of debugger (error level)
'no-debugger': 'error',

// Jest specific rules
// Disallow focused tests (error level)
'jest/no-focused-tests': 'error',

// Disallow disabled tests (warning level)
'jest/no-disabled-tests': 'warn',

// Disallow identical test titles (error level)
'jest/no-identical-title': 'error',
},
};
35 changes: 35 additions & 0 deletions javascriptapp/.lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// This file configures lint-staged, which runs linters on staged files before committing
// It helps ensure that only properly formatted and error-free code gets committed

module.exports = {
// For JavaScript files:
'*.js': [
// Run ESLint with auto-fix option
'eslint --fix',
// Format with Prettier
'prettier --write',
// Run Jest tests that are related to the staged files
// This ensures that your changes don't break existing tests
'jest --findRelatedTests --passWithNoTests',
],
// For JSON files:
'*.json': [
// Format JSON files with Prettier
'prettier --write',
],
// For Markdown files:
'*.md': [
// Format Markdown files with Prettier
'prettier --write',
],
// For HTML files:
'*.html': [
// Format HTML files with Prettier
'prettier --write',
],
// For CSS files:
'*.css': [
// Format CSS files with Prettier
'prettier --write',
],
};
100 changes: 100 additions & 0 deletions javascriptapp/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// This file configures Prettier, which is an opinionated code formatter
// It enforces a consistent style by parsing your code and re-printing it with its own rules

module.exports = {
// Specify the line length that the printer will wrap on
// Default: 80
printWidth: 100,

// Specify the number of spaces per indentation-level
// Default: 2
tabWidth: 2,

// Indent lines with tabs instead of spaces
// Default: false
useTabs: false,

// Print semicolons at the ends of statements
// Default: true
semi: true,

// Use single quotes instead of double quotes
// Default: false
singleQuote: true,

// Use single quotes in JSX
// Default: false
jsxSingleQuote: false,

// Print trailing commas wherever possible in multi-line comma-separated syntactic structures
// Default: 'es5'
// Options: 'none' | 'es5' | 'all'
trailingComma: 'es5',

// Print spaces between brackets in object literals
// Default: true
bracketSpacing: true,

// Put the > of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line
// instead of being alone on the next line
// Default: false
bracketSameLine: false,

// Include parentheses around a sole arrow function parameter
// Default: 'always'
// Options: 'always' | 'avoid'
arrowParens: 'always',

// Format only a segment of a file
// Default: 0
rangeStart: 0,
// Default: Infinity
rangeEnd: Infinity,

// Specify which parser to use
// Default: None
// parser: None,

// Specify the file name to use to infer which parser to use
// Default: None
// filepath: None,

// Require either '@prettier' or '@format' to be present in the file's first docblock comment
// in order for it to be formatted
// Default: false
requirePragma: false,

// Insert a special @format marker at the top of files specifying that
// the file has been formatted with prettier
// Default: false
insertPragma: false,

// By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer
// In some cases you may want to rely on editor/viewer soft wrapping instead
// Default: 'preserve'
// Options: 'always' | 'never' | 'preserve'
proseWrap: 'preserve',

// Specify the global whitespace sensitivity for HTML files
// Default: 'css'
// Options: 'css' | 'strict' | 'ignore'
htmlWhitespaceSensitivity: 'css',

// Whether or not to indent the code inside <script> and <style> tags in Vue files
// Default: false
vueIndentScriptAndStyle: false,

// End of line
// Default: 'lf'
// Options: 'lf' | 'crlf' | 'cr' | 'auto'
endOfLine: 'lf',

// Control whether Prettier formats quoted code embedded in the file
// Default: 'auto'
// Options: 'auto' | 'off'
embeddedLanguageFormatting: 'auto',

// Enforce single attribute per line in HTML, Vue and JSX
// Default: false
singleAttributePerLine: false,
};
39 changes: 39 additions & 0 deletions javascriptapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,48 @@ The app will be available at http://localhost:3000
- public/ - Static frontend files
- index.html - Main web interface
- tests/ - Jest test files
- .eslintrc.js - ESLint configuration
- .prettierrc.js - Prettier configuration

## Git Hooks

This project uses Git hooks to ensure code quality and test coverage:

### Pre-commit Hook
The pre-commit hook runs automatically before each commit and:
- Lints JavaScript files with ESLint
- Formats code with Prettier
- Runs tests related to changed files

To run these checks manually:
```
npm run lint # Check for linting issues
npm run lint:fix # Fix linting issues automatically
npm run format # Format code with Prettier
```

### Pre-push Hook
The pre-push hook runs automatically before each push and:
- Runs all tests with coverage
- Ensures code coverage meets minimum thresholds (80%)
- Checks for skipped tests

To bypass hooks in emergency situations (not recommended):
```
git commit --no-verify
git push --no-verify
```

### How the Hooks Work
The hooks are implemented as shell scripts in the `.git/hooks` directory:
- They only run on JavaScript files in the javascriptapp directory
- The pre-commit hook runs ESLint, Prettier, and related tests
- The pre-push hook runs all tests with coverage checks

## Technologies Used

Express.js - Backend server
Jest - Testing framework
SuperTest - HTTP testing library
ESLint - Code quality tool
Prettier - Code formatter
88 changes: 88 additions & 0 deletions javascriptapp/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// This file configures ESLint, which is a tool for identifying and reporting on patterns
// found in JavaScript code, with the goal of making code more consistent and avoiding bugs

const jestPlugin = require('eslint-plugin-jest');

module.exports = [
// Apply to all JavaScript files
{
// The environment in which your code runs
languageOptions: {
// Use ECMAScript 2021 syntax
ecmaVersion: 2021,
// Use ECMAScript modules
sourceType: 'module',
// Global variables
globals: {
// Node.js global variables
process: 'readonly',
// Browser global variables
document: 'readonly',
window: 'readonly',
// Jest global variables
jest: 'readonly',
expect: 'readonly',
test: 'readonly',
describe: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
it: 'readonly',
},
},

// Use ESLint's recommended rules
linterOptions: {
reportUnusedDisableDirectives: true,
},

// Custom rules
rules: {
// Disallow the use of console (error level)
// This helps catch debugging statements that might have been left in the code
'no-console': ['error', { allow: ['warn', 'error'] }],

// Require semicolons at the end of statements (error level)
semi: ['error', 'always'],

// Use single quotes for strings (warning level)
quotes: ['warn', 'single', { avoidEscape: true }],

// Disallow unused variables (warning level)
'no-unused-vars': ['warn'],

// Require consistent return statements in functions (error level)
'consistent-return': 'error',

// Require === and !== instead of == and != (error level)
eqeqeq: ['error', 'always'],

// Disallow the use of eval() (error level)
'no-eval': 'error',

// Disallow the use of alert, confirm, and prompt (error level)
'no-alert': 'error',

// Disallow the use of debugger (error level)
'no-debugger': 'error',
},
},

// Jest specific configuration
{
files: ['**/*.test.js', '**/*.spec.js'],
plugins: {
jest: jestPlugin,
},
rules: {
// Jest specific rules
// Disallow focused tests (error level)
'jest/no-focused-tests': 'error',

// Disallow disabled tests (warning level)
'jest/no-disabled-tests': 'warn',

// Disallow identical test titles (error level)
'jest/no-identical-title': 'error',
},
},
];
10 changes: 9 additions & 1 deletion javascriptapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"main": "server.js",
"scripts": {
"test": "jest --coverage",
"start": "node server.js"
"start": "node server.js",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"format": "prettier --write ."
},
"keywords": [],
"author": "",
Expand All @@ -14,7 +17,12 @@
"test": "tests"
},
"devDependencies": {
"eslint": "^9.25.0",
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-jest": "^28.11.0",
"jest": "^29.7.0",
"lint-staged": "^15.5.1",
"prettier": "^3.5.3",
"supertest": "^7.0.0"
},
"dependencies": {
Expand Down
Loading