wikilint 2.13.4 → 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.
@@ -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 字符位置
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.13.4",
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.3",
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": {