Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 3.07 KB

prettier.md

File metadata and controls

31 lines (20 loc) · 3.07 KB

Prettier Configuration Explained 📝

Prettier is an opinionated code formatter that supports many languages and integrates with most editors. It removes all original styling and ensures that all outputted code conforms to a consistent style. Prettier takes your code and reprints it from scratch by following the rules defined in its configuration file.

Why Prettier? 🤔

  • Consistency: Enforces a consistent code style across your project.
  • Saves time: Automates formatting so you can focus on the code logic instead.
  • Integrates with ESLint: Works alongside ESLint to ensure both style and quality.

Our Prettier Configuration Explained 🔧

Interested in seeing our custom setup? Check out our prettierrc.mjs configuration file directly. It's tailored to fit our project's specific needs, ensuring optimal code readability and maintainability. Dive in to explore the exact settings we use to keep our codebase clean and consistent.

Key Configuration Options 🗝️

  • arrowParens: 'always': Ensures arrow functions have parentheses around their parameters, improving clarity. arrowParens
  • semi: true: Enforces semicolon usage at the end of statements, preventing potential pitfalls in JS. semi
  • tabWidth: 2 & printWidth: 100: Sets indentation to 2 spaces and lines to a maximum of 100 characters, balancing readability with modern coding practices. tabWidth, printWidth
  • singleQuote: true & trailingComma: 'es5': Uses single quotes for strings and includes trailing commas where valid in ES5, aiding in version control. singleQuote, trailingComma
  • bracketSpacing: true: Applies space inside object literals, enhancing readability. bracketSpacing
  • endOfLine: 'lf': Enforces line feeds (LF) for line breaks, ensuring consistency across different OSs. endOfLine
  • plugins: Utilizes additional plugins for Astro and import sorting, enhancing the formatting capabilities. plugins
  • overrides: Applies specific formatting to certain file types, allowing for customized formatting rules. overrides

This configuration ensures our code is not only consistent and readable but also adheres to best practices recommended by Prettier, tailored specifically for our Astro project.

Conclusion 🎉

Adopting Prettier in our project has streamlined our development process, allowing us to focus more on writing quality code rather than formatting details. By configuring Prettier to meet our specific needs, we ensure a cohesive and maintainable codebase.