Skip to content

Commit e42c58c

Browse files
committed
chore: 修正构建,降级 eslint@8
1 parent 4b39c4f commit e42c58c

21 files changed

+850
-1677
lines changed

.npmrc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
engine-strict=true
1+
# @file .npmrc
2+
23
#registry=https://registry.npmmirror.com
34
registry=https://registry.npmjs.org
5+
6+
# https://docs.npmjs.com/cli/v10/using-npm/config#engine-strict
7+
engine-strict=true
8+
9+
# https://pnpm.io/cli/add#--ignore-workspace-root-check
10+
ignore-workspace-root-check=true
11+
12+
# https://pnpm.io/npmrc#link-workspace-packages
413
link-workspace-packages=true
14+
15+
# https://pnpm.io/npmrc#shamefully-hoist
16+
shamefully-hoist=true

.prettierignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ yarn.lock
3636
# testing
3737
/coverage
3838

39-
# project
40-
/test/example-dest
39+
# release-please
40+
.release-please-manifest.json

docs/src/App.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import classNames from 'classnames';
2-
import type { PropsWithChildren } from 'react';
2+
import { useEffect, useState, type PropsWithChildren } from 'react';
33
import { NavLink, useRoutes } from 'react-router-dom';
44
import { routes } from 'virtual:react-pages';
55
import SvgIcon from './icons/SvgIcon';
66

7-
function A({ children, to }: PropsWithChildren<{ to: string }>) {
7+
export function A({ children, to }: PropsWithChildren<{ to: string }>) {
88
return (
99
<NavLink
1010
className={({ isActive }) =>
@@ -13,7 +13,8 @@ function A({ children, to }: PropsWithChildren<{ to: string }>) {
1313
'bg-gray-6! text-gray-1!': isActive,
1414
},
1515
'text-4 text-gray-7 decoration-none rounded-1 px-4 py-2 flex items-center hover:bg-gray-2 transition-background-color duration-300',
16-
)}
16+
)
17+
}
1718
to={to}
1819
>
1920
{children}

docs/src/dts/process.env.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ namespace NodeJS {
1717
* Github deploy action
1818
*/
1919
VITE_APP_BASENAME?: string;
20-
2120
}
2221
}

docs/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { StrictMode } from 'react';
1+
import { StrictMode, useState } from 'react';
22
import ReactDOM from 'react-dom/client';
33
import { HashRouter } from 'react-router-dom';
44
import './main.scss';

docs/src/pages/(docs)/layout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function Layout() {
5050
<div>
5151
<aside className="fixed">
5252
<div className="w-150px flex flex-col gap-2 text-14px">
53-
{navs.map(nav => (
53+
{navs.map((nav) => (
5454
<NavLink
5555
key={nav.label}
5656
className={({ isActive }) =>
@@ -59,7 +59,8 @@ export default function Layout() {
5959
'bg-gray-6! text-gray-1!': location.pathname === nav.href || (nav.href !== '/docs' && isActive),
6060
},
6161
'bg-transparent text-gray-6 hover:bg-gray-2 block decoration-none rounded-1 px-3 py-2',
62-
)}
62+
)
63+
}
6364
to={nav.href}
6465
>
6566
{nav.label}

docs/vite.config.mts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ export default defineConfig({
5151
removeScriptTypeAttributes: true,
5252
removeStyleLinkTypeAttributes: true,
5353
}),
54-
// eslint-disable-next-line ts/ban-ts-comment
55-
// @ts-ignore
5654
reactPages.vite({
5755
debug: true,
5856
logLevel: 'info',

eslint.config.mjs

Lines changed: 106 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,109 @@
33
* @ref https://eslint.org/
44
*/
55

6-
import { antfu } from '@antfu/eslint-config';
7-
import imp from 'eslint-plugin-import-x';
8-
9-
export default antfu({
10-
type: 'lib',
11-
ignores: [
12-
'**/dist/**',
13-
'**/dist-*/**',
14-
],
15-
files: [
16-
'**/.*.{js,cjs,mjs}',
17-
'**/*.{js,mjs,cjs,ts,mts,jsx,tsx}',
18-
],
19-
stylistic: {
20-
semi: true,
21-
},
22-
typescript: {
23-
overrides: {
24-
// 不必要显式返回类型
25-
// @ref https://typescript-eslint.io/rules/explicit-function-return-type/
26-
'ts/explicit-function-return-type': ['off'],
27-
},
28-
},
29-
react: true,
30-
unocss: true,
31-
rules: {
32-
...imp.configs.recommended.rules,
33-
...imp.configs.typescript.rules,
34-
// 忽略 virtual: 开头的 import
35-
// @ref https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md
36-
'import/no-unresolved': ['error', { ignore: ['^virtual:'] }],
37-
// 不必要求如何使用 process
38-
// @ref https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/process.md
39-
'node/prefer-global/process': ['off'],
40-
},
41-
settings: {
42-
// 支持在 typeScript 解析 import
43-
// @ref https://github.com/un-ts/eslint-plugin-import-x?tab=readme-ov-file#typescript
44-
'import-x/resolver': {
45-
typescript: true,
46-
},
47-
},
48-
});
6+
import javaScript from '@eslint/js';
7+
import typeScript from 'typescript-eslint';
8+
import tsParser from '@typescript-eslint/parser';
9+
import react from 'eslint-plugin-react';
10+
import reactHooks from 'eslint-plugin-react-hooks';
11+
import reactRefresh from 'eslint-plugin-react-refresh';
12+
import importX from 'eslint-plugin-import-x';
13+
import globals from 'globals';
14+
import uno from '@unocss/eslint-plugin';
15+
import prettierRecommended from 'eslint-plugin-prettier/recommended';
16+
import prettierConfig from 'eslint-config-prettier';
17+
18+
export default typeScript.config(
19+
{
20+
ignores: ['**/.{git,idea,vscode,husky}/**', '**/dist/**', '**/dist-*/**', '**/coverage/**'],
21+
},
22+
23+
// import
24+
{
25+
plugins: {
26+
'import-x': importX,
27+
},
28+
rules: {
29+
...importX.configs.recommended.rules,
30+
...importX.configs.typescript.rules,
31+
32+
// 忽略 virtual: 开头的 import
33+
// @ref https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md
34+
'import-x/no-unresolved': ['error', { ignore: ['^virtual:'] }],
35+
},
36+
settings: {
37+
// 支持在 typeScript 解析 import
38+
// @ref https://github.com/un-ts/eslint-plugin-import-x?tab=readme-ov-file#typescript
39+
'import-x/resolver': {
40+
typescript: true,
41+
},
42+
},
43+
},
44+
45+
// js
46+
javaScript.configs.recommended,
47+
{
48+
rules: {
49+
'no-unused-vars': ['off'],
50+
},
51+
},
52+
53+
// ts
54+
...typeScript.configs.recommended,
55+
...typeScript.configs.recommendedTypeChecked,
56+
{
57+
languageOptions: {
58+
parser: tsParser,
59+
parserOptions: {
60+
project: true,
61+
tsconfigRootDir: import.meta.dirname,
62+
},
63+
},
64+
rules: {
65+
'@typescript-eslint/no-unused-vars': 'off',
66+
},
67+
},
68+
{
69+
files: ['**/*.{js,cjs,mjs,jsx}'],
70+
...typeScript.configs.disableTypeChecked,
71+
},
72+
73+
// react
74+
{
75+
files: ['**/*.{jsx,tsx}'],
76+
plugins: {
77+
react,
78+
'react-hooks': reactHooks,
79+
'react-refresh': reactRefresh,
80+
},
81+
settings: {
82+
react: {
83+
version: 'detect',
84+
},
85+
},
86+
rules: {
87+
...react.configs.recommended.rules,
88+
...reactHooks.configs.recommended.rules,
89+
'react/react-in-jsx-scope': 'off',
90+
},
91+
},
92+
93+
// uno
94+
uno.configs.flat,
95+
{
96+
files: ['**/*.{jsx,tsx}'],
97+
},
98+
99+
// prettier
100+
prettierRecommended,
101+
prettierConfig,
102+
103+
{
104+
languageOptions: {
105+
globals: {
106+
...globals.node,
107+
...globals.browser,
108+
},
109+
},
110+
},
111+
);

lint-staged.config.mjs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,13 @@
33
* @ref https://www.npmjs.com/package/lint-staged
44
*/
55
export default {
6-
'*.{js,mjs,cjs,ts,mts,jsx,tsx}': [
7-
'eslint --fix',
8-
],
6+
'*.{js,mjs,cjs,ts,mts,jsx,tsx}': ['eslint --fix'],
97

10-
'*.vue': [
11-
'eslint --fix',
12-
],
8+
'*.vue': ['eslint --fix'],
139

14-
'*.{css,scss}': [
15-
'stylelint --fix --allow-empty-input',
16-
],
10+
'*.{css,scss}': ['stylelint --fix --allow-empty-input'],
1711

18-
'!(package-lock).json': [
19-
'prettier --write',
20-
],
12+
'!(package-lock).json': ['prettier --write'],
2113

22-
'!(pnpm-lock).{yml,yaml}': [
23-
'prettier --write',
24-
],
14+
'!(pnpm-lock).{yml,yaml}': ['prettier --write'],
2515
};

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,30 @@
7070
"lodash-es": "^4.17.21",
7171
"unplugin": "^1.12.0"
7272
},
73+
"optionalDependencies": {
74+
"fsevents": "*"
75+
},
7376
"devDependencies": {
74-
"@antfu/eslint-config": "^2.23.2",
7577
"@commitlint/cli": "^19.3.0",
7678
"@commitlint/config-conventional": "^19.2.2",
7779
"@commitlint/types": "^19.0.3",
80+
"@eslint/js": "^9.8.0",
7881
"@types/lodash-es": "^4.17.12",
7982
"@types/node": "20",
8083
"@types/react": "^18.3.3",
84+
"@typescript-eslint/eslint-plugin": "^7.17.0",
85+
"@typescript-eslint/parser": "^7.17.0",
8186
"@unocss/eslint-plugin": "^0.61.6",
8287
"@vitest/coverage-v8": "^2.0.4",
83-
"eslint": "^9.8.0",
88+
"eslint": "^8.57.0",
89+
"eslint-config-prettier": "^9.1.0",
8490
"eslint-import-resolver-typescript": "^3.6.1",
8591
"eslint-plugin-import-x": "^3.1.0",
92+
"eslint-plugin-prettier": "^5.2.1",
93+
"eslint-plugin-react": "^7.35.0",
94+
"eslint-plugin-react-hooks": "^4.6.2",
95+
"eslint-plugin-react-refresh": "^0.4.9",
96+
"globals": "^15.8.0",
8697
"husky": "^9.1.3",
8798
"lint-staged": "^15.2.7",
8899
"prettier": "^3.3.3",
@@ -95,6 +106,7 @@
95106
"stylelint-config-recommended-scss": "^14.1.0",
96107
"stylelint-prettier": "^5.0.2",
97108
"typescript": "^5.5.4",
109+
"typescript-eslint": "^7.17.0",
98110
"unocss": "^0.61.6",
99111
"vite": "^5.3.5",
100112
"vite-plugin-dts": "^3.9.1",

0 commit comments

Comments
 (0)