背景
最新のCSSプロパティ(container-typeやtext-wrap)を利用した場合に以下のような警告が発生する。
Unknown property: 'container-type' ts-styled-plugin(9999)
これはvscode-styled-componentsでシンタックスハイライトを行っている場合、(内部で利用しているライブリが)最新のCSSプロパティに対応していないことが原因だった。
ちなみに@starting-styleに対しても似たような警告が発生する。
Unknown at rule @starting-style ts-styled-plugin(9999)
- Unknown property
- Unknown at rule
環境
- VS Code
- vscode-styled-components
対応方法
プロジェクトのtsconfig.jsonのpluginsに以下のような項目を追加する。
{
"compilerOptions": {
"plugins": [
{
"name": "@styled/typescript-styled-plugin",
"lint": {
"validProperties": ["container-type", "container-name", "text-wrap"],
"unknownAtRules": "ignore",
"validate": false
}
}
]
}
}validPropertiesには「Unknown property」として警告が発生したプロパティを追加することで、警告を解消できる。unknownAtRulesでは「Unknown at rule」に対しての無視指定をする。