Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ module.exports = {
endOfLine: "auto",
},
],
"vue/no-restricted-syntax": [
"error",
{
selector: "LogicalExpression[operator=??]",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ついでになのですが、同様にオプショナルチェーン?.)もエラーにできそうでしょうか 🙇
たしかこちらも同様にsyntax highlightが崩れるので・・・。

Copy link
Contributor Author

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ヶ所ほど残っていたので合わせて修正しますね

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

51acc52 でoptional chainingを禁止し、
5f0db60 で利用箇所を修正しました。シンプルに三項演算子に置き換えています a?.b => a ? a.b : undefined

message: `template内で"??"を使うとgithubのsyntax highlightが崩れるので\n三項演算子等を使って書き換えてください`,
},
{
selector: "MemberExpression[optional=true]",
message: `template内で"?."を使うとgithubのsyntax highlightが崩れるので\n三項演算子等を使って書き換えてください`,
},
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
Expand Down
39 changes: 33 additions & 6 deletions src/components/AudioInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,12 @@
:class="{
disabled: speedScaleSlider.qSliderProps.disable.value,
}"
>話速 {{ speedScaleSlider.state.currentValue.value?.toFixed(2) }}</span
>話速
{{
speedScaleSlider.state.currentValue.value
? speedScaleSlider.state.currentValue.value.toFixed(2)
: undefined
}}</span
>
<q-slider
dense
Expand All @@ -196,7 +201,12 @@
:class="{
disabled: pitchScaleSlider.qSliderProps.disable.value,
}"
>音高 {{ pitchScaleSlider.state.currentValue.value?.toFixed(2) }}</span
>音高
{{
pitchScaleSlider.state.currentValue.value
? pitchScaleSlider.state.currentValue.value.toFixed(2)
: undefined
}}</span
>
<q-slider
dense
Expand All @@ -223,7 +233,11 @@
disabled: intonationScaleSlider.qSliderProps.disable.value,
}"
>抑揚
{{ intonationScaleSlider.state.currentValue.value?.toFixed(2) }}</span
{{
intonationScaleSlider.state.currentValue.value
? intonationScaleSlider.state.currentValue.value.toFixed(2)
: undefined
}}</span
>
<q-slider
dense
Expand All @@ -249,7 +263,12 @@
:class="{
disabled: volumeScaleSlider.qSliderProps.disable.value,
}"
>音量 {{ volumeScaleSlider.state.currentValue.value?.toFixed(2) }}</span
>音量
{{
volumeScaleSlider.state.currentValue.value
? volumeScaleSlider.state.currentValue.value.toFixed(2)
: undefined
}}</span
>
<q-slider
dense
Expand All @@ -276,7 +295,11 @@
disabled: prePhonemeLengthSlider.qSliderProps.disable.value,
}"
>開始無音
{{ prePhonemeLengthSlider.state.currentValue.value?.toFixed(2) }}</span
{{
prePhonemeLengthSlider.state.currentValue.value
? prePhonemeLengthSlider.state.currentValue.value.toFixed(2)
: undefined
}}</span
>
<q-slider
dense
Expand All @@ -303,7 +326,11 @@
disabled: postPhonemeLengthSlider.qSliderProps.disable.value,
}"
>終了無音
{{ postPhonemeLengthSlider.state.currentValue.value?.toFixed(2) }}</span
{{
postPhonemeLengthSlider.state.currentValue.value
? postPhonemeLengthSlider.state.currentValue.value.toFixed(2)
: undefined
}}</span
>
<q-slider
dense
Expand Down
6 changes: 5 additions & 1 deletion src/components/AudioParameter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
!disable && (valueLabel.visible || previewSlider.state.isPanning.value)
"
>
{{ previewSlider.state.currentValue.value?.toFixed(precisionComputed) }}
{{
previewSlider.state.currentValue.value
? previewSlider.state.currentValue.value.toFixed(precisionComputed)
: undefined
}}
</q-badge>
<q-slider
vertical
Expand Down
4 changes: 3 additions & 1 deletion src/components/CharacterOrderDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
<img
:src="
characterInfosMap[speakerUuid].metas.styles[
selectedStyleIndexes[speakerUuid] ?? 0
selectedStyleIndexes[speakerUuid]
? selectedStyleIndexes[speakerUuid]
: 0
].iconPath
"
class="style-icon"
Expand Down
4 changes: 2 additions & 2 deletions src/components/HotkeySettingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
text-color="display-on-primary"
class="q-mt-sm"
@click="
changeHotkeySettings(lastAction, lastRecord)?.then(() =>
Copy link
Contributor Author

@k-chop k-chop Nov 4, 2022

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,
        },
      });
    };

changeHotkeySettings(lastAction, lastRecord).then(() =>
closeHotkeyDialog()
)
"
Expand All @@ -189,7 +189,7 @@
color="primary"
text-color="display-on-primary"
class="q-mt-sm"
@click="solveDuplicated()?.then(() => closeHotkeyDialog())"
@click="solveDuplicated().then(() => closeHotkeyDialog())"
:disabled="confirmBtnEnabled"
/>
</q-card-actions>
Expand Down