Coding Style & Formatting
To maintain consistency and readability across the codebase, Trufos employs automated tools for code formatting and linting.
Code Formatting: Prettier
Prettier is an opinionated code formatter used to ensure a consistent code style.
- Configuration: .prettierrc{ "trailingComma": "es5", "tabWidth": 2, "semi": true, "singleQuote": true, "printWidth": 100 }
- Usage: - Check Formatting: yarn prettier-checkThis command checks all TypeScript ( .ts,.tsx) files for formatting issues without modifying them.
- Apply Formatting: yarn prettierThis command automatically reformats all TypeScript files according to the defined style. 
 
- Check Formatting: 
- IDE Integration: It is highly recommended to integrate Prettier into your IDE to format code automatically on save. - VS Code: Install the Prettier - Code formatter extension. The project includes .vscode/settings.jsonwhich should enable format-on-save with Prettier for TypeScript files.
- IntelliJ (WebStorm, etc.): - Install the “Prettier” plugin from the JetBrains Marketplace.
- Configure it to run on save: Go to Settings/Preferences>Languages & Frameworks>JavaScript>Prettier. Enable “Run on save”. Ensure “Run for files” includes*.tsand*.tsx. (Alternatively, theCONTRIBUTING.mdsuggests using “Save Actions X” plugin for IntelliJ.)
 
 
- VS Code: Install the Prettier - Code formatter extension. The project includes 
Linting: ESLint
ESLint is used for static analysis to find problematic patterns or code that doesn’t adhere to certain style guidelines.
- Configuration: - eslint.config.mjs(Flat Config - preferred)
- .eslintrc.json(Legacy - might be partially used or in transition. The- eslint.config.mjsindicates a move to flat config.)
 The configuration extends several recommended rule sets: - eslint:recommended
- plugin:@typescript-eslint/recommended
- plugin:import/recommended(for import statement linting)
- plugin:import/electron
- plugin:import/typescript
 Key settings include: - Parser: @typescript-eslint/parser
- Import resolver for TypeScript paths.
- Rule import/no-unresolvedset toerror.
 
- Usage: yarn lintThis command runs ESLint on all .tsand.tsxfiles and reports any errors or warnings.
General Guidelines
- Follow the established coding style present in the project.
- Write clear and concise code.
- Add comments to explain complex logic or non-obvious decisions.
- Ensure your contributions pass both Prettier checks and ESLint checks before submitting a pull request.