Lint Staged With Husky for Pre-commit Validations

Поділитися
Вставка
  • Опубліковано 18 вер 2024

КОМЕНТАРІ • 44

  • @MonsterlessonsAcademy
    @MonsterlessonsAcademy  15 днів тому

    WATCH NEXT: Javascript Interview Questions and Answers - Dominate Your Next Interview - ua-cam.com/video/wnYKH2dO620/v-deo.htmlsi=5DfbGEfhXWiiv0a_

  • @karthikeyan878
    @karthikeyan878 2 роки тому +1

    Thank you so much for post the requested video. We want a video with Angular project.

  • @wojts7212
    @wojts7212 Рік тому +1

    amazing explanation, thanks. Very high quality content, keep going bro

  • @damagee8141
    @damagee8141 2 роки тому +6

    For anyone watching this video: Remember not to install eslint, lint-staged, husky and prettier as dependencies but as devDependencies instead.

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  2 роки тому +3

      You are totally right but only if people install later packages for prod only.

  • @feeelgoood
    @feeelgoood Рік тому

    one more good Oleksandr's lesson

  • @Issanjeewa
    @Issanjeewa Рік тому

    Great explanation, thanks 👍👍

  • @nikhilev3840
    @nikhilev3840 6 місяців тому

    Do we need them in dependency? I think we can install them as devDependancy right? The official documentation says so.

  • @playyourway2963
    @playyourway2963 Рік тому

    Thank you Sir ! clean & short ♥you earn my sub

  • @arnaldoceballos4653
    @arnaldoceballos4653 5 місяців тому

    Hello, question...in an Angular project, how can you execute the scripts defined in package.json in a git hook? For example, if you define in .lintstagedrc { "src/**/*.{ts,html}": "npm run lint" } and in package.json the script "lint": "ng lint", it does not recognize the command

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  5 місяців тому

      Unfortunately I don't help with debugging custom problems in UA-cam comments.

    • @arnaldoceballos4653
      @arnaldoceballos4653 5 місяців тому

      @@MonsterlessonsAcademy My question is if in an Angular project it is possible from lint-staged to run the scripts defined in package.json. I couldn't achieve this.

  • @techakayy
    @techakayy Рік тому

    Nice one mate! So, am I right it understanding that the pre-commit is primarily for fail-on-linting attempt (eslint) & not for formatting? Because any formatting write by prettier when git commit would be unstaged.

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  Рік тому +1

      Prettier is fine as well as a check but not as an autoformat as it will make files unstaged.

    • @techakayy
      @techakayy Рік тому

      @@MonsterlessonsAcademy Thank you!

  • @user-rm6zp3pe7y
    @user-rm6zp3pe7y 11 місяців тому

    it worked

  • @fl1pp1x
    @fl1pp1x Рік тому +1

    I have an issue - when i run "npx lint-staged" i have only one tasks call but if i do the same with pre-commit hook which calles the same "npx lint-staged" i have too many callings of tasks (50+), wdyt about this issue?, i cant imagine what is going wrong...

    • @fl1pp1x
      @fl1pp1x Рік тому

      "lint-staged": {
      "src/**/*.{js,jsx,ts,tsx,json,css,md,yml,yaml}": [
      "prettier --write"
      ],
      "src/**/*.{js,jsx,ts,tsx}": [
      "eslint --max-warnings=0"
      ]
      },

    • @fl1pp1x
      @fl1pp1x Рік тому

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

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  Рік тому

      I'm sorry I never had such issue.

  • @mdalishanali476
    @mdalishanali476 Рік тому

    thanks bro

  • @tuanvominh3219
    @tuanvominh3219 2 роки тому

    Amazing video 😄😄

  • @Nickdaplayer
    @Nickdaplayer Рік тому

    Hi, nice tutorial! Do I push the .husky-folder to the repository to ensure that other developers can use pre-commit hooks automatically? Or what is the best practice for that?

  • @booi_mangang
    @booi_mangang Рік тому

    do you still need these setups when the code automatically formatt and prettify itself when ctrl + s??

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  Рік тому

      Yes sure. You ctrl + s just calls prettier

    • @booi_mangang
      @booi_mangang Рік тому

      @@MonsterlessonsAcademy So, I don’t need to set all these up, right?

  • @jeffnikelson5824
    @jeffnikelson5824 2 роки тому

    jetbrains IDEs have that in pre commit settings integrated already, don't they?

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  2 роки тому +1

      Maybe but the idea is to install pre commit hooks automatically on the machine of every developer and not be dependent on IDE.

    • @jeffnikelson5824
      @jeffnikelson5824 2 роки тому

      @@MonsterlessonsAcademy Oh yes right, now i get your point!

  • @MominKhan-sm3gh
    @MominKhan-sm3gh 9 місяців тому +1

    Hey! Can you help me with the error given below when I run npx lint-staged.
    Error: > Couldn't find any `pages` or `app` directory. Please create one under the project root
    at findPagesDir (C:\Users\momin.hayat\Desktop\ops-2-next
    ode_modules
    ext\dist\lib\find-pages-dir.js:42:15)
    "lint-staged": {
    "src/**/*.{js,html,css}": "prettier --write",
    "src/**/*.{ts,tsx}": "next lint"
    }
    and my folder structure is following
    src/app/*

  • @g-luu
    @g-luu 2 роки тому

    Nice tutorial would have been nice if it was angular specific.

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  2 роки тому +1

      My next video will be exactly about Typescript and Eslint

    • @g-luu
      @g-luu 2 роки тому

      @Miguel A Thanks will check it out.