Skip to content

Commit 91d7017

Browse files
committed
chore: use ESLint V9 and fix errors
1 parent 1a5649c commit 91d7017

30 files changed

+1486
-1767
lines changed

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
shamefully-hoist=true
2+
auto-install-peers=true

.vscode/settings.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"eslint.experimental.useFlatConfig": true,
32
"cSpell.words": [
43
"astro",
54
"astrojs",
@@ -14,5 +13,11 @@
1413
"taze",
1514
"tsconfigs",
1615
"tsup"
17-
]
16+
],
17+
"editor.formatOnSave": true,
18+
"eslint.useFlatConfig": true,
19+
"editor.codeActionsOnSave": {
20+
"source.fixAll.eslint": "always",
21+
"source.fixAll.prettier": "always"
22+
}
1823
}

docs/astro.config.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { defineConfig } from 'astro/config'
2-
import { capitalize } from '@bassist/utils'
31
import react from '@astrojs/react'
42
import starlight from '@astrojs/starlight'
53
import tailwind from '@astrojs/tailwind'
4+
import { capitalize } from '@bassist/utils'
5+
import { defineConfig } from 'astro/config'
66

77
const autogenerates = {
88
reference: {

docs/src/components/AppliesTo.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Fragment, useMemo } from 'react'
2+
import { type Languages, getTranslation } from '@/i18n'
23
import pkg from '../../../package.json'
3-
import { getTranslation, type Languages } from '@/i18n'
44

55
const repoUrl = pkg.repository.url
66

@@ -24,15 +24,15 @@ export const AppliesTo: React.FC<AppliesToProps> = ({
2424
})
2525

2626
return (
27-
<blockquote className="flex items-center gap-2 w-full mt-6">
27+
<blockquote className="mt-6 flex w-full items-center gap-2">
2828
{title}
2929
<span className="flex items-center gap-3">{componentsDisplay}</span>
3030
</blockquote>
3131
)
3232
}
3333

3434
const formatGitHubIssue = (url: string) => {
35-
const pattern = /github\.com\/([^\/]+\/[^\/]+)\/issues\/(\d+)/
35+
const pattern = /github\.com\/([^/]+\/[^/]+)\/issues\/(\d+)/
3636
const match = url.match(pattern)
3737

3838
if (match) {
@@ -89,7 +89,7 @@ export const RelatedIssues: React.FC<{
8989
}, [issues])
9090

9191
return (
92-
<blockquote className="flex items-center gap-2 w-full">
92+
<blockquote className="flex w-full items-center gap-2">
9393
{title}
9494
<span className="flex items-center gap-2">{issuesDisplay}</span>
9595
</blockquote>

docs/src/components/CodeCollapser.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo, useState } from 'react'
2-
import { getTranslation, type Languages } from '@/i18n'
2+
import { type Languages, getTranslation } from '@/i18n'
33

44
export const CodeCollapser: React.FC<{
55
open?: boolean
@@ -24,7 +24,7 @@ export const CodeCollapser: React.FC<{
2424
}, [lang, open])
2525

2626
return (
27-
<details className="w-full my-6" open={open} onToggle={onToggle}>
27+
<details className="my-6 w-full" open={open} onToggle={onToggle}>
2828
<summary>{summary}</summary>
2929

3030
{children}

docs/src/components/Developer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ export const Developer: React.FC<{
77
}> = ({ avatar, name, homepage }) => {
88
return (
99
<a
10-
className="flex items-center gap-2 h-8 mt-8 mb-2 no-underline hover:underline"
10+
className="mb-2 mt-8 flex h-8 items-center gap-2 no-underline hover:underline"
1111
href={homepage}
1212
title={name}
1313
target="_blank"
1414
rel="noreferrer"
1515
>
16-
<div className="w-7 h-7 rounded-full overflow-hidden">
17-
<img className="w-full h-full object-fit" src={avatar} alt={name} />
16+
<div className="size-7 overflow-hidden rounded-full">
17+
<img className="size-full object-cover" src={avatar} alt={name} />
1818
</div>
1919

20-
<span className="text-lg font-600">{name}</span>
20+
<span className="text-lg font-[600]">{name}</span>
2121
</a>
2222
)
2323
}

docs/src/components/StatisticalData.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useMemo } from 'react'
21
import clsx from 'clsx'
2+
import React, { useMemo } from 'react'
33
import pkg from '../../../package.json'
44
import type { Languages } from '@/i18n'
55

@@ -56,7 +56,7 @@ const getContributors = async (cols = 10) => {
5656
try {
5757
const url = `https://contrib.nn.ci/api?repo=${repo}&cols=${cols}&no_bot`
5858
return await fetch(url).then((res) => res.text() || '')
59-
} catch (e) {
59+
} catch {
6060
return ''
6161
}
6262
}
@@ -99,7 +99,7 @@ export const Contributors: React.FC<{
9999
return lang === 'zh' ? '加载中...' : 'Loading…'
100100
}, [lang])
101101

102-
const cls = clsx('flex flex-wrap gap-6 w-full mt-6', {
102+
const cls = clsx('mt-6 flex w-full flex-wrap gap-6', {
103103
'<lg:justify-center': !!items.length,
104104
})
105105

@@ -117,11 +117,11 @@ export const Contributors: React.FC<{
117117
href={i.homepage}
118118
target="_blank"
119119
rel="noreferrer"
120-
className="flex flex-col items-center no-underline group"
120+
className="group flex flex-col items-center no-underline"
121121
>
122-
<div className="w-16 h-16 rounded-full overflow-hidden group-hover:opacity-70 transition-opacity">
122+
<div className="size-16 overflow-hidden rounded-full transition-opacity group-hover:opacity-70">
123123
<img
124-
className="w-full h-full object-cover"
124+
className="size-full object-cover"
125125
src={i.avatar}
126126
alt={i.username}
127127
/>

docs/src/components/examples/Widgets.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React, { useMemo } from 'react'
21
import clsx from 'clsx'
3-
import { getTranslation, type Languages, type TranslationKey } from '@/i18n'
2+
import React, { useMemo } from 'react'
3+
import { type Languages, type TranslationKey, getTranslation } from '@/i18n'
44
import {
5-
RichText,
65
ChineseRichText,
76
ChineseStringText,
8-
StringText,
9-
ShorterStringText,
7+
RichText,
108
ShorterChineseStringText,
9+
ShorterStringText,
10+
StringText,
1111
} from './Data'
1212

1313
export const DEFAULT_WIDTH_VALUE = 100
@@ -26,7 +26,7 @@ const ExampleContainer = React.forwardRef<
2626
return (
2727
<div
2828
ref={ref}
29-
className="w-full box-border p-3 bg-[var(--sl-color-gray-6)] my-6"
29+
className="my-6 box-border w-full bg-[var(--sl-color-gray-6)] p-3"
3030
style={{
3131
border:
3232
'1px solid color-mix(in srgb, var(--sl-color-gray-5), transparent 25%)',
@@ -50,14 +50,17 @@ const ExampleFormLabel: React.FC<ExampleFormLabelProps> = ({
5050
lang,
5151
labelKey,
5252
}) => {
53-
const titleCls = clsx('flex flex-shrink-0', lang === 'zh' ? 'w-24' : 'w-34')
53+
const titleCls = clsx(
54+
'flex shrink-0',
55+
lang === 'zh' ? 'w-[96px]' : 'w-[136px]',
56+
)
5457
return <span className={titleCls}>{getTranslation(lang, labelKey)}</span>
5558
}
5659

5760
const ExampleFormItem: React.FC<{
5861
children: React.ReactNode
5962
}> = ({ children }) => {
60-
return <div className="flex items-center gap-3 my-6">{children}</div>
63+
return <div className="my-6 flex items-center gap-3">{children}</div>
6164
}
6265

6366
const inputCls = 'w-100 max-w-3/4 cursor-pointer'

docs/src/components/examples/middle-truncate/ControllableMiddleTruncate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React, { useState } from 'react'
21
import { MiddleTruncate } from '@re-dev/react-truncate'
2+
import React, { useState } from 'react'
33
import {
44
DEFAULT_END_VALUE,
55
DEFAULT_HTML_VALUE,
66
DEFAULT_WIDTH_VALUE,
77
EW,
88
} from '@/components/examples/Widgets'
9-
import { useLang, type Languages } from '@/i18n'
109
import { useRefreshKey } from '@/hooks/use-refresh-key'
10+
import { type Languages, useLang } from '@/i18n'
1111

1212
export const ControllableMiddleTruncate: React.FC<{
1313
lang: Languages

docs/src/components/examples/show-more/BasicShowMore.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from 'react'
21
import { ShowMore } from '@re-dev/react-truncate'
2+
import React from 'react'
33
import { EW } from '@/components/examples/Widgets'
4-
import { useLang, type Languages } from '@/i18n'
4+
import { type Languages, useLang } from '@/i18n'
55

66
export const BasicShowMore: React.FC<{
77
lang: Languages

0 commit comments

Comments
 (0)