Skip to content

feat: pre-commit hook #7428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
npm run fix:tables
npm run test:links
npm run test:build
git update-index --again
Copy link
Contributor Author

@Lulalaby Lulalaby Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might not need to run test:build here in the pre-commit, since it generates a big chunk of text while committing, and we already run that in the CI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never remove runs from ci that are in precommit, precommit is not gauranteed in any way (if you don't run npm install for example)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i meant rather removing it from the precommit than from the ci

7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

See the [README](https://github.com/discord/discord-api-docs/blob/main/README.md) for licensing and legal information.

## Pre-requisites

To contribute to the documentation, you need to have [Node.js](https://nodejs.org/en/download/) installed on your machine.
The recommended version is the latest LTS version.
After you install it, run `npm install` to install the required dependencies.
This will setup a pre-commit hook to ensure that the changes you are commiting are formatted correctly.

## Types of Changes

### Wanted Changes
Expand Down
53 changes: 53 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"test:build": "tsx tools/checkBuild.ts",
"test:tables": "npx markdown-table-formatter \"docs/**/*.{md,mdx}\" --check",
"fix:tables": "npx markdown-table-formatter \"docs/**/*.{md,mdx}\"",
"decorate:docs": "node tools/doxygen/generate-social-sdk-mapping.js && node tools/doxygen/decorate-social-sdk-references.js"
"decorate:docs": "node tools/doxygen/generate-social-sdk-mapping.js && node tools/doxygen/decorate-social-sdk-references.js",
"prepare": "is-ci || husky"
},
"devDependencies": {
"@actions/core": "^1.10.1",
Expand All @@ -41,6 +42,8 @@
"eslint": "^9.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"husky": "9.1.7",
"is-ci": "4.1.0",
"execa": "^9.5.2",
"js-yaml": "^4.1.0",
"markdown-table-formatter": "^1.6.0",
Expand Down