Skip to content

Commit bbd55e5

Browse files
committed
refactor: 适应新版prettier配置
1 parent 6d8793b commit bbd55e5

File tree

234 files changed

+1428
-1555
lines changed

Some content is hidden

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

234 files changed

+1428
-1555
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
- 'package.json'
99

1010
jobs:
11-
1211
Version:
1312
name: Analysis Version
1413
runs-on: ubuntu-latest
@@ -26,11 +25,11 @@ jobs:
2625
run: |
2726
CURRENT_VERSION=$(jq -r .version package.json)
2827
echo "Current version: $CURRENT_VERSION"
29-
28+
3029
git checkout HEAD~1 -- package.json 2>/dev/null || true
3130
PREVIOUS_VERSION=$(jq -r .version package.json 2>/dev/null || echo "0.0.0")
3231
echo "Previous version: $PREVIOUS_VERSION"
33-
32+
3433
if [[ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]]; then
3534
echo "version_changed=true" >> $GITHUB_OUTPUT
3635
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
@@ -54,7 +53,7 @@ jobs:
5453
with:
5554
tag_name: v${{ needs.Version.outputs.current_version }}
5655
release_name: v${{ needs.Version.outputs.current_version }}
57-
body: "Install: https://www.npmjs.com/package/oflow-interface"
56+
body: 'Install: https://www.npmjs.com/package/oflow-interface'
5857
draft: false
5958
prerelease: false
6059

@@ -64,14 +63,13 @@ jobs:
6463
if: ${{ needs.Version.outputs.version_changed == 'true' }}
6564
runs-on: ubuntu-latest
6665
steps:
67-
6866
- name: Checkout Code
6967
uses: actions/checkout@v4
7068

7169
- name: Setup Bun Environment
7270
uses: oven-sh/setup-bun@v2
7371
with:
74-
bun-version: "latest"
72+
bun-version: 'latest'
7573

7674
- name: Install Dependencies
7775
run: bun install --frozen-lockfile
@@ -102,14 +100,13 @@ jobs:
102100
contents: read
103101
packages: write
104102
steps:
105-
106103
- name: Checkout Code
107104
uses: actions/checkout@v4
108105

109106
- name: Setup Bun Environment
110107
uses: oven-sh/setup-bun@v2
111108
with:
112-
bun-version: "latest"
109+
bun-version: 'latest'
113110

114111
- name: Install Dependencies
115112
run: bun install --frozen-lockfile
@@ -126,7 +123,7 @@ jobs:
126123
cp package.json package.json.bak
127124
jq '.name = "@O-FLOW/\(.name)" | .repository.url = "git+https://github.com/O-FLOW/rhine-var.git"' package.json > package.json.tmp
128125
mv package.json.tmp package.json
129-
jq empty package.json
126+
jq empty package.json
130127
131128
- name: Setup NodeJs for NPM
132129
uses: actions/setup-node@v4
@@ -142,4 +139,3 @@ jobs:
142139
run: npm publish
143140
env:
144141
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
145-

.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"jsxSingleQuote": true,
5+
"trailingComma": "all",
6+
"bracketSpacing": true,
7+
"printWidth": 100,
8+
"tabWidth": 2,
9+
"useTabs": false,
10+
"arrowParens": "always",
11+
"endOfLine": "lf"
12+
}

bun.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.ts

Lines changed: 81 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ import { defineConfig } from 'eslint/config'
1212
import eslintConfigPrettier from 'eslint-config-prettier/flat'
1313
import { importX } from 'eslint-plugin-import-x'
1414
import globals from 'globals'
15-
import tseslint, {ConfigArray} from 'typescript-eslint'
16-
15+
import tseslint, { ConfigArray } from 'typescript-eslint'
1716

1817
// Configuration
19-
const ENABLE_TYPE_CHECKED = true // Set to enable project-based type checking
20-
const ENABLE_FRONTEND = false // Set to enable Next.js, JSX, React, Hooks, and other frontend features
21-
const ENABLE_STYLESHEET = true // Set to enable CSS, SCSS, SASS and other stylesheet features
22-
const IGNORE_PRETTIER = true // Set to disable all rules that are unnecessary or might conflict with Prettier
23-
18+
const ENABLE_TYPE_CHECKED = true // Set to enable project-based type checking
19+
const ENABLE_FRONTEND = false // Set to enable Next.js, JSX, React, Hooks, and other frontend features
20+
const ENABLE_STYLESHEET = true // Set to enable CSS, SCSS, SASS and other stylesheet features
21+
const IGNORE_PRETTIER = true // Set to disable all rules that are unnecessary or might conflict with Prettier
2422

2523
const __filename = fileURLToPath(import.meta.url)
2624
const __dirname = path.dirname(__filename)
@@ -30,60 +28,58 @@ const compat = new FlatCompat({
3028
baseDirectory: __dirname,
3129
})
3230

33-
34-
const globalConfig = defineConfig([
35-
includeIgnoreFile(gitignorePath),
36-
{ignores: []},
37-
])
31+
const globalConfig = defineConfig([includeIgnoreFile(gitignorePath), { ignores: [] }])
3832

3933
const scriptFile = '*.{cjs,js,jsx,mjs,mjsx,cts,ts,tsx,mts,mtsx}'
4034
const jsFile = '*.{cjs,js,jsx,mjs,mjsx}'
4135
const tsFile = '*.{cts,ts,tsx,mts,mtsx}'
4236

43-
const tsConfig = ENABLE_TYPE_CHECKED ? [
44-
{
45-
files: [`**/${scriptFile}`],
46-
languageOptions: {
47-
parserOptions: {
48-
projectService: true,
49-
tsconfigRootDir: __dirname,
37+
const tsConfig = ENABLE_TYPE_CHECKED
38+
? [
39+
{
40+
files: [`**/${scriptFile}`],
41+
languageOptions: {
42+
parserOptions: {
43+
projectService: true,
44+
tsconfigRootDir: __dirname,
45+
},
46+
},
5047
},
51-
},
52-
},
53-
{
54-
...tseslint.configs.strictTypeChecked[0],
55-
files: [`**/${scriptFile}`],
56-
},
57-
{
58-
...tseslint.configs.strictTypeChecked[1],
59-
files: [`**/${tsFile}`],
60-
},
61-
{
62-
...tseslint.configs.strictTypeChecked[2],
63-
files: [`**/${scriptFile}`],
64-
},
65-
{
66-
...tseslint.configs.stylisticTypeChecked[2],
67-
files: [`**/${scriptFile}`],
68-
},
69-
] : [
70-
{
71-
...tseslint.configs.strict[0],
72-
files: [`**/${scriptFile}`],
73-
},
74-
{
75-
...tseslint.configs.strict[1],
76-
files: [`**/${tsFile}`],
77-
},
78-
{
79-
...tseslint.configs.strict[2],
80-
files: [`**/${scriptFile}`],
81-
},
82-
{
83-
...tseslint.configs.stylistic[2],
84-
files: [`**/${scriptFile}`],
85-
},
86-
]
48+
{
49+
...tseslint.configs.strictTypeChecked[0],
50+
files: [`**/${scriptFile}`],
51+
},
52+
{
53+
...tseslint.configs.strictTypeChecked[1],
54+
files: [`**/${tsFile}`],
55+
},
56+
{
57+
...tseslint.configs.strictTypeChecked[2],
58+
files: [`**/${scriptFile}`],
59+
},
60+
{
61+
...tseslint.configs.stylisticTypeChecked[2],
62+
files: [`**/${scriptFile}`],
63+
},
64+
]
65+
: [
66+
{
67+
...tseslint.configs.strict[0],
68+
files: [`**/${scriptFile}`],
69+
},
70+
{
71+
...tseslint.configs.strict[1],
72+
files: [`**/${tsFile}`],
73+
},
74+
{
75+
...tseslint.configs.strict[2],
76+
files: [`**/${scriptFile}`],
77+
},
78+
{
79+
...tseslint.configs.stylistic[2],
80+
files: [`**/${scriptFile}`],
81+
},
82+
]
8783

8884
const scriptConfig: ConfigArray = tseslint.config([
8985
{
@@ -96,14 +92,14 @@ const scriptConfig: ConfigArray = tseslint.config([
9692
`tools/**/${scriptFile}`,
9793
],
9894
languageOptions: {
99-
globals: globals.node
100-
}
95+
globals: globals.node,
96+
},
10197
},
10298
{
10399
files: [`src/**/${scriptFile}`],
104100
languageOptions: {
105-
globals: globals.browser
106-
}
101+
globals: globals.browser,
102+
},
107103
},
108104
{
109105
...js.configs.recommended,
@@ -128,12 +124,13 @@ const scriptConfig: ConfigArray = tseslint.config([
128124
},
129125
])
130126

131-
132127
const nextConfig = []
133128
if (ENABLE_FRONTEND) {
134-
nextConfig.push(...compat.config({
135-
extends: ['next/core-web-vitals', 'next/typescript'],
136-
}))
129+
nextConfig.push(
130+
...compat.config({
131+
extends: ['next/core-web-vitals', 'next/typescript'],
132+
}),
133+
)
137134

138135
for (const nextConfigElement of nextConfig) {
139136
if (!nextConfigElement.files) {
@@ -142,20 +139,20 @@ if (ENABLE_FRONTEND) {
142139
}
143140
}
144141

145-
146142
const cssConfig = []
147143

148144
if (ENABLE_STYLESHEET) {
149-
cssConfig.push(...defineConfig([
150-
{
151-
...css.configs.recommended,
152-
files: ['**/*.css'],
153-
language: 'css/css',
154-
}
155-
]))
145+
cssConfig.push(
146+
...defineConfig([
147+
{
148+
...css.configs.recommended,
149+
files: ['**/*.css'],
150+
language: 'css/css',
151+
},
152+
]),
153+
)
156154
}
157155

158-
159156
const markdownConfig = defineConfig([
160157
{
161158
...markdown.configs.recommended[0],
@@ -164,15 +161,11 @@ const markdownConfig = defineConfig([
164161
},
165162
])
166163

167-
168164
const jsonConfig = defineConfig([
169165
{
170166
...json.configs.recommended,
171167
files: ['**/*.json'],
172-
ignores: [
173-
'**/tsconfig.json',
174-
'**/tsconfig.*.json',
175-
],
168+
ignores: ['**/tsconfig.json', '**/tsconfig.*.json'],
176169
language: 'json/json',
177170
},
178171
{
@@ -182,14 +175,12 @@ const jsonConfig = defineConfig([
182175
},
183176
])
184177

185-
186178
const prettierConfig = []
187179

188180
if (IGNORE_PRETTIER) {
189181
prettierConfig.push(eslintConfigPrettier)
190182
}
191183

192-
193184
const customConfig = defineConfig([
194185
{
195186
files: [`**/${scriptFile}`],
@@ -199,7 +190,7 @@ const customConfig = defineConfig([
199190
'import-x/order': [
200191
'error',
201192
{
202-
'groups': [
193+
groups: [
203194
'builtin',
204195
'external',
205196
'internal',
@@ -209,29 +200,28 @@ const customConfig = defineConfig([
209200
'object',
210201
'type',
211202
],
212-
'pathGroups': [
203+
pathGroups: [
213204
{
214-
'pattern': '@/**',
215-
'group': 'internal',
216-
'position': 'before',
205+
pattern: '@/**',
206+
group: 'internal',
207+
position: 'before',
217208
},
218209
],
219-
'pathGroupsExcludedImportTypes': ['builtin'],
210+
pathGroupsExcludedImportTypes: ['builtin'],
220211
'newlines-between': 'always',
221-
'distinctGroup': false,
222-
'alphabetize': {
223-
'order': 'asc',
224-
'caseInsensitive': true
212+
distinctGroup: false,
213+
alphabetize: {
214+
order: 'asc',
215+
caseInsensitive: true,
225216
},
226-
'sortTypesGroup': true,
217+
sortTypesGroup: true,
227218
'newlines-between-types': 'always',
228219
},
229220
],
230221
},
231222
},
232223
])
233224

234-
235225
const config = [
236226
...globalConfig,
237227
...scriptConfig,

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"file-type": "^20.4.1",
5555
"globals": "^16.2.0",
5656
"mime": "^4.0.7",
57+
"prettier": "^3.5.3",
5758
"react": "19.1.0-canary-ff628334-20250205",
5859
"react-dom": "19.1.0-canary-ff628334-20250205",
5960
"rhine-var": "0.10.5",
@@ -76,4 +77,4 @@
7677
"dependencies": {
7778
"eslint-plugin-unused-imports": "^4.1.4"
7879
}
79-
}
80+
}

0 commit comments

Comments
 (0)