Last active
July 3, 2025 09:49
-
-
Save dilipsuthar97/d2567a3fd912ca6a48aa533f19d30ebe to your computer and use it in GitHub Desktop.
Revisions
-
dilipsuthar97 revised this gist
Jul 3, 2025 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,6 +66,21 @@ npx lint-staged } ``` ### If you want to include warnings also if no error max-warnings=0 means it'll not pass until warning will become zero ```json { ... "lint-staged": { "src/**/*.{js,ts,tsx}": [ "prettier --write", "eslint --max-warnings=0" ] } ... } ``` ### If you want to show errors on staged file's changed lines only | [eslint-plugin-diff](https://www.npmjs.com/package/eslint-plugin-diff) ``` yarn add -D eslint-plugin-diff -
dilipsuthar97 revised this gist
Jun 27, 2025 . No changes.There are no files selected for viewing
-
dilipsuthar97 revised this gist
Jun 27, 2025 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,7 +46,7 @@ The config that you've selected requires the following dependencies: npx husky init ``` #### Update `pre-commit` file at `/.husky/pre-commit` ``` npx lint-staged ``` @@ -66,19 +66,20 @@ npx lint-staged } ``` ### If you want to show errors on staged file's changed lines only | [eslint-plugin-diff](https://www.npmjs.com/package/eslint-plugin-diff) ``` yarn add -D eslint-plugin-diff ``` Update .eslintrc.js ```js module.exports = { extends: ['plugin:diff/diff', 'your-other-configs'], }; ``` ## Troubleshoot #### Warning: React version not specified in eslint-plugin-react settings. [Click here](https://github.com/jsx-eslint/eslint-plugin-react#configuration) - Update .eslintrc.js file ```json -
dilipsuthar97 revised this gist
Jun 27, 2025 . 1 changed file with 17 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ The config that you've selected requires the following dependencies: ``` ### Update package.json file ```json { ... "lint-staged": { @@ -51,9 +51,9 @@ npx husky init npx lint-staged ``` ## Config Change ### If you want to avoid warnings | [Click here for more](https://eslint.org/docs/latest/use/command-line-interface) ```json { ... "lint-staged": { @@ -66,11 +66,22 @@ npx lint-staged } ``` ### If you want to show errors on staged file's changed lines ``` yarn add -D eslint-plugin-diff ``` ```js module.exports = { extends: ['plugin:diff/diff', 'your-other-configs'], }; ``` ## Troubleshoot #### Warning: React version not specified in eslint-plugin-react settings. See https://github.com/jsx-eslint/eslint-plugin-react#configuration . - Update .eslintrc.js file ```json ... "settings": { "react": { -
dilipsuthar97 revised this gist
Jun 27, 2025 . 1 changed file with 16 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ # Husky in React native ## prettier + eslint + lint-staged + eslint-plugin-diff Husky lets us run commands or script before committing or pushing our code to git. It works as a pre runner before commiting anything. @@ -51,6 +51,21 @@ npx husky init npx lint-staged ``` ### Config Change #### If you want to avoid warnings | [Click here for more](https://eslint.org/docs/latest/use/command-line-interface) ``` { ... "lint-staged": { "src/**/*.{js,ts,tsx}": [ "prettier --write", "eslint --quiet" ] } ... } ``` ### Troubleshoot #### Warning: React version not specified in eslint-plugin-react settings. See https://github.com/jsx-eslint/eslint-plugin-react#configuration . -
dilipsuthar97 revised this gist
Jun 25, 2025 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ yarn add -D husky prettier eslint lint-staged ``` ### Configure eslint file (IF not configured) ``` npm init @eslint/config @@ -44,14 +44,10 @@ The config that you've selected requires the following dependencies: ### Configure husky ``` npx husky init ``` #### pre-commit file ``` npx lint-staged ``` -
dilipsuthar97 revised this gist
Jun 25, 2025 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,8 @@ Husky lets us run commands or script before committing or pushing our code to gi ### Install dependencies ``` yarn add -D husky prettier eslint lint-staged ``` ### Configure eslint file -
dilipsuthar97 revised this gist
Jun 4, 2024 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,10 +42,18 @@ The config that you've selected requires the following dependencies: ### Configure husky ``` npx husky init npx husky add .husky/pre-commit "npx lint-staged" ``` #### pre-commit file ``` #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" npx lint-staged ``` ### Troubleshoot #### Warning: React version not specified in eslint-plugin-react settings. See https://github.com/jsx-eslint/eslint-plugin-react#configuration . -
dilipsuthar97 revised this gist
Mar 29, 2024 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ # Husky in React native ## prettier + eslint + lint-staged Husky lets us run commands or script before committing or pushing our code to git. It works as a pre runner before commiting anything. ### Install dependencies ``` yarn add -D husky prettier eslint list-staged -
dilipsuthar97 revised this gist
Mar 29, 2024 . 1 changed file with 15 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,6 +45,19 @@ npx husky add .husky/pre-commit "npx lint-staged" ``` ### Troubleshoot #### Warning: React version not specified in eslint-plugin-react settings. See https://github.com/jsx-eslint/eslint-plugin-react#configuration . - Update .eslintrc.js file ``` ... "settings": { "react": { "version": "detect" } } ... ``` ### Test integration - Update any component file add junky code - hit `git add <file>` && `git commit -m "test husky"` -
dilipsuthar97 created this gist
Mar 29, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ # Husky in React native ## prettier + eslint + lint-staged ### Install dependencies ``` yarn add -D husky prettier eslint list-staged ``` ### Configure eslint file ``` npm init @eslint/config // select below options for process ✔ How would you like to use ESLint? · problems ✔ What type of modules does your project use? · esm ✔ Which framework does your project use? · react ✔ Does your project use TypeScript? · Yes ✔ Where does your code run? · browser ✔ What format do you want your config file to be in? · JavaScript The config that you've selected requires the following dependencies: @typescript-eslint/eslint-plugin@latest eslint-plugin-react@latest @typescript-eslint/parser@latest ✔ Would you like to install them now? · Yes ✔ Which package manager do you want to use? · yarn ``` ### Update package.json file ``` { ... "lint-staged": { "src/**/*.{js,ts,tsx}": [ "prettier --write", "eslint" ] } ... } ``` ### Configure husky ``` npx husky install npx husky add .husky/pre-commit "npx lint-staged" ``` ### Troubleshoot - Warning: React version not specified in eslint-plugin-react settings. See https://github.com/jsx-eslint/eslint-plugin-react#configuration . ``` ```