FRONTEND BEST PRACTICES
Code Quality and Standards
- ESLint
ESLint Nuxt Configuration
A linting tool for identifying and fixing issues in JavaScript and Vue codebases. - Prettier
Why Prettier?
Prettier enforces a consistent code format to improve readability across the codebase. - Unit Testing
Unit testing verifies the functionality of individual components, ensuring that each works as expected.- Vue Testing Library Provides a testing approach that emphasizes component behavior, making tests more maintainable.
- Vitest A fast, easy-to-configure unit testing framework for Vue 3, compatible with Vite.
- TypeScript
TypeScript Handbook
TypeScript adds static typing to JavaScript, making codebases more predictable and easier to refactor. - Visual Regression Testing
Visual regression testing tools like Chromatic and Percy help catch unintended changes in component design or layout. - Code Review
Regular code reviews ensure code quality, consistency, and adherence to best practices. - Documentation
Documenting code, components, and design systems helps onboard new team members and maintain codebases effectively. - Automation and CI/CD
Automate linting, testing, and deployment processes to ensure code quality and consistency.
Scoped Styles
Scoped styles provide a way to apply CSS specifically to individual components, avoiding global style conflicts and making CSS more manageable in large applications. Here are some resources to learn more:
-
Vue Scoped Styles
Vue Documentation - Scoped CSS
Scoped CSS helps ensure styles are only applied to the component where they’re defined, reducing conflicts in large applications. -
CSS Modules
CSS-Tricks - CSS Modules
CSS Modules make CSS locally scoped by default, preventing issues like naming conflicts and accidental style overrides. -
Benefits of Scoped Styles in Large Applications
Mastering the Art of Scoped CSS in React: A Stylish Guide to Cleaner, Safer, and More Maintainable Code
An overview of how scoped CSS can reduce bloat, improve maintainability, and increase style predictability.
Atomic CSS
Atomic CSS is a utility-first approach to styling where classes are highly reusable, concise, and meant to serve specific purposes, like layout and color. This approach minimizes CSS bloat and improves the speed of development.
-
Introduction to Atomic CSS
CSS-Tricks - Atomic CSS
Provides an overview of Atomic CSS principles and explains how it can streamline styling workflows. -
Why Atomic CSS
Figma - Design Systems Benefits of Atomic CSS
Resource on how Atomic CSS supports consistent, maintainable UI designs in a component-driven structure. -
Tailwind CSS (a popular atomic CSS framework)
Tailwind CSS Documentation
Shows how a utility-first approach with Atomic CSS promotes reusability, customization, and faster development cycles. -
Atomic Web Design
Atomic Web Design
Brad Frost’s blog on atomic web design, which promotes creating reusable and scalable UI components.
Storybook
Storybook is a powerful tool for developing, testing, and documenting UI components in isolation, making it a favourite for component-driven development.
-
Storybook Official Documentation
Storybook Documentation
Comprehensive guides on Storybook, from getting started to advanced usage, emphasizing component-driven development. -
Visual Regression Testing (VRT)
Tools for VRT allow you to track visual changes in your components, ensuring UI consistency. -
Storybook and Component Libraries Why You Should Use Storybook Discusses how Storybook enhances developer experience, team collaboration, and UI consistency by building UI components in isolation.
-
Distribute UI across an organization Discusses a walk through of design system distribution from packaging UI components to importing them into other apps.
TypeScript
TypeScript adds static typing to JavaScript, making codebases more predictable, easier to refactor, and enabling better tooling support.
-
TypeScript Handbook
TypeScript Documentation
The official documentation covers everything from TypeScript basics to advanced features. -
TypeScript Deep Dive by Basarat Ali Syed
GitHub Repository
An in-depth guide on TypeScript by Basarat, covering language features, best practices, and patterns. -
TypeScript for JavaScript Developers
Microsoft Learn - TypeScript for JavaScript Developers
A curated learning path from Microsoft to help JavaScript developers transition to TypeScript. -
Advanced Types in TypeScript
Advanced TypeScript Types Cheat Sheet (with Examples)
Covers advanced type features and patterns, including mapped types, conditional types, and more. -
TypeScript with React
TypeScript + React Cheatsheets
Cheat sheets and best practices for using TypeScript in React applications.
Learning
You can test TS features in the TS Playground
Also a good resource is https://www.totaltypescript.com/ they have some free workshops on https://github.com/total-typescript which are really good.
TypeScript packages
- tsx TypeScript Execute (tsx): The easiest way to run TypeScript in Node.js
- vue-tsc Provides type-checking capabilities specifically for Vue components in TypeScript, without needing to compile. Useful for CI pipelines and pre-build type-checking.
Summary
With these resources, you can build a solid foundation for component-driven development and write maintainable, scalable, and efficient code.
CONTINUE READING
MODERN CSS STYLING APPROACHES
CSS styling has evolved significantly, moving from traditional global stylesheets and independent style files to more modular, component-level approaches.
November 15, 2024
COMPONENT-DRIVEN DEVELOPMENT (CDD)
Component-driven development (CDD) is an approach to building applications by focusing on reusable, isolated UI components as the fundamental building blocks for the user interface.
November 15, 2024