個人で運用しているサービスのstylelintを13系から14系の上げたので、そのあたりでやったこととかをメモしておきます。
アップデート手順
公式で14系へのマイグレーションガイドが公開されているので、基本的にはそれをみてやっていきます。
.scss
を静的解析するためのライブラリの変更
We recommend extending a shared config that includes the appropriate PostCSS syntax for you. For example, if you use Stylelint to lint SCSS, you can extend the stylelint-config-standard-scss shared config.
今まではstyelint-scss
とstylelint-config-recommended-scss
を使っていたのですが、以下のstylelint-config-standard-scss
を使えば良くなったようなので、このライブラリを利用して、その他は削除するようにしました。
stylelint-config-standard-scss
にはstylelint-config-recommended-scss
の設定も含まれているのでextends
にはstylelint-config-standard-scss
のみを設定するようにしています。
{ "extends": ["stylelint-config-standard-scss"], "rules": { "no-empty-source": null } }
.vue
を静的解析に含めるための設定
If a shared config isn't available for your perferred language or library, then you can install the appropriate PostCSS syntax yourself and use the customSyntax option, which is now available in the configuration object.
今までは.vue
内のscssの記述も自動的に検査することが出来ましたが、今回からは自分で設定を追加しないといけなくなったようです。
HTML, XML and HTML-like embeds (.html, .xml, .svelte, .vue etc.) use postcss-html
.vue
の場合は上述の通りpostcss-html
をインストールして以下のようにoverrideの設定をすることで、.vue
に関してはpostcss-html
を利用するように設定を行います。
{ "extends": ["stylelint-config-standard-scss"], "overrides": [ { "files": ["**/*.vue"], "customSyntax": "postcss-html" } ], "rules": { "no-empty-source": null } }
おわりに
多少overrideまわりの設定でハマってしまいましたが、公式ドキュメント通りに設定を変更することでバージョンアップができました!こういうドキュメントもアップデート時に整備してもらえるの非常にありがたいですね🙏