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

Merged
merged 10 commits into from
Jan 19, 2025
Merged

feat: template literal tags #65

merged 10 commits into from
Jan 19, 2025

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
`;

@schoero schoero marked this pull request as ready for review January 19, 2025 08:25
@schoero schoero merged commit b922d6d into main Jan 19, 2025
20 checks passed
@schoero schoero deleted the feat/template-literal-tags branch January 19, 2025 15:26
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