wikilint 2.13.6 → 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 CHANGED
@@ -67,6 +67,7 @@ export interface AstNode {
67
67
  readonly childNodes: readonly AstNode[];
68
68
  /** 节点类型 */
69
69
  type: string;
70
+ toString(...args: unknown[]): string;
70
71
  /** Linter */
71
72
  lint(): LintError[];
72
73
  }
@@ -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 | 'text');
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
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AtomToken = void 0;
4
4
  const index_1 = require("./index");
5
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
6
  const atomTypes = [
6
7
  'arg-name',
7
8
  'attr-key',
package/dist/src/index.js CHANGED
@@ -337,34 +337,35 @@ 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,ext-attr#name';
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();
347
+ const value = cat.getValue(), attrs = cat.parentNode;
348
348
  if (cat.name === 'id') {
349
349
  key = `#${value === true ? '' : value}`;
350
350
  }
351
351
  else if (cat.tag === 'ref' && value !== true && value
352
- && cat.parentNode.parentNode.innerText) {
353
- key = `ref#${value}`;
352
+ && attrs.parentNode.innerText) {
353
+ const group = attrs.getAttr('group');
354
+ key = `${typeof group === 'string' && group || ' '}#${value}`;
354
355
  }
355
356
  else {
356
357
  continue;
357
358
  }
358
359
  }
359
- const thisCat = record[key];
360
+ const thisCat = record.get(key);
360
361
  if (thisCat) {
361
362
  thisCat.add(cat);
362
363
  }
363
364
  else {
364
- record[key] = new Set([cat]);
365
+ record.set(key, new Set([cat]));
365
366
  }
366
367
  }
367
- for (const [key, value] of Object.entries(record)) {
368
+ for (const [key, value] of record) {
368
369
  if (value.size > 1 && !key.startsWith('#mw-customcollapsible-')) {
369
370
  const isCat = !key.includes('#'), msg = `duplicated ${isCat ? 'category' : 'id/name'}`, severity = key.startsWith('#') ? 'warning' : 'error';
370
371
  errors.push(...[...value].map(cat => {
@@ -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 >= 0 ? i : undefined).map(String).join('');
53
- if (str && !(i >= 0 ? /^[a-z]+(?:\[\])?\s*(?:=|$)/iu : /^[a-z]+(?:\[\])?\s*=/iu).test(str)) {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.13.6",
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.5",
55
- "@stylistic/eslint-plugin": "^2.3.0",
56
- "@stylistic/stylelint-plugin": "^2.0.0",
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",
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": "^48.5.2",
64
+ "eslint-plugin-jsdoc": "^50.6.0",
65
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",
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": "^54.0.0",
70
+ "eslint-plugin-unicorn": "^56.0.1",
71
71
  "http-server": "^14.1.0",
72
- "stylelint": "^16.6.1",
72
+ "stylelint": "^16.11.0",
73
73
  "stylelint-config-recommended": "^14.0.0",
74
- "typescript": "^5.5.3",
75
- "v8r": "^3.0.0"
74
+ "typescript": "^5.7.2",
75
+ "v8r": "^4.2.0"
76
76
  },
77
77
  "engines": {
78
78
  "node": ">=22.11.0"