wikilint 2.18.1 → 2.18.3

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.
Files changed (54) hide show
  1. package/README.md +2 -2
  2. package/bin/cli.js +1 -1
  3. package/bin/config.js +2 -2
  4. package/config/.schema.json +13 -0
  5. package/config/default.json +460 -4
  6. package/config/enwiki.json +111 -0
  7. package/config/jawiki.json +954 -0
  8. package/config/llwiki.json +117 -0
  9. package/config/minimum.json +10 -0
  10. package/config/moegirl.json +104 -0
  11. package/config/zhwiki.json +109 -0
  12. package/dist/base.d.mts +3 -0
  13. package/dist/base.d.ts +3 -0
  14. package/dist/base.js +1 -0
  15. package/dist/base.mjs +2 -1
  16. package/dist/bin/config.js +82 -59
  17. package/dist/index.d.ts +3 -1
  18. package/dist/index.js +41 -29
  19. package/dist/lib/document.d.ts +6 -6
  20. package/dist/lib/document.js +43 -36
  21. package/dist/lib/lsp.d.ts +1 -0
  22. package/dist/lib/lsp.js +83 -55
  23. package/dist/lib/title.d.ts +18 -4
  24. package/dist/lib/title.js +12 -4
  25. package/dist/parser/braces.js +29 -15
  26. package/dist/parser/commentAndExt.js +5 -16
  27. package/dist/parser/links.js +1 -1
  28. package/dist/parser/redirect.js +1 -3
  29. package/dist/src/converter.js +1 -1
  30. package/dist/src/gallery.js +1 -1
  31. package/dist/src/heading.js +3 -3
  32. package/dist/src/imageParameter.js +9 -9
  33. package/dist/src/imagemap.js +3 -2
  34. package/dist/src/index.d.ts +1 -1
  35. package/dist/src/index.js +7 -5
  36. package/dist/src/link/base.js +1 -1
  37. package/dist/src/link/file.d.ts +2 -0
  38. package/dist/src/link/file.js +15 -13
  39. package/dist/src/link/galleryImage.js +1 -1
  40. package/dist/src/link/redirectTarget.js +1 -2
  41. package/dist/src/magicLink.js +1 -1
  42. package/dist/src/nested.js +5 -5
  43. package/dist/src/nowiki/index.js +3 -2
  44. package/dist/src/redirect.js +1 -2
  45. package/dist/src/syntax.d.ts +4 -2
  46. package/dist/src/syntax.js +4 -2
  47. package/dist/src/table/base.js +1 -1
  48. package/dist/src/table/index.js +2 -5
  49. package/dist/src/table/trBase.js +3 -1
  50. package/dist/src/transclude.js +23 -12
  51. package/dist/util/debug.js +11 -1
  52. package/dist/util/lint.js +31 -30
  53. package/dist/util/string.js +3 -4
  54. package/package.json +2 -3
@@ -212,6 +212,123 @@
212
212
  "模块讨论": 829,
213
213
  "模組討論": 829
214
214
  },
215
+ "functionHook": [
216
+ "msgnw",
217
+ "ns",
218
+ "nse",
219
+ "urlencode",
220
+ "lcfirst",
221
+ "ucfirst",
222
+ "lc",
223
+ "uc",
224
+ "localurl",
225
+ "localurle",
226
+ "fullurl",
227
+ "fullurle",
228
+ "canonicalurl",
229
+ "canonicalurle",
230
+ "formatnum",
231
+ "grammar",
232
+ "gender",
233
+ "plural",
234
+ "bidi",
235
+ "numberofpages",
236
+ "numberofusers",
237
+ "numberofactiveusers",
238
+ "numberofarticles",
239
+ "numberoffiles",
240
+ "numberofadmins",
241
+ "numberingroup",
242
+ "numberofedits",
243
+ "language",
244
+ "padleft",
245
+ "padright",
246
+ "anchorencode",
247
+ "defaultsort",
248
+ "filepath",
249
+ "pagesincategory",
250
+ "pagesize",
251
+ "protectionlevel",
252
+ "protectionexpiry",
253
+ "namespacee",
254
+ "namespacenumber",
255
+ "talkspace",
256
+ "talkspacee",
257
+ "subjectspace",
258
+ "subjectspacee",
259
+ "pagename",
260
+ "pagenamee",
261
+ "fullpagename",
262
+ "fullpagenamee",
263
+ "rootpagename",
264
+ "rootpagenamee",
265
+ "basepagename",
266
+ "basepagenamee",
267
+ "subpagename",
268
+ "subpagenamee",
269
+ "talkpagename",
270
+ "talkpagenamee",
271
+ "subjectpagename",
272
+ "subjectpagenamee",
273
+ "pageid",
274
+ "revisionid",
275
+ "revisionday",
276
+ "revisionday2",
277
+ "revisionmonth",
278
+ "revisionmonth1",
279
+ "revisionyear",
280
+ "revisiontimestamp",
281
+ "revisionuser",
282
+ "cascadingsources",
283
+ "namespace",
284
+ "int",
285
+ "special",
286
+ "speciale",
287
+ "tag",
288
+ "formatdate",
289
+ "displaytitle",
290
+ "regex",
291
+ "regex_var",
292
+ "regexquote",
293
+ "regexall",
294
+ "while",
295
+ "dowhile",
296
+ "loop",
297
+ "forargs",
298
+ "fornumargs",
299
+ "if",
300
+ "ifeq",
301
+ "switch",
302
+ "ifexist",
303
+ "ifexpr",
304
+ "iferror",
305
+ "time",
306
+ "timel",
307
+ "expr",
308
+ "rel2abs",
309
+ "titleparts",
310
+ "len",
311
+ "pos",
312
+ "rpos",
313
+ "sub",
314
+ "count",
315
+ "replace",
316
+ "explode",
317
+ "urldecode",
318
+ "choose",
319
+ "invoke",
320
+ "tab",
321
+ "var",
322
+ "varexists",
323
+ "var_final",
324
+ "vardefine",
325
+ "vardefineecho",
326
+ "widget",
327
+ "rmatch",
328
+ "rsplit",
329
+ "rreplace",
330
+ "seo"
331
+ ],
215
332
  "variable": [
216
333
  "!",
217
334
  "=",
@@ -83,6 +83,9 @@
83
83
  "category": 14,
84
84
  "module": 828
85
85
  },
86
+ "functionHook": [
87
+ "msgnw"
88
+ ],
86
89
  "variable": [
87
90
  "!",
88
91
  "=",
@@ -95,6 +98,13 @@
95
98
  ],
96
99
  "parserFunction": [
97
100
  {
101
+ "msgnw": "msgnw",
102
+ "pageid": "pageid",
103
+ "articlepath": "articlepath",
104
+ "server": "server",
105
+ "servername": "servername",
106
+ "scriptpath": "scriptpath",
107
+ "stylepath": "stylepath",
98
108
  "#language": "language",
99
109
  "#special": "special",
100
110
  "#speciale": "speciale",
@@ -242,6 +242,110 @@
242
242
  "模組討論": 829,
243
243
  "モジュール・トーク": 829
244
244
  },
245
+ "functionHook": [
246
+ "msgnw",
247
+ "ns",
248
+ "nse",
249
+ "urlencode",
250
+ "lcfirst",
251
+ "ucfirst",
252
+ "lc",
253
+ "uc",
254
+ "localurl",
255
+ "localurle",
256
+ "fullurl",
257
+ "fullurle",
258
+ "canonicalurl",
259
+ "canonicalurle",
260
+ "formatnum",
261
+ "grammar",
262
+ "gender",
263
+ "plural",
264
+ "bidi",
265
+ "numberofpages",
266
+ "numberofusers",
267
+ "numberofactiveusers",
268
+ "numberofarticles",
269
+ "numberoffiles",
270
+ "numberofadmins",
271
+ "numberingroup",
272
+ "numberofedits",
273
+ "language",
274
+ "padleft",
275
+ "padright",
276
+ "anchorencode",
277
+ "defaultsort",
278
+ "filepath",
279
+ "pagesincategory",
280
+ "pagesize",
281
+ "protectionlevel",
282
+ "protectionexpiry",
283
+ "namespacee",
284
+ "namespacenumber",
285
+ "talkspace",
286
+ "talkspacee",
287
+ "subjectspace",
288
+ "subjectspacee",
289
+ "pagename",
290
+ "pagenamee",
291
+ "fullpagename",
292
+ "fullpagenamee",
293
+ "rootpagename",
294
+ "rootpagenamee",
295
+ "basepagename",
296
+ "basepagenamee",
297
+ "subpagename",
298
+ "subpagenamee",
299
+ "talkpagename",
300
+ "talkpagenamee",
301
+ "subjectpagename",
302
+ "subjectpagenamee",
303
+ "pageid",
304
+ "revisionid",
305
+ "revisionday",
306
+ "revisionday2",
307
+ "revisionmonth",
308
+ "revisionmonth1",
309
+ "revisionyear",
310
+ "revisiontimestamp",
311
+ "revisionuser",
312
+ "cascadingsources",
313
+ "namespace",
314
+ "int",
315
+ "special",
316
+ "speciale",
317
+ "tag",
318
+ "formatdate",
319
+ "displaytitle",
320
+ "widget",
321
+ "while",
322
+ "dowhile",
323
+ "loop",
324
+ "forargs",
325
+ "fornumargs",
326
+ "regex",
327
+ "cscore",
328
+ "choose",
329
+ "if",
330
+ "ifeq",
331
+ "switch",
332
+ "ifexist",
333
+ "ifexpr",
334
+ "iferror",
335
+ "time",
336
+ "timel",
337
+ "expr",
338
+ "rel2abs",
339
+ "titleparts",
340
+ "categorytree",
341
+ "var",
342
+ "varexists",
343
+ "var_final",
344
+ "vardefine",
345
+ "vardefineecho",
346
+ "invoke",
347
+ "related"
348
+ ],
245
349
  "variable": [
246
350
  "!",
247
351
  "=",
@@ -310,6 +310,115 @@
310
310
  "話題": 2600,
311
311
  "话题": 2600
312
312
  },
313
+ "functionHook": [
314
+ "msgnw",
315
+ "ns",
316
+ "nse",
317
+ "urlencode",
318
+ "lcfirst",
319
+ "ucfirst",
320
+ "lc",
321
+ "uc",
322
+ "localurl",
323
+ "localurle",
324
+ "fullurl",
325
+ "fullurle",
326
+ "canonicalurl",
327
+ "canonicalurle",
328
+ "formatnum",
329
+ "grammar",
330
+ "gender",
331
+ "plural",
332
+ "formal",
333
+ "bidi",
334
+ "numberingroup",
335
+ "language",
336
+ "padleft",
337
+ "padright",
338
+ "anchorencode",
339
+ "defaultsort",
340
+ "filepath",
341
+ "pagesincategory",
342
+ "pagesize",
343
+ "protectionlevel",
344
+ "protectionexpiry",
345
+ "pagename",
346
+ "pagenamee",
347
+ "fullpagename",
348
+ "fullpagenamee",
349
+ "subpagename",
350
+ "subpagenamee",
351
+ "rootpagename",
352
+ "rootpagenamee",
353
+ "basepagename",
354
+ "basepagenamee",
355
+ "talkpagename",
356
+ "talkpagenamee",
357
+ "subjectpagename",
358
+ "subjectpagenamee",
359
+ "pageid",
360
+ "revisionid",
361
+ "revisionday",
362
+ "revisionday2",
363
+ "revisionmonth",
364
+ "revisionmonth1",
365
+ "revisionyear",
366
+ "revisiontimestamp",
367
+ "revisionuser",
368
+ "cascadingsources",
369
+ "namespace",
370
+ "namespacee",
371
+ "namespacenumber",
372
+ "talkspace",
373
+ "talkspacee",
374
+ "subjectspace",
375
+ "subjectspacee",
376
+ "numberofarticles",
377
+ "numberoffiles",
378
+ "numberofusers",
379
+ "numberofactiveusers",
380
+ "numberofpages",
381
+ "numberofadmins",
382
+ "numberofedits",
383
+ "bcp47",
384
+ "dir",
385
+ "interwikilink",
386
+ "interlanguagelink",
387
+ "int",
388
+ "special",
389
+ "speciale",
390
+ "tag",
391
+ "formatdate",
392
+ "displaytitle",
393
+ "if",
394
+ "ifeq",
395
+ "switch",
396
+ "ifexist",
397
+ "ifexpr",
398
+ "iferror",
399
+ "time",
400
+ "timel",
401
+ "timef",
402
+ "timefl",
403
+ "expr",
404
+ "rel2abs",
405
+ "titleparts",
406
+ "categorytree",
407
+ "lst",
408
+ "lstx",
409
+ "lsth",
410
+ "target",
411
+ "babel",
412
+ "coordinates",
413
+ "invoke",
414
+ "related",
415
+ "noexternallanglinks",
416
+ "property",
417
+ "statements",
418
+ "commaseparatedlist",
419
+ "assessment",
420
+ "mentor"
421
+ ],
313
422
  "variable": [
314
423
  "!",
315
424
  "=",
package/dist/base.d.mts CHANGED
@@ -5,6 +5,7 @@ export interface Config {
5
5
  readonly namespaces: Record<string, string>;
6
6
  readonly nsid: Record<string, number>;
7
7
  readonly variable: string[];
8
+ readonly functionHook: string[];
8
9
  readonly parserFunction: [Record<string, string>, Record<string, string> | string[], string[], string[]];
9
10
  readonly doubleUnderscore: [string[], string[], Record<string, string>?, Record<string, string>?];
10
11
  readonly protocol: string;
@@ -40,6 +41,7 @@ export declare const stages: {
40
41
  list: number;
41
42
  dd: number;
42
43
  converter: number;
44
+ 'list-range': number;
43
45
  };
44
46
  export type Stage = keyof typeof stages;
45
47
  export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css"];
@@ -270,6 +272,7 @@ export interface Parser {
270
272
  *
271
273
  * 创建语言服务
272
274
  * @param uri document URI / 文档标识
275
+ * @since v1.16.1
273
276
  */
274
277
  createLanguageService(uri: object): LanguageService;
275
278
  }
package/dist/base.d.ts CHANGED
@@ -5,6 +5,7 @@ export interface Config {
5
5
  readonly namespaces: Record<string, string>;
6
6
  readonly nsid: Record<string, number>;
7
7
  readonly variable: string[];
8
+ readonly functionHook: string[];
8
9
  readonly parserFunction: [Record<string, string>, Record<string, string> | string[], string[], string[]];
9
10
  readonly doubleUnderscore: [string[], string[], Record<string, string>?, Record<string, string>?];
10
11
  readonly protocol: string;
@@ -40,6 +41,7 @@ export declare const stages: {
40
41
  list: number;
41
42
  dd: number;
42
43
  converter: number;
44
+ 'list-range': number;
43
45
  };
44
46
  export type Stage = keyof typeof stages;
45
47
  export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css"];
@@ -270,6 +272,7 @@ export interface Parser {
270
272
  *
271
273
  * 创建语言服务
272
274
  * @param uri document URI / 文档标识
275
+ * @since v1.16.1
273
276
  */
274
277
  createLanguageService(uri: object): LanguageService;
275
278
  }
package/dist/base.js CHANGED
@@ -27,6 +27,7 @@ exports.stages = (() => {
27
27
  list: 10,
28
28
  dd: 10,
29
29
  converter: 11,
30
+ 'list-range': 11,
30
31
  };
31
32
  Object.setPrototypeOf(obj, null);
32
33
  return obj;
package/dist/base.mjs CHANGED
@@ -23,7 +23,8 @@ const stages = /* @__PURE__ */ (() => {
23
23
  "magic-link": 9,
24
24
  list: 10,
25
25
  dd: 10,
26
- converter: 11
26
+ converter: 11,
27
+ "list-range": 11
27
28
  };
28
29
  Object.setPrototypeOf(obj, null);
29
30
  return obj;
@@ -8,14 +8,82 @@ const path_1 = __importDefault(require("path"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const assert_1 = __importDefault(require("assert"));
10
10
  const cm_1 = require("@bhsd/common/dist/cm");
11
+ /**
12
+ * Converts an array to an object.
13
+ * @param config parser configuration
14
+ * @param config.articlePath article path
15
+ */
16
+ const arrToObj = ({ articlePath, ...obj }) => {
17
+ for (const [k, v] of Object.entries(obj)) {
18
+ if (Array.isArray(v) && v.every(x => typeof x === 'string')) {
19
+ Object.assign(obj, { [k]: Object.fromEntries(v.map(x => [x, true])) });
20
+ }
21
+ }
22
+ return obj;
23
+ };
24
+ /**
25
+ * Gets the aliases of magic words.
26
+ * @param magicwords magic words
27
+ * @param targets magic word names
28
+ */
29
+ const getAliases = (magicwords, targets) => magicwords
30
+ .filter(({ name }) => targets.has(name))
31
+ .flatMap(({ aliases }) => aliases.map(s => s.replace(/:$/u, '').toLowerCase()));
32
+ /**
33
+ * Filters out gadget-related namespaces.
34
+ * @param id namespace ID
35
+ */
36
+ const filterGadget = (id) => {
37
+ const n = Number(id);
38
+ return n < 2300 || n > 2303; // Gadget, Gadget talk, Gadget definition, Gadget definition talk
39
+ };
40
+ /**
41
+ * Execute the data script.
42
+ * @param obj MediaWiki module implementation
43
+ */
44
+ const execute = (obj) => {
45
+ Object.entries(obj.files).find(([k]) => k.endsWith('.data.js'))[1]();
46
+ };
47
+ const mw = {
48
+ loader: {
49
+ done: false,
50
+ /** @ignore */
51
+ impl(callback) {
52
+ execute(callback()[1]);
53
+ },
54
+ /** @ignore */
55
+ implement(name, callback) {
56
+ if (typeof callback === 'object') {
57
+ execute(callback);
58
+ }
59
+ else if (!this.done) {
60
+ callback();
61
+ }
62
+ if (name.startsWith('ext.CodeMirror.data')) {
63
+ this.done = true;
64
+ }
65
+ },
66
+ /** @ignore */
67
+ state() {
68
+ //
69
+ },
70
+ },
71
+ config: {
72
+ /** @ignore */
73
+ set({ extCodeMirrorConfig }) {
74
+ mwConfig = extCodeMirrorConfig;
75
+ },
76
+ },
77
+ };
78
+ let mwConfig;
11
79
  /**
12
80
  * Get the parser configuration for a Wikimedia Foundation project.
13
81
  * @param site site nickname
14
82
  * @param url script path
15
83
  * @param force whether to overwrite the existing configuration
16
- * @param old whether to target an older version of MediaWiki
84
+ * @param internal for internal use
17
85
  */
18
- exports.default = async (site, url, force, old) => {
86
+ exports.default = async (site, url, force, internal) => {
19
87
  if (!site || !url) {
20
88
  console.error('Usage: npx getParserConfig <site> <script path> [force]');
21
89
  process.exit(1);
@@ -23,61 +91,13 @@ exports.default = async (site, url, force, old) => {
23
91
  else if (/(?:\.php|\/)$/u.test(url)) {
24
92
  url = url.slice(0, url.lastIndexOf('/'));
25
93
  }
26
- let mwConfig;
27
- const mw = {
28
- loader: {
29
- /** @ignore */
30
- impl(callback) {
31
- Object.entries(callback()[1].files).find(([k]) => k.endsWith('.data.js'))[1]();
32
- },
33
- /** @ignore */
34
- implement(_, callback) {
35
- callback();
36
- },
37
- },
38
- config: {
39
- /** @ignore */
40
- set({ extCodeMirrorConfig }) {
41
- mwConfig = extCodeMirrorConfig;
42
- },
43
- },
44
- };
45
- /**
46
- * Converts an array to an object.
47
- * @param config parser configuration
48
- * @param config.articlePath article path
49
- */
50
- const arrToObj = ({ articlePath, ...obj }) => {
51
- for (const [k, v] of Object.entries(obj)) {
52
- if (Array.isArray(v) && v.every(x => typeof x === 'string')) {
53
- Object.assign(obj, { [k]: Object.fromEntries(v.map(x => [x, true])) });
54
- }
55
- }
56
- return obj;
57
- };
58
- /**
59
- * Gets the aliases of magic words.
60
- * @param magicwords magic words
61
- * @param targets magic word names
62
- */
63
- const getAliases = (magicwords, targets) => magicwords
64
- .filter(({ name }) => targets.has(name))
65
- .flatMap(({ aliases }) => aliases.map(s => s.replace(/:$/u, '').toLowerCase()));
66
- /**
67
- * Filters out gadget-related namespaces.
68
- * @param id namespace ID
69
- */
70
- const filterGadget = (id) => {
71
- const n = Number(id);
72
- return n < 2300 || n > 2303; // Gadget, Gadget talk, Gadget definition, Gadget definition talk
73
- };
74
- const m = await (await fetch(`${url}/load.php?modules=ext.CodeMirror${old ? '.data' : ''}`)).text(), params = {
94
+ const m = await (await fetch(`${url}/load.php?modules=ext.CodeMirror.data|ext.CodeMirror`)).text(), params = {
75
95
  action: 'query',
76
96
  meta: 'siteinfo',
77
- siprop: `general|magicwords|namespaces|namespacealiases${old ? '|variables' : ''}`,
97
+ siprop: 'general|magicwords|functionhooks|namespaces|namespacealiases',
78
98
  format: 'json',
79
99
  formatversion: '2',
80
- }, { query: { general: { variants }, magicwords, namespaces, namespacealiases, variables } } = await (await fetch(`${url}/api.php?${new URLSearchParams(params).toString()}`)).json();
100
+ }, { query: { general: { articlepath, variants }, magicwords, namespaces, namespacealiases, functionhooks, }, } = await (await fetch(`${url}/api.php?${new URLSearchParams(params).toString()}`)).json(), { query: { variables } } = await (await fetch(`${url}/api.php?${new URLSearchParams({ ...params, siprop: 'variables' }).toString()}`)).json();
81
101
  eval(m); // eslint-disable-line no-eval
82
102
  const dir = path_1.default.join('..', '..', 'config'), ns = Object.entries(namespaces).filter(([id]) => filterGadget(id))
83
103
  .flatMap(([id, { name, canonical = '' }]) => [
@@ -92,8 +112,8 @@ exports.default = async (site, url, force, old) => {
92
112
  ...ns.map(([id, canonical]) => [canonical.toLowerCase(), Number(id)]),
93
113
  ...namespacealiases.filter(({ id }) => filterGadget(id)).map(({ id, alias }) => [alias.toLowerCase(), id]),
94
114
  ]),
95
- ...old && { variable: [...variables, '='] },
96
- articlePath: '/wiki/$1',
115
+ functionHook: [...functionhooks.map(s => s.toLowerCase()), 'msgnw'],
116
+ articlePath: articlepath,
97
117
  };
98
118
  config.doubleUnderscore[0] = [];
99
119
  config.doubleUnderscore[1] = [];
@@ -107,12 +127,15 @@ exports.default = async (site, url, force, old) => {
107
127
  }
108
128
  config.parserFunction[2] = getAliases(magicwords, new Set(['msg', 'raw']));
109
129
  config.parserFunction[3] = getAliases(magicwords, new Set(['subst', 'safesubst']));
110
- const file = path_1.default.join(__dirname, dir, `${site}.json`), exists = fs_1.default.existsSync(file);
111
- if (exists) {
112
- assert_1.default.deepStrictEqual(arrToObj(require(file)), arrToObj(config));
130
+ if (!config.variable) { // eslint-disable-line @typescript-eslint/no-unnecessary-condition
131
+ Object.assign(config, { variable: [...new Set([...variables, '='])] });
113
132
  }
114
- if (force || !exists) {
133
+ const file = path_1.default.join(__dirname, dir, `${site}.json`);
134
+ if (force || !fs_1.default.existsSync(file)) {
115
135
  fs_1.default.writeFileSync(file, `${JSON.stringify(config, null, '\t')}\n`);
116
136
  }
137
+ else if (!internal) {
138
+ assert_1.default.deepStrictEqual(arrToObj(require(file)), arrToObj(config));
139
+ }
117
140
  return config;
118
141
  };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type { Config, LintError, TokenTypes, Parser as ParserBase, Stage } from './base';
2
- import type { Title } from './lib/title';
2
+ import type { Title, TitleOptions } from './lib/title';
3
3
  import type { LanguageService, QuickFixData } from './lib/lsp';
4
4
  import type { Token } from './internal';
5
5
  declare interface Parser extends ParserBase {
6
+ /** @since v1.5.1 */
6
7
  rules: readonly LintError.Rule[];
7
8
  /**
8
9
  * Normalize page title
@@ -19,6 +20,7 @@ declare interface Parser extends ParserBase {
19
20
  *
20
21
  * 创建语言服务
21
22
  * @param uri document URI / 文档标识
23
+ * @since v1.16.1
22
24
  */
23
25
  createLanguageService(uri: object): LanguageService;
24
26
  }