This project uses a comprehensive linting and formatting setup to maintain code quality across both TypeScript/Angular and Rust codebases.
- ESLint: Linting for TypeScript and Angular code
- Prettier: Code formatting
- Angular ESLint: Angular-specific linting rules
- Clippy: Official Rust linter
- Rustfmt: Official Rust code formatter
- Husky: Git hooks management
- lint-staged: Run linters on staged files
npm run lint # Run ESLint
npm run lint:fix # Run ESLint with auto-fix
npm run format # Format code with Prettier
npm run format:check # Check if code is formattednpm run lint:rust # Run Clippy
npm run format:rust # Format Rust code
npm run format:rust:check # Check Rust formattingnpm run lint:all # Run all linters and formatters (check only)
npm run fix:all # Run all linters and formatters with auto-fixThe project automatically runs linting and formatting on staged files before each commit. This ensures:
- Code quality standards are maintained
- Consistent formatting across the codebase
- Early detection of potential issues
If you encounter errors during pre-commit:
- Rust formatting errors: Ensure you're in the project root directory and
src-tauri/Cargo.tomlexists - ESLint/Prettier SIGKILL errors: Usually caused by insufficient memory or conflicting processes
- To bypass hooks temporarily: Use
git commit --no-verify(not recommended for main branch)
If the pre-commit hooks fail, you'll see errors like:
✖ cargo fmt --:
`cargo metadata` exited with an error: error: could not find `Cargo.toml` in `/home/hakan/Documents/GitHub/rclone-manager` or any parent directory
This usually indicates that the Rust commands are not running from the correct directory. The fix is to ensure that the lint-staged configuration uses shell commands that properly change to the src-tauri directory.
-
TOML Parse Errors: If you see "duplicate key" errors, check:
src-tauri/Cargo.tomlfor duplicate keyssrc-tauri/rustfmt.tomlfor conflicting configuration options- Ensure the Rust edition is valid (2015, 2018, 2021)
-
ESLint Errors: The project has strict linting rules. Common issues:
@typescript-eslint/no-explicit-any: Replaceanytypes with proper types@typescript-eslint/no-unused-vars: Remove unused variables@angular-eslint/prefer-inject: Useinject()instead of constructor injection
-
Cargo Clippy Warnings: Rust linter warnings that should be addressed:
- Run
npm run lint:rustto see detailed warnings - Fix warnings or use
#[allow(clippy::warning_name)]if necessary
- Run
If the pre-commit hooks fail, you can run the linting tools manually:
# Frontend linting
npm run lint # Check for errors
npm run lint:fix # Auto-fix errors
npm run format # Format code
# Rust linting (run from project root)
npm run lint:rust # Check for warnings
npm run format:rust # Format code
# Or run directly in src-tauri directory
cd src-tauri
cargo fmt # Format code
cargo clippy -- -D warnings # Check for warningsNot recommended for production, but for testing:
git commit --no-verify -m "commit message".eslintrc.js- ESLint configuration.prettierrc.json- Prettier configuration.prettierignore- Prettier ignore patternssrc-tauri/.clippy.toml- Clippy configurationsrc-tauri/rustfmt.toml- Rustfmt configuration.vscode/settings.json- VS Code integration settings
The project includes VS Code settings for:
- Format on save
- ESLint integration
- Rust analyzer configuration
- Automatic code actions
- ESLint (dbaeumer.vscode-eslint)
- Prettier (esbenp.prettier-vscode)
- Rust Analyzer (rust-lang.rust-analyzer)
- Angular Language Service (Angular.ng-template)
- Install dependencies:
npm install - The linting tools are automatically configured
- Pre-commit hooks are set up automatically
- Start coding with confidence!