個人プロジェクトのQuicintでStylelintをv13系からv14系へ移行してみたのでその流れを備忘録として残したいと思います。
Stylelint v14系ではいくつかの大きな変更点が含まれますが、単体の移行手順自体は多くありません。詳しくはMigrating to 14.0.0を確認するものとして概要は以下になります。
stylelint
単体のアップデート
- 標準config指定を
stylelint-config-standard-scss
に変更
- 標準configにて新しく追加された新ルールの確認と適用
移行作業
まずはncuや直接指定等でStylelint自体のアップデートを行い、続けて以下で新しい標準configをインストールします。
例としてv13時点で標準configにstylelint-config-standard
を使用していた場合、v14ではstylelint-config-standard-scss
に変更されるので不要なconfigの削除も適宜行います。
ここまでの変更点が以下です。付随する移行作業は別として、Stylelint単体の移行はこれだけです。
package.jsonを表示
.stylelintrc.jsonを表示
新ルールの確認
新しい標準configstylelint-config-standard-scss
のChangeLogを見るといくつかの新しく追加されたルールを確認できます。
移行直後ではこれらルールに引っかかる環境も多いはずですので適宜新ルールの確認と適用を行うことになります。
ただ残念ながらstylelint --fix
などで自動修正を行うと私の場合だと高い確率でat-rule系の記述が壊れる様子でしたので、行う際は手動対応が基本と考えておくと良さそうです。
新ルールの数も2,3個というわけではないのでひとまずルールに関しては時間があるときに対応するのも良い選択肢です。
"stylelint-config-standard-scss": "^3.0.0"
時点だと以下ルールをオーバーライドすると取り敢えず引っかかる事はなくなります。
VS Codeなどでもv13系を使っているとWARNINGが出るようになってきましたが、幸いStylelint単体の移行作業はそこまで多くはないのでなるべく早いタイミングで移行を進めていきたいところです。
参考:Migrating to 14.0.0
参考:stylelint-config-standard-scss
参考:stylelint-config-standard-scssのChangeLog