wikilint 2.8.0 → 2.9.1

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 (113) hide show
  1. package/dist/base.d.ts +4 -2
  2. package/dist/base.js +1 -0
  3. package/dist/index.d.ts +3 -7
  4. package/dist/index.js +8 -2
  5. package/dist/lib/element.d.ts +0 -13
  6. package/dist/lib/element.js +4 -11
  7. package/dist/lib/node.d.ts +1 -1
  8. package/dist/lib/node.js +1 -1
  9. package/dist/lib/rect.d.ts +18 -0
  10. package/dist/lib/rect.js +32 -0
  11. package/dist/lib/text.d.ts +0 -6
  12. package/dist/lib/text.js +6 -17
  13. package/dist/mixin/attributesParent.js +2 -1
  14. package/dist/mixin/hidden.d.ts +2 -0
  15. package/dist/mixin/hidden.js +9 -4
  16. package/dist/parser/braces.js +16 -4
  17. package/dist/parser/commentAndExt.js +1 -8
  18. package/dist/parser/converter.js +2 -3
  19. package/dist/parser/externalLinks.js +2 -9
  20. package/dist/parser/hrAndDoubleUnderscore.js +1 -1
  21. package/dist/parser/html.js +1 -1
  22. package/dist/parser/links.js +1 -1
  23. package/dist/parser/magicLinks.js +28 -17
  24. package/dist/parser/redirect.js +1 -1
  25. package/dist/parser/table.js +1 -1
  26. package/dist/src/arg.d.ts +0 -4
  27. package/dist/src/arg.js +6 -5
  28. package/dist/src/atom.d.ts +2 -2
  29. package/dist/src/atom.js +3 -4
  30. package/dist/src/attribute.d.ts +0 -4
  31. package/dist/src/attribute.js +6 -18
  32. package/dist/src/attributes.d.ts +0 -2
  33. package/dist/src/attributes.js +5 -10
  34. package/dist/src/converter.d.ts +0 -2
  35. package/dist/src/converter.js +2 -2
  36. package/dist/src/converterFlags.d.ts +0 -4
  37. package/dist/src/converterFlags.js +4 -3
  38. package/dist/src/converterRule.d.ts +0 -2
  39. package/dist/src/converterRule.js +2 -2
  40. package/dist/src/extLink.d.ts +0 -4
  41. package/dist/src/extLink.js +3 -3
  42. package/dist/src/gallery.d.ts +0 -4
  43. package/dist/src/gallery.js +3 -3
  44. package/dist/src/heading.d.ts +0 -4
  45. package/dist/src/heading.js +5 -10
  46. package/dist/src/hidden.d.ts +1 -1
  47. package/dist/src/hidden.js +53 -3
  48. package/dist/src/html.d.ts +2 -7
  49. package/dist/src/html.js +16 -36
  50. package/dist/src/imageParameter.d.ts +0 -4
  51. package/dist/src/imageParameter.js +5 -5
  52. package/dist/src/imagemap.d.ts +0 -4
  53. package/dist/src/imagemap.js +6 -5
  54. package/dist/src/index.d.ts +0 -11
  55. package/dist/src/index.js +34 -32
  56. package/dist/src/link/base.d.ts +0 -4
  57. package/dist/src/link/base.js +4 -8
  58. package/dist/src/link/file.d.ts +0 -2
  59. package/dist/src/link/file.js +7 -7
  60. package/dist/src/link/galleryImage.d.ts +0 -2
  61. package/dist/src/link/galleryImage.js +2 -3
  62. package/dist/src/link/index.d.ts +0 -2
  63. package/dist/src/link/index.js +1 -1
  64. package/dist/src/link/redirectTarget.d.ts +0 -4
  65. package/dist/src/link/redirectTarget.js +4 -4
  66. package/dist/src/magicLink.d.ts +7 -5
  67. package/dist/src/magicLink.js +37 -7
  68. package/dist/src/nested.d.ts +0 -2
  69. package/dist/src/nested.js +5 -5
  70. package/dist/src/nowiki/base.d.ts +2 -2
  71. package/dist/src/nowiki/base.js +3 -4
  72. package/dist/src/nowiki/comment.d.ts +3 -6
  73. package/dist/src/nowiki/comment.js +78 -28
  74. package/dist/src/nowiki/doubleUnderscore.d.ts +3 -3
  75. package/dist/src/nowiki/doubleUnderscore.js +68 -19
  76. package/dist/src/nowiki/index.d.ts +0 -2
  77. package/dist/src/nowiki/index.js +2 -2
  78. package/dist/src/nowiki/noinclude.d.ts +1 -1
  79. package/dist/src/nowiki/noinclude.js +53 -3
  80. package/dist/src/nowiki/quote.d.ts +0 -2
  81. package/dist/src/nowiki/quote.js +19 -25
  82. package/dist/src/paramTag/index.d.ts +0 -4
  83. package/dist/src/paramTag/index.js +5 -5
  84. package/dist/src/parameter.d.ts +0 -2
  85. package/dist/src/parameter.js +4 -3
  86. package/dist/src/pre.d.ts +0 -2
  87. package/dist/src/pre.js +1 -1
  88. package/dist/src/redirect.d.ts +4 -5
  89. package/dist/src/redirect.js +83 -33
  90. package/dist/src/syntax.d.ts +2 -4
  91. package/dist/src/syntax.js +4 -5
  92. package/dist/src/table/index.d.ts +2 -5
  93. package/dist/src/table/index.js +7 -6
  94. package/dist/src/table/td.d.ts +0 -4
  95. package/dist/src/table/td.js +13 -7
  96. package/dist/src/table/tr.d.ts +2 -2
  97. package/dist/src/table/tr.js +1 -2
  98. package/dist/src/table/trBase.d.ts +0 -2
  99. package/dist/src/table/trBase.js +2 -2
  100. package/dist/src/tagPair/ext.d.ts +0 -2
  101. package/dist/src/tagPair/ext.js +6 -8
  102. package/dist/src/tagPair/include.d.ts +6 -6
  103. package/dist/src/tagPair/include.js +76 -26
  104. package/dist/src/tagPair/index.d.ts +2 -4
  105. package/dist/src/tagPair/index.js +6 -7
  106. package/dist/src/transclude.d.ts +0 -4
  107. package/dist/src/transclude.js +10 -14
  108. package/dist/util/debug.js +10 -1
  109. package/dist/util/lint.js +4 -3
  110. package/dist/util/string.js +5 -5
  111. package/i18n/zh-hans.json +1 -0
  112. package/i18n/zh-hant.json +1 -0
  113. package/package.json +12 -12
@@ -1,4 +1,38 @@
1
1
  "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
2
36
  Object.defineProperty(exports, "__esModule", { value: true });
3
37
  exports.IncludeToken = void 0;
4
38
  const lint_1 = require("../../util/lint");
@@ -9,31 +43,47 @@ const index_2 = require("./index");
9
43
  * `<includeonly>`或`<noinclude>`或`<onlyinclude>`
10
44
  * @classdesc `{childNodes: [AstText, AstText]}`
11
45
  */
12
- class IncludeToken extends (0, hidden_1.hiddenToken)(index_2.TagPairToken) {
13
- type = 'include';
14
- /**
15
- * @param name 标签名
16
- * @param attr 标签属性
17
- * @param inner 内部wikitext
18
- * @param closed 是否封闭
19
- */
20
- constructor(name, attr = '', inner, closed, config = index_1.default.getConfig(), accum = []) {
21
- super(name, attr, inner ?? '', inner === undefined ? closed : closed ?? '', config, accum);
22
- }
23
- /** @override */
24
- lint(start = this.getAbsoluteIndex()) {
25
- if (this.closed) {
26
- return [];
46
+ let IncludeToken = (() => {
47
+ let _classDecorators = [(0, hidden_1.hiddenToken)()];
48
+ let _classDescriptor;
49
+ let _classExtraInitializers = [];
50
+ let _classThis;
51
+ let _classSuper = index_2.TagPairToken;
52
+ var IncludeToken = class extends _classSuper {
53
+ static { _classThis = this; }
54
+ static {
55
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
56
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
57
+ IncludeToken = _classThis = _classDescriptor.value;
58
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
59
+ __runInitializers(_classThis, _classExtraInitializers);
27
60
  }
28
- const e = (0, lint_1.generateForSelf)(this, { start }, 'unclosed-comment', index_1.default.msg('unclosed $1', `<${this.name}>`));
29
- e.suggestions = [
30
- {
31
- desc: 'close',
32
- range: [e.endIndex, e.endIndex],
33
- text: `</${this.name}>`,
34
- },
35
- ];
36
- return [e];
37
- }
38
- }
61
+ type = 'include';
62
+ /**
63
+ * @param name 标签名
64
+ * @param attr 标签属性
65
+ * @param inner 内部wikitext
66
+ * @param closed 是否封闭
67
+ */
68
+ constructor(name, attr = '', inner, closed, config, accum) {
69
+ super(name, attr, inner ?? '', inner === undefined ? closed : closed ?? '', config, accum);
70
+ }
71
+ /** @private */
72
+ lint(start = this.getAbsoluteIndex()) {
73
+ if (this.closed) {
74
+ return [];
75
+ }
76
+ const e = (0, lint_1.generateForSelf)(this, { start }, 'unclosed-comment', index_1.default.msg('unclosed $1', `<${this.name}>`));
77
+ e.suggestions = [
78
+ {
79
+ desc: 'close',
80
+ range: [e.endIndex, e.endIndex],
81
+ text: `</${this.name}>`,
82
+ },
83
+ ];
84
+ return [e];
85
+ }
86
+ };
87
+ return IncludeToken = _classThis;
88
+ })();
39
89
  exports.IncludeToken = IncludeToken;
@@ -1,5 +1,5 @@
1
- import Parser from '../../index';
2
1
  import { Token } from '../index';
2
+ import type { Config } from '../../base';
3
3
  import type { AstNodes } from '../../lib/node';
4
4
  /** 成对标签 */
5
5
  export declare abstract class TagPairToken extends Token {
@@ -19,7 +19,5 @@ export declare abstract class TagPairToken extends Token {
19
19
  * @param inner 内部wikitext
20
20
  * @param closed 是否封闭;约定`undefined`表示自封闭,`''`表示未闭合
21
21
  */
22
- constructor(name: string, attr: string | Token, inner: string | Token, closed?: string, config?: Parser.Config, accum?: Token[]);
23
- /** @override */
24
- text(): string;
22
+ constructor(name: string, attr: string | Token, inner: string | Token, closed?: string, config?: Config, accum?: Token[]);
25
23
  }
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TagPairToken = void 0;
4
- const index_1 = require("../../index");
5
- const index_2 = require("../index");
4
+ const index_1 = require("../index");
6
5
  /** 成对标签 */
7
- class TagPairToken extends index_2.Token {
6
+ class TagPairToken extends index_1.Token {
8
7
  #tags;
9
8
  closed;
10
9
  selfClosing;
@@ -18,7 +17,7 @@ class TagPairToken extends index_2.Token {
18
17
  * @param inner 内部wikitext
19
18
  * @param closed 是否封闭;约定`undefined`表示自封闭,`''`表示未闭合
20
19
  */
21
- constructor(name, attr, inner, closed, config = index_1.default.getConfig(), accum = []) {
20
+ constructor(name, attr, inner, closed, config, accum = []) {
22
21
  super(undefined, config);
23
22
  this.setAttribute('name', name.toLowerCase());
24
23
  this.#tags = [name, closed || name];
@@ -32,10 +31,10 @@ class TagPairToken extends index_2.Token {
32
31
  toString() {
33
32
  const { selfClosing, firstChild, lastChild, } = this, [opening, closing] = this.#tags;
34
33
  return selfClosing
35
- ? `<${opening}${String(firstChild)}/>`
36
- : `<${opening}${String(firstChild)}>${String(lastChild)}${this.closed ? `</${closing}>` : ''}`;
34
+ ? `<${opening}${firstChild.toString()}/>`
35
+ : `<${opening}${firstChild.toString()}>${lastChild.toString()}${this.closed ? `</${closing}>` : ''}`;
37
36
  }
38
- /** @override */
37
+ /** @private */
39
38
  text() {
40
39
  const [opening, closing] = this.#tags;
41
40
  return this.selfClosing
@@ -28,10 +28,6 @@ export declare abstract class TranscludeToken extends Token {
28
28
  setModifier(modifier: string): boolean;
29
29
  /** 是否是模板或模块 */
30
30
  isTemplate(): boolean;
31
- /** @override */
32
- text(): string;
33
- /** @override */
34
- lint(start?: number, re?: RegExp): LintError[];
35
31
  /**
36
32
  * @override
37
33
  * @param token 待插入的子节点
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TranscludeToken = void 0;
4
4
  const string_1 = require("../util/string");
5
5
  const lint_1 = require("../util/lint");
6
+ const rect_1 = require("../lib/rect");
6
7
  const debug_1 = require("../util/debug");
7
8
  const constants_1 = require("../util/constants");
8
9
  const index_1 = require("../index");
@@ -51,7 +52,7 @@ class TranscludeToken extends index_2.Token {
51
52
  if (isVar || isFunction && canonicalName) {
52
53
  this.setAttribute('name', canonicalName ?? lcName);
53
54
  this.type = 'magic-word';
54
- const pattern = new RegExp(`^\\s*${name}\\s*$`, isSensitive ? 'u' : 'iu'), token = new syntax_1.SyntaxToken(magicWord, pattern, 'magic-word-name', config, accum, {});
55
+ const pattern = new RegExp(String.raw `^\s*${name}\s*$`, isSensitive ? 'u' : 'iu'), token = new syntax_1.SyntaxToken(magicWord, pattern, 'magic-word-name', config, accum, {});
55
56
  super.insertAt(token);
56
57
  if (arg.length > 0) {
57
58
  parts.unshift([arg.join(':')]);
@@ -72,7 +73,7 @@ class TranscludeToken extends index_2.Token {
72
73
  const name = (0, string_1.removeComment)(title).trim();
73
74
  if (!this.normalizeTitle(name, 10, true).valid) {
74
75
  accum.pop();
75
- throw new SyntaxError('非法的模板名称');
76
+ throw new SyntaxError('Invalid template name');
76
77
  }
77
78
  const token = new atom_1.AtomToken(title, 'template-name', config, accum, {});
78
79
  super.insertAt(token);
@@ -131,10 +132,10 @@ class TranscludeToken extends index_2.Token {
131
132
  /** @private */
132
133
  toString() {
133
134
  return `{{${this.modifier}${this.type === 'magic-word'
134
- ? `${String(this.firstChild)}${this.length === 1 ? '' : ':'}${this.childNodes.slice(1).map(String).join('|')}`
135
+ ? `${this.firstChild.toString()}${this.length === 1 ? '' : ':'}${this.childNodes.slice(1).map(String).join('|')}`
135
136
  : super.toString('|')}}}`;
136
137
  }
137
- /** @override */
138
+ /** @private */
138
139
  text() {
139
140
  const { childNodes, length, firstChild, modifier, type, name } = this;
140
141
  return type === 'magic-word' && name === 'vardefine'
@@ -156,16 +157,14 @@ class TranscludeToken extends index_2.Token {
156
157
  getGaps() {
157
158
  return 1;
158
159
  }
159
- /** @override */
160
+ /** @private */
160
161
  lint(start = this.getAbsoluteIndex(), re) {
161
- const errors = super.lint(start, re), { type, childNodes, length } = this;
162
- let rect;
162
+ const errors = super.lint(start, re), { type, childNodes, length } = this, rect = new rect_1.BoundingRect(this, start);
163
163
  if (!this.isTemplate()) {
164
164
  return errors;
165
165
  }
166
166
  const title = this.#getTitle();
167
167
  if (title.fragment !== undefined) {
168
- rect = { start, ...this.getRootNode().posFromIndex(start) };
169
168
  const child = childNodes[type === 'template' ? 0 : 1], e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', 'useless fragment'), textNode = child.childNodes.find((c) => c.type === 'text' && c.data.includes('#'));
170
169
  if (textNode) {
171
170
  e.fix = {
@@ -176,17 +175,14 @@ class TranscludeToken extends index_2.Token {
176
175
  errors.push(e);
177
176
  }
178
177
  if (!title.valid) {
179
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
180
178
  errors.push((0, lint_1.generateForChild)(childNodes[1], rect, 'invalid-invoke', 'illegal module name'));
181
179
  }
182
180
  if (type === 'magic-word' && length === 2) {
183
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
184
181
  errors.push((0, lint_1.generateForSelf)(this, rect, 'invalid-invoke', 'missing module function'));
185
182
  return errors;
186
183
  }
187
184
  const duplicatedArgs = this.getDuplicatedArgs().filter(([, parameter]) => !parameter[0].querySelector('ext'));
188
185
  if (duplicatedArgs.length > 0) {
189
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
190
186
  errors.push(...duplicatedArgs.flatMap(([, args]) => args).map(arg => (0, lint_1.generateForChild)(arg, rect, 'no-duplicate', 'duplicated parameter')));
191
187
  }
192
188
  return errors;
@@ -257,9 +253,9 @@ class TranscludeToken extends index_2.Token {
257
253
  * @throws `Error` 不是可接受的魔术字
258
254
  */
259
255
  getPossibleValues() {
260
- const { type, name, childNodes, constructor: { name: cName } } = this;
256
+ const { type, name, childNodes } = this;
261
257
  if (type === 'template') {
262
- throw new Error(`${cName}.getPossibleValues 方法仅供特定魔术字使用!`);
258
+ throw new Error(`TranscludeToken.getPossibleValues method is only for specific magic words!`);
263
259
  }
264
260
  let start;
265
261
  switch (name) {
@@ -273,7 +269,7 @@ class TranscludeToken extends index_2.Token {
273
269
  start = 3;
274
270
  break;
275
271
  default:
276
- throw new Error(`${cName}.getPossibleValues 方法仅供特定魔术字使用!`);
272
+ throw new Error(`TranscludeToken.getPossibleValues method is only for specific magic words!`);
277
273
  }
278
274
  const queue = childNodes.slice(start, start + 2).map(({ childNodes: [, value] }) => value);
279
275
  for (let i = 0; i < queue.length;) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.emptyArray = exports.setChildNodes = exports.isToken = exports.Shadow = void 0;
3
+ exports.mixin = exports.emptyArray = exports.setChildNodes = exports.isToken = exports.Shadow = void 0;
4
4
  exports.Shadow = {
5
5
  running: false,
6
6
  /** @private */
@@ -47,3 +47,12 @@ exports.setChildNodes = setChildNodes;
47
47
  */
48
48
  const emptyArray = (n, callback) => new Array(n).fill(undefined).map((_, i) => callback(i));
49
49
  exports.emptyArray = emptyArray;
50
+ /**
51
+ * 同步混入的类名
52
+ * @param target 混入的目标
53
+ * @param source 混入的源
54
+ */
55
+ const mixin = (target, source) => {
56
+ Object.defineProperty(target, 'name', { value: source.name });
57
+ };
58
+ exports.mixin = mixin;
package/dist/util/lint.js CHANGED
@@ -1,19 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateForSelf = exports.generateForChild = void 0;
4
+ const rect_1 = require("../lib/rect");
4
5
  const index_1 = require("../index");
5
6
  /**
6
7
  * 生成lint函数
7
8
  * @param func lint函数
8
9
  */
9
- const factory = (func) => (token, boundingRect, rule, msg, severity = 'error') => {
10
- const { start } = boundingRect, { top, left } = 'top' in boundingRect ? boundingRect : token.getRootNode().posFromIndex(start), { offsetHeight, offsetWidth } = token, { startIndex, startLine, startCol } = func(token, start, top, left);
10
+ const factory = (func) => (token, rect, rule, msg, severity = 'error') => {
11
+ const { start } = rect, { top, left } = 'top' in rect ? rect : new rect_1.BoundingRect(token, start), { offsetHeight, offsetWidth } = token, { startIndex, startLine, startCol } = func(token, start, top, left);
11
12
  return {
12
13
  rule,
13
14
  message: index_1.default.msg(msg),
14
15
  severity,
15
16
  startIndex,
16
- endIndex: startIndex + String(token).length,
17
+ endIndex: startIndex + token.toString().length,
17
18
  startLine,
18
19
  endLine: startLine + offsetHeight - 1,
19
20
  startCol,
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.noWrap = exports.decodeHtml = exports.text = exports.escapeRegExp = exports.removeComment = exports.tidy = exports.extUrlChar = exports.extUrlCharFirst = void 0;
4
- const commonExtUrlChar = '[^[\\]<>"\0-\x1F\x7F\\p{Zs}\uFFFD]';
5
- exports.extUrlCharFirst = `(?:\\[[\\da-f:.]+\\]|${commonExtUrlChar})`;
6
- exports.extUrlChar = `(?:${commonExtUrlChar}|\0\\d+[c!~]\x7F)*`;
4
+ const commonExtUrlChar = String.raw `[^[\]<>"\0-\x1F\x7F\p{Zs}\uFFFD]`;
5
+ exports.extUrlCharFirst = String.raw `(?:\[[\da-f:.]+\]|${commonExtUrlChar})`;
6
+ exports.extUrlChar = String.raw `(?:${commonExtUrlChar}|\0\d+[c!~]\x7F)*`;
7
7
  /**
8
8
  * 生成正则替换函数
9
9
  * @param regex 正则表达式
@@ -15,7 +15,7 @@ exports.tidy = factory(/[\0\x7F]|\r$/gmu, '');
15
15
  /** remove half-parsed comment-like tokens */
16
16
  exports.removeComment = factory(/\0\d+c\x7F/gu, '');
17
17
  /** escape special chars for RegExp constructor */
18
- exports.escapeRegExp = factory(/[\\{}()|.?*+^$[\]]/gu, '\\$&');
18
+ exports.escapeRegExp = factory(/[\\{}()|.?*+^$[\]]/gu, String.raw `\$&`);
19
19
  /**
20
20
  * extract effective wikitext
21
21
  * @param childNodes a Token's contents
@@ -29,4 +29,4 @@ exports.decodeHtml = factory(/&(?:#(\d+|x[\da-fA-F]+)|([lLgG][tT]|[lr]brac[ke]))
29
29
  ? String.fromCodePoint(Number((/^x/iu.test(code) ? '0' : '') + code))
30
30
  : names[name.toLowerCase()]);
31
31
  /** escape newlines */
32
- exports.noWrap = factory(/\n/gu, '\\n');
32
+ exports.noWrap = factory(/\n/gu, String.raw `\n`);
package/i18n/zh-hans.json CHANGED
@@ -28,6 +28,7 @@
28
28
  "invalid conversion flag": "无效的转换标记",
29
29
  "invalid gallery image": "无效的图库图片",
30
30
  "invalid gallery image parameter": "无效的图库图片参数",
31
+ "invalid ISBN": "无效的ISBN",
31
32
  "invalid link in <imagemap>": "无效的<imagemap>链接",
32
33
  "invalid parameter of <$1>": "<$1>的无效参数",
33
34
  "invalid self-closing tag": "无效自封闭标签",
package/i18n/zh-hant.json CHANGED
@@ -28,6 +28,7 @@
28
28
  "invalid conversion flag": "無效的轉換標記",
29
29
  "invalid gallery image": "無效的圖庫圖片",
30
30
  "invalid gallery image parameter": "無效的圖庫圖片參數",
31
+ "invalid ISBN": "無效的ISBN",
31
32
  "invalid link in <imagemap>": "無效的<imagemap>連結",
32
33
  "invalid parameter of <$1>": "<$1>的無效參數",
33
34
  "invalid self-closing tag": "無效自封閉標籤",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.8.0",
3
+ "version": "2.9.1",
4
4
  "description": "A Node.js linter for MediaWiki markup",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -27,13 +27,14 @@
27
27
  "wikilint": "./bin/cli.js"
28
28
  },
29
29
  "main": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
30
31
  "repository": {
31
32
  "type": "git",
32
33
  "url": "git+https://github.com/bhsd-harry/wikiparser-node.git"
33
34
  },
34
35
  "scripts": {
35
- "declaration": "grep -rl --include='*.d.ts' '@private' dist/ | xargs bash sed.sh -i -E '/^\\s+\\/\\*\\* @private/,+1d'; grep -rl --include='*.d.ts' '/util/' dist/ | xargs bash sed.sh -i -E '/^import .+\\/util\\//d'; node ./dist/bin/declaration.js",
36
- "prepublishOnly": "npm run build",
36
+ "declaration": "grep -rl --include='*.d.ts' '@private' dist/ | xargs bash sed.sh -i -E '/^\\s+\\/\\*\\* @private/,+1d'; grep -rl --include='*.d.ts' '/util/' dist/ | xargs bash sed.sh -i -E '/^import .+\\/util\\//d'; bash sed.sh -i -E 's/abstract (lint|print|text)\\b/\\1/' dist/lib/node.d.ts; node ./dist/bin/declaration.js",
37
+ "prepublishOnly": "npm run build:core",
37
38
  "build:core": "bash build.sh",
38
39
  "build": "npm run build:core",
39
40
  "diff": "bash diff.sh",
@@ -41,6 +42,7 @@
41
42
  "lint:ts": "tsc --noEmit && eslint --cache .",
42
43
  "lint:json": "v8r -s config/.schema.json config/*.json",
43
44
  "lint": "npm run lint:ts && npm run lint:json",
45
+ "prof": "node --prof dist/test/prof.js && node --prof-process isolate-0x*-v8.log > test/prof.txt && bash sed.sh -i '0,/Bottom up/d' test/prof.txt && rm isolate-0x*-v8.log",
44
46
  "test": "node dist/test/test.js",
45
47
  "test:end": "pkill -x http-server",
46
48
  "test:real": "node dist/test/real.js"
@@ -49,22 +51,20 @@
49
51
  "chalk": "^4.1.2"
50
52
  },
51
53
  "devDependencies": {
52
- "@cypress/request": "^3.0.1",
53
- "@stylistic/eslint-plugin": "^1.5.4",
54
+ "@stylistic/eslint-plugin": "^2.1.0",
54
55
  "@types/node": "^20.11.6",
55
- "@types/request": "^2.48.12",
56
- "@typescript-eslint/eslint-plugin": "^7.1.0",
57
- "@typescript-eslint/parser": "^7.1.0",
56
+ "@typescript-eslint/eslint-plugin": "^7.10.0",
57
+ "@typescript-eslint/parser": "^7.10.0",
58
58
  "eslint": "^8.56.0",
59
59
  "eslint-plugin-es-x": "^7.5.0",
60
60
  "eslint-plugin-eslint-comments": "^3.2.0",
61
61
  "eslint-plugin-jsdoc": "^48.0.2",
62
- "eslint-plugin-json-es": "^1.5.7",
63
- "eslint-plugin-n": "^17.4.0",
62
+ "eslint-plugin-json-es": "^1.6.0",
63
+ "eslint-plugin-n": "^17.6.0",
64
64
  "eslint-plugin-promise": "^6.1.1",
65
65
  "eslint-plugin-regexp": "^2.2.0",
66
- "eslint-plugin-unicorn": "^52.0.0",
67
- "typescript": "^5.3.3",
66
+ "eslint-plugin-unicorn": "^53.0.0",
67
+ "typescript": "^5.4.5",
68
68
  "v8r": "^3.0.0"
69
69
  },
70
70
  "engines": {