Skip to content

Commit 93091e2

Browse files
committed
重构 ESLint 配置,删除旧的 CommonJS 格式文件,新增 ES 模块格式的配置文件。更新相关依赖,调整 TypeScript 和 React 的 ESLint 规则,确保兼容性和最佳实践。
1 parent 3f12d33 commit 93091e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5144
-5333
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 5 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import base from './src/eslint/base.mjs'
2+
3+
export default [
4+
...base,
5+
6+
{
7+
ignores: ['src/eslint-legacy/**', 'examples/**'],
8+
},
9+
]

examples/green-wall/.eslintrc.cjs

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/green-wall/eslint.config.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { TYPESCRIPT_FILES } from 'prefer-code-style/constants'
2+
import nextConfig from 'prefer-code-style/eslint/preset/next'
3+
4+
export default [
5+
...nextConfig,
6+
7+
{
8+
files: TYPESCRIPT_FILES,
9+
rules: {
10+
'import/no-unresolved': [2, { ignore: ['^\\~/'] }],
11+
},
12+
},
13+
]

examples/green-wall/plugins/script.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ if (isProfile) {
123123
let td = '<td></td>'
124124

125125
if (col.level !== ContributionLevel.Null) {
126-
const level =
127-
col.level === ContributionLevel.NONE
126+
const level
127+
= col.level === ContributionLevel.NONE
128128
? 0
129129
: col.level === ContributionLevel.FIRST_QUARTILE
130130
? 1
@@ -339,7 +339,6 @@ if (isProfile) {
339339
retryBtn.classList.add('btn')
340340
retryBtn.textContent = 'Retry'
341341
retryBtn.addEventListener('click', () => {
342-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
343342
handleLoadData()
344343
})
345344

examples/green-wall/src/app/about/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ export default function AboutPage() {
7979
<SectionTitle>Reporting issues</SectionTitle>
8080
<Paragraph>
8181
Got bugs or have any suggestions for this project? Welcome to leave your message on the{' '}
82-
<TextLink passHref href="https://github.com/Codennnn/Green-Wall/issues" target="_blank">
82+
<TextLink
83+
passHref
84+
href="https://github.com/Codennnn/Green-Wall/issues"
85+
target="_blank"
86+
>
8387
GitHub issues.
8488
</TextLink>
8589
</Paragraph>

examples/green-wall/src/app/share/[username]/SharePage.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use client'
22

3-
import { useEffect, useMemo } from 'react'
4-
53
import Image from 'next/image'
64
import Link from 'next/link'
75
import { useParams, useSearchParams } from 'next/navigation'
6+
import { useEffect, useMemo } from 'react'
87

98
import { ContributionsGraph } from '~/components/ContributionsGraph'
109
import { ErrorMessage } from '~/components/ErrorMessage'

examples/green-wall/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export const sizeProperties = {
3737
>
3838

3939
export const DEFAULT_SIZE: GraphSize = GraphSize.Small
40+
4041
export const DEFAULT_THEME: Themes = 'GitHub'
42+
4143
export const DEFAULT_DISPLAY_NAME: DisplayName = DisplayName.Username
4244

4345
export const THEMES = [

examples/green-wall/src/services.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ export async function fetchGitHubUser(username: string): Promise<ContributionBas
4040
throw new Error(`fetch error: ${res.statusText}.`)
4141
}
4242

43-
const json: GitHubApiJson<{ user: GitHubUser | null }> = await res.json()
43+
const json = await res.json() as GitHubApiJson<{ user: GitHubUser | null }>
4444

4545
if (!json.data?.user) {
4646
if (json.errors) {
4747
const error = json.errors.at(0)
48+
4849
if (error) {
4950
throw new Error(error.message)
5051
}
5152
}
53+
5254
throw new Error(json.message)
5355
}
5456

@@ -100,7 +102,7 @@ export async function fetchContributionsCollection(
100102
throw new Error(`fetch error: ${res.statusText}.`)
101103
}
102104

103-
const json: GitHubApiJson<{ user: GitHubContributionCalendar | null }> = await res.json()
105+
const json = await res.json() as GitHubApiJson<{ user: GitHubContributionCalendar | null }>
104106

105107
if (!json.data?.user) {
106108
throw new Error(json.message)

examples/green-wall/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface Theme {
2424
}
2525

2626
export type GitHubUsername = string
27+
2728
export type ContributionYear = number
2829

2930
export interface GitHubUser {
@@ -82,5 +83,5 @@ export interface GraphSettings {
8283
export interface GitHubApiJson<Data> {
8384
data?: Data
8485
message?: string
85-
errors?: { type: string; message: string }[]
86+
errors?: { type: string, message: string }[]
8687
}

0 commit comments

Comments
 (0)