Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: template literal tags #65

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

schoero
Copy link
Owner

@schoero schoero commented Jan 8, 2025

Adds support for tagged template literals. Closes #64

const styles = tw`this will get linted`;

This PR does not change the default settings, so no tags will get linted out of the box.

To lint tagged template literals, the best way is to use the strings matcher to ensure that nested expressions will get linted correctly.

{
  //...
  options: [{ 
    tags: [
      [
        "tw", [{ match: MatcherType.String }]
      ]
    ]
  }]
}
const styles = tw`
  this string will get linted
  ${
    someVar === "this string will NOT get linted" 
      ? "this string will get linted"
      : "this string will get linted"
  }
  this string will get linted
`;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supporting tagged string literals like twbg-blue-500
1 participant