Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get rid of these SASS linting errors when using Tailwind-CSS?

Tags:

Linting error

I'm using Tailwind in a Gatsby.js project. My environment is VSCode, using Prettier code formatter.

How do I get rid of these linting error alerts?

like image 510
Sandy Wyper Avatar asked May 31 '20 15:05

Sandy Wyper


People also ask

Can you use sass with Tailwind?

Since Tailwind is a PostCSS plugin, there's nothing stopping you from using it with Sass, Less, Stylus, or other preprocessors, just like you can with other PostCSS plugins like Autoprefixer.

How do I get rid of unknown at Rule <UNK>Tailwind?

Here's how to fix this. Open the settings, search for “unknown”, the first result should be the one you're looking for: CSS > Lint: Unknown At Rules : Change that to ignore : Done!

What is Postcss Tailwind?

Tailwind CSS works by scanning all of your HTML files, JavaScript components, and any other templates for class names, generating the corresponding styles and then writing them to a static CSS file. It's fast, flexible, and reliable — with zero-runtime.

Can you use normal CSS with Tailwind?

You can use both yours and Tailwind. You'll find that some of your styles may change though. The idea of Tailwind is to give you a base level of styling and tools to help you build something unique. So to answer the question, no you don't need to start over.


1 Answers

Solution for both .css and .scss

  1. At the root level of your project, update or create a dir .vscode with a file settings.json:

enter image description here

  1. Add the following to .vscode/settings.json:
{   "css.validate": false,   "less.validate": false,   "scss.validate": false } 
  1. Install the vscode-stylelint extension

enter image description here

  1. install stylelint-config-standard:

npm i stylelint-config-standard -D

  1. create a stylelint.config.js file at the root level and add:
module.exports = {   extends: ['stylelint-config-recommended'],   rules: {     "at-rule-no-unknown": [       true,       {         ignoreAtRules: [           "tailwind",           "apply",           "variants",           "responsive",           "screen",         ],       },     ],     "declaration-block-trailing-semicolon": null,     "no-descending-specificity": null,   }, }; 
  1. restart vsCode

Results:

You get rid of these SASS linting errors when using Tailwind-CSS and keep doing css validation with stylelint.

enter image description here

like image 192
ArtiomLK Avatar answered Oct 31 '22 19:10

ArtiomLK