9

I followed this doc to add CSS reset to my app.
https://create-react-app.dev/docs/adding-css-reset/#indexcss

But it showed this message:

enter image description here

"stylelint": {
"extends": "stylelint-config-recommended",
"rules": {
  "at-rule-no-unknown": null
}

How to fix this problem?it is annoying...

codenoobforreal
  • 101
  • 1
  • 5

3 Answers3

4

To fix this warning you just need to add this line to.vscode/settings.json inside your project (you can create this file if it doesn't already exist):

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

Source: https://create-react-app.dev/docs/adding-css-reset/#indexcss

thalesbruno
  • 146
  • 5
1

For VS Code -

To make the VS Code recognise this custom CSS directive, you can provide custom data for VS Code's CSS Language Service as mentioned here - https://github.com/Microsoft/vscode-css-languageservice/blob/master/docs/customData.md.

Create a CSS custom data set file with the following info. Place it at location .vscode/custom.css-data.json relative to the project root.

{
  "version": 1.1,
  "properties": [],
  "atDirectives": [
    {
      "name": "@import-normalize",
      "description": "bring in normalize.css styles"
    }
  ],
  "pseudoClasses": [],
  "pseudoElements": []
}

Now, if you don't have already, create a .vscode\settings.json file relative to project root. Add a field with key "css.customData" and value as the path to custom data set. For example,

{
  "css.customData": ["./.vscode/custom.css-data.json"]
}

Now, you will no longer get "Unknown at rule" warning. When you hover over "@import-normalize", you will see the description you set for it in custom.css-data.json

"bring in normalize.css styles" shown in tooltip when "@import-normalize" is hovered

Omkar Rajam
  • 721
  • 7
  • 13
0

@import-normalize is a non-standard at-rule. From the rule's documentation:

This rule considers at-rules defined in the CSS Specifications, up to and including Editor's Drafts, to be known.

However, the rule has an ignoreAtRules secondary option for exactly this use case, where you can list the non-standard imports you are using.

For example, in your package.json:

{
  "stylelint": {
    "extends": "stylelint-config-recommended",
    "rules": {
      "at-rule-no-unknown": [true, {
        "ignoreAtRules": ["import-normalise"]
      }]
    }
  }
}

Or within your .stylelintrc file:

{
  "extends": "stylelint-config-recommended",
  "rules": {
    "at-rule-no-unknown": [true, {
      "ignoreAtRules": ["import-normalise"]
    }
  }
}
Appleshell
  • 7,088
  • 6
  • 47
  • 96
jeddy3
  • 3,451
  • 1
  • 12
  • 21