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

431-fix: Correct behavior of husky precommit #432

Merged
merged 4 commits into from
Jul 31, 2024

Conversation

thirdmadman
Copy link
Collaborator

@thirdmadman thirdmadman commented Jul 26, 2024

What type of PR is this? (select all that apply)

  • πŸ• Feature
  • πŸ› Bug Fix
  • 🚧 Breaking Change
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ“ Documentation Update

Description

Correct behavior of husky precommit, now it runs npx lint-staged and changes files before making the commit itself.

Related Tickets & Documents

Screenshots, Recordings

precommit-error-fix

Added/updated tests?

  • πŸ‘Œ Yes
  • πŸ™…β€β™‚οΈ No, because they aren't needed
  • πŸ™‹β€β™‚οΈ No, because I need help

[optional] Are there any post deployment tasks we need to perform?

no

[optional] What gif best describes this PR or how it makes you feel?

Summary by CodeRabbit

  • New Features

    • Introduced a pre-commit hook to run linting checks before commits.
  • Changes

    • Simplified the pre-commit script to focus solely on linting.
    • Updated the prepare-commit-msg script to run the build process instead of combined tasks.

@thirdmadman thirdmadman self-assigned this Jul 26, 2024
@github-actions github-actions bot changed the title fix: 431 - correct behavior of husky precommit 431-fix: Correct behavior of husky precommit Jul 26, 2024
Copy link

github-actions bot commented Jul 26, 2024

Qodana for JS

It seems all right πŸ‘Œ

No new problems were found according to the checks applied

πŸ’‘ Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Detected 82 dependencies

Third-party software list

This page lists the third-party software dependencies used in project

Dependency Version Licenses
@next/env 14.2.4 MIT
@next/swc-linux-x64-gnu 14.2.4 MIT
@next/swc-linux-x64-musl 14.2.4 MIT
@playwright/test 1.45.1 Apache-2.0
@remix-run/router 1.17.1 MIT
@swc/counter 0.1.3 Apache-2.0
@swc/helpers 0.5.5 Apache-2.0
anymatch 3.1.3 ISC
binary-extensions 2.3.0 MIT
braces 3.0.3 MIT
brcast 3.0.2 MIT
busboy 1.6.0 MIT
caniuse-lite 1.0.30001640 CC-BY-4.0
chokidar 3.6.0 MIT
class-variance-authority 0.7.0 Apache-2.0
classnames 2.5.1 MIT
client-only 0.0.1 MIT
clsx 2.0.0 MIT
css-vendor 0.3.8 MIT
dayjs 1.11.11 MIT
fill-range 7.1.1 MIT
glob-parent 5.1.2 ISC
graceful-fs 4.2.11 ISC
hoist-non-react-statics 2.5.5 BSD-3-Clause
hyphenate-style-name 1.1.0 BSD-3-Clause
immutable 4.3.6 MIT
is-binary-path 2.1.0 MIT
is-function 1.0.2 MIT
is-glob 4.0.3 MIT
is-in-browser 1.1.3 MIT
is-number 7.0.0 MIT
is-plain-object 2.0.4 MIT
isobject 3.0.1 MIT
js-tokens 4.0.0 MIT
jss-camel-case 6.1.0 MIT
jss-compose 5.0.0 MIT
jss-default-unit 8.0.2 MIT
jss-expand 5.3.0 MIT
jss-extend 6.2.0 MIT
jss-global 3.0.0 MIT
jss-nested 6.0.1 MIT
jss-preset-default 4.5.0 MIT
jss-props-sort 6.0.0 MIT
jss-template 1.0.1 MIT
jss-vendor-prefixer 7.0.0 MIT
jss 9.8.7 MIT
loose-envify 1.4.0 MIT
nanoid 3.3.7 MIT
next 14.2.4 MIT
nextjs-toploader 1.6.12 MIT
normalize-path 3.0.0 MIT
nprogress 0.2.0 MIT
object-assign 4.1.1 MIT
picocolors 1.0.1 ISC
picomatch 2.3.1 MIT
playwright-core 1.45.1 Apache-2.0
playwright 1.45.1 Apache-2.0
postcss 8.4.31 MIT
prop-types 15.8.1 MIT
react-dom 16.14.0 MIT
react-dom 18.3.1 MIT
react-double-marquee 1.1.0 MIT
react-easy-swipe 0.0.21 MIT
react-is 16.13.1 MIT
react-json-pretty 2.2.0 MIT
react-jss 8.6.1 MIT
react-responsive-carousel 3.2.23 MIT
react-router-dom 6.24.1 MIT
react-router 6.24.1 MIT
react 16.14.0 MIT
react 18.3.1 MIT
readdirp 3.6.0 MIT
sass 1.77.6 MIT
scheduler 0.19.1 MIT
scheduler 0.23.2 MIT
source-map-js 1.2.0 BSD-3-Clause
streamsearch 1.1.0 MIT
styled-jsx 5.1.1 MIT
theming 1.3.0 MIT
to-regex-range 5.0.1 MIT
tslib 2.6.3 0BSD
warning 3.0.0 BSD-3-Clause
Contact Qodana team

Contact us at [email protected]

package.json Outdated Show resolved Hide resolved
Copy link

Lighthouse Report:

  • Performance: 84 / 100
  • Accessibility: 91 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

.husky/prepare-commit-msg Outdated Show resolved Hide resolved
.husky/pre-commit Outdated Show resolved Hide resolved
Copy link

Lighthouse Report:

  • Performance: 88 / 100
  • Accessibility: 91 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@thirdmadman thirdmadman requested review from ansivgit and Wystov July 29, 2024 13:29
@thirdmadman thirdmadman marked this pull request as ready for review July 29, 2024 17:57
Copy link
Contributor

coderabbitai bot commented Jul 29, 2024

Walkthrough

Walkthrough

The changes introduce a clearer workflow for pre-commit tasks within a project using Husky. A pre-commit hook is added to ensure that linting is executed before commits, while the previous automatic build step is removed. This adjustment aims to prevent style issues from being committed by ensuring that all code is appropriately linted prior to finalizing any commits, enhancing overall code quality.

Changes

Files Change Summary
.husky/pre-commit New pre-commit hook added to run npm run precommit for linting before commits.
.husky/prepare-commit-msg Modified script to only run npm run build, removing prior linting interactions.
package.json Updated precommit script to only execute npx lint-staged, removing concurrent build process.

Assessment against linked issues

Objective Addressed Explanation
Correct behavior of husky precommit (#431) βœ…
Ensure all files are linted and fixed before commit (#431) ❌ The removal of the build step may allow unbuilt code.

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e883696 and 5d60be5.

Files selected for processing (3)
  • .husky/pre-commit (1 hunks)
  • .husky/prepare-commit-msg (1 hunks)
  • package.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • .husky/pre-commit
Additional comments not posted (2)
.husky/prepare-commit-msg (1)

44-44: Ensure build step is necessary here.

Running npm run build in the commit message preparation script might lead to longer commit times. Verify if this is the intended behavior and if it aligns with the development workflow.

package.json (1)

20-20: LGTM! Simplified precommit script.

The change to the precommit script ensures that only linting is performed before committing, which aligns with the PR objectives.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
.husky/prepare-commit-msg (1)

41-41: Remove redundant echo statement.

The echo statement on line 41 is redundant and can be removed to clean up the script.

-  echo "-"

@thirdmadman thirdmadman requested review from SpaNb4 and natanchik July 29, 2024 18:10
Copy link
Member

@Quiddlee Quiddlee left a comment

Choose a reason for hiding this comment

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

We can delete the concurrently dependency

npm uninstall concurrently

@ansivgit ansivgit merged commit e6b7565 into main Jul 31, 2024
6 checks passed
@ansivgit ansivgit deleted the fix/431-correct-behavior-of-husky-precommit branch July 31, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Correct behavior of husky precommit
6 participants