wikilint 2.48.2 → 3.1.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.
Files changed (72) hide show
  1. package/README.md +1 -1
  2. package/config/.schema.json +5 -0
  3. package/data/signatures.json +2 -2
  4. package/dist/base.d.mts +4 -2
  5. package/dist/base.d.ts +4 -2
  6. package/dist/base.js +1 -0
  7. package/dist/base.mjs +2 -1
  8. package/dist/bin/config.js +1 -1
  9. package/dist/index.d.ts +1 -3
  10. package/dist/index.js +20 -14
  11. package/dist/internal.d.ts +1 -0
  12. package/dist/lib/document.d.ts +7 -6
  13. package/dist/lib/document.js +3 -1
  14. package/dist/lib/lintConfig.js +1 -0
  15. package/dist/lib/lsp.js +9 -7
  16. package/dist/lib/node.d.ts +0 -4
  17. package/dist/lib/node.js +8 -0
  18. package/dist/lib/text.js +4 -3
  19. package/dist/lib/title.js +6 -1
  20. package/dist/map.d.ts +2 -1
  21. package/dist/parser/commentAndExt.js +1 -1
  22. package/dist/parser/hrAndDoubleUnderscore.js +3 -2
  23. package/dist/parser/table.js +2 -1
  24. package/dist/src/arg.d.ts +1 -1
  25. package/dist/src/arg.js +1 -1
  26. package/dist/src/attributes.d.ts +4 -3
  27. package/dist/src/converter.d.ts +1 -1
  28. package/dist/src/converter.js +1 -1
  29. package/dist/src/converterRule.d.ts +1 -1
  30. package/dist/src/converterRule.js +1 -1
  31. package/dist/src/extLink.d.ts +1 -1
  32. package/dist/src/extLink.js +1 -1
  33. package/dist/src/index.js +54 -58
  34. package/dist/src/link/category.d.ts +1 -1
  35. package/dist/src/link/category.js +1 -1
  36. package/dist/src/link/galleryImage.js +1 -1
  37. package/dist/src/link/index.d.ts +1 -1
  38. package/dist/src/link/index.js +1 -1
  39. package/dist/src/link/redirectTarget.d.ts +1 -1
  40. package/dist/src/link/redirectTarget.js +1 -1
  41. package/dist/src/magicLink.d.ts +4 -3
  42. package/dist/src/magicLink.js +1 -1
  43. package/dist/src/multiLine/gallery.d.ts +4 -4
  44. package/dist/src/multiLine/gallery.js +13 -4
  45. package/dist/src/multiLine/imagemap.d.ts +5 -3
  46. package/dist/src/multiLine/imagemap.js +1 -1
  47. package/dist/src/nested.d.ts +1 -1
  48. package/dist/src/nested.js +1 -1
  49. package/dist/src/nowiki/list.js +6 -3
  50. package/dist/src/nowiki/listBase.d.ts +24 -0
  51. package/dist/src/nowiki/listBase.js +104 -0
  52. package/dist/src/paramLine.d.ts +1 -1
  53. package/dist/src/paramLine.js +1 -1
  54. package/dist/src/pre.d.ts +5 -3
  55. package/dist/src/redirect.d.ts +1 -1
  56. package/dist/src/redirect.js +1 -1
  57. package/dist/src/singleLine/charinsertLine.d.ts +1 -1
  58. package/dist/src/singleLine/charinsertLine.js +1 -1
  59. package/dist/src/table/index.d.ts +2 -2
  60. package/dist/src/table/index.js +1 -1
  61. package/dist/src/table/tr.d.ts +1 -1
  62. package/dist/src/table/tr.js +1 -1
  63. package/dist/src/tag/index.d.ts +7 -5
  64. package/dist/src/tag/index.js +9 -4
  65. package/dist/src/tagPair/ext.js +1 -1
  66. package/dist/src/transclude.d.ts +1 -1
  67. package/dist/src/transclude.js +1 -1
  68. package/dist/util/debug.js +7 -1
  69. package/i18n/en.json +1 -0
  70. package/i18n/zh-hans.json +1 -0
  71. package/i18n/zh-hant.json +1 -0
  72. package/package.json +2 -2
@@ -6,7 +6,7 @@ import type { Token, CharinsertToken, AstText } from '../../internal';
6
6
  * lines in `<charinsert>`
7
7
  *
8
8
  * `<charinsert>` 的行
9
- * @classdesc `{childNodes: (AstText | ExtToken)[]}`
9
+ * @classdesc `{childNodes: (AstText|ExtToken)[]}`
10
10
  */
11
11
  export declare abstract class CharinsertLineToken extends SingleLineToken {
12
12
  readonly childNodes: readonly (AstText | ExtToken)[];
@@ -14,7 +14,7 @@ const ext_1 = require("../tagPair/ext");
14
14
  * lines in `<charinsert>`
15
15
  *
16
16
  * `<charinsert>` 的行
17
- * @classdesc `{childNodes: (AstText | ExtToken)[]}`
17
+ * @classdesc `{childNodes: (AstText|ExtToken)[]}`
18
18
  */
19
19
  class CharinsertLineToken extends index_2.SingleLineToken {
20
20
  get type() {
@@ -6,13 +6,13 @@ import type { TableCoords } from './trBase';
6
6
  export type TableTokens = TableToken | TrToken | TdToken;
7
7
  /** @extends {Array<TableCoords[]>} */
8
8
  export declare class Layout extends Array<TableCoords[]> {
9
- abstract static from(arr: TableCoords[][]): Layout;
9
+ static from: (arr: TableCoords[][]) => Layout;
10
10
  }
11
11
  /**
12
12
  * table
13
13
  *
14
14
  * 表格
15
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[], ...TrToken[], ?SyntaxToken]}`
15
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...TdToken[], ...TrToken[], SyntaxToken?]}`
16
16
  */
17
17
  export declare abstract class TableToken extends TrBaseToken {
18
18
  readonly childNodes: readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[], SyntaxToken] | readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[]];
@@ -53,7 +53,7 @@ exports.Layout = Layout;
53
53
  * table
54
54
  *
55
55
  * 表格
56
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[], ...TrToken[], ?SyntaxToken]}`
56
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...TdToken[], ...TrToken[], SyntaxToken?]}`
57
57
  */
58
58
  let TableToken = (() => {
59
59
  let _classSuper = trBase_1.TrBaseToken;
@@ -5,7 +5,7 @@ import type { Token, TdToken, TableToken, SyntaxToken, AttributesToken } from '.
5
5
  * table row that contains the newline at the beginning but not at the end
6
6
  *
7
7
  * 表格行,含开头的换行,不含结尾的换行
8
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[]]}`
8
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...TdToken[]]}`
9
9
  */
10
10
  export declare abstract class TrToken extends TrBaseToken {
11
11
  readonly childNodes: readonly [SyntaxToken, AttributesToken, ...TdToken[]];
@@ -6,7 +6,7 @@ const trBase_1 = require("./trBase");
6
6
  * table row that contains the newline at the beginning but not at the end
7
7
  *
8
8
  * 表格行,含开头的换行,不含结尾的换行
9
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[]]}`
9
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...TdToken[]]}`
10
10
  */
11
11
  class TrToken extends trBase_1.TrBaseToken {
12
12
  get type() {
@@ -1,17 +1,18 @@
1
1
  import { Token } from '../index';
2
2
  import type { Config } from '../../base';
3
3
  import type { AttributesToken, SyntaxToken } from '../../internal';
4
+ declare type Child = AttributesToken | SyntaxToken;
4
5
  /**
5
6
  * HTML tag
6
7
  *
7
8
  * HTML标签
8
- * @classdesc `{childNodes: [AttributesToken]}`
9
+ * @classdesc `{childNodes: [AttributesToken|SyntaxToken]}`
9
10
  */
10
11
  export declare abstract class TagToken extends Token {
11
12
  #private;
12
- readonly childNodes: readonly [AttributesToken | SyntaxToken];
13
- abstract get firstChild(): AttributesToken | SyntaxToken;
14
- abstract get lastChild(): AttributesToken | SyntaxToken;
13
+ readonly childNodes: readonly [Child];
14
+ abstract get firstChild(): Child;
15
+ abstract get lastChild(): Child;
15
16
  abstract get type(): 'html' | 'tvar';
16
17
  abstract get selfClosing(): boolean | undefined;
17
18
  /** whether to be a closing tag / 是否是闭合标签 */
@@ -21,7 +22,7 @@ export declare abstract class TagToken extends Token {
21
22
  * @param attr 标签属性
22
23
  * @param closing 是否闭合
23
24
  */
24
- constructor(tag: string, attr: AttributesToken | SyntaxToken, closing: boolean, config?: Config, accum?: Token[]);
25
+ constructor(tag: string, attr: Child, closing: boolean, config?: Config, accum?: Token[]);
25
26
  /**
26
27
  * Find the matching tag
27
28
  *
@@ -29,3 +30,4 @@ export declare abstract class TagToken extends Token {
29
30
  */
30
31
  findMatchingTag(): this | undefined;
31
32
  }
33
+ export {};
@@ -8,7 +8,7 @@ const index_1 = require("../index");
8
8
  * HTML tag
9
9
  *
10
10
  * HTML标签
11
- * @classdesc `{childNodes: [AttributesToken]}`
11
+ * @classdesc `{childNodes: [AttributesToken|SyntaxToken]}`
12
12
  */
13
13
  class TagToken extends index_1.Token {
14
14
  #closing;
@@ -47,7 +47,6 @@ class TagToken extends index_1.Token {
47
47
  findMatchingTag() {
48
48
  LINT: return (0, lint_1.cache)(this.#match, () => {
49
49
  const { type, name, closing, selfClosing, } = this;
50
- // eslint-disable-next-line prefer-const
51
50
  let { parentNode } = this, isVoid = false, isFlexible = false;
52
51
  if (type === 'html') {
53
52
  const [, flexibleTags, voidTags] = this.getAttribute('config').html;
@@ -63,9 +62,15 @@ class TagToken extends index_1.Token {
63
62
  }
64
63
  const { childNodes } = parentNode, i = childNodes.indexOf(this), siblings = closing ? childNodes.slice(0, i) : childNodes.slice(i + 1).reverse(), stack = [this], { rev } = debug_1.Shadow;
65
64
  let cur = siblings.pop(), until;
66
- while (cur) {
67
- // eslint-disable-next-line no-empty, @typescript-eslint/no-unnecessary-condition
65
+ while (cur || parentNode.is('list-range') && parentNode.parentNode) {
68
66
  if (!cur) {
67
+ const parent = parentNode.parentNode, ch = parent.childNodes, j = ch.indexOf(parentNode);
68
+ Array.prototype.push.apply(siblings, closing ? ch.slice(0, j) : ch.slice(j + 1).reverse());
69
+ parentNode = parent;
70
+ }
71
+ else if (cur.is('list-range')) {
72
+ const ch = cur.childNodes;
73
+ Array.prototype.push.apply(siblings, closing ? ch : [...ch].reverse());
69
74
  }
70
75
  else if (until) {
71
76
  if (cur === until) {
@@ -223,7 +223,7 @@ let ExtToken = (() => {
223
223
  LINT: {
224
224
  const refName = this.getAttr('name'), text = this.innerText?.trim();
225
225
  let msg = '';
226
- if (this.closest('ext#references')) {
226
+ if (this.closest('ext-inner#references')) {
227
227
  if (!refName) {
228
228
  msg = 'no-named-in-references';
229
229
  }
@@ -8,7 +8,7 @@ export declare const invalidTemplateMsg = "Invalid template name";
8
8
  * template or magic word
9
9
  *
10
10
  * 模板或魔术字
11
- * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken[], ...ParameterToken[]]}`
11
+ * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...ParameterToken[]]}`
12
12
  */
13
13
  export declare abstract class TranscludeToken extends Token {
14
14
  #private;
@@ -55,7 +55,7 @@ const sortArgs = /** @ignore */ ({ childNodes }, args) => [...args].sort((a, b)
55
55
  * template or magic word
56
56
  *
57
57
  * 模板或魔术字
58
- * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken[], ...ParameterToken[]]}`
58
+ * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...ParameterToken[]]}`
59
59
  */
60
60
  let TranscludeToken = (() => {
61
61
  let _classDecorators = [noEscape_1.noEscape, (0, gapped_1.gapped)()];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mixin = exports.emptyArray = exports.getMagicWordInfo = exports.setChildNodes = exports.isLink = exports.isRowEnd = exports.Shadow = void 0;
3
+ exports.mixin = exports.emptyArray = exports.getMagicWordInfo = exports.setChildNodes = exports.isLink = exports.isRowEnd = exports.isIsolated = exports.Shadow = void 0;
4
4
  exports.isToken = isToken;
5
5
  exports.Shadow = {
6
6
  running: false,
@@ -37,6 +37,12 @@ exports.Shadow = {
37
37
  function isToken(type) {
38
38
  return (node) => node.type === type;
39
39
  }
40
+ /**
41
+ * 扩展节点是否提供独立解析环境
42
+ * @param name 扩展节点名称
43
+ */
44
+ const isIsolated = (name) => name === 'poem' || name === 'indicator';
45
+ exports.isIsolated = isIsolated;
40
46
  /**
41
47
  * 是否是行尾
42
48
  * @param token 节点
package/i18n/en.json CHANGED
@@ -17,6 +17,7 @@
17
17
  "duplicate-ext-parameter": "duplicate parameter of <$1>",
18
18
  "duplicate-id": "duplicate HTML id",
19
19
  "duplicate-image-parameter": "duplicate image $1 parameter",
20
+ "duplicate-name": "duplicate name of <indicator>",
20
21
  "duplicate-parameter": "duplicate template parameter",
21
22
  "encode": null,
22
23
  "escape": null,
package/i18n/zh-hans.json CHANGED
@@ -17,6 +17,7 @@
17
17
  "duplicate-ext-parameter": "重复的<$1>参数",
18
18
  "duplicate-id": "重复的HTML id属性",
19
19
  "duplicate-image-parameter": "重复的图像$1参数",
20
+ "duplicate-name": "重复的<indicator> name属性",
20
21
  "duplicate-parameter": "重复的模板参数",
21
22
  "encode": "编码",
22
23
  "escape": "转义",
package/i18n/zh-hant.json CHANGED
@@ -17,6 +17,7 @@
17
17
  "duplicate-ext-parameter": "重複的<$1>參數",
18
18
  "duplicate-id": "重複的HTML id屬性",
19
19
  "duplicate-image-parameter": "重複的圖片$1參數",
20
+ "duplicate-name": "重複的<indicator> name屬性",
20
21
  "duplicate-parameter": "重複的模板參數",
21
22
  "encode": "編碼",
22
23
  "escape": "跳脫",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.48.2",
3
+ "version": "3.1.0",
4
4
  "description": "A Node.js linter for MediaWiki markup",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -125,6 +125,6 @@
125
125
  "vscode-languageserver-textdocument": "^1.0.16"
126
126
  },
127
127
  "engines": {
128
- "node": "^20.19.0 || ^22.13.0 || >=24.11.0"
128
+ "node": "^22.13.0 || >=24.11.0"
129
129
  }
130
130
  }