tailwind-merge icon indicating copy to clipboard operation
tailwind-merge copied to clipboard

Add info to docs on how to prevent using incorrect `twMerge`

Open dcastil opened this issue 2 years ago • 2 comments

When configuring tailwind-merge, one creates their own twMerge function to call. I should add a guide on how to prevent to accidentally use import { twMerge } from 'tailwind-merge' instead of import { twMerge } from 'src/my-own-tailwind-merge' and explain the ESLint rule I use for that.

dcastil avatar Jun 21 '23 11:06 dcastil

Hi @dcastil, any thought on how to go about this?

IEdiong avatar Aug 16 '24 15:08 IEdiong

@IEdiong I typically use ESLint to do that, more specifically the no-restricted-imports rule.

This is my config for it:

{
    "rules": {
        "no-restricted-imports": [
            "error",
            {
                "paths": [
                    {
                        "importNames": ["twMerge"],
                        "name": "tailwind-merge",
                        "message": "Please import { twMerge } from 'path/to/my/own/tailwind-merge'."
                    }
                ]
            }
        ]
    }
}

dcastil avatar Aug 17 '24 17:08 dcastil