Master Frontend Tooling: Prettier, Stylelint, ESLint, and Git Hooks for Design Systems
This article explains how GrowingIO's Design System leverages a component library and introduces essential frontend development tools—including Prettier, stylelint, ESLint, Commitizen, commitlint, lint‑staged, and Husky—detailing their installation, configuration, usage, and integration into CI pipelines to ensure consistent, maintainable code.
Introduction
In the 1960s the "software crisis" emerged as computers outpaced software development. Fifty years later a similar challenge appears in design, where UI components become inconsistent and hard to maintain. A design system—a collection of reusable, standardised components—solves this problem.
GrowingIO's product R&D team built the GrowingIO Design System to provide consistent interaction experiences and improve development efficiency. This article introduces the development tools used to build the component library.
TL;DR
The tools are divided into two categories: code formatting tools and code management tools.
1. Code Formatting Tools
Prettier : opinionated code formatter supporting JavaScript, JSX, TypeScript, CSS, Less, SCSS, HTML, JSON, GraphQL, Markdown, YAML, etc.
stylelint : modern CSS/SCSS/LESS linter with over 170 built‑in rules, plugin support, and auto‑fix capabilities.
ESLint : pluggable JavaScript linter that parses code with Espree, analyses AST patterns, and allows custom rule plugins.
2. Code Management Tools
Commitizen : assists developers in writing conventional commit messages.
commitlint : validates commit messages against a configurable convention.
lint‑staged : runs linters only on staged files to speed up checks.
husky : integrates all the above tools into Git hooks (pre‑commit, commit‑msg, etc.).
Tool Details
Prettier
Prettier formats code according to a consistent style, handling line length and language‑specific syntax.
<code>$ yarn add --dev --exact prettier</code>Configuration example:
<code>$ echo {}> .prettierrc.js</code> <code>$ yarn prettier --write .</code>stylelint
stylelint enforces CSS/LESS/SCSS style rules and can be combined with Prettier.
<code>$ yarn add --dev stylelint stylelint-config-standard stylelint-config-prettier</code> <code>module.exports = {</code><code> extends: ["stylelint-config-standard", "stylelint-config-prettier"],</code><code>};</code> <code>$ npx stylelint --syntax less --fix</code>ESLint
ESLint checks JavaScript/TypeScript code for errors and style violations.
<code>$ yarn add --dev eslint</code> <code>$ npx eslint --init</code> <code>module.exports = {</code><code> env: {browser: true, es2021: true, jest: true},</code><code> extends: ["plugin:react/recommended", "airbnb", "prettier", "prettier/react"],</code><code> parser: "@typescript-eslint/parser",</code><code> plugins: ["react", "@typescript-eslint", "prettier"],</code><code> rules: {"prettier/prettier": "error"},</code><code>};</code> <code>$ npx eslint --cache --fix</code>Commitizen
<code>$ yarn global add commitizen</code> <code>$ commitizen init cz-conventional-changelog --yarn --dev --exact</code>commitlint
<code>$ yarn add --dev @commitlint/config-conventional @commitlint/cli</code> <code>echo "module.exports = {extends: ['@commitlint/config-conventional']}" > .commitlintrc.js</code>lint‑staged
<code>$ npx mrm lint-staged</code> <code>module.exports = {</code><code> "**/*": "prettier --write --ignore-unknown",</code><code> "*.less": "stylelint --syntax less --fix",</code><code> "*.(j|t)s?(x)": "eslint --cache --fix",</code><code>};</code>husky
<code>$ yarn add --dev husky</code> <code>module.exports = {</code><code> hooks: {</code><code> "pre-commit": "lint-staged",</code><code> "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",</code><code> },</code><code>};</code>Running
git cznow triggers the configured hooks, ensuring formatted code and valid commit messages.
CI Integration
The tools are integrated into a GitHub Actions workflow, which runs the checks on each push and annotates the results directly in the pull request.
CI visualisation:
Conclusion
The article introduced the motivation behind a design system and provided a comprehensive reference of the frontend tooling—Prettier, stylelint, ESLint, Commitizen, commitlint, lint‑staged, and Husky—used to build and maintain a robust component library.
GrowingIO Tech Team
The official technical account of GrowingIO, showcasing our tech innovations, experience summaries, and cutting‑edge black‑tech.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.