wikilint 2.13.4 → 2.13.6
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.
- package/dist/index.js +0 -1
- package/dist/lib/node.d.ts +6 -0
- package/dist/lib/node.js +11 -0
- package/dist/src/index.js +12 -3
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +21 -2
package/dist/index.js
CHANGED
package/dist/lib/node.d.ts
CHANGED
|
@@ -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/dist/src/index.js
CHANGED
|
@@ -337,7 +337,7 @@ class Token extends element_1.AstElement {
|
|
|
337
337
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
338
338
|
let errors = super.lint(start, re);
|
|
339
339
|
if (this.type === 'root') {
|
|
340
|
-
const record = {}, selector = 'category,html-attr#id,ext-attr#id,table-attr#id';
|
|
340
|
+
const record = {}, selector = 'category,html-attr#id,ext-attr#id,table-attr#id,ext-attr#name';
|
|
341
341
|
for (const cat of this.querySelectorAll(selector)) {
|
|
342
342
|
let key;
|
|
343
343
|
if (cat.type === 'category') {
|
|
@@ -345,7 +345,16 @@ class Token extends element_1.AstElement {
|
|
|
345
345
|
}
|
|
346
346
|
else {
|
|
347
347
|
const value = cat.getValue();
|
|
348
|
-
|
|
348
|
+
if (cat.name === 'id') {
|
|
349
|
+
key = `#${value === true ? '' : value}`;
|
|
350
|
+
}
|
|
351
|
+
else if (cat.tag === 'ref' && value !== true && value
|
|
352
|
+
&& cat.parentNode.parentNode.innerText) {
|
|
353
|
+
key = `ref#${value}`;
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
349
358
|
}
|
|
350
359
|
const thisCat = record[key];
|
|
351
360
|
if (thisCat) {
|
|
@@ -357,7 +366,7 @@ class Token extends element_1.AstElement {
|
|
|
357
366
|
}
|
|
358
367
|
for (const [key, value] of Object.entries(record)) {
|
|
359
368
|
if (value.size > 1 && !key.startsWith('#mw-customcollapsible-')) {
|
|
360
|
-
const isCat = !key.
|
|
369
|
+
const isCat = !key.includes('#'), msg = `duplicated ${isCat ? 'category' : 'id/name'}`, severity = key.startsWith('#') ? 'warning' : 'error';
|
|
361
370
|
errors.push(...[...value].map(cat => {
|
|
362
371
|
const e = (0, lint_1.generateForSelf)(cat, { start: cat.getAbsoluteIndex() }, 'no-duplicate', msg, severity);
|
|
363
372
|
if (isCat) {
|
package/i18n/zh-hans.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"content to be moved out from the table": "将被移出表格的内容",
|
|
12
12
|
"duplicated $1 attribute": "重复的$1属性",
|
|
13
13
|
"duplicated category": "重复的分类",
|
|
14
|
-
"duplicated id": "重复的id",
|
|
14
|
+
"duplicated id/name": "重复的id/name",
|
|
15
15
|
"duplicated image $1 parameter": "重复的图片$1参数",
|
|
16
16
|
"duplicated parameter": "重复参数",
|
|
17
17
|
"extension tag in HTML tag attributes": "HTML标签属性中的扩展标签",
|
package/i18n/zh-hant.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"content to be moved out from the table": "將被移出表格的內容",
|
|
12
12
|
"duplicated $1 attribute": "重複的$1屬性",
|
|
13
13
|
"duplicated category": "重複的分類",
|
|
14
|
-
"duplicated id": "重複的id",
|
|
14
|
+
"duplicated id/name": "重複的id/name",
|
|
15
15
|
"duplicated image $1 parameter": "重複的圖片$1參數",
|
|
16
16
|
"duplicated parameter": "重複參數",
|
|
17
17
|
"extension tag in HTML tag attributes": "HTML標籤屬性中的擴展標籤",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikilint",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.6",
|
|
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.
|
|
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": {
|