This document outlines the coding standards, tools configuration, and development workflow for the Nostria project.
Important: This project uses CRLF line endings exclusively for Windows development consistency.
- All developers work on Windows
- Consistent with Windows development environment
- Eliminates cross-platform line ending issues
- Simplifies Git configuration and file handling
The following files enforce CRLF line endings:
.gitattributes: Enforces CRLF for all text files in Git.editorconfig: Setsend_of_line = crlffor all editors.prettierrc: Sets"endOfLine": "crlf"for code formatting.vscode/settings.json: Sets"files.eol": "\r\n"for VS Code
If you need to normalize existing files to CRLF:
npm run normalize-line-endingsThis script will:
- Convert all LF line endings to CRLF
- Update Git index with normalized files
- Show status of changed files
- Print Width: 100 characters
- Quote Style: Single quotes
- Semicolons: Always required
- Tab Width: 2 spaces
- Trailing Commas: ES5 compatible
- Line Endings: CRLF
- Bracket Spacing: Enabled
- Arrow Parens: Avoid when possible
# Format all files
npm run format
# Check formatting without modifying files
npm run format:check- Based on Angular ESLint recommended rules
- TypeScript ESLint integration
- Prettier integration for formatting conflicts
- Auto-generated API files are ignored (
src/app/api/**/*)
# Run linter
npm run lint
# Fix auto-fixable linting issues
npm run lint-fix
# Check linting without fixing
npm run lint:checkThe project includes VS Code workspace settings that:
- Enable format on save
- Auto-fix ESLint issues on save
- Enforce consistent indentation (2 spaces)
- Set CRLF line endings
- Configure file associations for Angular development
- Angular Language Service: Angular IntelliSense
- ESLint: Linting integration
- Prettier: Code formatting
- TypeScript Hero: TypeScript utilities
# Ensure CRLF line endings on checkout
git config core.autocrlf true
# Set default branch name
git config init.defaultBranch mainThe .gitattributes file ensures:
- All text files use CRLF line endings
- Binary files are handled correctly
- Consistent behavior across different Git configurations
-
Ensure your Git configuration is correct:
git config core.autocrlf true -
Install dependencies:
npm install
-
Verify formatting and linting work:
npm run format:check npm run lint:check
- Format on Save: Enabled automatically in VS Code
- Lint on Save: Auto-fixes ESLint issues
- Pre-commit: Consider using husky for pre-commit hooks
# Format all files
npm run format
# Fix linting issues
npm run lint-fix
# Verify everything passes
npm run lint:check
npm run format:check- Use standalone components (default)
- Prefer signals for state management
- Use
input()andoutput()functions - Set
OnPushchange detection strategy - Use native control flow (
@if,@for,@switch)
- Enable strict type checking
- Prefer type inference when obvious
- Avoid
anytype; useunknownwhen uncertain - Use
inject()function instead of constructor injection
src/
├── app/
│ ├── components/ # Reusable UI components
│ ├── pages/ # Route components
│ ├── services/ # Business logic and data services
│ ├── pipes/ # Custom pipes
│ └── interfaces/ # TypeScript interfaces and types
├── styles/ # Global styles
└── environments/ # Environment configurations
If you encounter line ending problems:
-
Run the normalization script:
npm run normalize-line-endings
-
Refresh Git index:
git add --renormalize . -
Commit the changes:
git commit -m "Normalize line endings to CRLF"
If Prettier and ESLint conflict:
- Check both configurations are aligned
- Run format before linting:
npm run format npm run lint-fix
If development server is slow:
- Check for circular dependencies
- Use
ng build --watchfor faster rebuilds - Consider using
ng serve --hmrfor hot module replacement
- Angular Style Guide
- TypeScript Handbook
- Prettier Configuration
- ESLint Rules
- Nostr NIPs - Protocol specifications