feat(husky): run fix-redirects command in precommit #33485
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
crypto
#33291 (comment)Issue
Sometimes we have to manually edit the redirects file which may introduce errors. Command
yarn content validate-redirects en-us --strict
is run in GitHub PR checks. We have to wait for GitHub workflow to know about the error. Also, yari errors messages are not intuitive:From the log message above it is not clear that this is a sorting issue. The issue is auto fixable and one shouldn't be bothered to fix it manually.
Solution
It would be good if we auto fix fixable errors in husky pre-commit hook itself by running
⚠️ Note: The script suggested in this PR runs only when
yarn content fix-redirects en-US
and do redirects check as well._redirects.txt
is modified and it doesn't run on all commits.In case of
.lintstagedrc.json
, all modified file paths are appended to the commands, this is not desirable for thefix-redirects
command. It throws invalid locale error. In order to avoid appending file paths to commands.lintstagedrc.js
file has been introduced to the repo.