← Workflows

阅读中文版本

Local Lint Setup Workflow

Configure and run a linter locally to catch code quality issues before pushing to the remote repository.

beginner~20 minlintingcode-qualityworkflow

Objective

Catch lint errors locally before they reach CI to save build time and reduce review cycles.

Environment

  • A project with a linter configured
  • Package manager to install dependencies
  • Source files to lint

Steps

1. Install linter

Install the linter and its plugins as development dependencies.

Expected state: The linter binary is available in the project.

2. Run lint

Execute the linter on the source directory and review the output.

Expected state: A list of lint warnings and errors is produced.

3. Fix issues

Address each lint error; suppress or configure rules for acceptable warnings.

Expected state: All lint errors are resolved; warnings are configured.

4. Verify clean run

Run the linter again to confirm zero errors.

Expected state: The linter exits with code 0 and no errors.

Decision points

Should warnings fail the build?

  • Yes, treat as errors
  • No, only errors fail

Start with warnings as warnings; escalate to errors once the codebase is clean.

Expected outcome

The linter passes with zero errors, and the configuration is saved for the team.

Verification

Run the linter and confirm exit code 0 with no error-level issues.

Cleanup

No cleanup needed; lint configuration should be committed.

Catch issues early

Local linting catches problems before CI, saving build minutes and review time.

npx eslint src/
npx ruff check src/

Implementation Notes

This workflow provides a structured approach to ensure consistent results across team members and environments.

Common Pitfalls

Skipping verification steps or rushing through the process can lead to incomplete results. Always follow each step in order and verify before proceeding.