Skip to content

Commit 7bee593

Browse files
committed
Update dependencies and dev dependencies
The update of the `find-up` dependency is held back, as it removes support for Node.js 16.
1 parent 677777c commit 7bee593

File tree

4 files changed

+89
-82
lines changed

4 files changed

+89
-82
lines changed

lib/index.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
import path from 'node:path'
4242
import {PassThrough} from 'node:stream'
43-
import {fileURLToPath} from 'node:url'
43+
import {fileURLToPath, pathToFileURL} from 'node:url'
4444
import {findUp, pathExists} from 'find-up'
4545
import {loadPlugin} from 'load-plugin'
4646
import {engine} from 'unified-engine'
@@ -79,8 +79,8 @@ function vfileMessageToDiagnostic(message) {
7979
message.fatal === true
8080
? DiagnosticSeverity.Error
8181
: message.fatal === false
82-
? DiagnosticSeverity.Warning
83-
: DiagnosticSeverity.Information,
82+
? DiagnosticSeverity.Warning
83+
: DiagnosticSeverity.Information,
8484
message.ruleId || undefined,
8585
message.source || undefined
8686
)
@@ -196,7 +196,7 @@ export function createUnifiedLanguageServer({
196196
try {
197197
processor = /** @type {EngineOptions['processor']} */ (
198198
await loadPlugin(processorName, {
199-
cwd,
199+
from: pathToFileURL(cwd + '/'),
200200
key: processorSpecifier
201201
})
202202
)
@@ -290,15 +290,17 @@ export function createUnifiedLanguageServer({
290290
let cwd
291291
if (workspaces.size === 0) {
292292
cwd = await findUp(
293-
async (dir) => {
294-
const pkgExists = await pathExists(path.join(dir, 'package.json'))
295-
if (pkgExists) {
296-
return dir
293+
async (directory) => {
294+
const packageExists = await pathExists(
295+
path.join(directory, 'package.json')
296+
)
297+
if (packageExists) {
298+
return directory
297299
}
298300

299-
const gitExists = await pathExists(path.join(dir, '.git'))
301+
const gitExists = await pathExists(path.join(directory, '.git'))
300302
if (gitExists) {
301-
return dir
303+
return directory
302304
}
303305
},
304306
{

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
],
3333
"dependencies": {
3434
"find-up": "^6.0.0",
35-
"load-plugin": "^5.0.0",
35+
"load-plugin": "^6.0.0",
3636
"unified-engine": "^11.0.0",
3737
"unist-util-lsp": "^2.0.0",
3838
"vfile": "^6.0.0",
@@ -42,15 +42,15 @@
4242
},
4343
"devDependencies": {
4444
"@types/node": "^20.0.0",
45-
"c8": "^8.0.0",
45+
"c8": "^9.0.0",
4646
"prettier": "^3.0.0",
4747
"remark": "^15.0.0",
48-
"remark-cli": "^11.0.0",
49-
"remark-preset-wooorm": "^9.0.0",
48+
"remark-cli": "^12.0.0",
49+
"remark-preset-wooorm": "^10.0.0",
5050
"type-coverage": "^2.0.0",
5151
"typescript": "^5.0.0",
5252
"unified": "^11.0.0",
53-
"xo": "^0.56.0"
53+
"xo": "^0.58.0"
5454
},
5555
"scripts": {
5656
"prepack": "npm run build",

readme.md

+62-60
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,33 @@ Create a **[language server][]** based on **[unified][]** ecosystems.
1212

1313
## Contents
1414

15-
* [What is this?](#what-is-this)
16-
* [When should I use this?](#when-should-i-use-this)
17-
* [Install](#install)
18-
* [Use](#use)
19-
* [API](#api)
20-
* [`createUnifiedLanguageServer(options)`](#createunifiedlanguageserveroptions)
21-
* [Examples](#examples)
22-
* [Types](#types)
23-
* [Language Server features](#language-server-features)
24-
* [Watching files](#watching-files)
25-
* [Requests](#requests)
26-
* [Configuration](#configuration)
27-
* [Compatibility](#compatibility)
28-
* [Related](#related)
29-
* [Contribute](#contribute)
30-
* [License](#license)
15+
* [What is this?](#what-is-this)
16+
* [When should I use this?](#when-should-i-use-this)
17+
* [Install](#install)
18+
* [Use](#use)
19+
* [API](#api)
20+
* [`createUnifiedLanguageServer(options)`](#createunifiedlanguageserveroptions)
21+
* [Examples](#examples)
22+
* [Types](#types)
23+
* [Language Server features](#language-server-features)
24+
* [Watching files](#watching-files)
25+
* [Requests](#requests)
26+
* [Configuration](#configuration)
27+
* [Compatibility](#compatibility)
28+
* [Related](#related)
29+
* [Contribute](#contribute)
30+
* [License](#license)
3131

3232
## What is this?
3333

3434
This package exports a function which can be used to create a
3535
[language server][] based on [unified][] processors.
3636
It can do the following:
3737

38-
* format documents based on a unified processor
39-
* validate documents based on a unified processor
40-
* support configuration files (such as `.remarkrc`) using
41-
[`unified-engine`][unified-engine]
38+
* format documents based on a unified processor
39+
* validate documents based on a unified processor
40+
* support configuration files (such as `.remarkrc`) using
41+
[`unified-engine`][unified-engine]
4242

4343
**unified** is a project that validates and transforms content with abstract
4444
syntax trees (ASTs).
@@ -58,7 +58,7 @@ various editors.
5858

5959
## Install
6060

61-
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
61+
This package is [ESM only][].
6262
In Node.js (version 16.0+), install with [npm][]:
6363

6464
```sh
@@ -162,11 +162,11 @@ Name of configuration files to load (`string`, optional).
162162

163163
For examples, see the following projects:
164164

165-
* `redot-language-server`
166-
(coming soon)
167-
* `rehype-language-server`
168-
(coming soon)
169-
* [`remark-language-server`](https://github.com/remarkjs/remark-language-server)
165+
* `redot-language-server`
166+
(coming soon)
167+
* `rehype-language-server`
168+
(coming soon)
169+
* [`remark-language-server`](https://github.com/remarkjs/remark-language-server)
170170

171171
## Types
172172

@@ -187,39 +187,39 @@ change was made.
187187
Language servers created using this package implement the following language
188188
server features:
189189

190-
* `textDocument/codeAction`
191-
— the language server implements code actions based on the `expected` field
192-
on reported messages.
193-
A code action can either insert, replace, or delete text based on the range
194-
of the message and the expected value.
195-
* `textDocument/didChange`
196-
— when a document is changed by the client, the language server processes it
197-
using a unified pipeline.
198-
Any messages collected are published to the client using
199-
`textDocument/publishDiagnostics`.
200-
* `textDocument/didClose`
201-
— when a document is closed by the client, the language server resets
202-
diagnostics by publishing an empty array using
203-
`textDocument/publishDiagnostics`.
204-
* `textDocument/didOpen`
205-
— when a document is opened by the client, the language server processes it
206-
using a unified pipeline.
207-
Any messages collected are published to the client using
208-
`textDocument/publishDiagnostics`.
209-
* `textDocument/formatting`
210-
— when document formatting is requested by the client, the language server
211-
processes it using a unified pipeline.
212-
The stringified result is returned.
213-
* `workspace/didChangeWatchedFiles` and `workspace/didChangeWorkspaceFolders`
214-
— when the client signals a watched file or workspace has changed, the
215-
language server processes all open files using a unified pipeline.
216-
Any messages collected are published to the client using
217-
`textDocument/publishDiagnostics`.
190+
* `textDocument/codeAction`
191+
— the language server implements code actions based on the `expected` field
192+
on reported messages.
193+
A code action can either insert, replace, or delete text based on the range
194+
of the message and the expected value.
195+
* `textDocument/didChange`
196+
— when a document is changed by the client, the language server processes it
197+
using a unified pipeline.
198+
Any messages collected are published to the client using
199+
`textDocument/publishDiagnostics`.
200+
* `textDocument/didClose`
201+
— when a document is closed by the client, the language server resets
202+
diagnostics by publishing an empty array using
203+
`textDocument/publishDiagnostics`.
204+
* `textDocument/didOpen`
205+
— when a document is opened by the client, the language server processes it
206+
using a unified pipeline.
207+
Any messages collected are published to the client using
208+
`textDocument/publishDiagnostics`.
209+
* `textDocument/formatting`
210+
— when document formatting is requested by the client, the language server
211+
processes it using a unified pipeline.
212+
The stringified result is returned.
213+
* `workspace/didChangeWatchedFiles` and `workspace/didChangeWorkspaceFolders`
214+
— when the client signals a watched file or workspace has changed, the
215+
language server processes all open files using a unified pipeline.
216+
Any messages collected are published to the client using
217+
`textDocument/publishDiagnostics`.
218218

219219
### Configuration
220220

221-
* `requireConfig` (default: `false`)
222-
— If true, files will only be checked if a configuration file is present.
221+
* `requireConfig` (default: `false`)
222+
— If true, files will only be checked if a configuration file is present.
223223

224224
## Compatibility
225225

@@ -234,10 +234,10 @@ It should work anywhere where LSP 3.6.0 or later is implemented.
234234

235235
## Related
236236

237-
* [`unified`](https://github.com/unifiedjs/unified)
238-
— create pipeline for working with syntax trees
239-
* [`unified-args`](https://github.com/unifiedjs/unified-args)
240-
— create a CLI for a unified pipeline
237+
* [`unified`](https://github.com/unifiedjs/unified)
238+
— create pipeline for working with syntax trees
239+
* [`unified-args`](https://github.com/unifiedjs/unified-args)
240+
— create a CLI for a unified pipeline
241241

242242
## Contribute
243243

@@ -267,6 +267,8 @@ abide by its terms.
267267

268268
[downloads]: https://www.npmjs.com/package/unified-language-server
269269

270+
[esm only]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
271+
270272
[size-badge]: https://img.shields.io/bundlephobia/minzip/unified-language-server.svg
271273

272274
[size]: https://bundlephobia.com/result?p=unified-language-server

test/index.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -981,28 +981,31 @@ function cleanStack(stack, max) {
981981
* @param relativeCwd The cwd to use for the process relative to this test file.
982982
*/
983983
function startLanguageServer(serverFilePath, relativeCwd = './') {
984-
const bin = fileURLToPath(new URL(serverFilePath, import.meta.url))
984+
const binary = fileURLToPath(new URL(serverFilePath, import.meta.url))
985985
const cwd = new URL(relativeCwd, import.meta.url)
986986

987987
// Using ipc is useful for debugging. This allows logging in the language
988988
// server.
989989
// Enabling this breaks code coverage
990990
// https://github.com/bcoe/c8/issues/189
991991
if (process.argv.includes('--ipc')) {
992-
const proc = spawn('node', [bin, '--node-ipc'], {
992+
const serverProcess = spawn('node', [binary, '--node-ipc'], {
993993
cwd,
994994
stdio: [null, 'inherit', 'inherit', 'ipc']
995995
})
996996
connection = createProtocolConnection(
997-
new IPCMessageReader(proc),
998-
new IPCMessageWriter(proc)
997+
new IPCMessageReader(serverProcess),
998+
new IPCMessageWriter(serverProcess)
999999
)
10001000
connection.onDispose(() => {
1001-
proc.kill()
1001+
serverProcess.kill()
10021002
})
10031003
} else {
1004-
const proc = spawn('node', [bin, '--stdio'], {cwd})
1005-
connection = createProtocolConnection(proc.stdout, proc.stdin)
1004+
const serverProcess = spawn('node', [binary, '--stdio'], {cwd})
1005+
connection = createProtocolConnection(
1006+
serverProcess.stdout,
1007+
serverProcess.stdin
1008+
)
10061009
}
10071010

10081011
connection.onDispose(() => {

0 commit comments

Comments
 (0)