Skip to content

Standards ​

Code Submission Validation and Formatting:

Using tools like ESLint, Prettier, Stylelint, along with Husky and Lint-staged, to achieve automatic validation and formatting when code is submitted, standardizing the team development process.

Code Submission Standardization:

Using CommitLint, cz-git and other tools to standardize Git commit messages, improving project maintainability and collaboration efficiency.

Automation ​

Code submissions will automatically execute configured files, completing code validation and formatting automatically. Configuration is located in package.json.

bash
"lint-staged": {
  "*.{js,ts}": [
    "eslint --fix",
    "prettier --write"
  ],
  "*.{cjs,json}": [
    "prettier --write"
  ],
  "*.{vue,html}": [
    "eslint --fix",
    "prettier --write",
    "stylelint --fix"
  ],
  "*.{scss,css}": [
    "stylelint --fix",
    "prettier --write"
  ],
  "*.md": [
    "prettier --write"
  ]
}

Tools: ​

  • Eslint - JavaScript code checking
  • Prettier - Code formatting
  • Stylelint - CSS code checking
  • Commitlint - Git commit message checking
  • Husky - Git hook tool
  • Lint-staged - Used for running code validation before git commits
  • cz-git - Visual commit tool

Commands ​

bash
# Check JavaScript syntax in the project
pnpm lint

# Fix JavaScript syntax errors in the project
pnpm fix

# Use Prettier to format all specified file types
pnpm lint:prettier

# Use Stylelint to check and automatically fix style issues in CSS, SCSS, and Vue files
pnpm lint:stylelint

# Run lint-staged to only check staged files, ensuring code quality before commits
pnpm lint:lint-staged

# Set up Husky Git hooks for running scripts before Git operations
pnpm prepare

# Use Commitizen to standardize commit messages, ensuring consistent commit formats
pnpm commit

Commit Standards ​

bash
feat, // New feature
fix, // Fix defects
docs, // Documentation changes
style, // Code formatting (not affecting functionality, such as spaces, semicolons, etc.)
refactor, // Code refactoring (excluding bug fixes and new features)
perf, // Performance optimization
test, // Add missing tests or modify existing tests
build, // Build process, external dependency changes (such as upgrading npm packages, modifying webpack configuration, etc.)
ci, // Modify CI configuration, scripts
revert, // Revert commit
chore, // Changes to build process or auxiliary tools and libraries (not affecting source files, test cases)
wip // Work in progress

Committing Code ​

bash
git add .
pnpm commit

...

git push

Released under the MIT License