Skip to content

Commit c895ed1

Browse files
committed
refactor: 🎨 使用 oxlint
1 parent cc0c588 commit c895ed1

186 files changed

Lines changed: 3163 additions & 1750 deletions

File tree

Some content is hidden

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

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**/dist/**
2+
**/public/**
3+
**/dev-dist/**
4+
**/assets/**
5+
*.user.js

.github/workflows/docs.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: updateDocsPage
33
on:
44
push:
55
paths:
6-
- "**.md"
6+
- '**.md'
77

88
jobs:
99
deploy:
@@ -27,7 +27,7 @@ jobs:
2727
uses: actions/setup-node@v4
2828
with:
2929
node-version: 20
30-
cache: "pnpm"
30+
cache: 'pnpm'
3131

3232
- name: Install dependencies
3333
run: pnpm install --no-frozen-lockfile
@@ -40,6 +40,6 @@ jobs:
4040
with:
4141
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
4242
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
43-
projectName: "comic-read-docs"
44-
directory: "docs/.vitepress/dist"
43+
projectName: 'comic-read-docs'
44+
directory: 'docs/.vitepress/dist'
4545
branch: main

.github/workflows/pages-deployment.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: actions/setup-node@v4
2525
with:
2626
node-version: 20
27-
cache: "pnpm"
27+
cache: 'pnpm'
2828

2929
- name: Install dependencies
3030
run: pnpm install --no-frozen-lockfile
@@ -37,6 +37,6 @@ jobs:
3737
with:
3838
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
3939
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
40-
projectName: "comic-read"
41-
directory: "src/pwa/dist"
40+
projectName: 'comic-read'
41+
directory: 'src/pwa/dist'
4242
branch: main

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Checkout
1414
uses: actions/checkout@v4
1515
with:
16-
ref: "master"
16+
ref: 'master'
1717
- name: Release
1818
uses: softprops/action-gh-release@v1
1919
with:

.oxlintrc.json

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": [
4+
"oxc",
5+
"typescript",
6+
"promise",
7+
"unicorn",
8+
"import",
9+
"jsdoc",
10+
"vitest"
11+
],
12+
"categories": {
13+
"correctness": "error",
14+
"suspicious": "error",
15+
"pedantic": "error",
16+
"perf": "error",
17+
"style": "warn"
18+
},
19+
"env": {
20+
"builtin": true
21+
},
22+
// 有 bug,只能使用 .eslintignore 来禁用,暂时注释
23+
// "ignorePatterns": [
24+
// "**/dist/**",
25+
// "**/public/**",
26+
// "**/dev-dist/**",
27+
// "*.user.js"
28+
// ],
29+
"rules": {
30+
// 目前不支持跳过 return new Promise 的,只能暂时关掉
31+
"require-await": "off",
32+
33+
// 和 eslint 冲突的
34+
"no-duplicate-imports": "off",
35+
36+
// 新增的
37+
"curly": "off",
38+
"id-length": "off",
39+
"promise/avoid-new": "off",
40+
"init-declarations": "off",
41+
"func-names": ["error", "as-needed"],
42+
"yoda": ["error", { "always": true }],
43+
"new-cap": ["error", { "capIsNew": false }],
44+
45+
"max-lines": "off",
46+
"max-depth": "off",
47+
"max-params": "off",
48+
"max-classes-per-file": "off",
49+
"max-lines-per-function": "off",
50+
51+
"no-ternary": "off",
52+
"no-debugger": "off",
53+
"no-continue": "off",
54+
"no-script-url": "off",
55+
"no-magic-numbers": "off",
56+
"no-await-in-loop": "off",
57+
"no-console": ["warn", { "allow": ["warn", "error"] }],
58+
"no-unused-vars": ["warn", { "args": "all", "argsIgnorePattern": "^_" }],
59+
60+
"sort-keys": "off",
61+
"sort-vars": "off",
62+
"sort-imports": "off",
63+
64+
"import/extensions": "off",
65+
"import/consistent-type-specifier-style": "off",
66+
"import/exports-last": "off",
67+
"import/group-exports": "off",
68+
"import/prefer-default-export": "off",
69+
"import/max-dependencies": "off",
70+
"import/no-namespace": "off",
71+
"import/no-unassigned-import": "off",
72+
"import/no-anonymous-default-export": "off",
73+
"import/no-named-as-default": "off",
74+
75+
"jsdoc/require-param": "off",
76+
"jsdoc/require-returns": "off",
77+
"jsdoc/require-param-type": "off",
78+
"jsdoc/require-returns-type": "off",
79+
"jsdoc/check-tag-names": "off",
80+
81+
"unicorn/consistent-function-scoping": "off",
82+
"unicorn/filename-case": "off",
83+
"unicorn/switch-case-braces": "off",
84+
"unicorn/prefer-query-selector": "off",
85+
"unicorn/prefer-global-this": "off",
86+
"unicorn/prefer-add-event-listener": "off",
87+
"unicorn/no-null": "off",
88+
"unicorn/no-useless-undefined": "off",
89+
"unicorn/no-anonymous-default-export": "off",
90+
"unicorn/no-unreadable-array-destructuring": "off",
91+
"unicorn/no-negation-in-equality-check": "off",
92+
93+
"typescript/consistent-indexed-object-style": "error",
94+
"typescript/prefer-as-const": "error",
95+
"typescript/consistent-type-definitions": ["warn", "type"],
96+
"typescript/consistent-type-imports": [
97+
"error",
98+
{ "disallowTypeAnnotations": false }
99+
],
100+
101+
"promise/prefer-await-to-callbacks": "off",
102+
"promise/prefer-await-to-then": "off",
103+
104+
"jest/require-hook": "off",
105+
"jest/prefer-lowercase-title": "off",
106+
"jest/require-top-level-describe": "off",
107+
"jest/no-hooks": "off",
108+
"jest/no-standalone-expect": "off",
109+
"jest/no-conditional-in-test": "off",
110+
"jest/consistent-test-it": [
111+
"error",
112+
{ "fn": "it", "withinDescribe": "it" }
113+
],
114+
115+
"no-restricted-imports": [
116+
"warn",
117+
{
118+
"patterns": [
119+
{
120+
"group": ["helper/**/*", "!helper/languages"],
121+
"message": "只能直接通过 helper 导入"
122+
},
123+
{
124+
"group": ["**/request", "!request"],
125+
"message": "必须直接导入"
126+
}
127+
]
128+
}
129+
]
130+
},
131+
"overrides": [
132+
{
133+
"files": ["src/site/**/*"],
134+
"rules": {
135+
"no-restricted-imports": [
136+
"warn",
137+
{
138+
"patterns": [
139+
{
140+
"group": [
141+
"*/**/*",
142+
"!solid-js/**/*",
143+
"!components/**/*",
144+
"!userscript/**/*",
145+
"!@material*/**/*",
146+
"../**/*",
147+
"!.*/**/*"
148+
],
149+
"message": "只能通过 main 导入"
150+
}
151+
]
152+
}
153+
]
154+
}
155+
}
156+
]
157+
}

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**/*.md
2+
**/*.yaml
3+
**/*.yml
4+
**/*.json5
5+
**/public/*
6+
*.user.js

.prettierrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"useTabs": false,
33
"bracketSpacing": true,
4-
"singleQuote": true
4+
"singleQuote": true,
5+
"plugins": ["@prettier/plugin-oxc"]
56
}

.storybook/main.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import type { StorybookConfig } from "storybook-solidjs-vite";
2-
3-
const config: StorybookConfig = {
4-
stories: ["../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
5-
staticDirs: ['../src/stories/public'],
6-
framework: "storybook-solidjs-vite",
7-
addons: ['@vueless/storybook-dark-mode', "@storybook/addon-docs"],
8-
core: {
9-
disableTelemetry: true,
10-
disableWhatsNewNotifications: true,
11-
enableCrashReports: false,
12-
},
13-
};
14-
export default config;
1+
import type { StorybookConfig } from 'storybook-solidjs-vite';
2+
3+
const config: StorybookConfig = {
4+
stories: ['../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
5+
staticDirs: ['../src/stories/public'],
6+
framework: 'storybook-solidjs-vite',
7+
addons: ['@vueless/storybook-dark-mode', '@storybook/addon-docs'],
8+
core: {
9+
disableTelemetry: true,
10+
disableWhatsNewNotifications: true,
11+
enableCrashReports: false,
12+
},
13+
};
14+
export default config;

.storybook/preview.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { type Preview } from 'storybook-solidjs-vite';
2-
import { INITIAL_VIEWPORTS } from 'storybook/viewport';
3-
4-
import './global.css';
5-
import 'normalize.css';
6-
7-
const preview: Preview = {
8-
parameters: {
9-
viewport: { viewports: INITIAL_VIEWPORTS },
10-
controls: { disableSaveFromUI: true },
11-
},
12-
};
13-
14-
export default preview;
1+
import type { Preview } from 'storybook-solidjs-vite';
2+
3+
import { INITIAL_VIEWPORTS } from 'storybook/viewport';
4+
5+
import './global.css';
6+
import 'normalize.css';
7+
8+
const preview: Preview = {
9+
parameters: {
10+
viewport: { viewports: INITIAL_VIEWPORTS },
11+
controls: { disableSaveFromUI: true },
12+
},
13+
};
14+
15+
export default preview;

.storybook/test-runner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { waitForPageReady, type TestRunnerConfig } from '@storybook/test-runner';
1+
import type { TestRunnerConfig } from '@storybook/test-runner';
2+
23
import percySnapshot from '@percy/playwright';
4+
import { waitForPageReady } from '@storybook/test-runner';
35

46
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
57

0 commit comments

Comments
 (0)