Skip to content

Commit dcd531c

Browse files
chore: update lint (#247)
* chore: update lint * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * ci: fix ci * docs(changeset): add changelog * feat: update release script
1 parent 95a1be6 commit dcd531c

27 files changed

Lines changed: 1401 additions & 1227 deletions

.changeset/jolly-waves-raise.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@arkts/language-service": patch
3+
"@arkts/language-server": patch
4+
"vscode-naily-ets": patch
5+
---
6+
7+
feat: 添加[oxk](https://github.com/ohos-rs/oxc-ark)代码格式化支持

.changeset/shiny-pets-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"vscode-naily-ets": patch
3+
---
4+
5+
feat: 添加hvigor资源管理器的oh-package.json5依赖索引

.cursorignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
out
22
dist
3-
node_modules
43
.vscode-test
54
.idea
65
.husky

.github/workflows/changesets.yml

Lines changed: 101 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,101 @@ jobs:
4242
- name: Run Lint
4343
run: pnpm run lint
4444

45+
pack:
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
settings:
50+
- host: macos-latest
51+
pack: pnpm -F vscode-naily-ets run pack --target darwin-x64
52+
env:
53+
OS: darwin
54+
ARCH: x64
55+
- host: macos-latest
56+
pack: pnpm -F vscode-naily-ets run pack --target darwin-arm64
57+
env:
58+
OS: darwin
59+
ARCH: arm64
60+
- host: ubuntu-latest
61+
pack: pnpm -F vscode-naily-ets run pack --target linux-x64
62+
env:
63+
OS: linux
64+
ARCH: x64
65+
- host: ubuntu-latest
66+
pack: pnpm -F vscode-naily-ets run pack --target linux-arm64
67+
env:
68+
OS: linux
69+
ARCH: arm64
70+
- host: ubuntu-latest
71+
pack: pnpm -F vscode-naily-ets run pack --target alpine-x64
72+
env:
73+
OS: linux
74+
ARCH: x64
75+
LIBC: musl
76+
- host: ubuntu-latest
77+
pack: pnpm -F vscode-naily-ets run pack --target alpine-arm64
78+
env:
79+
OS: linux
80+
ARCH: arm64
81+
LIBC: musl
82+
- host: ubuntu-latest
83+
pack: pnpm -F vscode-naily-ets run pack --target linux-armhf
84+
env:
85+
OS: linux
86+
CPU: arm
87+
- host: windows-latest
88+
pack: pnpm -F vscode-naily-ets run pack --target win32-x64
89+
env:
90+
OS: win32
91+
ARCH: x64
92+
- host: windows-latest
93+
pack: pnpm -F vscode-naily-ets run pack --target win32-arm64
94+
env:
95+
OS: win32
96+
ARCH: arm64
97+
- host: macos-latest
98+
pack: pnpm -F vscode-naily-ets run pack --target web
99+
env:
100+
CPU: wasm32
101+
name: ${{ matrix.settings.env.CPU == 'wasm32' && 'Package Extension - web' || format('Package Extension - {0} - {1} - {2}', matrix.settings.env.OS, matrix.settings.env.ARCH, matrix.settings.env.OS == 'win32' && 'msvc' || (matrix.settings.env.LIBC || 'glibc')) }}
102+
runs-on: ${{ matrix.settings.host }}
103+
needs: lint
104+
steps:
105+
- name: Checkout Repo
106+
uses: actions/checkout@v5
107+
with:
108+
submodules: recursive
109+
110+
- name: Setup Node.js
111+
uses: actions/setup-node@v4
112+
with:
113+
node-version: 22.x
114+
registry-url: 'https://registry.npmjs.org'
115+
116+
- name: Setup pnpm
117+
uses: pnpm/action-setup@v2
118+
with:
119+
version: 10.17.0
120+
run_install: true
121+
122+
- name: Run Pack
123+
run: ${{ matrix.settings.pack }}
124+
env:
125+
OS: ${{ matrix.settings.env.OS }}
126+
ARCH: ${{ matrix.settings.env.ARCH }}
127+
LIBC: ${{ matrix.settings.env.OS == 'win32' && 'msvc' || matrix.settings.env.CPU == 'wasm32' && '' || matrix.settings.env.LIBC || 'glibc' }}
128+
CPU: ${{ matrix.settings.env.CPU }}
129+
130+
- name: Upload Artifact
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: ${{ matrix.settings.env.CPU == 'wasm32' && 'vscode-naily-ets-web' || format('vscode-naily-ets-{0}-{1}-{2}', matrix.settings.env.OS, matrix.settings.env.ARCH, matrix.settings.env.OS == 'win32' && 'msvc' || (matrix.settings.env.LIBC || 'glibc')) }}
134+
path: packages/vscode/vscode-naily-ets-*.vsix
135+
45136
release:
46-
name: Create Release Pull Request
137+
name: Create Release Pull Request or Release
47138
runs-on: ubuntu-latest
48-
needs: lint
49-
if: success()
139+
needs: [lint, pack]
50140
steps:
51141
- name: Checkout Repo
52142
uses: actions/checkout@v5
@@ -63,10 +153,15 @@ jobs:
63153
uses: pnpm/action-setup@v2
64154
with:
65155
version: 10.17.0
66-
run_install: |
67-
- args: ['--force']
156+
run_install: true
157+
158+
- name: Download Artifact
159+
uses: actions/download-artifact@v4
160+
with:
161+
name: ${{ matrix.settings.env.CPU == 'wasm32' && 'vscode-naily-ets-web' || format('vscode-naily-ets-{0}-{1}-{2}', matrix.settings.env.OS, matrix.settings.env.ARCH, matrix.settings.env.OS == 'win32' && 'msvc' || (matrix.settings.env.LIBC || 'glibc')) }}
162+
path: packages/vscode/vscode-naily-ets-*.vsix
68163

69-
- name: Create Release Pull Request
164+
- name: Create Release Pull Request or Release
70165
id: changesets
71166
uses: changesets/action@v1
72167
with:

.github/workflows/pr.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,93 @@ jobs:
4040

4141
- name: Run Lint
4242
run: pnpm run lint
43+
pack:
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
settings:
48+
- host: macos-latest
49+
pack: pnpm -F vscode-naily-ets run pack --target darwin-x64
50+
env:
51+
OS: darwin
52+
ARCH: x64
53+
- host: macos-latest
54+
pack: pnpm -F vscode-naily-ets run pack --target darwin-arm64
55+
env:
56+
OS: darwin
57+
ARCH: arm64
58+
- host: ubuntu-latest
59+
pack: pnpm -F vscode-naily-ets run pack --target linux-x64
60+
env:
61+
OS: linux
62+
ARCH: x64
63+
- host: ubuntu-latest
64+
pack: pnpm -F vscode-naily-ets run pack --target linux-arm64
65+
env:
66+
OS: linux
67+
ARCH: arm64
68+
- host: ubuntu-latest
69+
pack: pnpm -F vscode-naily-ets run pack --target alpine-x64
70+
env:
71+
OS: linux
72+
ARCH: x64
73+
LIBC: musl
74+
- host: ubuntu-latest
75+
pack: pnpm -F vscode-naily-ets run pack --target alpine-arm64
76+
env:
77+
OS: linux
78+
ARCH: arm64
79+
LIBC: musl
80+
- host: ubuntu-latest
81+
pack: pnpm -F vscode-naily-ets run pack --target linux-armhf
82+
env:
83+
OS: linux
84+
CPU: arm
85+
- host: windows-latest
86+
pack: pnpm -F vscode-naily-ets run pack --target win32-x64
87+
env:
88+
OS: win32
89+
ARCH: x64
90+
- host: windows-latest
91+
pack: pnpm -F vscode-naily-ets run pack --target win32-arm64
92+
env:
93+
OS: win32
94+
ARCH: arm64
95+
- host: macos-latest
96+
pack: pnpm -F vscode-naily-ets run pack --target web
97+
env:
98+
CPU: wasm32
99+
name: ${{ matrix.settings.env.CPU == 'wasm32' && 'Package Extension - web' || format('Package Extension - {0} - {1} - {2}', matrix.settings.env.OS, matrix.settings.env.ARCH, matrix.settings.env.OS == 'win32' && 'msvc' || (matrix.settings.env.LIBC || 'glibc')) }}
100+
runs-on: ${{ matrix.settings.host }}
101+
needs: lint
102+
steps:
103+
- name: Checkout Repo
104+
uses: actions/checkout@v5
105+
with:
106+
submodules: recursive
107+
108+
- name: Setup Node.js
109+
uses: actions/setup-node@v4
110+
with:
111+
node-version: 22.x
112+
registry-url: 'https://registry.npmjs.org'
113+
114+
- name: Setup pnpm
115+
uses: pnpm/action-setup@v2
116+
with:
117+
version: 10.17.0
118+
run_install: true
119+
120+
- name: Run Pack
121+
run: ${{ matrix.settings.pack }}
122+
env:
123+
OS: ${{ matrix.settings.env.OS }}
124+
ARCH: ${{ matrix.settings.env.ARCH }}
125+
LIBC: ${{ matrix.settings.env.OS == 'win32' && 'msvc' || matrix.settings.env.CPU == 'wasm32' && '' || matrix.settings.env.LIBC || 'glibc' }}
126+
CPU: ${{ matrix.settings.env.CPU }}
127+
128+
- name: Upload Artifact
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: ${{ matrix.settings.env.CPU == 'wasm32' && 'vscode-naily-ets-web-none' || format('vscode-naily-ets-{0}-{1}-{2}', matrix.settings.env.OS, matrix.settings.env.ARCH, matrix.settings.env.OS == 'win32' && 'msvc' || (matrix.settings.env.LIBC || 'glibc')) }}
132+
path: packages/vscode/vscode-naily-ets-*.vsix

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,6 @@
6868
],
6969
"i18n-ally.dirStructure": "file",
7070
"i18n-ally.pathMatcher": "package.nls.?{locale?}.json",
71-
"i18n-ally.sourceLanguage": "en"
71+
"i18n-ally.sourceLanguage": "en",
72+
"typescript.tsdk": "node_modules/typescript/lib"
7273
}

package.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"release": "pnpm -F \"{packages/*}\" build && tsx ./scripts/publish.ts",
1515
"test": "vitest --coverage --ui",
1616
"test:compatible": "vitest run e2e/compatible.test.ts",
17-
"lint": "eslint && oxlint && tsc --noEmit && tsc --noEmit --project packages/vscode/src/project/tsconfig.json && tsc --noEmit --project packages/vscode/src/qualifier-editor/tsconfig.json && vitest --coverage",
17+
"lint": "eslint && oxlint && tsc --noEmit && vitest --coverage",
1818
"prepare": "pnpm -F \"{packages/*}\" build"
1919
},
2020
"dependencies": {
@@ -57,9 +57,25 @@
5757
"@arkts/project-detector-win32-x64-msvc": "catalog:prod",
5858
"@arkts/sdk-downloader": "catalog:prod",
5959
"@arkts/shared": "workspace:*",
60+
"@arkts/types": "workspace:*",
6061
"@changesets/changelog-github": "catalog:scripts",
6162
"@changesets/cli": "catalog:scripts",
6263
"@iconify-json/ph": "catalog:frontend",
64+
"@ohos-rs/oxk": "catalog:prod",
65+
"@ohos-rs/oxk-android-arm-eabi": "catalog:prod",
66+
"@ohos-rs/oxk-android-arm64": "catalog:prod",
67+
"@ohos-rs/oxk-darwin-arm64": "catalog:prod",
68+
"@ohos-rs/oxk-darwin-x64": "catalog:prod",
69+
"@ohos-rs/oxk-freebsd-x64": "catalog:prod",
70+
"@ohos-rs/oxk-linux-arm-gnueabihf": "catalog:prod",
71+
"@ohos-rs/oxk-linux-arm64-gnu": "catalog:prod",
72+
"@ohos-rs/oxk-linux-arm64-musl": "catalog:prod",
73+
"@ohos-rs/oxk-linux-x64-gnu": "catalog:prod",
74+
"@ohos-rs/oxk-linux-x64-musl": "catalog:prod",
75+
"@ohos-rs/oxk-wasm32-wasi": "catalog:prod",
76+
"@ohos-rs/oxk-win32-arm64-msvc": "catalog:prod",
77+
"@ohos-rs/oxk-win32-ia32-msvc": "catalog:prod",
78+
"@ohos-rs/oxk-win32-x64-msvc": "catalog:prod",
6379
"@types/lodash": "catalog:prod",
6480
"@types/markdown-it": "catalog:types",
6581
"@types/node": "catalog:types",
@@ -118,6 +134,11 @@
118134
"vscode-languageserver-textdocument": "catalog:prod",
119135
"vscode-nls": "catalog:prod"
120136
},
137+
"pnpm": {
138+
"overrides": {
139+
"eslint-plugin-antfu": "3.1.1"
140+
}
141+
},
121142
"simple-git-hooks": {
122143
"pre-commit": "pnpm lint"
123144
}

packages/language-server/src/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import process from 'node:process'
99
import { ETSLanguagePlugin } from '@arkts/language-plugin'
1010
import { createArkTServices, ProjectDetectorManager } from '@arkts/language-service'
1111
import { Uri } from '@arkts/project-detector'
12+
import { format } from '@ohos-rs/oxk'
1213
import { createConnection, createServer, createTypeScriptProject, FileChangeType } from '@volar/language-server/node'
1314
import * as ets from 'ohos-typescript'
1415
import { create as createTypeScriptServices } from 'volar-service-typescript'
@@ -27,6 +28,10 @@ connection.onRequest('ets/waitForEtsConfigurationChangedRequested', (e) => {
2728
lspConfiguration.setConfiguration(e)
2829
})
2930

31+
connection.onRequest('ets/formatDocument', async (e) => {
32+
return format(e.textDocument.uri, e.textDocument.text)
33+
})
34+
3035
connection.onInitialize(async (params) => {
3136
if (params.locale) lspConfiguration.setLocale(params.locale)
3237
lspConfiguration.setConfiguration({ typescript: params.initializationOptions?.typescript })
@@ -63,10 +68,16 @@ connection.onInitialize(async (params) => {
6368
isValidationEnabled: document => !((document.languageId === 'json' || document.languageId === 'jsonc')),
6469
isSuggestionsEnabled: document => !((document.languageId === 'json' || document.languageId === 'jsonc')),
6570
isAutoClosingTagsEnabled: document => !((document.languageId === 'json' || document.languageId === 'jsonc')),
66-
isFormattingEnabled: document => !((document.languageId === 'json' || document.languageId === 'jsonc')),
6771
disableAutoImportCache: true,
6872
})
6973
patchSemantic(typescriptServices, lspConfiguration)
74+
delete typescriptServices[1].capabilities.documentFormattingProvider
75+
const originalCreate = typescriptServices[1].create
76+
typescriptServices[1].create = (context) => {
77+
const instance = originalCreate(context)
78+
delete instance.provideDocumentFormattingEdits
79+
return instance
80+
}
7081

7182
// TODO
7283
connection.onRequest('ets/onDidChangeTextDocument', () => {})
@@ -103,8 +114,8 @@ connection.onInitialize(async (params) => {
103114
}
104115
}),
105116
[
106-
...typescriptServices,
107117
...arkTSServices,
118+
...typescriptServices,
108119
],
109120
)
110121
})

packages/language-server/src/patches/patch-semantic.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export function patchSemantic(typescriptServices: LanguageServicePlugin[], confi
2626
const instance = originalCreate(context)
2727
const contextUtil = new ContextUtil(context)
2828

29+
delete instance.provideDocumentFormattingEdits
30+
2931
function findNodeInPosition<TNode extends ets.Node>(currentPositionOffset: number, predicate: (node: ets.Node) => node is TNode, sourceFile: ets.SourceFile): TNode | undefined {
3032
let foundNode: TNode | undefined
3133
sourceFile.forEachChild(function walk(node): void {

packages/language-server/tsdown.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ export default defineConfig({
1414
},
1515
},
1616
fixedExtension: false,
17+
external: ['@ohos-rs/oxk'],
1718
})

0 commit comments

Comments
 (0)