diff --git a/.clinerules b/.clinerules new file mode 100644 index 0000000..e063ba7 --- /dev/null +++ b/.clinerules @@ -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. diff --git a/javascriptapp/.eslintrc.js b/javascriptapp/.eslintrc.js new file mode 100644 index 0000000..d846608 --- /dev/null +++ b/javascriptapp/.eslintrc.js @@ -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', + }, +}; diff --git a/javascriptapp/.lintstagedrc.js b/javascriptapp/.lintstagedrc.js new file mode 100644 index 0000000..1c4931c --- /dev/null +++ b/javascriptapp/.lintstagedrc.js @@ -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', + ], +}; diff --git a/javascriptapp/.prettierrc.js b/javascriptapp/.prettierrc.js new file mode 100644 index 0000000..a4a3a59 --- /dev/null +++ b/javascriptapp/.prettierrc.js @@ -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