Skip to content

Add husky pre-commit hooks for linting and formatting #7228

@afarber

Description

@afarber

Summary

Following the Cucumber-js v12 upgrade in #7221, add automated pre-commit hooks to ensure code
quality and consistency.

Proposed Changes

  • Install husky and lint-staged as dev dependencies
  • Add pre-commit hook that runs npm run lint on staged files
  • Consider adding automatic formatting with prettier (we already have .prettierrc)
  • Add pre-commit hook to run tests on relevant changed files

Benefits

  • Prevents committing code that doesn't pass linting
  • Reduces CI failures due to style issues
  • Maintains consistent code formatting across contributors

Implementation

 npm install --save-dev husky lint-staged
 npx husky init

 Add to package.json:
 "lint-staged": {
   "features/**/*.js": ["eslint --fix", "git add"],
   "test/**/*.cjs": ["eslint --fix", "git add"]
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions