Skip to content

Commit

Permalink
* fix moment/luxon#1650 @ <PotBadgeTimeView> & registerRelative()
Browse files Browse the repository at this point in the history
… @ `stores/relativeTime`

* switch to flat config as `@tanstack/eslint-plugin-query`: TanStack/query#7663, `eslint-plugin-pinia`: lisilinhart/eslint-plugin-pinia#35 & `eslint-plugin-import-x`: un-ts/eslint-plugin-import-x#122 now supports it @ eslint.config.js
@ fe
  • Loading branch information
n0099 committed Aug 27, 2024
1 parent 915350f commit 022ade8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 6 additions & 8 deletions fe/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@ import * as vueESLintParser from 'vue-eslint-parser';
// eslint-disable-next-line import-x/extensions
import vueESLintConfigTypescriptRecommendedExtends from '@vue/eslint-config-typescript/recommended.js';
import pluginVue from 'eslint-plugin-vue';
import { fixupConfigRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import eslintJs from '@eslint/js';
import pluginStylistic from '@stylistic/eslint-plugin';
import pluginTanstackQuery from '@tanstack/eslint-plugin-query';
import * as typescriptESLintParser from '@typescript-eslint/parser';
import pluginImportX from 'eslint-plugin-import-x';
import pluginPinia from 'eslint-plugin-pinia';
Expand All @@ -543,18 +543,16 @@ const compat = new FlatCompat();
export default withNuxt(
eslintJs.configs.recommended,
...pluginVue.configs['flat/recommended'],
...compat.config(vueESLintConfigTypescriptRecommendedExtends), // https://github.com/vuejs/eslint-config-typescript/issues/76#issuecomment-2051234597
...compat.config(vueESLintConfigTypescriptRecommendedExtends), // https://github.com/vuejs/eslint-config-typescript/issues/76#issuecomment-2148720004
...compat.extends( // https://github.com/ota-meshi/typescript-eslint-parser-for-extra-files/issues/95#issuecomment-2148604881
'plugin:@typescript-eslint/strict-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
),
...compat.config(pluginImportX.configs.recommended), // https://github.com/un-ts/eslint-plugin-import-x/pull/85
pluginImportX.configs.typescript, // https://github.com/import-js/eslint-plugin-import/issues/2556#issuecomment-2119520339
...fixupConfigRules(...compat.extends(
'plugin:@tanstack/eslint-plugin-query/recommended', // https://github.com/TanStack/query/pull/7253
)),
pluginImportX.flatConfigs.recommended,
pluginImportX.flatConfigs.typescript,
...pluginTanstackQuery.configs['flat/recommended'],
pluginUnicorn.configs['flat/recommended'],
...compat.config(pluginPinia.configs.all),
pluginPinia.configs['all-flat'],
{ languageOptions: { ecmaVersion: 'latest' } },
{ ignores: ['node_modules/', '.nuxt/', '.yarn/', '.pnp.*'] },
{ linterOptions: { reportUnusedDisableDirectives: 'error' } },
Expand Down
4 changes: 3 additions & 1 deletion fe/src/components/post/badge/TimeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const tippyCotentRelativeTo = computed(() => (props.relativeTo === undefined ||
? ''
: `${props.relativeToText}:<br>
${props.relativeTo.toLocaleString(DateTime.DATETIME_FULL_WITH_SECONDS)}<br>
相差 ${props.current.diff(props.relativeTo).rescale().toHuman()}`));
相差 ${props.current
.diff(props.relativeTo, undefined, { conversionAccuracy: 'longterm' })

Check failure on line 41 in fe/src/components/post/badge/TimeView.vue

View workflow job for this annotation

GitHub Actions / runs-on (ubuntu-latest) / eslint

Expected indentation of 8 spaces but found 12

Check failure on line 41 in fe/src/components/post/badge/TimeView.vue

View workflow job for this annotation

GitHub Actions / runs-on (windows-latest) / eslint

Expected indentation of 8 spaces but found 12

Check failure on line 41 in fe/src/components/post/badge/TimeView.vue

View workflow job for this annotation

GitHub Actions / runs-on (macos-latest) / eslint

Expected indentation of 8 spaces but found 12
.rescale().toHuman()}`));

Check failure on line 42 in fe/src/components/post/badge/TimeView.vue

View workflow job for this annotation

GitHub Actions / runs-on (ubuntu-latest) / eslint

Expected indentation of 8 spaces but found 12

Check failure on line 42 in fe/src/components/post/badge/TimeView.vue

View workflow job for this annotation

GitHub Actions / runs-on (windows-latest) / eslint

Expected indentation of 8 spaces but found 12

Check failure on line 42 in fe/src/components/post/badge/TimeView.vue

View workflow job for this annotation

GitHub Actions / runs-on (macos-latest) / eslint

Expected indentation of 8 spaces but found 12
const tippyContent = computed(() => `本${props.postType}${props.timestampType}:<br>
${hydrationStore.isHydratingOrSSR
? currentInChina.value.toLocaleString(DateTime.DATETIME_FULL_WITH_SECONDS)
Expand Down
4 changes: 3 additions & 1 deletion fe/src/stores/relativeTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export const useRelativeTimeStore = defineStore('relativeTime', () => {
});
}
const registerRelative = (dateTime: DateTime, options?: ToRelativeOptions) => computed(() => {
const relativeDuration = dateTime.diff(DateTime.now()).shiftTo(...units);
const relativeDuration = dateTime
.diff(DateTime.now(), undefined, { conversionAccuracy: 'longterm' })
.shiftTo(...units);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const { unit } = units
.map(unit => ({ unit, value: relativeDuration.get(unit) }))
Expand Down

0 comments on commit 022ade8

Please sign in to comment.