wikilint 2.13.3 → 2.13.5

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.
@@ -383,7 +383,6 @@
383
383
  "#匹配式": "ifeq",
384
384
  "#若相等": "ifeq",
385
385
  "#如果相等": "ifeq",
386
- "#若表達式": "ifeq",
387
386
  "#ifeq": "ifeq",
388
387
  "#多选式": "switch",
389
388
  "#多条件式": "switch",
@@ -397,6 +396,7 @@
397
396
  "#如有": "ifexist",
398
397
  "#ifexist": "ifexist",
399
398
  "#若表达式": "ifexpr",
399
+ "#若表達式": "ifexpr",
400
400
  "#ifexpr": "ifexpr",
401
401
  "#错误式": "iferror",
402
402
  "#如果错误": "iferror",
@@ -364,7 +364,6 @@
364
364
  "#匹配式": "ifeq",
365
365
  "#若相等": "ifeq",
366
366
  "#如果相等": "ifeq",
367
- "#若表達式": "ifeq",
368
367
  "#ifeq": "ifeq",
369
368
  "#多选式": "switch",
370
369
  "#多条件式": "switch",
@@ -378,6 +377,7 @@
378
377
  "#如有": "ifexist",
379
378
  "#ifexist": "ifexist",
380
379
  "#若表达式": "ifexpr",
380
+ "#若表達式": "ifexpr",
381
381
  "#ifexpr": "ifexpr",
382
382
  "#错误式": "iferror",
383
383
  "#如果错误": "iferror",
@@ -39,6 +39,12 @@ export declare abstract class AstNode implements AstNodeBase {
39
39
  get offsetWidth(): number;
40
40
  /** 获取根节点 */
41
41
  getRootNode(): Token | this;
42
+ /**
43
+ * 将行列号转换为字符位置
44
+ * @param top 行号
45
+ * @param left 列号
46
+ */
47
+ indexFromPos(top: number, left: number): number | undefined;
42
48
  /**
43
49
  * 将字符位置转换为行列号
44
50
  * @param index 字符位置
package/dist/lib/node.js CHANGED
@@ -71,6 +71,17 @@ class AstNode {
71
71
  }
72
72
  return parentNode ?? this;
73
73
  }
74
+ /**
75
+ * 将行列号转换为字符位置
76
+ * @param top 行号
77
+ * @param left 列号
78
+ */
79
+ indexFromPos(top, left) {
80
+ const lines = String(this).split('\n');
81
+ return top >= 0 && left >= 0 && top <= lines.length - 1 && left <= lines[top].length
82
+ ? lines.slice(0, top).reduce((acc, cur) => acc + cur.length + 1, 0) + left
83
+ : undefined;
84
+ }
74
85
  /**
75
86
  * 将字符位置转换为行列号
76
87
  * @param index 字符位置
@@ -59,7 +59,7 @@ class TranscludeToken extends index_2.Token {
59
59
  if (isFunction || parts.length === 0 && !this.#raw) {
60
60
  const [magicWord, ...arg] = title.split(':'), cleaned = (0, string_1.removeComment)(magicWord), name = cleaned[arg.length > 0 ? 'trimStart' : 'trim'](), lcName = name.toLowerCase(), canonicalName = Object.prototype.hasOwnProperty.call(insensitive, lcName) && insensitive[lcName], isSensitive = sensitive.includes(name), isVar = isSensitive || insensitiveVars.has(canonicalName);
61
61
  if (isVar || isFunction && canonicalName) {
62
- this.setAttribute('name', canonicalName || lcName);
62
+ this.setAttribute('name', canonicalName || lcName.replace(/^#/u, ''));
63
63
  this.#type = 'magic-word';
64
64
  const pattern = new RegExp(String.raw `^\s*${name}\s*$`, isSensitive ? 'u' : 'iu'), token = new syntax_1.SyntaxToken(magicWord, pattern, 'magic-word-name', config, accum, {});
65
65
  super.insertAt(token);
@@ -0,0 +1 @@
1
+ export declare const commonHtmlAttrs: Set<string>, htmlAttrs: Record<string, Set<string>>, extAttrs: Record<string, Set<string>>, obsoleteAttrs: Record<string, Set<string>>;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noWrap = exports.decodeNumber = exports.decodeHtml = exports.text = exports.rawurldecode = exports.escapeRegExp = exports.removeComment = exports.tidy = exports.extUrlChar = exports.extUrlCharFirst = void 0;
3
+ exports.noWrap = exports.decodeNumber = exports.decodeHtml = exports.text = exports.escapeRegExp = exports.removeComment = exports.tidy = exports.extUrlChar = exports.extUrlCharFirst = exports.rawurldecode = void 0;
4
+ var common_1 = require("@bhsd/common");
5
+ Object.defineProperty(exports, "rawurldecode", { enumerable: true, get: function () { return common_1.rawurldecode; } });
4
6
  const commonExtUrlChar = String.raw `[^[\]<>"\0-\x1F\x7F\p{Zs}\uFFFD]`;
5
7
  exports.extUrlCharFirst = String.raw `(?:\[[\da-f:.]+\]|${commonExtUrlChar})`;
6
8
  exports.extUrlChar = String.raw `(?:${commonExtUrlChar}|\0\d+[cn!~]\x7F)*`;
@@ -16,12 +18,6 @@ exports.tidy = factory(/[\0\x7F]|\r$/gmu, '');
16
18
  exports.removeComment = factory(/\0\d+[cn]\x7F/gu, '');
17
19
  /** escape special chars for RegExp constructor */
18
20
  exports.escapeRegExp = factory(/[\\{}()|.?*+^$[\]]/gu, String.raw `\$&`);
19
- /**
20
- * PHP的`rawurldecode`函数的JavaScript实现
21
- * @param str 要解码的字符串
22
- */
23
- const rawurldecode = (str) => decodeURIComponent(str.replace(/%(?![\da-f]{2})/giu, '%25'));
24
- exports.rawurldecode = rawurldecode;
25
21
  /**
26
22
  * extract effective wikitext
27
23
  * @param childNodes a Token's contents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.13.3",
3
+ "version": "2.13.5",
4
4
  "description": "A Node.js linter for MediaWiki markup",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -51,8 +51,27 @@
51
51
  "chalk": "^4.1.2"
52
52
  },
53
53
  "devDependencies": {
54
- "@bhsd/common": "^0.4.2",
54
+ "@bhsd/common": "^0.4.5",
55
+ "@stylistic/eslint-plugin": "^2.3.0",
56
+ "@stylistic/stylelint-plugin": "^2.0.0",
55
57
  "@types/node": "^22.9.0",
58
+ "@typescript-eslint/eslint-plugin": "^7.15.0",
59
+ "@typescript-eslint/parser": "^7.15.0",
60
+ "esbuild": "^0.21.4",
61
+ "eslint": "^8.56.0",
62
+ "eslint-plugin-es-x": "^8.0.0",
63
+ "eslint-plugin-eslint-comments": "^3.2.0",
64
+ "eslint-plugin-jsdoc": "^48.5.2",
65
+ "eslint-plugin-json-es": "^1.6.0",
66
+ "eslint-plugin-markdown": "^4.0.1",
67
+ "eslint-plugin-n": "^17.9.0",
68
+ "eslint-plugin-promise": "^6.2.0",
69
+ "eslint-plugin-regexp": "^2.6.0",
70
+ "eslint-plugin-unicorn": "^54.0.0",
71
+ "http-server": "^14.1.0",
72
+ "stylelint": "^16.6.1",
73
+ "stylelint-config-recommended": "^14.0.0",
74
+ "typescript": "^5.5.3",
56
75
  "v8r": "^3.0.0"
57
76
  },
58
77
  "engines": {