@electron/lint-roller 2.1.0 → 2.3.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/configs/markdownlint.json +1 -0
- package/dist/bin/lint-markdown-api-history.d.ts +8 -0
- package/dist/bin/lint-markdown-api-history.js +285 -0
- package/dist/bin/lint-markdown-api-history.js.map +1 -0
- package/markdownlint-rules/emd002.js +1 -1
- package/markdownlint-rules/emd003.js +1 -1
- package/markdownlint-rules/emd004.js +30 -0
- package/markdownlint-rules/index.js +2 -1
- package/package.json +10 -8
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.findPossibleApiHistoryBlocks = void 0;
|
|
5
|
+
const promises_1 = require("node:fs/promises");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const ajv_1 = require("ajv");
|
|
8
|
+
const minimist = require("minimist");
|
|
9
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
10
|
+
const yaml_1 = require("yaml");
|
|
11
|
+
const helpers_1 = require("../lib/helpers");
|
|
12
|
+
const markdown_1 = require("../lib/markdown");
|
|
13
|
+
// "<any char>: <match group>"
|
|
14
|
+
const possibleStringRegex = /^[ \S]+?: *?(\S[ \S]+?)$/gm;
|
|
15
|
+
const nonAlphaNumericDotRegex = /[^a-zA-Z0-9.]/g;
|
|
16
|
+
function isHTML(node) {
|
|
17
|
+
return node.type === 'html';
|
|
18
|
+
}
|
|
19
|
+
async function findPossibleApiHistoryBlocks(content) {
|
|
20
|
+
const { fromMarkdown } = (await (0, helpers_1.dynamicImport)('mdast-util-from-markdown'));
|
|
21
|
+
const { visit } = (await (0, helpers_1.dynamicImport)('unist-util-visit'));
|
|
22
|
+
const tree = fromMarkdown(content);
|
|
23
|
+
const codeBlocks = [];
|
|
24
|
+
visit(tree,
|
|
25
|
+
// Very loose check for YAML history blocks to help catch user error
|
|
26
|
+
(node) => isHTML(node) &&
|
|
27
|
+
node.value.includes('```') &&
|
|
28
|
+
node.value.toLowerCase().includes('yaml') &&
|
|
29
|
+
node.value.toLowerCase().includes('history'), (node, index) => {
|
|
30
|
+
codeBlocks.push({
|
|
31
|
+
previousNode: index !== null ? tree.children[index - 1] : undefined,
|
|
32
|
+
value: node.value,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
return codeBlocks;
|
|
36
|
+
}
|
|
37
|
+
exports.findPossibleApiHistoryBlocks = findPossibleApiHistoryBlocks;
|
|
38
|
+
async function main(workspaceRoot, globs, { checkPlacement, breakingChangesFile, checkStrings, schema, ignoreGlobs = [] }) {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f;
|
|
40
|
+
let documentCounter = 0;
|
|
41
|
+
let historyBlockCounter = 0;
|
|
42
|
+
let errorCounter = 0;
|
|
43
|
+
let warningCounter = 0;
|
|
44
|
+
try {
|
|
45
|
+
const { fromHtml } = (await (0, helpers_1.dynamicImport)('hast-util-from-html'));
|
|
46
|
+
const { fromMarkdown } = (await (0, helpers_1.dynamicImport)('mdast-util-from-markdown'));
|
|
47
|
+
const workspace = new markdown_1.DocsWorkspace(workspaceRoot, globs, ignoreGlobs);
|
|
48
|
+
let validateAgainstSchema = null;
|
|
49
|
+
if (schema) {
|
|
50
|
+
try {
|
|
51
|
+
const ajv = new ajv_1.default();
|
|
52
|
+
const ApiHistorySchemaFile = await (0, promises_1.readFile)(schema, { encoding: 'utf-8' });
|
|
53
|
+
const ApiHistorySchema = JSON.parse(ApiHistorySchemaFile);
|
|
54
|
+
validateAgainstSchema = ajv.compile(ApiHistorySchema);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new Error(`Error occurred while attempting to read API history schema and compile AJV validator:\n${error}\n`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
let breakingChangesFileHeadingIds = null;
|
|
61
|
+
if (breakingChangesFile) {
|
|
62
|
+
try {
|
|
63
|
+
const breakingChanges = await (0, promises_1.readFile)(breakingChangesFile, { encoding: 'utf-8' });
|
|
64
|
+
const markdownBreakingChanges = fromMarkdown(breakingChanges);
|
|
65
|
+
const headings = markdownBreakingChanges.children.filter((e) => e.type === 'heading' && e.depth === 3);
|
|
66
|
+
// Convert to GitHub heading ID format
|
|
67
|
+
breakingChangesFileHeadingIds = headings.map((heading) => heading.children.reduce((acc, cur) => acc +
|
|
68
|
+
cur.value
|
|
69
|
+
.toLowerCase()
|
|
70
|
+
.replace(/ /g, '-')
|
|
71
|
+
.replace(/[^a-zA-Z0-9-]/g, ''), ''));
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw new Error(`Error occurred while attempting to read breaking changes file and parse the heading IDs:\n${error}\n`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
for (const document of await workspace.getAllMarkdownDocuments()) {
|
|
78
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
79
|
+
const filepath = workspace.getWorkspaceRelativePath(uri);
|
|
80
|
+
documentCounter++;
|
|
81
|
+
const documentText = document.getText();
|
|
82
|
+
if (!documentText.includes('<!--'))
|
|
83
|
+
continue;
|
|
84
|
+
const possibleHistoryBlocks = await findPossibleApiHistoryBlocks(documentText);
|
|
85
|
+
for (const possibleHistoryBlock of possibleHistoryBlocks) {
|
|
86
|
+
historyBlockCounter++;
|
|
87
|
+
const { children: [htmlComment], } = fromHtml(possibleHistoryBlock.value);
|
|
88
|
+
if (htmlComment.type !== 'comment')
|
|
89
|
+
continue;
|
|
90
|
+
const { children: [codeBlock], } = fromMarkdown(htmlComment.value);
|
|
91
|
+
if (codeBlock.type !== 'code' ||
|
|
92
|
+
((_a = codeBlock.lang) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== 'yaml' ||
|
|
93
|
+
((_b = codeBlock.meta) === null || _b === void 0 ? void 0 : _b.trim().toLowerCase()) !== 'history') {
|
|
94
|
+
console.error('Error occurred while parsing Markdown document:\n\n' +
|
|
95
|
+
`'${filepath}'\n\n` +
|
|
96
|
+
"Couldn't extract matches from possible API history block, did you use the correct format?\n\n" +
|
|
97
|
+
'Possible API history block:\n\n' +
|
|
98
|
+
`${possibleHistoryBlock.value}\n`);
|
|
99
|
+
errorCounter++;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
// Special chars in YAML strings may break the parser if not surrounded by quotes,
|
|
103
|
+
// including just causing the parser to read a value as null instead of throwing an error
|
|
104
|
+
// <https://stackoverflow.com/questions/19109912/yaml-do-i-need-quotes-for-strings-in-yaml>
|
|
105
|
+
if (checkStrings) {
|
|
106
|
+
const possibleStrings = codeBlock.value.matchAll(possibleStringRegex);
|
|
107
|
+
for (const [matchedLine, matchedGroup] of possibleStrings) {
|
|
108
|
+
const trimmedMatchedGroup = matchedGroup.trim();
|
|
109
|
+
const isMatchedGroupInsideQuotes = (trimmedMatchedGroup.startsWith('"') && trimmedMatchedGroup.endsWith('"')) ||
|
|
110
|
+
(trimmedMatchedGroup.startsWith("'") && trimmedMatchedGroup.endsWith("'"));
|
|
111
|
+
// Most special characters won't cause a problem if they're inside quotes
|
|
112
|
+
if (isMatchedGroupInsideQuotes)
|
|
113
|
+
continue;
|
|
114
|
+
// I've only seen errors occur when the first or last character is a special character - @piotrpdev
|
|
115
|
+
const isFirstCharNonAlphaNumeric = trimmedMatchedGroup[0].match(nonAlphaNumericDotRegex) !== null;
|
|
116
|
+
const isLastCharNonAlphaNumeric = ((_c = trimmedMatchedGroup.at(-1)) === null || _c === void 0 ? void 0 : _c.match(nonAlphaNumericDotRegex)) !== null;
|
|
117
|
+
if (isFirstCharNonAlphaNumeric || isLastCharNonAlphaNumeric) {
|
|
118
|
+
console.warn('Warning occurred while parsing Markdown document:\n\n' +
|
|
119
|
+
`'${filepath}'\n\n` +
|
|
120
|
+
'Possible string value starts/ends with a non-alphanumeric character.\n\n' +
|
|
121
|
+
'This might cause issues when parsing the YAML (might not throw an error)\n\n' +
|
|
122
|
+
'Matched group:\n\n' +
|
|
123
|
+
`${matchedGroup}\n\n` +
|
|
124
|
+
'Matched line:\n\n' +
|
|
125
|
+
`${matchedLine}\n\n` +
|
|
126
|
+
'API history block:\n\n' +
|
|
127
|
+
`${possibleHistoryBlock.value}\n`);
|
|
128
|
+
// Not throwing an error because it might be a false positive or desired behavior
|
|
129
|
+
warningCounter++;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (checkPlacement) {
|
|
134
|
+
if (((_d = possibleHistoryBlock.previousNode) === null || _d === void 0 ? void 0 : _d.type) !== 'heading') {
|
|
135
|
+
console.error('Error occurred while parsing Markdown document:\n\n' +
|
|
136
|
+
`'${filepath}'\n\n` +
|
|
137
|
+
'API history block must be preceded by a heading\n\n' +
|
|
138
|
+
'API history block:\n\n' +
|
|
139
|
+
`${possibleHistoryBlock.value}\n`);
|
|
140
|
+
errorCounter++;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
let unsafeHistory = null;
|
|
145
|
+
try {
|
|
146
|
+
unsafeHistory = (0, yaml_1.parse)(codeBlock.value);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
console.error('Error occurred while parsing Markdown document:\n\n' +
|
|
150
|
+
`'${filepath}'\n\n` +
|
|
151
|
+
`(YAML) ${error}\n\n` +
|
|
152
|
+
'API history block:\n\n' +
|
|
153
|
+
`${possibleHistoryBlock.value}\n`);
|
|
154
|
+
errorCounter++;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (!schema || validateAgainstSchema === null)
|
|
158
|
+
continue;
|
|
159
|
+
const isValid = validateAgainstSchema(unsafeHistory);
|
|
160
|
+
if (!isValid) {
|
|
161
|
+
console.error('Error occurred while parsing Markdown document:\n\n' +
|
|
162
|
+
`'${filepath}'\n\n` +
|
|
163
|
+
'Error validating YAML\n\n' +
|
|
164
|
+
'Validation errors:\n\n' +
|
|
165
|
+
`${JSON.stringify(validateAgainstSchema.errors, null, 4)}\n\n` +
|
|
166
|
+
'Parsed YAML:\n\n' +
|
|
167
|
+
`${JSON.stringify(unsafeHistory, null, 4)}\n\n` +
|
|
168
|
+
'API history block:\n\n' +
|
|
169
|
+
`${possibleHistoryBlock.value}\n`);
|
|
170
|
+
errorCounter++;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (breakingChangesFile && breakingChangesFileHeadingIds !== null) {
|
|
174
|
+
const safeHistory = unsafeHistory;
|
|
175
|
+
const breakingChangeHeaders = [];
|
|
176
|
+
const changesAndDeprecations = [
|
|
177
|
+
...((_e = safeHistory.changes) !== null && _e !== void 0 ? _e : []),
|
|
178
|
+
...((_f = safeHistory.deprecated) !== null && _f !== void 0 ? _f : []),
|
|
179
|
+
];
|
|
180
|
+
for (const change of changesAndDeprecations) {
|
|
181
|
+
if (change['breaking-changes-header']) {
|
|
182
|
+
breakingChangeHeaders.push(change['breaking-changes-header']);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
for (const header of breakingChangeHeaders) {
|
|
186
|
+
if (!breakingChangesFileHeadingIds.includes(header)) {
|
|
187
|
+
console.error('Error occurred while parsing Markdown document:\n\n' +
|
|
188
|
+
`'${filepath}'\n\n` +
|
|
189
|
+
"Couldn't find the following breaking changes header:\n\n" +
|
|
190
|
+
`'${header}'\n\n` +
|
|
191
|
+
`in this breaking changes file:\n\n` +
|
|
192
|
+
`'${breakingChangesFile}'\n\n` +
|
|
193
|
+
'Parsed YAML:\n\n' +
|
|
194
|
+
`${JSON.stringify(safeHistory, null, 4)}\n\n` +
|
|
195
|
+
'API history block:\n\n' +
|
|
196
|
+
`${possibleHistoryBlock.value}\n\n`);
|
|
197
|
+
errorCounter++;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// ? Maybe collect all api history and export it to a single file for future use.
|
|
202
|
+
}
|
|
203
|
+
// ? Maybe replace user YAML with result of <https://eemeli.org/yaml/#tostring-options> for consistent style (but not in CI)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
errorCounter++;
|
|
208
|
+
console.error('Error occurred while linting:\n', error);
|
|
209
|
+
}
|
|
210
|
+
finally {
|
|
211
|
+
return { historyBlockCounter, documentCounter, errorCounter, warningCounter };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function parseCommandLine() {
|
|
215
|
+
const showUsage = (arg) => {
|
|
216
|
+
if (!arg || arg.startsWith('-')) {
|
|
217
|
+
console.log('Usage: lint-roller-markdown-api-history [--root <dir>] <globs>' +
|
|
218
|
+
' [-h|--help]' +
|
|
219
|
+
' [--check-placement] [--breaking-changes-file <path>] [--check-strings]' +
|
|
220
|
+
' [--schema <path>]' +
|
|
221
|
+
' [--ignore <globs>] [--ignore-path <path>]');
|
|
222
|
+
process.exit(1);
|
|
223
|
+
}
|
|
224
|
+
return true;
|
|
225
|
+
};
|
|
226
|
+
const opts = minimist(process.argv.slice(2), {
|
|
227
|
+
boolean: ['help', 'check-placement', 'check-strings'],
|
|
228
|
+
string: ['root', 'ignore', 'ignore-path', 'schema', 'breaking-changes-file'],
|
|
229
|
+
unknown: showUsage,
|
|
230
|
+
default: {
|
|
231
|
+
'check-placement': true,
|
|
232
|
+
'check-strings': true,
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
if (opts.help || !opts._.length)
|
|
236
|
+
showUsage();
|
|
237
|
+
return opts;
|
|
238
|
+
}
|
|
239
|
+
async function init() {
|
|
240
|
+
try {
|
|
241
|
+
const opts = parseCommandLine();
|
|
242
|
+
if (!opts.root) {
|
|
243
|
+
opts.root = '.';
|
|
244
|
+
}
|
|
245
|
+
if (opts.ignore) {
|
|
246
|
+
opts.ignore = Array.isArray(opts.ignore) ? opts.ignore : [opts.ignore];
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
opts.ignore = [];
|
|
250
|
+
}
|
|
251
|
+
if (opts['ignore-path']) {
|
|
252
|
+
const ignores = await (0, promises_1.readFile)((0, node_path_1.resolve)(opts['ignore-path']), { encoding: 'utf-8' });
|
|
253
|
+
for (const ignore of ignores.split('\n')) {
|
|
254
|
+
opts.ignore.push(ignore.trimEnd());
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (opts.schema) {
|
|
258
|
+
opts.schema = (0, node_path_1.resolve)(process.cwd(), opts.schema);
|
|
259
|
+
}
|
|
260
|
+
if (opts['breaking-changes-file']) {
|
|
261
|
+
opts['breaking-changes-file'] = (0, node_path_1.resolve)(process.cwd(), opts['breaking-changes-file']);
|
|
262
|
+
}
|
|
263
|
+
const { historyBlockCounter, documentCounter, errorCounter, warningCounter } = await main((0, node_path_1.resolve)(process.cwd(), opts.root), opts._, {
|
|
264
|
+
checkPlacement: opts['check-placement'],
|
|
265
|
+
breakingChangesFile: opts['breaking-changes-file'],
|
|
266
|
+
checkStrings: opts['check-strings'],
|
|
267
|
+
ignoreGlobs: opts.ignore,
|
|
268
|
+
schema: opts.schema,
|
|
269
|
+
});
|
|
270
|
+
console.log(`Processed ${historyBlockCounter} API history block(s) in ${documentCounter} document(s) with ${errorCounter} error(s) and ${warningCounter} warning(s).`);
|
|
271
|
+
if (errorCounter > 0)
|
|
272
|
+
process.exit(1);
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
console.error(`Error(s) occurred while initializing 'lint-markdown-api-history':\n${error}`);
|
|
276
|
+
process.exit(1);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (require.main === module) {
|
|
280
|
+
init().catch((error) => {
|
|
281
|
+
console.error(error);
|
|
282
|
+
process.exit(1);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=lint-markdown-api-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-markdown-api-history.js","sourceRoot":"","sources":["../../bin/lint-markdown-api-history.ts"],"names":[],"mappings":";;;;AAEA,+CAA+D;AA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C5B,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -8915,7 +8915,7 @@ function decode($0, $1, $2) {
|
|
|
8915
8915
|
return decodeNamedCharacterReference($2) || $0;
|
|
8916
8916
|
}
|
|
8917
8917
|
|
|
8918
|
-
// node_modules/unist-util-stringify-position/lib/index.js
|
|
8918
|
+
// node_modules/mdast-util-from-markdown/node_modules/unist-util-stringify-position/lib/index.js
|
|
8919
8919
|
function stringifyPosition(value) {
|
|
8920
8920
|
if (!value || typeof value !== "object") {
|
|
8921
8921
|
return "";
|
|
@@ -8915,7 +8915,7 @@ function decode($0, $1, $2) {
|
|
|
8915
8915
|
return decodeNamedCharacterReference($2) || $0;
|
|
8916
8916
|
}
|
|
8917
8917
|
|
|
8918
|
-
// node_modules/unist-util-stringify-position/lib/index.js
|
|
8918
|
+
// node_modules/mdast-util-from-markdown/node_modules/unist-util-stringify-position/lib/index.js
|
|
8919
8919
|
function stringifyPosition(value) {
|
|
8920
8920
|
if (!value || typeof value !== "object") {
|
|
8921
8921
|
return "";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const { addError, filterTokens } = require('markdownlint/helpers');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
names: ['EMD004', 'no-newline-in-links'],
|
|
5
|
+
description: 'Newlines inside link text',
|
|
6
|
+
tags: ['newline', 'links'],
|
|
7
|
+
parser: 'markdownit',
|
|
8
|
+
function: function EMD004(params, onError) {
|
|
9
|
+
filterTokens(params, 'inline', (token) => {
|
|
10
|
+
const { children } = token;
|
|
11
|
+
let { lineNumber } = token;
|
|
12
|
+
let inLink = false;
|
|
13
|
+
for (const child of children) {
|
|
14
|
+
const { type } = child;
|
|
15
|
+
if (type === 'link_open') {
|
|
16
|
+
inLink = true;
|
|
17
|
+
} else if (type === 'link_close') {
|
|
18
|
+
inLink = false;
|
|
19
|
+
} else if (type === 'softbreak') {
|
|
20
|
+
if (inLink) {
|
|
21
|
+
addError(onError, lineNumber);
|
|
22
|
+
break;
|
|
23
|
+
} else {
|
|
24
|
+
lineNumber++;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@electron/lint-roller",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Markdown linting helpers for Electron org repos",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"electron-markdownlint": "./dist/bin/markdownlint-cli-wrapper.js",
|
|
10
10
|
"lint-roller-markdown-links": "./dist/bin/lint-markdown-links.js",
|
|
11
11
|
"lint-roller-markdown-standard": "./dist/bin/lint-markdown-standard.js",
|
|
12
|
-
"lint-roller-markdown-ts-check": "./dist/bin/lint-markdown-ts-check.js"
|
|
12
|
+
"lint-roller-markdown-ts-check": "./dist/bin/lint-markdown-ts-check.js",
|
|
13
|
+
"lint-roller-markdown-api-history": "./dist/bin/lint-markdown-api-history.js"
|
|
13
14
|
},
|
|
14
15
|
"files": [
|
|
15
16
|
"configs",
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
"lint:prettier:fix": "prettier --write \"{bin,lib,markdownlint-rules,tests}/**/*.{js,mjs,ts}\"",
|
|
33
34
|
"lint": "yarn run lint:prettier && yarn run lint:markdown",
|
|
34
35
|
"lint:fix": "yarn run lint:eslint:fix && yarn run lint:prettier:fix",
|
|
35
|
-
"test": "yarn run build &&
|
|
36
|
+
"test": "yarn run build && vitest run --reporter=verbose"
|
|
36
37
|
},
|
|
37
38
|
"repository": {
|
|
38
39
|
"type": "git",
|
|
@@ -48,7 +49,6 @@
|
|
|
48
49
|
"@electron-internal/eslint-config": "^1.0.1",
|
|
49
50
|
"@types/balanced-match": "^1.0.3",
|
|
50
51
|
"@types/glob": "^8.1.0",
|
|
51
|
-
"@types/jest": "^29.5.8",
|
|
52
52
|
"@types/markdown-it": "^13.0.6",
|
|
53
53
|
"@types/minimist": "^1.2.5",
|
|
54
54
|
"@types/node": "20.1.2",
|
|
@@ -56,15 +56,16 @@
|
|
|
56
56
|
"eslint": "^8.54.0",
|
|
57
57
|
"eslint-config-prettier": "^9.1.0",
|
|
58
58
|
"eslint-plugin-node": "^11.1.0",
|
|
59
|
-
"jest": "^29.7.0",
|
|
60
59
|
"prettier": "^3.2.5",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
60
|
+
"typescript": "^5.4.5",
|
|
61
|
+
"vitest": "^1.5.3"
|
|
63
62
|
},
|
|
64
63
|
"dependencies": {
|
|
65
64
|
"@dsanders11/vscode-markdown-languageservice": "^0.3.0",
|
|
65
|
+
"ajv": "^8.16.0",
|
|
66
66
|
"balanced-match": "^2.0.0",
|
|
67
67
|
"glob": "^8.1.0",
|
|
68
|
+
"hast-util-from-html": "^2.0.1",
|
|
68
69
|
"markdown-it": "^13.0.1",
|
|
69
70
|
"markdownlint-cli": "^0.40.0",
|
|
70
71
|
"mdast-util-from-markdown": "^1.3.0",
|
|
@@ -74,7 +75,8 @@
|
|
|
74
75
|
"unist-util-visit": "^4.1.2",
|
|
75
76
|
"vscode-languageserver": "^8.1.0",
|
|
76
77
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
77
|
-
"vscode-uri": "^3.0.7"
|
|
78
|
+
"vscode-uri": "^3.0.7",
|
|
79
|
+
"yaml": "^2.4.5"
|
|
78
80
|
},
|
|
79
81
|
"peerDependencies": {
|
|
80
82
|
"typescript": ">= 4.7.0"
|