style: fix eslint error (#332)

This commit is contained in:
Libin YANG 2024-08-20 12:39:32 +08:00 committed by GitHub
parent 28dcd0599f
commit 4be8252ded
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 79 additions and 82 deletions

View File

@ -18,7 +18,7 @@ import {
HoverCardTrigger, HoverCardTrigger,
} from '@/components/ui/hover-card' } from '@/components/ui/hover-card'
import { codeBlockThemeOptions, colorOptions, fontFamilyOptions, fontSizeOptions, githubConfig, legendOptions, themeOptions } from '@/config' import { codeBlockThemeOptions, colorOptions, fontFamilyOptions, fontSizeOptions, legendOptions, themeOptions } from '@/config'
import { useStore } from '@/stores' import { useStore } from '@/stores'
const store = useStore() const store = useStore()

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { nextTick, ref } from 'vue' import { nextTick } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { ElNotification } from 'element-plus' import { ElNotification } from 'element-plus'
import CodeMirror from 'codemirror' import CodeMirror from 'codemirror'
@ -19,12 +19,6 @@ import {
DropdownMenuTrigger, DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu' } from '@/components/ui/dropdown-menu'
import {
HoverCard,
HoverCardContent,
HoverCardTrigger,
} from '@/components/ui/hover-card'
import { mergeCss, solveWeChatImage } from '@/utils' import { mergeCss, solveWeChatImage } from '@/utils'
import { useStore } from '@/stores' import { useStore } from '@/stores'

View File

@ -10,7 +10,7 @@ import {
import { Check } from 'lucide-vue-next' import { Check } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DropdownMenuCheckboxItemProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<DropdownMenuCheckboxItemProps & { class?: HTMLAttributes[`class`] }>()
const emits = defineEmits<DropdownMenuCheckboxItemEmits>() const emits = defineEmits<DropdownMenuCheckboxItemEmits>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
@ -30,9 +30,9 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
props.class, props.class,
)" )"
> >
<span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> <span class="absolute left-2 h-3.5 w-3.5 flex items-center justify-center">
<DropdownMenuItemIndicator> <DropdownMenuItemIndicator>
<Check class="w-4 h-4" /> <Check class="h-4 w-4" />
</DropdownMenuItemIndicator> </DropdownMenuItemIndicator>
</span> </span>
<slot /> <slot />

View File

@ -10,7 +10,7 @@ import {
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = withDefaults( const props = withDefaults(
defineProps<DropdownMenuContentProps & { class?: HTMLAttributes['class'] }>(), defineProps<DropdownMenuContentProps & { class?: HTMLAttributes[`class`] }>(),
{ {
sideOffset: 4, sideOffset: 4,
}, },

View File

@ -3,7 +3,7 @@ import { type HTMLAttributes, computed } from 'vue'
import { DropdownMenuItem, type DropdownMenuItemProps, useForwardProps } from 'radix-vue' import { DropdownMenuItem, type DropdownMenuItemProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DropdownMenuItemProps & { class?: HTMLAttributes['class'], inset?: boolean }>() const props = defineProps<DropdownMenuItemProps & { class?: HTMLAttributes[`class`], inset?: boolean }>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
const { class: _, ...delegated } = props const { class: _, ...delegated } = props

View File

@ -3,7 +3,7 @@ import { type HTMLAttributes, computed } from 'vue'
import { DropdownMenuLabel, type DropdownMenuLabelProps, useForwardProps } from 'radix-vue' import { DropdownMenuLabel, type DropdownMenuLabelProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DropdownMenuLabelProps & { class?: HTMLAttributes['class'], inset?: boolean }>() const props = defineProps<DropdownMenuLabelProps & { class?: HTMLAttributes[`class`], inset?: boolean }>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
const { class: _, ...delegated } = props const { class: _, ...delegated } = props

View File

@ -10,7 +10,7 @@ import {
import { Circle } from 'lucide-vue-next' import { Circle } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DropdownMenuRadioItemProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<DropdownMenuRadioItemProps & { class?: HTMLAttributes[`class`] }>()
const emits = defineEmits<DropdownMenuRadioItemEmits>() const emits = defineEmits<DropdownMenuRadioItemEmits>()
@ -31,7 +31,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
props.class, props.class,
)" )"
> >
<span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> <span class="absolute left-2 h-3.5 w-3.5 flex items-center justify-center">
<DropdownMenuItemIndicator> <DropdownMenuItemIndicator>
<Circle class="h-2 w-2 fill-current" /> <Circle class="h-2 w-2 fill-current" />
</DropdownMenuItemIndicator> </DropdownMenuItemIndicator>

View File

@ -7,7 +7,7 @@ import {
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DropdownMenuSeparatorProps & { const props = defineProps<DropdownMenuSeparatorProps & {
class?: HTMLAttributes['class'] class?: HTMLAttributes[`class`]
}>() }>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {

View File

@ -3,7 +3,7 @@ import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ const props = defineProps<{
class?: HTMLAttributes['class'] class?: HTMLAttributes[`class`]
}>() }>()
</script> </script>

View File

@ -8,7 +8,7 @@ import {
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DropdownMenuSubContentProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<DropdownMenuSubContentProps & { class?: HTMLAttributes[`class`] }>()
const emits = defineEmits<DropdownMenuSubContentEmits>() const emits = defineEmits<DropdownMenuSubContentEmits>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {

View File

@ -8,7 +8,7 @@ import {
import { ChevronRight } from 'lucide-vue-next' import { ChevronRight } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DropdownMenuSubTriggerProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<DropdownMenuSubTriggerProps & { class?: HTMLAttributes[`class`] }>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
const { class: _, ...delegated } = props const { class: _, ...delegated } = props

View File

@ -9,7 +9,7 @@ import {
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = withDefaults( const props = withDefaults(
defineProps<HoverCardContentProps & { class?: HTMLAttributes['class'] }>(), defineProps<HoverCardContentProps & { class?: HTMLAttributes[`class`] }>(),
{ {
sideOffset: 4, sideOffset: 4,
}, },

View File

@ -3,7 +3,7 @@ import prettier from 'prettier/standalone'
import prettierCss from 'prettier/parser-postcss' import prettierCss from 'prettier/parser-postcss'
import prettierMarkdown from 'prettier/parser-markdown' import prettierMarkdown from 'prettier/parser-markdown'
import { defaultTheme, prefix } from '@/config' import { prefix } from '@/config'
export function addPrefix(str) { export function addPrefix(str) {
return `${prefix}__${str}` return `${prefix}__${str}`
@ -323,10 +323,13 @@ export function exportHTML() {
} }
/** /**
* 生成列表字符串 * 根据数据生成 Markdown 表格
* @param {*} data 对应内容集合 *
* @param {*} rows * @param {object} options - 选项
* @param {*} cols * @param {object} options.data - 表格数据
* @param {number} options.rows - 行数
* @param {number} options.cols - 列数
* @returns {string} 生成的 Markdown 表格
*/ */
export function createTable({ data, rows, cols }) { export function createTable({ data, rows, cols }) {
let table = `` let table = ``
@ -354,8 +357,8 @@ export function toBase64(file) {
} }
export function checkImage(file) { export function checkImage(file) {
// check filename suffix // 检查文件名后缀
const isValidSuffix = /\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(file.name) const isValidSuffix = /\.(gif|jpe?g|png)$/i.test(file.name)
if (!isValidSuffix) { if (!isValidSuffix) {
return { return {
ok: false, ok: false,
@ -363,15 +366,15 @@ export function checkImage(file) {
} }
} }
// check file size // 检查文件大小
const maxSize = 10 const maxSizeMB = 10
const valid = file.size / 1024 / 1024 <= maxSize if (file.size > maxSizeMB * 1024 * 1024) {
if (!valid) {
return { return {
ok: false, ok: false,
msg: `由于公众号限制,图片大小不能超过 ${maxSize}M`, msg: `由于公众号限制,图片大小不能超过 ${maxSizeMB}M`,
} }
} }
return { ok: true } return { ok: true }
} }

View File

@ -24,7 +24,7 @@ class WxRenderer {
'font-size': this.opts.size, 'font-size': this.opts.size,
}) })
for (const ele in themeTpl.inline) { for (const ele in themeTpl.inline) {
if (themeTpl.inline.hasOwnProperty(ele)) { if (Object.prototype.hasOwnProperty.call(themeTpl.inline, ele)) {
const style = themeTpl.inline[ele] const style = themeTpl.inline[ele]
mapping[ele] = merge(themeTpl.BASE, style) mapping[ele] = merge(themeTpl.BASE, style)
} }
@ -32,7 +32,7 @@ class WxRenderer {
const base_block = merge(base, {}) const base_block = merge(base, {})
for (const ele in themeTpl.block) { for (const ele in themeTpl.block) {
if (themeTpl.block.hasOwnProperty(ele)) { if (Object.prototype.hasOwnProperty.call(themeTpl.block, ele)) {
const style = themeTpl.block[ele] const style = themeTpl.block[ele]
mapping[ele] = merge(base_block, style) mapping[ele] = merge(base_block, style)
} }
@ -151,12 +151,12 @@ class WxRenderer {
`code`, `code`,
)}>${text}</code></pre>` )}>${text}</code></pre>`
} }
renderer.codespan = (text, lang) => renderer.codespan = (text, _) =>
`<code ${getStyles(`codespan`)}>${text}</code>` `<code ${getStyles(`codespan`)}>${text}</code>`
renderer.listitem = text => renderer.listitem = text =>
`<li ${getStyles(`listitem`)}><span><%s/></span>${text}</li>` `<li ${getStyles(`listitem`)}><span><%s/></span>${text}</li>`
renderer.list = (text, ordered, start) => { renderer.list = (text, ordered, _) => {
text = text.replace(/<\/*p .*?>/g, ``).replace(/<\/*p>/g, ``) text = text.replace(/<\/*p .*?>/g, ``).replace(/<\/*p>/g, ``)
const segments = text.split(`<%s/>`) const segments = text.split(`<%s/>`)
if (!ordered) { if (!ordered) {
@ -220,7 +220,7 @@ class WxRenderer {
`<section style="padding:0 8px;"><table class="preview-table"><thead ${getStyles( `<section style="padding:0 8px;"><table class="preview-table"><thead ${getStyles(
`thead`, `thead`,
)}>${header}</thead><tbody>${body}</tbody></table></section>` )}>${header}</thead><tbody>${body}</tbody></table></section>`
renderer.tablecell = (text, flags) => renderer.tablecell = (text, _) =>
`<td ${getStyles(`td`)}>${text}</td>` `<td ${getStyles(`td`)}>${text}</td>`
renderer.hr = () => `<hr ${getStyles(`hr`)}>` renderer.hr = () => `<hr ${getStyles(`hr`)}>`
return renderer return renderer

View File

@ -1,87 +1,87 @@
const animate = require("tailwindcss-animate") const animate = require(`tailwindcss-animate`)
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
module.exports = { module.exports = {
darkMode: ["class"], darkMode: [`class`],
safelist: ["dark"], safelist: [`dark`],
prefix: "", prefix: ``,
experimental: { experimental: {
optimizeUniversalDefaults: true, optimizeUniversalDefaults: true,
}, },
content: [ content: [
'./pages/**/*.{ts,tsx,vue}', `./pages/**/*.{ts,tsx,vue}`,
'./components/**/*.{ts,tsx,vue}', `./components/**/*.{ts,tsx,vue}`,
'./app/**/*.{ts,tsx,vue}', `./app/**/*.{ts,tsx,vue}`,
'./src/**/*.{ts,tsx,vue}', `./src/**/*.{ts,tsx,vue}`,
], ],
theme: { theme: {
extend: { extend: {
colors: { colors: {
border: "hsl(var(--border))", border: `hsl(var(--border))`,
input: "hsl(var(--input))", input: `hsl(var(--input))`,
ring: "hsl(var(--ring))", ring: `hsl(var(--ring))`,
background: "hsl(var(--background))", background: `hsl(var(--background))`,
foreground: "hsl(var(--foreground))", foreground: `hsl(var(--foreground))`,
primary: { primary: {
DEFAULT: "hsl(var(--primary))", DEFAULT: `hsl(var(--primary))`,
foreground: "hsl(var(--primary-foreground))", foreground: `hsl(var(--primary-foreground))`,
}, },
secondary: { secondary: {
DEFAULT: "hsl(var(--secondary))", DEFAULT: `hsl(var(--secondary))`,
foreground: "hsl(var(--secondary-foreground))", foreground: `hsl(var(--secondary-foreground))`,
}, },
destructive: { destructive: {
DEFAULT: "hsl(var(--destructive))", DEFAULT: `hsl(var(--destructive))`,
foreground: "hsl(var(--destructive-foreground))", foreground: `hsl(var(--destructive-foreground))`,
}, },
muted: { muted: {
DEFAULT: "hsl(var(--muted))", DEFAULT: `hsl(var(--muted))`,
foreground: "hsl(var(--muted-foreground))", foreground: `hsl(var(--muted-foreground))`,
}, },
accent: { accent: {
DEFAULT: "hsl(var(--accent))", DEFAULT: `hsl(var(--accent))`,
foreground: "hsl(var(--accent-foreground))", foreground: `hsl(var(--accent-foreground))`,
}, },
popover: { popover: {
DEFAULT: "hsl(var(--popover))", DEFAULT: `hsl(var(--popover))`,
foreground: "hsl(var(--popover-foreground))", foreground: `hsl(var(--popover-foreground))`,
}, },
card: { card: {
DEFAULT: "hsl(var(--card))", DEFAULT: `hsl(var(--card))`,
foreground: "hsl(var(--card-foreground))", foreground: `hsl(var(--card-foreground))`,
}, },
}, },
borderRadius: { borderRadius: {
xl: "calc(var(--radius) + 4px)", xl: `calc(var(--radius) + 4px)`,
lg: "var(--radius)", lg: `var(--radius)`,
md: "calc(var(--radius) - 2px)", md: `calc(var(--radius) - 2px)`,
sm: "calc(var(--radius) - 4px)", sm: `calc(var(--radius) - 4px)`,
}, },
keyframes: { keyframes: {
"accordion-down": { 'accordion-down': {
from: { height: 0 }, from: { height: 0 },
to: { height: "var(--radix-accordion-content-height)" }, to: { height: `var(--radix-accordion-content-height)` },
}, },
"accordion-up": { 'accordion-up': {
from: { height: "var(--radix-accordion-content-height)" }, from: { height: `var(--radix-accordion-content-height)` },
to: { height: 0 }, to: { height: 0 },
}, },
"collapsible-down": { 'collapsible-down': {
from: { height: 0 }, from: { height: 0 },
to: { height: 'var(--radix-collapsible-content-height)' }, to: { height: `var(--radix-collapsible-content-height)` },
}, },
"collapsible-up": { 'collapsible-up': {
from: { height: 'var(--radix-collapsible-content-height)' }, from: { height: `var(--radix-collapsible-content-height)` },
to: { height: 0 }, to: { height: 0 },
}, },
}, },
animation: { animation: {
"accordion-down": "accordion-down 0.2s ease-out", 'accordion-down': `accordion-down 0.2s ease-out`,
"accordion-up": "accordion-up 0.2s ease-out", 'accordion-up': `accordion-up 0.2s ease-out`,
"collapsible-down": "collapsible-down 0.2s ease-in-out", 'collapsible-down': `collapsible-down 0.2s ease-in-out`,
"collapsible-up": "collapsible-up 0.2s ease-in-out", 'collapsible-up': `collapsible-up 0.2s ease-in-out`,
}, },
}, },
}, },