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

微笑、不失礼 提交于 2020-06-12 03:47:14

问题


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?


回答1:


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:

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

  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.




回答2:


You have to get a code formatter for VSCode to solve it.

I recommend you to download Beautify available on this link.




回答3:


Quick Solution for both .css and .scss (NOT RECOMMENDED)

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

  1. Add the following to .vscode/settings.json:
{
  "css.validate": false
}

Results:

You get rid of these SASS linting errors when using Tailwind-CSS but you disable CSS validation.



来源:https://stackoverflow.com/questions/62118325/how-do-you-get-rid-of-these-sass-linting-errors-when-using-tailwind-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!