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

Create a tutorial to use Standard together with Husky #1938

Open
FlashAmarillo opened this issue Sep 18, 2023 · 0 comments
Open

Create a tutorial to use Standard together with Husky #1938

FlashAmarillo opened this issue Sep 18, 2023 · 0 comments

Comments

@FlashAmarillo
Copy link

What version of this package are you using?

"standard": "17.1.0",

What problem do you want to solve?

I would like to discuss the possibility of developing a tutorial within the official documentation of standard on how to build a basic configuration for pre-commits using husky with the intention of being able to format the documents before committing and if standard finds errors or inconsistencies in the files do not let commit, configure standard to work together with Husky is complicated and I could not find official documentation of any of the libraries so they can work together correctly, and for developers who do not have much experience playing bash code can be complicated.

What do you think is the correct solution to this problem?

In my current project configuration I have a configuration with the "lint-staged" library and I have modified my package.json file as follows:

{
  "author": {
author....
  },
  "dependencies": {
all dependencies
  },
  "devDependencies": {
 ... all dev dependencies
    "husky": "^8.0.3",
    "lint-staged": "^14.0.1",
    "standard":"^17.1.0",

  },
  "eslintConfig": {
    "extends": "./node_modules/standard/eslintrc.json".
  },
  "license": "MIT",
  "lint-staged": {
    "*.js": [
      "standard --fix",
      "git add"
    ]
  },
  "name": "deviceinv",
  "scripts": {
all scripts...
  },
  "version": "1.0.0"
}

and my pre-commit file would look like this:

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged

and so far I have had the following result on my terminal:

➜ git commit -m "configuracion de husky con standarjs ya completada, se agregan algunos archivos evaluados con el lintern"
⚠ Some of your tasks use `git add` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.


[STARTED] Preparing lint-staged...
[COMPLETED] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] package.json — 16 files
[STARTED] *.js — 10 files
[STARTED] standard --fix
[COMPLETED] standard --fix
[STARTED] git add
[COMPLETED] git add
[COMPLETED] *.js — 10 files
[COMPLETED] package.json — 16 files
[COMPLETED] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
[COMPLETED] Applying modifications from tasks...
[STARTED] Cleaning up temporary files...
[COMPLETED] Cleaning up temporary files...
[@dev/sites 04986f6] configuracion de husky con standarjs ya completada, se agregan algunos archivos evaluados con el lintern
 16 files changed, 1543 insertions(+), 596 deletions(-)
 rewrite src/helpers/index.js (72%)
 rewrite src/pages/InternalNavigationPage.jsx (90%)
 rewrite src/pages/NoMatch.jsx (89%)
 rewrite tests/components/FormBasicInfo.test.js (85%)
 rewrite tests/helpers/index.test.js (98%)

so far in my current project it works correctly, but I must use the "lint-staged" dependency to facilitate the integration of standard with husky, maybe there is a better solution, but it would be very helpful to incorporate a tutorial that explains a correct way to use standard with husky.

Are you willing to submit a pull request to implement this change?

not currently but I would like to know more about how I could participate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants
@FlashAmarillo and others