<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ALI RAZA</title>
    <description>The latest articles on DEV Community by ALI RAZA (@ali-raza-fa22).</description>
    <link>https://dev.to/ali-raza-fa22</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2969454%2F36f095cf-2952-4ccf-b927-038ee15586d8.png</url>
      <title>DEV Community: ALI RAZA</title>
      <link>https://dev.to/ali-raza-fa22</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ali-raza-fa22"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>ALI RAZA</dc:creator>
      <pubDate>Mon, 05 Jan 2026 02:25:13 +0000</pubDate>
      <link>https://dev.to/ali-raza-fa22/-2a4h</link>
      <guid>https://dev.to/ali-raza-fa22/-2a4h</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/ali-raza-fa22" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2969454%2F36f095cf-2952-4ccf-b927-038ee15586d8.png" alt="ali-raza-fa22"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/ali-raza-fa22/setting-up-husky-and-lint-staged-for-nextjs-38ji" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Setting up husky and lint-staged for Next.js&lt;/h2&gt;
      &lt;h3&gt;ALI RAZA ・ Sep 3 '25&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#nextjs&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#typescript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>nextjs</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Setting up husky and lint-staged for Next.js</title>
      <dc:creator>ALI RAZA</dc:creator>
      <pubDate>Wed, 03 Sep 2025 08:09:13 +0000</pubDate>
      <link>https://dev.to/ali-raza-fa22/setting-up-husky-and-lint-staged-for-nextjs-38ji</link>
      <guid>https://dev.to/ali-raza-fa22/setting-up-husky-and-lint-staged-for-nextjs-38ji</guid>
      <description>&lt;h2&gt;
  
  
  Setting up pre-commit hook:
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;I am assuming you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;have already created Next.js app.&lt;/li&gt;
&lt;li&gt;know git&lt;/li&gt;
&lt;li&gt;using pnpm and Windows. &lt;/li&gt;
&lt;li&gt;know what is husky lint-staged eslint prettier&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://typicode.github.io/husky/get-started.html" rel="noopener noreferrer"&gt;Husky&lt;/a&gt; is a popular Git hook tool that helps developers enforce and automate certain actions and scripts before committing or pushing code to a Git repository, like linting code, running tests, formatting code, or performing other custom action.&lt;br&gt;
&lt;a href="//github.com/lint-staged/lint-staged"&gt;lint-staged&lt;/a&gt; makes quality checks run faster by only checking files you're about to commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm add &lt;span class="nt"&gt;--save-dev&lt;/span&gt; husky prettier lint-staged eslint

pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;husky init
&lt;span class="c"&gt;# or with npm: npx husky init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Ensure &lt;code&gt;package.json&lt;/code&gt; has the &lt;code&gt;prepare&lt;/code&gt; script so Husky is installed after &lt;code&gt;pnpm install&lt;/code&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"prepare"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"husky"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now init husky:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;husky init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and edit &lt;code&gt;.husky/pre-commit&lt;/code&gt; and add &lt;code&gt;pnpm exec lint-staged&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Edit &lt;code&gt;package.json&lt;/code&gt; and add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"lint-staged"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"*.{js,jsx,ts,tsx}"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"eslint --max-warnings=0 --fix"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"prettier --write"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"*.{json,md,css,scss,html,yml,yaml}"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"prettier --write"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration tells lint-staged to run ESLint with automatic fixing followed by Prettier formatting on JavaScript files, and only Prettier on JSON, CSS, and Markdown files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing pre-commit hook:
&lt;/h2&gt;

&lt;p&gt;Edit any file and add following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;This is an error variable &lt;code&gt;a&lt;/code&gt; is not used.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Test commit"&lt;/span&gt; &lt;span class="c"&gt;# this will fail.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;✔ Backed up original state &lt;span class="k"&gt;in &lt;/span&gt;git stash &lt;span class="o"&gt;(&lt;/span&gt;93148b8&lt;span class="o"&gt;)&lt;/span&gt;
✔ Hiding unstaged changes to partially staged files...
⚠ Running tasks &lt;span class="k"&gt;for &lt;/span&gt;staged files...
  ❯ package.json — 5 files
    ❯ &lt;span class="k"&gt;*&lt;/span&gt;.&lt;span class="o"&gt;{&lt;/span&gt;js,jsx,ts,tsx&lt;span class="o"&gt;}&lt;/span&gt; — 1 file
      ✖ eslint &lt;span class="nt"&gt;--max-warnings&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0 &lt;span class="nt"&gt;--fix&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;FAILED]
      ◼ prettier &lt;span class="nt"&gt;--write&lt;/span&gt;
    ✔ &lt;span class="k"&gt;*&lt;/span&gt;.&lt;span class="o"&gt;{&lt;/span&gt;json,md,css,scss,html,yml,yaml&lt;span class="o"&gt;}&lt;/span&gt; — 3 files
↓ Skipped because of errors from tasks.
↓ Skipped because of errors from tasks.
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...

✖ eslint &lt;span class="nt"&gt;--max-warnings&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0 &lt;span class="nt"&gt;--fix&lt;/span&gt;:

&lt;span class="o"&gt;[&lt;/span&gt;...]&lt;span class="se"&gt;\a&lt;/span&gt;pp&lt;span class="se"&gt;\p&lt;/span&gt;age.tsx
  3:3  warning  &lt;span class="s1"&gt;'a'&lt;/span&gt; is assigned a value but never used  @typescript-eslint/no-unused-vars

✖ 1 problem &lt;span class="o"&gt;(&lt;/span&gt;0 errors, 1 warning&lt;span class="o"&gt;)&lt;/span&gt;

ESLint found too many warnings &lt;span class="o"&gt;(&lt;/span&gt;maximum: 0&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
husky - pre-commit script failed &lt;span class="o"&gt;(&lt;/span&gt;code 1&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Debugging lint-staged issues
&lt;/h2&gt;

&lt;p&gt;When lint-staged doesn't behave as expected, you can debug it by running it with verbose output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm dlx lint-staged &lt;span class="nt"&gt;--verbose&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also test your configuration without making a commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm dlx lint-staged &lt;span class="nt"&gt;--debug&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;CI/CD should also run &lt;code&gt;pnpm run lint&lt;/code&gt; and &lt;code&gt;pnpm run format&lt;/code&gt; (or &lt;code&gt;format:write&lt;/code&gt;) to enforce consistency.&lt;/li&gt;
&lt;li&gt;Keep local Node/pnpm versions in sync across the team to avoid formatter diffs.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Written on 9/3/25&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>nextjs</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
