Skip to content

Commit

Permalink
* fix violation of roslyn analyzer rule RSPEC-2325 @ c#/shared
Browse files Browse the repository at this point in the history
* fix vueuse/vueuse#4216 @ utils/echarts.ts
* fix typescript-eslint/typescript-eslint#9706 @ api/index.ts
* fix violation of eslitn rule `@stylistic/indent` @ pages/posts.vue
$ git checkout 982e84b^1 src/components/post/badge/{Common,Time}.vue # to fix vuejs/language-tools#4820
@ fe

$ git ls-files -z | xargs -0 sed -i 's/\t/    /g'
  • Loading branch information
n0099 committed Sep 19, 2024
1 parent 694976f commit 8b1f1ca
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "tbclient.protobuf"]
path = tbclient.protobuf
url = git@github.com:n0099/tbclient.protobuf.git
path = tbclient.protobuf
url = git@github.com:n0099/tbclient.protobuf.git
8 changes: 4 additions & 4 deletions c#/crawler/src/Tieba/Crawl/Saver/SaverWithRevision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ public partial class SaverWithRevision<TBaseRevision, TRevisionId>
}
public partial class SaverWithRevision<TBaseRevision, TRevisionId>
{
protected abstract NullFieldsBitMask GetRevisionNullFieldBitMask(string fieldName);

protected IEnumerable<ExistingAndNewEntity<TEntity>> SaveNewEntities<TEntity>(
protected static IEnumerable<ExistingAndNewEntity<TEntity>> SaveNewEntities<TEntity>(
CrawlerDbContext db,
IReadOnlyCollection<MaybeExistingAndNewEntity<TEntity>> maybeEntities)
where TEntity : RowVersionedEntity
Expand All @@ -76,7 +74,7 @@ protected IEnumerable<ExistingAndNewEntity<TEntity>> SaveNewEntities<TEntity>(
.Select(entity => new ExistingAndNewEntity<TEntity>(entity.Existing!, entity.New));
}

protected void SaveExistingEntities<TEntity>(
protected static void SaveExistingEntities<TEntity>(
CrawlerDbContext db,
IEnumerable<ExistingAndNewEntity<TEntity>> existingAndNewEntities)
where TEntity : RowVersionedEntity =>
Expand All @@ -103,6 +101,8 @@ on newNavigation.Metadata.Name equals existingNavigation.Metadata.Name
.ForEach(prop => prop.IsModified = false);
});

protected abstract NullFieldsBitMask GetRevisionNullFieldBitMask(string fieldName);

protected void SaveExistingEntityRevisions<TEntity, TRevision>(
CrawlerDbContext db,
Func<TEntity, TRevision> revisionFactory,
Expand Down
6 changes: 3 additions & 3 deletions c#/shared/src/Db/TbmDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ public class TbmDbContext<TModelCacheKeyFactory>(ILogger<TbmDbContext<TModelCach
public DbSet<ImageInReply> ImageInReplies => Set<ImageInReply>();
public DbSet<ReplyContentImage> ReplyContentImages => Set<ReplyContentImage>();

protected static void OnModelCreatingWithFid(ModelBuilder b, uint fid) =>
b.Entity<ReplyContentImage>().ToTable($"tbmc_f{fid}_reply_content_image");

[SuppressMessage("Naming", "CA1725:Parameter names should match base declaration")]
[SuppressMessage("Critical Code Smell", "S927:Parameter names should match base declaration and other partial definitions")]
[SuppressMessage("Style", "IDE0058:Expression value is never used")]
Expand Down Expand Up @@ -176,9 +179,6 @@ protected override void OnModelCreating(ModelBuilder b)
b.Entity<ReplyContentImage>().HasOne(e => e.ImageInReply).WithMany();
}

protected void OnModelCreatingWithFid(ModelBuilder b, uint fid) =>
b.Entity<ReplyContentImage>().ToTable($"tbmc_f{fid}_reply_content_image");

protected virtual void OnConfiguringNpgsql(NpgsqlDbContextOptionsBuilder builder) { }
protected virtual void OnBuildingNpgsqlDataSource(NpgsqlDataSourceBuilder builder) { }

Expand Down
70 changes: 35 additions & 35 deletions c#/tbm.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B0F531C7-9D14-4F81-B809-D6429D4103FC}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
stylecop.json = stylecop.json
GlobalSuppressions.cs = GlobalSuppressions.cs
Directory.Build.props = Directory.Build.props
EndProjectSection
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
stylecop.json = stylecop.json
GlobalSuppressions.cs = GlobalSuppressions.cs
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TbClient", "tbClient\TbClient.csproj", "{4D782E36-9769-4B10-8D5F-F1F3648F8D74}"
EndProject
Expand All @@ -20,32 +20,32 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "tbm.ImagePipeline", "imagePipeline\tbm.ImagePipeline.csproj", "{3DC9F1EC-5F76-4F78-9F00-99908CED450B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D7F086F7-6DBF-4C26-AB68-0093063FF755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7F086F7-6DBF-4C26-AB68-0093063FF755}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7F086F7-6DBF-4C26-AB68-0093063FF755}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7F086F7-6DBF-4C26-AB68-0093063FF755}.Release|Any CPU.Build.0 = Release|Any CPU
{3DAC21AE-4493-4CF2-B887-203A781C12AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DAC21AE-4493-4CF2-B887-203A781C12AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DAC21AE-4493-4CF2-B887-203A781C12AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DAC21AE-4493-4CF2-B887-203A781C12AA}.Release|Any CPU.Build.0 = Release|Any CPU
{3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Release|Any CPU.Build.0 = Release|Any CPU
{4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A136C5D5-62D8-4451-B139-33124D2A44E5}
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D7F086F7-6DBF-4C26-AB68-0093063FF755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7F086F7-6DBF-4C26-AB68-0093063FF755}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7F086F7-6DBF-4C26-AB68-0093063FF755}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7F086F7-6DBF-4C26-AB68-0093063FF755}.Release|Any CPU.Build.0 = Release|Any CPU
{3DAC21AE-4493-4CF2-B887-203A781C12AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DAC21AE-4493-4CF2-B887-203A781C12AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DAC21AE-4493-4CF2-B887-203A781C12AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DAC21AE-4493-4CF2-B887-203A781C12AA}.Release|Any CPU.Build.0 = Release|Any CPU
{3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Release|Any CPU.Build.0 = Release|Any CPU
{4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A136C5D5-62D8-4451-B139-33124D2A44E5}
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions c#/tbm.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Roslynator/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Roslynator/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tieba/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tesseract/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Spid/@EntryIndexedValue">True</s:Boolean>
Expand Down
6 changes: 0 additions & 6 deletions fe/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ const queryFunctionWithReCAPTCHA = async <TResponse>
export type ApiErrorClass = ApiResponseError | FetchError;
type QueryFunctions = typeof queryFunction | typeof queryFunctionWithReCAPTCHA;
const useApi = <

// https://github.com/typescript-eslint/typescript-eslint/issues/9706
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
TApi extends Api<TResponse, TQueryParam>,
TResponse = TApi['response'],
TQueryParam extends ObjUnknown = TApi['queryParam']>
Expand Down Expand Up @@ -128,9 +125,6 @@ const useApi = <
return ret;
};
const useApiWithCursor = <

// https://github.com/typescript-eslint/typescript-eslint/issues/9706
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
TApi extends Api<TResponse, TQueryParam>,
TResponse extends CursorPagination = TApi['response'],
TQueryParam extends ObjUnknown = TApi['queryParam']>
Expand Down
9 changes: 5 additions & 4 deletions fe/src/components/post/badge/Common.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import { faClock } from '@fortawesome/free-regular-svg-icons';
import { faArrowUpRightFromSquare, faHashtag, faLink } from '@fortawesome/free-solid-svg-icons';
import { DateTime } from 'luxon';
const props = defineProps<{
// https://github.com/vuejs/language-tools/issues/3267
const { post } = defineProps<{
post: TPost,
postIDKey: TPostIDKey,
postTypeText: PostTypeTextOf<TPost>
Expand All @@ -64,7 +65,7 @@ const formatTime = (time: UnixTimestamp) => {
};
const tippyContent = () => `
首次收录时间:${formatTime(props.post.createdAt)}<br>
最后更新时间:${formatTime(props.post.updatedAt ?? props.post.createdAt)}<br>
最后发现时间:${formatTime(props.post.lastSeenAt ?? props.post.updatedAt ?? props.post.createdAt)}`;
首次收录时间:${formatTime(post.createdAt)}<br>
最后更新时间:${formatTime(post.updatedAt ?? post.createdAt)}<br>
最后发现时间:${formatTime(post.lastSeenAt ?? post.updatedAt ?? post.createdAt)}`;
</script>
25 changes: 13 additions & 12 deletions fe/src/components/post/badge/Time.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@mouseleave="highlightPostStore.unset()"
:current="currentDateTime" :relativeTo="previousDateTime"
:relativeToText="`相对于上一${postType}${timestampType}`"
:postType="props.postType" :timestampType="timestampType" v-bind="$attrs">
:postType="postType" :timestampType="timestampType" v-bind="$attrs">
<!-- https://github.com/vuejs/language-tools/issues/4798 -->
<FontAwesome :icon="faChevronUp" class="me-1 align-bottom" />
</PostBadgeTimeView>
Expand All @@ -18,7 +18,7 @@
@mouseleave="highlightPostStore.unset()"
:current="currentDateTime" :relativeTo="nextDateTime"
:relativeToText="`相对于下一${postType}${timestampType}`"
:postType="props.postType" :timestampType="timestampType" v-bind="$attrs">
:postType="postType" :timestampType="timestampType" v-bind="$attrs">
<FontAwesome :icon="faChevronDown" class="me-1 align-bottom" />
</PostBadgeTimeView>
<PostBadgeTimeView
Expand All @@ -29,12 +29,12 @@
@mouseleave="highlightPostStore.unset()"
:current="currentDateTime" :relativeTo="parentDateTime"
:relativeToText="`相对于所属${postTypeText[postTypeText.indexOf(postType) - 1]}${timestampType}`"
:postType="props.postType" :timestampType="timestampType" v-bind="$attrs">
:postType="postType" :timestampType="timestampType" v-bind="$attrs">
<FontAwesome :icon="faAnglesUp" class="me-1 align-bottom" />
</PostBadgeTimeView>
</ClientOnly>
<PostBadgeTimeView
:current="currentDateTime" :postType="props.postType"
:current="currentDateTime" :postType="postType"
:timestampType="timestampType" class="text-end"
:class="{ 'post-badge-time-current-full': hydrationStore.isHydratingOrSSR }" v-bind="$attrs" />
</template>
Expand All @@ -54,7 +54,7 @@ import { faAnglesUp, faChevronDown, faChevronUp } from '@fortawesome/free-solid-
import { DateTime } from 'luxon';
defineOptions({ inheritAttrs: false });
const props = defineProps<{
const { previousPost, nextPost, currentPost, parentPost, postTimeKey } = defineProps<{
previousPost?: TPost,
nextPost?: TPost,
currentPost: TPost,
Expand All @@ -69,21 +69,22 @@ const props = defineProps<{
const highlightPostStore = useHighlightPostStore();
const hydrationStore = useHydrationStore();
useNoScript(`<style>
const noScriptStyle = `<style>
.post-badge-time-current-full {
width: auto !important;
}
</style>`);
</style>`; // https://github.com/nuxt/nuxt/issues/13848
useHead({ noscript: [{ innerHTML: noScriptStyle }] });
// https://github.com/typescript-eslint/typescript-eslint/issues/9723
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents, @typescript-eslint/no-unnecessary-type-parameters
const getPostTime = <T extends TPost | TParentPost>(post?: T) =>
post?.[props.postTimeKey as keyof T] as TPostTimeValue | undefined;
const previousTime = computed(() => getPostTime(props.previousPost));
const nextTime = computed(() => getPostTime(props.nextPost));
const parentTime = computed(() => getPostTime(props.parentPost));
post?.[postTimeKey as keyof T] as TPostTimeValue | undefined;
const previousTime = computed(() => getPostTime(previousPost));
const nextTime = computed(() => getPostTime(nextPost));
const parentTime = computed(() => getPostTime(parentPost));
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const currentTime = computed(() => getPostTime(props.currentPost)!);
const currentTime = computed(() => getPostTime(currentPost)!);
const previousDateTime = computed(() =>
undefinedOr(previousTime.value, i => DateTime.fromSeconds(i)));
Expand Down
4 changes: 2 additions & 2 deletions fe/src/pages/posts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ watch([dataUpdatedAt, errorUpdatedAt], async (updatedAt: UnixTimestamp[]) => {
const postCount = _.sum(Object.values(fetchedPage?.pages.matchQueryPostCount ?? {}));
notyShow('success', `已加载${postCount}条记录
${isQueryCached
? '使用前端本地缓存'
: `
? '使用前端本地缓存'
: `
前端耗时${_.round(renderDuration / 1000, 2)}s
${isQueriedBySSR ? '使用服务端渲染预请求' : ''}
后端+网络耗时${_.round(networkDuration / 1000, 2)}s`}`);
Expand Down
2 changes: 1 addition & 1 deletion fe/src/utils/echarts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as echarts from 'echarts/core';
import type { ColorPaletteOptionMixin } from 'echarts/types/src/util/types.d.ts';

export const useResizeableEcharts = (el: Parameters<typeof useResizeObserver>[0]) =>
useResizeObserver(el, _.debounce((entries: Parameters<Parameters<typeof useResizeObserver>[1]>[0]) => { // https://github.com/vueuse/vueuse/issues/4216
useResizeObserver(el, _.debounce((entries: readonly ResizeObserverEntry[]) => {
entries.forEach(entry => {
echarts.getInstanceByDom(entry.target as HTMLElement)?.resize();
});
Expand Down

0 comments on commit 8b1f1ca

Please sign in to comment.