Skip to content

Commit

Permalink
* fix all violations of eslint rule no-restricted-syntax that intro…
Browse files Browse the repository at this point in the history
…duced in aa2bba7 @ app/router.options.ts & utils/post/queryForm/queryParams.ts

* fix all violations of eslint rule `@typescript-eslint/unbound-method` @ pages/bilibiliVote.vue
* enable option `allowAsThisParameter` for rule `@typescript-eslint/no-invalid-void-type` to allow using `this: void` to resolve violation of rule `@typescript-eslint/unbound-method` @ eslint.config.js
* replace the callback as v-bind of `ref` with plain attr @ `<RelativeTime>`
* referencing vuejs/language-tools#4798 in comment since 2f8b0a0 @ `<PostBadgeTime>`
@ fe
  • Loading branch information
n0099 committed Sep 4, 2024
1 parent 8d887a9 commit f2c98c4
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fe/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ const rules = [{ // as of [email protected]
'@typescript-eslint/no-confusing-void-expression': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-invalid-void-type': ['error', { allowAsThisParameter: true }],
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
Expand Down
2 changes: 1 addition & 1 deletion fe/src/app/router.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const redirectRoute = (before: string, after: string): RouteRecordRedirect[] =>
}, { path: before, redirect: after }];

export default {
routes: _routes => {
routes(_routes) {
const postCursorRoute = withCursorRoute(async () => import('@/pages/posts.vue'));
const postChildren = [
postCursorRoute('fid/:fid(\\d+)', 'posts/fid'),
Expand Down
2 changes: 1 addition & 1 deletion fe/src/components/RelativeTime.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<span :ref="el => rootEl = (el as HTMLElement)">
<span ref="rootEl">
<template v-if="hydrationStore.isHydratingOrSSR || !isAlreadySeen">
<template v-if="relativeTo === undefined">
{{ dateTimeInShanghai.toLocaleString({
Expand Down
1 change: 1 addition & 0 deletions fe/src/components/post/badge/Time.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:current="currentDateTime" :relativeTo="previousDateTime"
:relativeToText="`相对于上一${postType}${timestampType}`"
:postType="props.postType" :timestampType="timestampType" v-bind="$attrs">
<!-- https://github.com/vuejs/language-tools/issues/4798 -->
<FontAwesome :icon="faChevronUp" class="me-1 align-bottom" />
</PostBadgeTimeView>
<PostBadgeTimeView
Expand Down
4 changes: 2 additions & 2 deletions fe/src/pages/bilibiliVote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ const loadCharts = {
});
});
},
top5CandidateCountGroupByTime() {
top5CandidateCountGroupByTime(this: void) {
const timeGranularity = query.value.top5CandidateCountGroupByTimeGranularity;
const top5CandidateCountGroupByTime = timeGranularity === 'minute'
? json.top5CandidatesVoteCountGroupByMinute
Expand Down Expand Up @@ -669,7 +669,7 @@ const loadCharts = {
series
} as echarts.ComposeOption<AxisPointerComponentOption | GridComponentOption | LineSeriesOption>);
},
allVoteCountGroupByTime() {
allVoteCountGroupByTime(this: void) {
const timeGranularity = query.value.allVoteCountGroupByTimeGranularity;
const allVoteCountGroupByTime = timeGranularity === 'minute'
? json.allVoteCountGroupByMinute
Expand Down
10 changes: 5 additions & 5 deletions fe/src/utils/post/queryForm/queryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,30 @@ const paramsMetadataKeyByType: { [P in 'array' | 'dateTimeRange' | 'numeric' | '
watcher?: ParamPreprocessorOrWatcher
} } = { // mutating param object will sync changes
array: {
preprocessor: param => {
preprocessor(param) {
if (_.isString(param.value))
param.value = param.value.split(',');
}
},
numeric: { default: { subParam: { range: '=' } } },
textMatch: {
default: { subParam: { matchBy: 'explicit', spaceSplit: false } },
preprocessor: param => {
preprocessor(param) {
param.subParam.spaceSplit = boolStrToBool(param.subParam.spaceSplit);
},
watcher: param => {
watcher(param) {
if (param.subParam.matchBy === 'regex')
param.subParam.spaceSplit = false;
}
},
dateTimeRange: {
default: { subParam: { range: undefined } },
preprocessor: param => {
preprocessor(param) {
if (!_.isString(param.value))
return;
param.subParam.range = param.value.split(',');
},
watcher: param => {
watcher(param) {
// combine datetime range into root param's value
param.value = _.isArray(param.subParam.range) ? param.subParam.range.join(',') : '';
}
Expand Down

0 comments on commit f2c98c4

Please sign in to comment.