-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
template内での ?? と ?. の利用をeslintで制限する #1010
template内での ?? と ?. の利用をeslintで制限する #1010
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!!
こういった設定もあるんですね!!
"vue/no-restricted-syntax": [ | ||
"error", | ||
{ | ||
selector: "LogicalExpression[operator=??]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ついでになのですが、同様にオプショナルチェーン(?.
)もエラーにできそうでしょうか 🙇
たしかこちらも同様にsyntax highlightが崩れるので・・・。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional chainingも MemberExpression[optional=true]
で問題なく対応できそうでした!
利用箇所が10ヶ所ほど残っていたので合わせて修正しますね
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -175,7 +175,7 @@ | |||
text-color="display-on-primary" | |||
class="q-mt-sm" | |||
@click=" | |||
changeHotkeySettings(lastAction, lastRecord)?.then(() => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changeHotkeySettingsの返り値は Promise<void>
確定で
?.
は必要なさそうだったので単純に外しました
(下の solveDuplicated
も同様)
const changeHotkeySettings = (action: string, combo: string) => {
return store.dispatch("SET_HOTKEY_SETTINGS", {
data: {
action: action as HotkeyAction,
combination: combo,
},
});
};
余談: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approveできてなかったので再LGTM!!
そうなんですよね、issueがそのままなので悲しみがあります・・・。
こちらもマージできていませんでした・・・!マージします!! |
検索用にメモ Null 合体演算子 (??) |
内容
何度かコメントされているのを観測したのでeslintで弾くようにしてみました。
eslint-plugin-vueの
vue/no-restricted-syntax
ルールを使っています。これはtemplate内でのみ有効なので
<script>
内や他には影響を及ぼしません。ref: https://eslint.vuejs.org/rules/no-restricted-syntax.html
単に禁止だと理由が伝わらないのでカスタムメッセージを設定しました(スクリーンショット参照)
スクリーンショット・動画など