@markuplint/language-server 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/const.d.ts +10 -0
- package/lib/const.js +10 -0
- package/lib/server/parser-load-failure.d.ts +11 -1
- package/lib/server/parser-load-failure.js +27 -2
- package/lib/server/v5.js +11 -0
- package/locales/ja.json +2 -1
- package/package.json +9 -9
package/lib/const.d.ts
CHANGED
|
@@ -39,3 +39,13 @@ export declare const BUNDLED_PARSER_LOAD_ERROR = "The markuplint bundled with th
|
|
|
39
39
|
* `{2*}` the working directory.
|
|
40
40
|
*/
|
|
41
41
|
export declare const BUNDLED_PARSER_LOAD_COMPAT_ERROR = "The markuplint bundled with the language server (v{0}) cannot load {1*} from {2*} because the markuplint installed there is incompatible with Node.js 22+. Upgrade it to markuplint@4.10.0 or later, then restart the language server.";
|
|
42
|
+
/**
|
|
43
|
+
* Error message shown when the configuration needs `@markuplint/pretenders` (`pretenders.scan`, `pretenders.auto`,
|
|
44
|
+
* or a pretender that has a `filePath`) and the markuplint bundled with the language server is the one in use.
|
|
45
|
+
* markuplint does not install `@markuplint/pretenders` and the extension does not bundle it, and the bundled
|
|
46
|
+
* `@markuplint/file-resolver` imports it relative to itself, so installing it in the workspace is not enough
|
|
47
|
+
* until markuplint itself is installed there. The message of the error that markuplint raises tells to install
|
|
48
|
+
* it in the project, which does not fix this case.
|
|
49
|
+
* Displayed as a popup via `errorToPopup`. `{0}` is the bundled version, `{1*}` the working directory.
|
|
50
|
+
*/
|
|
51
|
+
export declare const BUNDLED_PRETENDERS_NOT_FOUND_ERROR = "The markuplint bundled with the language server (v{0}) does not include @markuplint/pretenders, which your configuration needs. Install markuplint and @markuplint/pretenders in {1*}, then restart the language server so that it can use the local installation.";
|
package/lib/const.js
CHANGED
|
@@ -42,3 +42,13 @@ export const BUNDLED_PARSER_LOAD_ERROR = 'The markuplint bundled with the langua
|
|
|
42
42
|
* `{2*}` the working directory.
|
|
43
43
|
*/
|
|
44
44
|
export const BUNDLED_PARSER_LOAD_COMPAT_ERROR = 'The markuplint bundled with the language server (v{0}) cannot load {1*} from {2*} because the markuplint installed there is incompatible with Node.js 22+. Upgrade it to markuplint@4.10.0 or later, then restart the language server.';
|
|
45
|
+
/**
|
|
46
|
+
* Error message shown when the configuration needs `@markuplint/pretenders` (`pretenders.scan`, `pretenders.auto`,
|
|
47
|
+
* or a pretender that has a `filePath`) and the markuplint bundled with the language server is the one in use.
|
|
48
|
+
* markuplint does not install `@markuplint/pretenders` and the extension does not bundle it, and the bundled
|
|
49
|
+
* `@markuplint/file-resolver` imports it relative to itself, so installing it in the workspace is not enough
|
|
50
|
+
* until markuplint itself is installed there. The message of the error that markuplint raises tells to install
|
|
51
|
+
* it in the project, which does not fix this case.
|
|
52
|
+
* Displayed as a popup via `errorToPopup`. `{0}` is the bundled version, `{1*}` the working directory.
|
|
53
|
+
*/
|
|
54
|
+
export const BUNDLED_PRETENDERS_NOT_FOUND_ERROR = 'The markuplint bundled with the language server (v{0}) does not include @markuplint/pretenders, which your configuration needs. Install markuplint and @markuplint/pretenders in {1*}, then restart the language server so that it can use the local installation.';
|
|
@@ -18,10 +18,20 @@ export type ParserLoadFailureContext = {
|
|
|
18
18
|
* @returns The package name (scoped when applicable), or `null` if the message is not a parser load failure
|
|
19
19
|
*/
|
|
20
20
|
export declare function extractMissingParserName(message: string): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Whether an error is what markuplint raises for a configuration that needs `@markuplint/pretenders` when it
|
|
23
|
+
* is not installed: an error that says how to install it, with the `ERR_MODULE_NOT_FOUND` of the import as its
|
|
24
|
+
* `cause`. It is reported as a `config-error` of the file (the `lint-error` event of `MLEngine`) rather than
|
|
25
|
+
* as a rejection of `exec()`, so it is told by its cause.
|
|
26
|
+
*
|
|
27
|
+
* @param error - The error of the `lint-error` event, or of a rejection
|
|
28
|
+
* @returns `true` when the cause is the missing `@markuplint/pretenders`
|
|
29
|
+
*/
|
|
30
|
+
export declare function isPretendersNotInstalled(error: unknown): boolean;
|
|
21
31
|
/**
|
|
22
32
|
* Builds the user-facing explanation for a parser load failure.
|
|
23
33
|
*
|
|
24
|
-
* @param error - The rejection from `MLEngine#exec()`
|
|
34
|
+
* @param error - The rejection from `MLEngine#exec()`, or the error of its `lint-error` event
|
|
25
35
|
* @param context - Which markuplint module linted the document
|
|
26
36
|
* @returns The message to show, or `null` if the error is not a parser load failure
|
|
27
37
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isFatalError } from 'markuplint/suppressions';
|
|
2
|
-
import { BUNDLED_PARSER_LOAD_COMPAT_ERROR, BUNDLED_PARSER_LOAD_ERROR, PARSER_NOT_FOUND_ERROR } from '../const.js';
|
|
2
|
+
import { BUNDLED_PARSER_LOAD_COMPAT_ERROR, BUNDLED_PARSER_LOAD_ERROR, BUNDLED_PRETENDERS_NOT_FOUND_ERROR, PARSER_NOT_FOUND_ERROR, } from '../const.js';
|
|
3
3
|
import { t } from '../i18n.js';
|
|
4
|
+
const PRETENDERS_PACKAGE = '@markuplint/pretenders';
|
|
4
5
|
// `@markuplint/file-resolver` (v3+) rewrites a bare parser specifier that is not importable into an
|
|
5
6
|
// absolute path under the config's directory before giving up, so the reported specifier is
|
|
6
7
|
// usually `<configDir>/@markuplint/xxx-parser`, not the name the user wrote.
|
|
@@ -39,10 +40,24 @@ function packageNameOf(spec) {
|
|
|
39
40
|
}
|
|
40
41
|
return segments.length === 1 ? name : null;
|
|
41
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Whether an error is what markuplint raises for a configuration that needs `@markuplint/pretenders` when it
|
|
45
|
+
* is not installed: an error that says how to install it, with the `ERR_MODULE_NOT_FOUND` of the import as its
|
|
46
|
+
* `cause`. It is reported as a `config-error` of the file (the `lint-error` event of `MLEngine`) rather than
|
|
47
|
+
* as a rejection of `exec()`, so it is told by its cause.
|
|
48
|
+
*
|
|
49
|
+
* @param error - The error of the `lint-error` event, or of a rejection
|
|
50
|
+
* @returns `true` when the cause is the missing `@markuplint/pretenders`
|
|
51
|
+
*/
|
|
52
|
+
export function isPretendersNotInstalled(error) {
|
|
53
|
+
return (error instanceof Error &&
|
|
54
|
+
error.cause instanceof Error &&
|
|
55
|
+
extractMissingParserName(error.cause.message) === PRETENDERS_PACKAGE);
|
|
56
|
+
}
|
|
42
57
|
/**
|
|
43
58
|
* Builds the user-facing explanation for a parser load failure.
|
|
44
59
|
*
|
|
45
|
-
* @param error - The rejection from `MLEngine#exec()`
|
|
60
|
+
* @param error - The rejection from `MLEngine#exec()`, or the error of its `lint-error` event
|
|
46
61
|
* @param context - Which markuplint module linted the document
|
|
47
62
|
* @returns The message to show, or `null` if the error is not a parser load failure
|
|
48
63
|
*/
|
|
@@ -50,6 +65,16 @@ export function describeParserLoadFailure(error, context) {
|
|
|
50
65
|
if (!(error instanceof Error)) {
|
|
51
66
|
return null;
|
|
52
67
|
}
|
|
68
|
+
if (isPretendersNotInstalled(error)) {
|
|
69
|
+
if (context.isLocalModule) {
|
|
70
|
+
// The message of the error says how to install it, which is the fix for a local markuplint.
|
|
71
|
+
return error.message;
|
|
72
|
+
}
|
|
73
|
+
if (context.fallbackReason === 'import-assertion-compat') {
|
|
74
|
+
return t(BUNDLED_PARSER_LOAD_COMPAT_ERROR, context.version, PRETENDERS_PACKAGE, context.workspace);
|
|
75
|
+
}
|
|
76
|
+
return t(BUNDLED_PRETENDERS_NOT_FOUND_ERROR, context.version, context.workspace);
|
|
77
|
+
}
|
|
53
78
|
const parser = extractMissingParserName(error.message);
|
|
54
79
|
if (!parser) {
|
|
55
80
|
return null;
|
package/lib/server/v5.js
CHANGED
|
@@ -5,6 +5,7 @@ import { getFilePath } from '../utils/get-file-path.js';
|
|
|
5
5
|
import { createQuickFixActions, createFixAllAction } from './code-actions.js';
|
|
6
6
|
import { convertDiagnostics } from './convert-diagnostics.js';
|
|
7
7
|
import { getAccessibilityByLocation } from './get-accessibility-by-location.js';
|
|
8
|
+
import { isPretendersNotInstalled } from './parser-load-failure.js';
|
|
8
9
|
import { applySuppressionsToViolations, loadSuppressions } from './suppression-support.js';
|
|
9
10
|
const engines = new Map();
|
|
10
11
|
const fixStates = new Map();
|
|
@@ -78,8 +79,18 @@ config, locale, log, diagnosticsLog, sendDiagnostics, notFoundParserError, works
|
|
|
78
79
|
engine.on('log', (phase, message) => {
|
|
79
80
|
log(`[${phase}]: ${message}`, 'trace');
|
|
80
81
|
});
|
|
82
|
+
// The lint fails again on every edit of the document, with the same cause until the package is installed
|
|
83
|
+
// and the server restarted (which the popup says), so the popup is shown once per document.
|
|
84
|
+
let pretendersPopupShown = false;
|
|
81
85
|
engine.on('lint-error', (_filePath, _sourceCode, error) => {
|
|
82
86
|
diagnosticsLog(error.message, 'error');
|
|
87
|
+
// A configuration that needs `@markuplint/pretenders` is a `config-error` diagnostic, not a rejection of
|
|
88
|
+
// `exec()`, so the popup that a missing parser gets has to be asked for here: the diagnostic tells to
|
|
89
|
+
// install it in the project, which does not fix it for the markuplint bundled with the language server.
|
|
90
|
+
if (!pretendersPopupShown && isPretendersNotInstalled(error)) {
|
|
91
|
+
pretendersPopupShown = true;
|
|
92
|
+
notFoundParserError(error);
|
|
93
|
+
}
|
|
83
94
|
});
|
|
84
95
|
engine.on('config-errors', (_filePath, errors) => {
|
|
85
96
|
for (const error of errors) {
|
package/locales/ja.json
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"[suppressed] this warning is suppressed but should be fixed:": "[抑制中] この警告は抑制されていますが、本来は修正すべき問題です:",
|
|
17
17
|
"parser not found. you probably need to install {0} for documents of language {1}.": "パーサーが見つかりません。言語 {1} の文書には {0} をインストールする必要があります。",
|
|
18
18
|
"the markuplint bundled with the language server (v{0}) cannot load parsers installed in your workspace. install markuplint and {1} in {2}, then restart the language server so that it can use the local installation.": "言語サーバーにバンドルされたmarkuplint(v{0})はワークスペースにインストールされたパーサーを読み込めません。ローカル版を使えるように、{2} にmarkuplintと{1}をインストールしてから言語サーバーを再起動してください。",
|
|
19
|
-
"the markuplint bundled with the language server (v{0}) cannot load {1} from {2} because the markuplint installed there is incompatible with node.js 22+. upgrade it to markuplint@4.10.0 or later, then restart the language server.": "言語サーバーにバンドルされたmarkuplint(v{0})は {2} の{1}を読み込めません。そこにインストールされたmarkuplintがNode.js 22+と互換性がないためです。markuplint@4.10.0以降にアップグレードしてから言語サーバーを再起動してください。"
|
|
19
|
+
"the markuplint bundled with the language server (v{0}) cannot load {1} from {2} because the markuplint installed there is incompatible with node.js 22+. upgrade it to markuplint@4.10.0 or later, then restart the language server.": "言語サーバーにバンドルされたmarkuplint(v{0})は {2} の{1}を読み込めません。そこにインストールされたmarkuplintがNode.js 22+と互換性がないためです。markuplint@4.10.0以降にアップグレードしてから言語サーバーを再起動してください。",
|
|
20
|
+
"the markuplint bundled with the language server (v{0}) does not include @markuplint/pretenders, which your configuration needs. install markuplint and @markuplint/pretenders in {1}, then restart the language server so that it can use the local installation.": "言語サーバーにバンドルされたmarkuplint(v{0})には、設定が必要とする@markuplint/pretendersが含まれていません。ローカル版を使えるように、{1} にmarkuplintと@markuplint/pretendersをインストールしてから言語サーバーを再起動してください。"
|
|
20
21
|
}
|
|
21
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/language-server",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Language Server Protocol server for markuplint",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
"clean": "tsc --build --clean tsconfig.build.json"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@markuplint/file-resolver": "5.
|
|
45
|
-
"@markuplint/i18n": "5.
|
|
46
|
-
"@markuplint/ml-config": "5.
|
|
47
|
-
"@markuplint/ml-spec": "5.
|
|
44
|
+
"@markuplint/file-resolver": "5.5.0",
|
|
45
|
+
"@markuplint/i18n": "5.5.0",
|
|
46
|
+
"@markuplint/ml-config": "5.5.0",
|
|
47
|
+
"@markuplint/ml-spec": "5.5.0",
|
|
48
48
|
"debug": "^4.4.3",
|
|
49
|
-
"markuplint": "5.
|
|
50
|
-
"semver": "^7.8.
|
|
49
|
+
"markuplint": "5.5.0",
|
|
50
|
+
"semver": "^7.8.6",
|
|
51
51
|
"vscode-languageserver": "^9.0.1",
|
|
52
|
-
"vscode-languageserver-textdocument": "^1.0.
|
|
52
|
+
"vscode-languageserver-textdocument": "^1.0.16"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/debug": "4.1.13",
|
|
56
56
|
"@types/semver": "7.8.0",
|
|
57
57
|
"vscode-jsonrpc": "8.2.1"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "fedebcfd56eaec4642e68643b2f9e10750d810e1"
|
|
60
60
|
}
|