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"]
}
Summary
Following the Cucumber-js v12 upgrade in #7221, add automated pre-commit hooks to ensure code
quality and consistency.
Proposed Changes
npm run linton staged filesBenefits
Implementation