Skip to content
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

chore(husky): configure pre-commit hooks for code linting and formatting #44

Open
wants to merge 3 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/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,35 @@ npm run dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

## Contribution Guidelines

Contribute using `husky` and `lint-staged` for quality commits. Ensure code passes linting (`eslint`, `stylelint`) and tests before committing.

### Husky Setup

To ensure the proper functioning of code commit hooks (like pre-commit), team members should execute the following command after pulling the latest code containing Husky's configuration:

```bash
npx husky install
```

### Commit Message Standards

Use `commitlint` for standardized messages. Format: `<type>(<scope>): <summary>`. Types: feat, fix, docs, style, refactor, test, chore.

### Submitting Changes

1. Make changes in your local branch.
2. `git add` for staging.
3. `git commit -m '<message>'` (follow standards).
4. `git push` for pushing changes.

### Standard Pull Request Process

1. **Fork the Repository**: Start by forking the repository to your GitHub account.
2. **Create a New Branch**: Create a new branch for your changes. Name it appropriately.
3. **Implement Your Changes**: Make your changes in your branch and commit them.
4. **Pull Request**: Go to the original repository and click on "Pull Request". Select your branch and describe the changes you've made.
5. **Review Process**: Wait for the maintainers to review your PR. Be responsive to any comments or requests for changes.
6. **Merging**: Once your PR is approved, it will be merged into the main branch.
8 changes: 8 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @ts-check

/** @type {import('@commitlint/types').UserConfig} */
const config = {
extends: ['@commitlint/config-conventional'],
};

module.exports = config;
13 changes: 13 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @ts-check

import path from 'node:path'

/** @type {import('lint-staged').Config} */
const config = {
'**/*.(ts|tsx|js|jsx|mjs|cjs)': (filenames) =>
`next lint --fix --file ${filenames.map((f) => path.relative(process.cwd(), f)).join(' --file ')}`,

'**/*.(md|json|html|yml|yaml)': (filenames) => `prettier --write ${filenames.join(' ')}`,
}

export default config
16 changes: 14 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
const isProduction = process.env.NODE_ENV === 'production'

/** @type {import('next').NextConfig} */
const nextConfig = {}
const nextConfig = {
reactStrictMode: false,
trailingSlash: true,
compiler: {
removeConsole: isProduction
? {
exclude: ['error', 'warn'],
}
: false,
},
}

module.exports = nextConfig
export default nextConfig
Loading
Loading