This repository uses Prettier to automatically format HTML, CSS, and JavaScript files for consistent code style.
The formatting rules are defined in .prettierrc and include:
- printWidth: 120 characters per line
- tabWidth: 2 spaces for indentation
- useTabs: false (use spaces, not tabs)
- singleQuote: false (use double quotes)
- htmlWhitespaceSensitivity: "css" (preserve CSS-sensitive whitespace)
Formats all HTML, CSS, and JavaScript files in the docs directory.
Checks if files are properly formatted without making changes.
Formats only HTML files.
Formats only CSS files.
Formats only JavaScript files.
Install the required dependencies:
npm installnpm run formatnpm run format:checknpm run format:html
npm run format:css
npm run format:jsThe formatter will process files in the docs/ directory:
docs/**/*.html- All HTML filesdocs/**/*.css- All CSS filesdocs/**/*.js- All JavaScript files
Files excluded from formatting (see .prettierignore):
node_modules/package-lock.json- Image files (
.png,.jpg, etc.) - Documentation files (
README.md,LICENSE) - Minified files (
*.min.js,*.min.css)
You can integrate Prettier into your development workflow:
- Pre-commit hooks: Run
npm run formatbefore committing - Editor integration: Configure your editor to format on save
- CI/CD: Add
npm run format:checkto your deployment pipeline
Install the Prettier extension and add to your settings:
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}Most modern editors support Prettier. Check the Prettier documentation for your specific editor.
If you encounter formatting issues:
- Run
npm run formatto fix formatting - Check the
.prettierrcconfiguration - Verify files aren't in
.prettierignore - Check for syntax errors in your files
- Consistent code style across all files
- Automatic formatting saves time
- Team collaboration with unified formatting
- Reduced code review time spent on formatting
- Modern tooling that's widely adopted