Overview
Learn how to keep your code clean and consistent using formatting (standardizing code style) and linting (catching code errors).
Tools
- Nuxt ESLint: Checks your code for errors and enforces Nuxt/Vue standards.
- Prettier: Automatically formats your code for a consistent look.
- simple-git-hooks: Runs formatting and linting when you save changes to your project.
Usage
- Linting: Run
npm run lintto check for issues in your code. - Auto Fix Lint Errors: Run
npm run lint-fixto automatically fix common problems. - Formatting: Run
npm run formatto style your code automatically. - Full Cleanup: Run
npm run format:allto lint and format your entire codebase in one go. - Auto-Formatting: Code is automatically linted and formatted when you commit changes.
Configuration Files
Modify these only if you need custom settings:
eslint.config.mjs: Sets rules for code error checking..prettierignore: Lists files to skip during formatting..prettierrc: Defines formatting styles (e.g., tabs, quotes).package.json(Git Hooks): Sets up auto-formatting when saving changes.