Skip to content

Add husky and configure lint-staged #1861

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

Merged
merged 9 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 3 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Build documentation

env:
HUSKY: 0

on:
push:
branches:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/meilisearch-prototype-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Testing the code base against a specific Meilisearch feature
name: Meilisearch prototype tests

env:
HUSKY: 0

# Will only run for PRs and pushes to *-beta
on:
pull_request:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pre-release-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Testing the code base against the Meilisearch pre-releases
name: Pre-Release Tests

env:
HUSKY: 0

# Will only run for PRs and pushes to bump-meilisearch-v*
on:
pull_request:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
release:
types: [published]

env:
HUSKY: 0

jobs:
publish-npm:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Tests

env:
HUSKY: 0

on:
pull_request:
push:
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint-staged
5 changes: 2 additions & 3 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// https://prettier.io/docs/en/options.html

/** @see {@link https://prettier.io/docs/en/options.html} */
export default {
plugins: ["./node_modules/prettier-plugin-jsdoc/dist/index.js"],
// https://github.com/hosseinmd/prettier-plugin-jsdoc#tsdoc
/** {@link https://github.com/hosseinmd/prettier-plugin-jsdoc#tsdoc} */
tsdoc: true,
};
21 changes: 13 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ First of all, thank you for contributing to Meilisearch! The goal of this docume
- [How to Contribute](#how-to-contribute)
- [Development Workflow](#development-workflow)
- [Git Guidelines](#git-guidelines)
- [Release Process (for internal team only)](#release-process-for-internal-team-only)
- [Release Process (for internal team only)](#release-process-for-the-internal-team-only)

<!-- /MarkdownTOC -->

Expand Down Expand Up @@ -42,6 +42,7 @@ To run this project, you will need:
You can set up your local environment natively or using `docker`, check out the [`docker-compose.yml`](/docker-compose.yml).

Example of running all the checks with docker:

```bash
docker-compose run --rm package bash -c "yarn install && yarn test && yarn lint"
```
Expand Down Expand Up @@ -79,6 +80,7 @@ We do not enforce any branch naming style, but please use something descriptive
### Git Commits

As minimal requirements, your commit message should:

- be capitalized
- not finish by a dot or any other punctuation character (!,?)
- start with a verb so that we can read your commit message this way: "This commit will ...", where "..." is the commit message.
Expand Down Expand Up @@ -119,11 +121,13 @@ _[Read more about this](https://github.com/meilisearch/integration-guides/blob/m
Make a PR modifying the following files with the right version:

[`package.json`](/package.json):

```javascript
"version": "X.X.X",
```

[`src/package-version`](/src/package-version.ts)

```javascript
export const PACKAGE_VERSION = 'X.X.X'
```
Expand All @@ -137,6 +141,7 @@ GitHub Actions will be triggered and push the package to [npm](https://www.npmjs
#### Release a `beta` Version

This package is able to create multiple types of betas:

- A standard package beta, working on the latest version of Meilisearch.
- A beta implementing the changes of a rc version of Meilisearch.
- A beta implementing a specific feature `prototype` of Meilisearch.
Expand All @@ -159,16 +164,16 @@ Here are the steps to release a beta version of this package depending on its ty

3. Commit and push your code to the newly created branch (step 1).


4. Go to the [GitHub interface for releasing](https://github.com/meilisearch/meilisearch-js/releases): on this page, click on `Draft a new release`.

5. Create a GitHub pre-release:
- Fill the description with the detailed changelogs
- Fill the title with `vX.X.X-beta.0`
- Fill the tag with `vX.X.X-beta.0`
- ⚠️ Select the `vX.X.X-beta.0` branch and NOT `main`
- ⚠️ Click on the "This is a pre-release" checkbox
- Click on "Publish release"

- Fill the description with the detailed changelogs
- Fill the title with `vX.X.X-beta.0`
- Fill the tag with `vX.X.X-beta.0`
- ⚠️ Select the `vX.X.X-beta.0` branch and NOT `main`
- ⚠️ Click on the "This is a pre-release" checkbox
- Click on "Publish release"

<hr>

Expand Down
6 changes: 6 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import("lint-staged").Configuration}
* @see {@link https://github.com/lint-staged/lint-staged?tab=readme-ov-file#configuration}
* @see {@link https://github.com/lint-staged/lint-staged?tab=readme-ov-file#using-js-configuration-files}
*/
export default { "*.{js,ts}": ["prettier -w", "eslint"] };
26 changes: 9 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,41 +60,33 @@
"lint": "eslint",
"lint:fix": "eslint --fix",
"style": "yarn fmt && yarn lint",
"style:fix": "yarn fmt:fix && yarn lint:fix"
"style:fix": "yarn fmt:fix && yarn lint:fix",
"prepare": "husky"
},
"files": [
"src",
"dist",
"CONTRIBUTING.md"
],
"lint-staged": {
"**/*.{ts,tsx,js,jsx,css,scss,sass,less,md}": [
"prettier --write",
"git add"
],
"src/**/*.{ts,tsx}": [
"yarn lint:fix",
"git add"
]
},
"devDependencies": {
"@eslint/js": "^9.19.0",
"@types/eslint__js": "^8.42.3",
"@vitest/coverage-v8": "2.0.5",
"@types/node": "^22.13.0",
"eslint": "^9.19.0",
"eslint-plugin-tsdoc": "^0.4.0",
"@typescript-eslint/utils": "^8.19.0",
"@vitest/coverage-v8": "2.0.5",
"@vitest/eslint-plugin": "^1.1.25",
"eslint": "^9.19.0",
"eslint-config-prettier": "^10.0.1",
"typescript": "^5.7.3",
"vite": "^6.0.9",
"@typescript-eslint/utils": "^8.22.0",
"eslint-plugin-tsdoc": "^0.4.0",
"globals": "^15.14.0",
"husky": "^9.1.7",
"lint-staged": "15.4.3",
"prettier": "^3.4.2",
"prettier-plugin-jsdoc": "^1.3.2",
"typedoc": "^0.27.6",
"typescript": "^5.7.3",
"typescript-eslint": "^8.22.0",
"vite": "^6.0.9",
"vitest": "2.0.5"
},
"packageManager": "[email protected]"
Expand Down
57 changes: 56 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,14 @@
"@typescript-eslint/types" "8.22.0"
"@typescript-eslint/visitor-keys" "8.22.0"

"@typescript-eslint/[email protected]":
version "8.23.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.23.0.tgz#ee3bb7546421ca924b9b7a8b62a77d388193ddec"
integrity sha512-OGqo7+dXHqI7Hfm+WqkZjKjsiRtFUQHPdGMXzk5mYXhJUedO7e/Y7i8AK3MyLMgZR93TX4bIzYrfyVjLC+0VSw==
dependencies:
"@typescript-eslint/types" "8.23.0"
"@typescript-eslint/visitor-keys" "8.23.0"

"@typescript-eslint/[email protected]":
version "8.22.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.22.0.tgz#cd9f23c23f021357ef0baa3490d4d96edcc97509"
Expand All @@ -726,6 +734,11 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.22.0.tgz#d9dec7116479ad03aeb6c8ac9c5223c4c79cf360"
integrity sha512-0S4M4baNzp612zwpD4YOieP3VowOARgK2EkN/GBn95hpyF8E2fbMT55sRHWBq+Huaqk3b3XK+rxxlM8sPgGM6A==

"@typescript-eslint/[email protected]":
version "8.23.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.23.0.tgz#3355f6bcc5ebab77ef6dcbbd1113ec0a683a234a"
integrity sha512-1sK4ILJbCmZOTt9k4vkoulT6/y5CHJ1qUYxqpF1K/DBAd8+ZUL4LlSCxOssuH5m4rUaaN0uS0HlVPvd45zjduQ==

"@typescript-eslint/[email protected]":
version "8.22.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.22.0.tgz#c188c3e19529d5b3145577c0bd967e2683b114df"
Expand All @@ -740,7 +753,21 @@
semver "^7.6.0"
ts-api-utils "^2.0.0"

"@typescript-eslint/[email protected]", "@typescript-eslint/utils@^8.22.0":
"@typescript-eslint/[email protected]":
version "8.23.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.23.0.tgz#f633ef08efa656e386bc44b045ffcf9537cc6924"
integrity sha512-LcqzfipsB8RTvH8FX24W4UUFk1bl+0yTOf9ZA08XngFwMg4Kj8A+9hwz8Cr/ZS4KwHrmo9PJiLZkOt49vPnuvQ==
dependencies:
"@typescript-eslint/types" "8.23.0"
"@typescript-eslint/visitor-keys" "8.23.0"
debug "^4.3.4"
fast-glob "^3.3.2"
is-glob "^4.0.3"
minimatch "^9.0.4"
semver "^7.6.0"
ts-api-utils "^2.0.1"

"@typescript-eslint/[email protected]":
version "8.22.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.22.0.tgz#c8cc4e52a9c711af8a741a82dc5d7242b7a8dd44"
integrity sha512-T8oc1MbF8L+Bk2msAvCUzjxVB2Z2f+vXYfcucE2wOmYs7ZUwco5Ep0fYZw8quNwOiw9K8GYVL+Kgc2pETNTLOg==
Expand All @@ -750,6 +777,16 @@
"@typescript-eslint/types" "8.22.0"
"@typescript-eslint/typescript-estree" "8.22.0"

"@typescript-eslint/utils@^8.19.0":
version "8.23.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.23.0.tgz#b269cbdc77129fd6e0e600b168b5ef740a625554"
integrity sha512-uB/+PSo6Exu02b5ZEiVtmY6RVYO7YU5xqgzTIVZwTHvvK3HsL8tZZHFaTLFtRG3CsV4A5mhOv+NZx5BlhXPyIA==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
"@typescript-eslint/scope-manager" "8.23.0"
"@typescript-eslint/types" "8.23.0"
"@typescript-eslint/typescript-estree" "8.23.0"

"@typescript-eslint/[email protected]":
version "8.22.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.22.0.tgz#02cc005014c372033eb9171e2275b76cba722a3f"
Expand All @@ -758,6 +795,14 @@
"@typescript-eslint/types" "8.22.0"
eslint-visitor-keys "^4.2.0"

"@typescript-eslint/[email protected]":
version "8.23.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.23.0.tgz#40405fd26a61d23f5f4c2ed0f016a47074781df8"
integrity sha512-oWWhcWDLwDfu++BGTZcmXWqpwtkwb5o7fxUIGksMQQDSdPW9prsSnfIOZMlsj4vBOSrcnjIUZMiIjODgGosFhQ==
dependencies:
"@typescript-eslint/types" "8.23.0"
eslint-visitor-keys "^4.2.0"

"@vitest/[email protected]":
version "2.0.5"
resolved "https://registry.yarnpkg.com/@vitest/coverage-v8/-/coverage-v8-2.0.5.tgz#411961ce4fd1177a32b4dd74ab576ed3b859155e"
Expand Down Expand Up @@ -1477,6 +1522,11 @@ human-signals@^5.0.0:
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-5.0.0.tgz#42665a284f9ae0dade3ba41ebc37eb4b852f3a28"
integrity sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==

husky@^9.1.7:
version "9.1.7"
resolved "https://registry.yarnpkg.com/husky/-/husky-9.1.7.tgz#d46a38035d101b46a70456a850ff4201344c0b2d"
integrity sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==

ignore@^5.2.0, ignore@^5.3.1:
version "5.3.2"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.2.tgz#3cd40e729f3643fd87cb04e50bf0eb722bc596f5"
Expand Down Expand Up @@ -2479,6 +2529,11 @@ ts-api-utils@^2.0.0:
resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-2.0.0.tgz#b9d7d5f7ec9f736f4d0f09758b8607979044a900"
integrity sha512-xCt/TOAc+EOHS1XPnijD3/yzpH6qg2xppZO1YDqGoVsNXfQfzHpOdNuXwrwOU8u4ITXJyDCTyt8w5g1sZv9ynQ==

ts-api-utils@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-2.0.1.tgz#660729385b625b939aaa58054f45c058f33f10cd"
integrity sha512-dnlgjFSVetynI8nzgJ+qF62efpglpWRk8isUEWZGWlJYySCTD6aKvbUDu+zbPeDakk3bg5H4XpitHukgfL1m9w==

type-check@^0.4.0, type-check@~0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"
Expand Down
Loading