Skip to content

Instantly share code, notes, and snippets.

@dilipsuthar97
Last active July 3, 2025 09:49
Show Gist options
  • Select an option

  • Save dilipsuthar97/d2567a3fd912ca6a48aa533f19d30ebe to your computer and use it in GitHub Desktop.

Select an option

Save dilipsuthar97/d2567a3fd912ca6a48aa533f19d30ebe to your computer and use it in GitHub Desktop.

Revisions

  1. dilipsuthar97 revised this gist Jul 3, 2025. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions husky-readme.md
    Original 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
  2. dilipsuthar97 revised this gist Jun 27, 2025. No changes.
  3. dilipsuthar97 revised this gist Jun 27, 2025. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions husky-readme.md
    Original 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
    ```

    #### pre-commit file
    #### 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
    ### 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. See https://github.com/jsx-eslint/eslint-plugin-react#configuration .
    #### 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
  4. dilipsuthar97 revised this gist Jun 27, 2025. 1 changed file with 17 additions and 6 deletions.
    23 changes: 17 additions & 6 deletions husky-readme.md
    Original 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)
    ```
    ## 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
    }
    ```

    ### Troubleshoot
    ### 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": {
  5. dilipsuthar97 revised this gist Jun 27, 2025. 1 changed file with 16 additions and 1 deletion.
    17 changes: 16 additions & 1 deletion husky-readme.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Husky in React native
    ## prettier + eslint + lint-staged
    ## 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 .

  6. dilipsuthar97 revised this gist Jun 25, 2025. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions husky-readme.md
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ yarn add -D husky prettier eslint lint-staged
    ```

    ### Configure eslint file
    ### 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
    npx husky add .husky/pre-commit "npx lint-staged"
    ```

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

  7. dilipsuthar97 revised this gist Jun 25, 2025. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion husky-readme.md
    Original 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 list-staged
    yarn add -D husky prettier eslint lint-staged
    ```

    ### Configure eslint file
  8. dilipsuthar97 revised this gist Jun 4, 2024. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion husky-readme.md
    Original 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 install
    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 .

  9. dilipsuthar97 revised this gist Mar 29, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions husky-readme.md
    Original 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
  10. dilipsuthar97 revised this gist Mar 29, 2024. 1 changed file with 15 additions and 2 deletions.
    17 changes: 15 additions & 2 deletions husky-readme.md
    Original 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 .
    #### 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"`
  11. dilipsuthar97 created this gist Mar 29, 2024.
    50 changes: 50 additions & 0 deletions husky-readme.md
    Original 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 .
    ```
    ```