Skip to content

Commit

Permalink
fix: pass eslint (#46)
Browse files Browse the repository at this point in the history
* fix: @typescript-eslint/no-empty-object-type

* fix: vue/no-dupe-keys

* fix: use @ts-expect-error instead of @ts-ignore

* fix: irregular space

* fix: @typescript-eslint/no-empty-object-type

* fix: v-for and v-if related errors

* fix: add eslint disable for typst
  • Loading branch information
cxzlw authored Nov 29, 2024
1 parent 3090cf5 commit fa46f98
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 186 deletions.
2 changes: 2 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export default [
"@typescript-eslint/no-explicit-any": "off",
"vue/multi-word-component-names": "off",
"@typescript-eslint/no-unused-vars": "warn",
// 这条规则被类型检查器替代
"no-undef": "off",
},
},
];
23 changes: 9 additions & 14 deletions extensions/chart/src/widgets/bubbleChart.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<script setup lang="ts">
import { useSimpleChart } from '../utils/useSimpleChart.ts'
import type { LineChartOptions } from '..'
import { LineChart } from '..'
import type { LineChartOptions } from "..";
import { LineChart } from "..";
import { useSimpleChart } from "../utils/useSimpleChart.ts";
export interface BubbleChartOptions extends LineChartOptions {
}
export type BubbleChartOptions = LineChartOptions;
const props = withDefaults(defineProps<BubbleChartOptions>(), {
gridAlign: false,
})
const {
options,
} = useSimpleChart<BubbleChartOptions>(props)
});
const { options } = useSimpleChart<BubbleChartOptions>(props);
options.style ??= {}
options.style ??= {};
options.style = {
showLine: false,
animateIndex: true,
...options.style,
}
};
</script>

<template>
Expand All @@ -27,6 +24,4 @@ options.style = {
</LineChart>
</template>

<style scoped>
</style>
<style scoped></style>
23 changes: 9 additions & 14 deletions extensions/chart/src/widgets/scatterChart.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<script setup lang="ts">
import { useSimpleChart } from '../utils/useSimpleChart.ts'
import type { LineChartOptions } from '..'
import { LineChart } from '..'
import type { LineChartOptions } from "..";
import { LineChart } from "..";
import { useSimpleChart } from "../utils/useSimpleChart.ts";
export interface ScatterChartOptions extends LineChartOptions {
}
export type ScatterChartOptions = LineChartOptions;
const props = withDefaults(defineProps<ScatterChartOptions>(), {
gridAlign: false,
})
const {
options,
} = useSimpleChart<ScatterChartOptions>(props)
});
const { options } = useSimpleChart<ScatterChartOptions>(props);
options.style ??= {}
options.style ??= {};
options.style = {
showLine: false,
animateIndex: true,
...options.style,
}
};
</script>

<template>
Expand All @@ -27,6 +24,4 @@ options.style = {
</LineChart>
</template>

<style scoped>
</style>
<style scoped></style>
43 changes: 21 additions & 22 deletions extensions/geometry/src/dot.vue
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
<script setup lang="ts">
import { defineWidget } from '@vue-motion/core'
import { type FigureOptions, figure } from '@vue-motion/lib'
import { computed, defineProps } from 'vue'
import { Arc, Text } from '@vue-motion/lib'
import { defineWidget } from "@vue-motion/core";
import { Arc, type FigureOptions, Text, figure } from "@vue-motion/lib";
import { computed, defineProps } from "vue";
export interface DotOptions extends FigureOptions {
size?: number
tag?: string | null
position?: 'left' | 'right' | 'top' | 'bottom' | [number, number]
size?: number;
tag?: string | null;
position?: "left" | "right" | "top" | "bottom" | [number, number];
}
const props = defineProps<DotOptions>()
const options = defineWidget<DotOptions>(props)
const props = defineProps<DotOptions>();
const options = defineWidget<DotOptions>(props);
const position = computed(() => {
const _position = computed(() => {
if (Array.isArray(options.position)) {
return options.position
return options.position;
}
if (options.position === 'left') {
return [-(options.size ?? 20), 0]
if (options.position === "left") {
return [-(options.size ?? 20), 0];
}
if (options.position === 'right') {
return [options.size ?? 20, 0]
if (options.position === "right") {
return [options.size ?? 20, 0];
}
if (options.position === 'top') {
return [0, -(options.size ?? 20)]
if (options.position === "top") {
return [0, -(options.size ?? 20)];
}
if (options.position === 'bottom') {
return [0, options.size ?? 20]
if (options.position === "bottom") {
return [0, options.size ?? 20];
}
return [0, -(options.size ?? 20)]
})
return [0, -(options.size ?? 20)];
});
</script>

<template>
<g v-bind="figure(options)">
<Arc :radius="(options.size ?? 20) / 2" />
<Text v-if="options.tag" :x="position[0]" :y="position[1]">
<Text v-if="options.tag" :x="_position[0]" :y="_position[1]">
{{ options.tag }}
</Text>
</g>
Expand Down
6 changes: 3 additions & 3 deletions extensions/layout/src/container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const children = useChildren();
const mountedFlag = ref(false);
const width: ComputedRef<number> = computed(() => {
const _width: ComputedRef<number> = computed(() => {
if (!mountedFlag.value) return 0;
if (options.width) return options.width;
const counter: number[] = [];
Expand All @@ -39,7 +39,7 @@ const width: ComputedRef<number> = computed(() => {
});
return Math.max(...counter);
});
const height: ComputedRef<number> = computed(() => {
const _height: ComputedRef<number> = computed(() => {
if (!mountedFlag.value) return 0;
if (options.height) return options.height;
const counter: number[] = [];
Expand Down Expand Up @@ -94,7 +94,7 @@ const paddingRight = computed(
height: `${height}px`,
}"
>
<g :transform="`translate(${width / 2}, ${height / 2})`">
<g :transform="`translate(${_width / 2}, ${_height / 2})`">
<slot />
</g>
</svg>
Expand Down
6 changes: 3 additions & 3 deletions extensions/math/src/math-function.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { defineWidget } from "@vue-motion/core";
import type { FigureOptions, Growable } from "@vue-motion/lib";
import { Path, figure } from "@vue-motion/lib";
import { defineWidget } from "@vue-motion/core";
import { ref, watch } from "vue";
// import type { MathFunction } from './math-function'
export interface MathFunctionOptions extends FigureOptions, Growable {
Expand Down Expand Up @@ -38,7 +38,7 @@ function generateSvgPath(
for (let x = xMin; x <= xMax; x += step) {
const y = mathFunc(x);
// Convert the values ​​of a mathematical function to SVG coordinates
// Convert the values of a mathematical function to SVG coordinates
const svgX = (x - xMin) * scaleX;
const svgY = (yMax - y) * scaleY; // Invert the y-axis to conform to the SVG coordinate system
Expand Down
92 changes: 65 additions & 27 deletions extensions/math/src/number-axis.vue
Original file line number Diff line number Diff line change
@@ -1,49 +1,75 @@
<script setup lang="ts">
import { Line, Polygon, Text, widget } from '@vue-motion/lib'
import { defineWidget } from '@vue-motion/core'
import type { Growable, WidgetOptions } from '@vue-motion/lib'
import { defineWidget } from "@vue-motion/core";
import type { Growable, WidgetOptions } from "@vue-motion/lib";
import { Line, Polygon, Text, widget } from "@vue-motion/lib";
export interface NumberAxisOptions extends WidgetOptions, Growable {
baseUnit?: 'number' | 'radian' | 'degree'
interval?: number
trend?: (count: number) => string
tip?: string // Arrow tip color or 'none'
trim?: string // Arrow trim color or 'none'
fontColor?: string // Font color
fontSize?: number // Font size
domain: [number, number]
baseUnit?: "number" | "radian" | "degree";
interval?: number;
trend?: (count: number) => string;
tip?: string; // Arrow tip color or 'none'
trim?: string; // Arrow trim color or 'none'
fontColor?: string; // Font color
fontSize?: number; // Font size
domain: [number, number];
}
const props = defineProps<NumberAxisOptions>()
const options = defineWidget<NumberAxisOptions>(props)
const props = defineProps<NumberAxisOptions>();
const options = defineWidget<NumberAxisOptions>(props);
function getIntervalOrDefault(interval?: number): number {
return interval ?? 100
return interval ?? 100;
}
function getProgressOrDefault(progress?: number): number {
return progress ?? 1
return progress ?? 1;
}
</script>

<template>
<g v-if="options.baseUnit === 'radian'" v-bind="widget(options)">
<Line
:from="[options.domain[0] * getIntervalOrDefault(options.interval) * getProgressOrDefault(options.progress), 0]"
:to="[options.domain[1] * getIntervalOrDefault(options.interval) * getProgressOrDefault(options.progress), 0]"
:from="[
options.domain[0] *
getIntervalOrDefault(options.interval) *
getProgressOrDefault(options.progress),
0,
]"
:to="[
options.domain[1] *
getIntervalOrDefault(options.interval) *
getProgressOrDefault(options.progress),
0,
]"
:border-color="options.trim ?? 'white'"
/>
<Line
v-for="i in Math.floor(Math.abs(options.domain[1] - options.domain[0]) / Math.PI * 2)"
:from="[(i + 1) * (options.interval ?? Math.PI * 50), -10]" :to="[(i + 1) * (options.interval ?? Math.PI * 50), 10]"
:border-color="trim ?? 'white'" :x="(options.domain[0] - 1) * (options.interval ?? Math.PI * 50)"
v-for="i in Math.floor(
(Math.abs(options.domain[1] - options.domain[0]) / Math.PI) * 2,
)"
:key="i"
:from="[(i + 1) * (options.interval ?? Math.PI * 50), -10]"
:to="[(i + 1) * (options.interval ?? Math.PI * 50), 10]"
:border-color="trim ?? 'white'"
:x="(options.domain[0] - 1) * (options.interval ?? Math.PI * 50)"
/>
<Text
v-for="i in Math.floor(Math.abs(options.domain[1] - options.domain[0]) / Math.PI * 2)" border-color="none"
:fill-color="options.fontColor ?? 'white'" :x="(options.domain[0] + i) * (options.interval ?? Math.PI * 50)" :y="20"
:rotation="-(options.rotation ?? 0)" align="start" :font-size="20"
v-for="i in Math.floor(
(Math.abs(options.domain[1] - options.domain[0]) / Math.PI) * 2,
)"
:key="i"
border-color="none"
:fill-color="options.fontColor ?? 'white'"
:x="(options.domain[0] + i) * (options.interval ?? Math.PI * 50)"
:y="20"
:rotation="-(options.rotation ?? 0)"
align="start"
:font-size="20"
>
{{ (options.trend ?? (x => (x).toString()))((i + options.domain[0]) / 2) }} π
{{
(options.trend ?? ((x) => x.toString()))((i + options.domain[0]) / 2)
}}
π
</Text>
<Polygon
:points="[
Expand All @@ -60,19 +86,31 @@ function getProgressOrDefault(progress?: number): number {
<!-- ToDo: Add support for degree -->
<g v-else v-bind="widget(options)">
<Line
:from="[options.domain[0] * getIntervalOrDefault(options.interval) * getProgressOrDefault(options.progress), 0]"
:to="[options.domain[1] * getIntervalOrDefault(options.interval) * getProgressOrDefault(options.progress), 0]"
:from="[
options.domain[0] *
getIntervalOrDefault(options.interval) *
getProgressOrDefault(options.progress),
0,
]"
:to="[
options.domain[1] *
getIntervalOrDefault(options.interval) *
getProgressOrDefault(options.progress),
0,
]"
:border-color="options.trim ?? 'white'"
/>
<Line
v-for="i in Math.abs(options.domain[1] - options.domain[0])"
:key="i"
:from="[(i + 1) * getIntervalOrDefault(options.interval), -10]"
:to="[(i + 1) * getIntervalOrDefault(options.interval), 10]"
:border-color="options.trim ?? 'white'"
:x="(options.domain[0] - 1) * getIntervalOrDefault(options.interval)"
/>
<Text
v-for="i in Math.abs(options.domain[1] - options.domain[0] + 1)"
:key="i"
border-color="none"
:fill-color="options.fontColor ?? 'white'"
:x="(options.domain[0] + i - 1) * getIntervalOrDefault(options.interval)"
Expand All @@ -81,7 +119,7 @@ function getProgressOrDefault(progress?: number): number {
align="start"
:font-size="20"
>
{{ (options.trend ?? (x => x.toString()))(i + options.domain[0] - 1) }}
{{ (options.trend ?? ((x) => x.toString()))(i + options.domain[0] - 1) }}
</Text>
<Polygon
:points="[
Expand Down
Loading

0 comments on commit fa46f98

Please sign in to comment.