6

How to properly configure Tailwind CSS and VS Code to at least disable errors about at-rule and empty tag error inside VueJS single file component (vue-cli)?

<template>
...
</template>

<style lang="scss">
  body {
    // } expected
    @apply font-source pt-4;
  } // at-rule or selector expected

  h5,h4,h3,h2,h1 {
    // } expected
    @apply font-pt font-bold;
  } // at-rule or selector expected
</style>
3
  • disable the es-lint may it works Commented May 9, 2019 at 15:56
  • 4
    lol I don't want to disable es-lint lint. Commented May 9, 2019 at 15:59
  • then keep es-lint Commented May 9, 2019 at 16:05

4 Answers 4

8

I got it working with the help of this guide

TLDR

  1. Install VS Code plugin stylelint (publisher name: stylelint)

  2. Disable scss / css validation for the project. Hit F1 and search "settings json".

    settings.json

"scss.validate": false
"css.validate": false
  1. Add and configure stylelint plugin. Add the following file and contents to your project root.

    stylelint.config.js

module.exports = {
    rules: {
        'at-rule-no-unknown': [
            true,
            {
                ignoreAtRules: ['tailwind', 'apply', 'variants', 'responsive', 'screen']
            }
        ],
        'declaration-block-trailing-semicolon': null,
        'no-descending-specificity': null
    }
}
  1. (optional) You "may" need to restart vs code to see the changes
Sign up to request clarification or add additional context in comments.

1 Comment

Anyone in the future, if your validation settings are already false and you are still experiencing the problem, setting them to true then back to false worked for me.
0

You could also add this to your VS Code workspace settings (.vscode/settings.json):

{
  "scss.lint.unknownAtRules": "ignore"
}

Comments

-1

maybe remove lang="scss" or use the class directly in the template should work ?

1 Comment

OP is using SCSS, there's the issue. Removing it or changing to lang="postcss" breaks CSS.
-1

I fixed this error by changing my style's lang attribute to "postcss". Tailwind is essentially a PostCSS plugin.

<style lang="postcss">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.