LoginSignup
1
0

More than 1 year has passed since last update.

VueのOptionAPIで使われていないプロパティを検知するESlintルール

Posted at

結論

vue/no-unused-property を使う
https://eslint.vuejs.org/rules/no-unused-properties.html

背景

ReactのJSX構文やVueのCompositionAPIでは、JavaScript的にPropsやメソッド、リアクティブな変数を定義できるため、no-unused-varルールで使われていないものを検知することができる。
VueのOptionAPIでは、Vue独自の構文でクラス的な記法でプロパティを定義するため、JavaScriptのルールでは使われていないものを検知することができない。

使用例

image.png

注意点

vueのステート管理ライブラリであるvuexのmapGettersでラップした場合はこのルールだけでは検知ができない
image.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0