Skip to content

Add info to docs on how to prevent using incorrect twMerge #259

Open
@dcastil

Description

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.

Activity

IEdiong

IEdiong commented on Aug 16, 2024

@IEdiong

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

dcastil

dcastil commented on Aug 17, 2024

@dcastil
OwnerAuthor

@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'."
                    }
                ]
            }
        ]
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    context-v1Related to tailwind-merge v1featureIs new feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @dcastil@IEdiong

      Issue actions

        Add info to docs on how to prevent using incorrect `twMerge` · Issue #259 · dcastil/tailwind-merge