question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The new svelte-check can't deal with Tailwindcss's new experimental applyComplexClasses feature

See original GitHub issue

Describe the bug

Tailwindcss’s latest release contains an experimental feature under the flag applyComplexClasses. It, finally, makes @apply just as powerful as normal element classes. As in, in the past you couldn’t write @apply hover:bg-red-200; because @apply couldn’t handle the hover: part. Now it finally can. However, now svelte-check will throw an error saying that that is invalid css code.

/Users/evert/Sites/sapper-cms/src/routes/index.svelte:26:17
Error: Semicolon or block is expected (svelte)
    div {
        @apply hover:bg-red-200;
    }

To Reproduce

Sorry, I can’t provide a REPL to showcase the simplest example, because this requires setting up tailwindcss in a repo. I used this template and the only change I had to make was to enable the experimental feature in tailwind by adding the following line of code to tailwind.config.js:

export const experimental = "all"

And then editing src/routes/index.svelte by adding something like the following in the <style> element.

div {
    @apply hover:bg-red-200;
}

Expected behavior

What I would like to happen is for svelte-check to somehow understand that I’m using tailwindcss and that then this syntax is valid.

Information about my Svelte project

  • My browser and the version: Brave 1.12.114 using Chromium 84
  • My operating system: macOS 11
  • Sapper version 0.28.0
  • Svelte version 3.24.1
  • Bundler: Rollup

Severity

It’s mostly annoying, because now I have to turn off svelte check in order to continue with my project.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lorenzosignoretticommented, Sep 10, 2021

@lorenzosignoretti So, I think you can find the solution here. Let me know if that didn’t help you.

@Gobi-one Thanks for the reply! I had actually already enabled the preprocess: true option for jest on .svelte files. I took a look at the other config files that you shared on your SO post and I mine look basically the same. I should note I am using SvelteKit, so the issue may be linked to that. For now, I am just sticking to adding some classes on the elements themselves.

1reaction
Gobi-onecommented, Aug 18, 2021

@jwrunner Thank you for this quick answer. In fact I misread the bug, I only have an issue while using jest and @apply with complex classes. It works well when I run it (yarn run dev), just the tests that fails with “ParseError: Semicolon or block is expected”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install Tailwind CSS with SvelteKit
Setting up Tailwind CSS in a SvelteKit project. Create your project. Start by creating a new SvelteKit project if you don't have one...
Read more >
Solid Sapper setup with PostCSS and Tailwind - codechips
Test -driving the new setup#. To check that Tailwind and PostCSS works in Svelte components, replace your src/routes/index.svelte with this code.
Read more >
[Update] Using Svelte with Tailwindcss - A better approach
Using this new approach will enable us to benefit from every feature of Tailwind by combining Svelte's preprocessing ability and PostCSS.
Read more >
How to Use Tailwind on a Svelte Site | CSS-Tricks
Step 1: Scaffold a new Svelte site · Step 2: Adding Tailwind CSS · Step 3: Configuring Tailwind · Step 4: Making Tailwind...
Read more >
Build an App with SvelteKit and Tailwind CSS - YouTube
Have you tried out the hottest new framework in Web Development? In this video, we'll create a TODO app using SvelteKit and Tailwind...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found