wikilint 2.13.5 → 2.13.7
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/base.d.ts +1 -0
- package/dist/index.js +0 -1
- package/dist/lib/node.d.ts +3 -1
- package/dist/lib/node.js +4 -0
- package/dist/src/atom.js +1 -0
- package/dist/src/index.js +17 -7
- package/dist/src/paramTag/index.js +2 -2
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +18 -18
package/dist/base.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/lib/node.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare abstract class AstNode implements AstNodeBase {
|
|
|
19
19
|
data?: string | undefined;
|
|
20
20
|
readonly childNodes: readonly AstNodes[];
|
|
21
21
|
abstract get type(): TokenTypes | 'text';
|
|
22
|
-
abstract set type(value: TokenTypes |
|
|
22
|
+
abstract set type(value: TokenTypes | "text");
|
|
23
23
|
/** 可见部分 */
|
|
24
24
|
text(): string;
|
|
25
25
|
lint(): LintError[];
|
|
@@ -57,6 +57,8 @@ export declare abstract class AstNode implements AstNodeBase {
|
|
|
57
57
|
getRelativeIndex(j?: number): number;
|
|
58
58
|
/** 获取当前节点的绝对位置 */
|
|
59
59
|
getAbsoluteIndex(): number;
|
|
60
|
+
/** 获取当前节点的行列位置和大小 */
|
|
61
|
+
getBoundingClientRect(): Dimension & Position;
|
|
60
62
|
/**
|
|
61
63
|
* 是否是某种类型的节点
|
|
62
64
|
* @param type 节点类型
|
package/dist/lib/node.js
CHANGED
|
@@ -118,6 +118,10 @@ class AstNode {
|
|
|
118
118
|
const { parentNode } = this;
|
|
119
119
|
return parentNode ? parentNode.getAbsoluteIndex() + this.getRelativeIndex() : 0;
|
|
120
120
|
}
|
|
121
|
+
/** 获取当前节点的行列位置和大小 */
|
|
122
|
+
getBoundingClientRect() {
|
|
123
|
+
return { ...this.#getDimension(), ...this.getRootNode().posFromIndex(this.getAbsoluteIndex()) };
|
|
124
|
+
}
|
|
121
125
|
/** @private */
|
|
122
126
|
seal(key, permanent) {
|
|
123
127
|
Object.defineProperty(this, key, {
|
package/dist/src/atom.js
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -337,27 +337,37 @@ 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 =
|
|
340
|
+
const record = new Map(), 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') {
|
|
344
344
|
key = cat.name;
|
|
345
345
|
}
|
|
346
346
|
else {
|
|
347
|
-
const value = cat.getValue();
|
|
348
|
-
|
|
347
|
+
const value = cat.getValue(), attrs = cat.parentNode;
|
|
348
|
+
if (cat.name === 'id') {
|
|
349
|
+
key = `#${value === true ? '' : value}`;
|
|
350
|
+
}
|
|
351
|
+
else if (cat.tag === 'ref' && value !== true && value
|
|
352
|
+
&& attrs.parentNode.innerText) {
|
|
353
|
+
const group = attrs.getAttr('group');
|
|
354
|
+
key = `${typeof group === 'string' && group || ' '}#${value}`;
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
349
359
|
}
|
|
350
|
-
const thisCat = record
|
|
360
|
+
const thisCat = record.get(key);
|
|
351
361
|
if (thisCat) {
|
|
352
362
|
thisCat.add(cat);
|
|
353
363
|
}
|
|
354
364
|
else {
|
|
355
|
-
record
|
|
365
|
+
record.set(key, new Set([cat]));
|
|
356
366
|
}
|
|
357
367
|
}
|
|
358
|
-
for (const [key, value] of
|
|
368
|
+
for (const [key, value] of record) {
|
|
359
369
|
if (value.size > 1 && !key.startsWith('#mw-customcollapsible-')) {
|
|
360
|
-
const isCat = !key.
|
|
370
|
+
const isCat = !key.includes('#'), msg = `duplicated ${isCat ? 'category' : 'id/name'}`, severity = key.startsWith('#') ? 'warning' : 'error';
|
|
361
371
|
errors.push(...[...value].map(cat => {
|
|
362
372
|
const e = (0, lint_1.generateForSelf)(cat, { start: cat.getAbsoluteIndex() }, 'no-duplicate', msg, severity);
|
|
363
373
|
if (isCat) {
|
|
@@ -49,8 +49,8 @@ class ParamTagToken extends index_2.Token {
|
|
|
49
49
|
errors.push((0, lint_1.generateForChild)(child, rect, 'no-ignored', msg));
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
|
-
const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i
|
|
53
|
-
if (str && !(i
|
|
52
|
+
const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
|
|
53
|
+
if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
|
|
54
54
|
const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', msg);
|
|
55
55
|
e.suggestions = [
|
|
56
56
|
{
|
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.7",
|
|
4
4
|
"description": "A Node.js linter for MediaWiki markup",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mediawiki",
|
|
@@ -51,28 +51,28 @@
|
|
|
51
51
|
"chalk": "^4.1.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@bhsd/common": "^0.4.
|
|
55
|
-
"@stylistic/eslint-plugin": "^2.
|
|
56
|
-
"@stylistic/stylelint-plugin": "^
|
|
57
|
-
"@types/node": "^22.
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
59
|
-
"@typescript-eslint/parser": "^
|
|
60
|
-
"esbuild": "^0.
|
|
61
|
-
"eslint": "^8.
|
|
62
|
-
"eslint-plugin-es-x": "^8.
|
|
54
|
+
"@bhsd/common": "^0.4.6",
|
|
55
|
+
"@stylistic/eslint-plugin": "^2.11.0",
|
|
56
|
+
"@stylistic/stylelint-plugin": "^3.1.1",
|
|
57
|
+
"@types/node": "^22.10.1",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^8.16.0",
|
|
59
|
+
"@typescript-eslint/parser": "^8.16.0",
|
|
60
|
+
"esbuild": "^0.24.0",
|
|
61
|
+
"eslint": "^8.57.1",
|
|
62
|
+
"eslint-plugin-es-x": "^8.4.1",
|
|
63
63
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
64
|
-
"eslint-plugin-jsdoc": "^
|
|
64
|
+
"eslint-plugin-jsdoc": "^50.6.0",
|
|
65
65
|
"eslint-plugin-json-es": "^1.6.0",
|
|
66
|
-
"eslint-plugin-markdown": "
|
|
67
|
-
"eslint-plugin-n": "^17.
|
|
68
|
-
"eslint-plugin-promise": "^
|
|
66
|
+
"eslint-plugin-markdown": "4.0.1",
|
|
67
|
+
"eslint-plugin-n": "^17.14.0",
|
|
68
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
69
69
|
"eslint-plugin-regexp": "^2.6.0",
|
|
70
|
-
"eslint-plugin-unicorn": "^
|
|
70
|
+
"eslint-plugin-unicorn": "^56.0.1",
|
|
71
71
|
"http-server": "^14.1.0",
|
|
72
|
-
"stylelint": "^16.
|
|
72
|
+
"stylelint": "^16.11.0",
|
|
73
73
|
"stylelint-config-recommended": "^14.0.0",
|
|
74
|
-
"typescript": "^5.
|
|
75
|
-
"v8r": "^
|
|
74
|
+
"typescript": "^5.7.2",
|
|
75
|
+
"v8r": "^4.2.0"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": ">=22.11.0"
|