wikilint 2.12.4 → 2.12.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.
@@ -69,7 +69,12 @@
69
69
  "link"
70
70
  ]
71
71
  ],
72
- "namespaces": {},
72
+ "namespaces": {
73
+ "0": "",
74
+ "6": "File",
75
+ "10": "Template",
76
+ "828": "Module"
77
+ },
73
78
  "nsid": {
74
79
  "file": 6,
75
80
  "category": 14
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Config, LintError, Parser as ParserBase } from './base';
1
+ import type { Config, LintError, TokenTypes, Parser as ParserBase } from './base';
2
2
  import type { Title } from './lib/title';
3
3
  import type { Token } from './internal';
4
4
  declare interface Parser extends ParserBase {
@@ -16,6 +16,6 @@ declare const Parser: Parser;
16
16
  // @ts-expect-error mixed export styles
17
17
  export = Parser;
18
18
  export default Parser;
19
- export type { Config, LintError };
19
+ export type { Config, LintError, TokenTypes };
20
20
  export type * from './internal';
21
21
  declare global { type Acceptable = unknown; }
package/dist/src/arg.d.ts CHANGED
@@ -8,6 +8,7 @@ import type { LintError } from '../base';
8
8
  * @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
9
9
  */
10
10
  export declare abstract class ArgToken extends Token {
11
+ #private;
11
12
  readonly childNodes: readonly [AtomToken] | readonly [AtomToken, Token, ...HiddenToken[]];
12
13
  abstract get firstChild(): AtomToken;
13
14
  abstract get lastChild(): Token;
package/dist/src/arg.js CHANGED
@@ -56,6 +56,15 @@ class ArgToken extends index_2.Token {
56
56
  getGaps() {
57
57
  return 1;
58
58
  }
59
+ /** 设置name */
60
+ #setName() {
61
+ this.setAttribute('name', this.firstChild.toString(true).trim());
62
+ }
63
+ /** @private */
64
+ afterBuild() {
65
+ this.#setName();
66
+ super.afterBuild();
67
+ }
59
68
  /** @private */
60
69
  lint(start = this.getAbsoluteIndex(), re) {
61
70
  const { childNodes: [argName, argDefault, ...rest] } = this;
@@ -64,10 +64,14 @@ const commonHtmlAttrs = new Set([
64
64
  time: new Set(['datetime']),
65
65
  meta: new Set(['itemprop', 'content']),
66
66
  link: new Set(['itemprop', 'href', 'title']),
67
- gallery: new Set(['mode', 'showfilename', 'caption', 'perrow', 'widths', 'heights', 'showthumbnails', 'type']),
68
- poem: new Set(['compact', 'align']),
67
+ gallery: typeAttrs,
68
+ poem: blockAttrs,
69
+ categorytree: blockAttrs,
70
+ combooption: blockAttrs,
71
+ }, empty = new Set(), extAttrs = {
72
+ gallery: new Set(['mode', 'showfilename', 'caption', 'perrow', 'widths', 'heights', 'showthumbnails']),
73
+ poem: new Set(['compact']),
69
74
  categorytree: new Set([
70
- 'align',
71
75
  'hideroot',
72
76
  'onlyroot',
73
77
  'depth',
@@ -77,8 +81,7 @@ const commonHtmlAttrs = new Set([
77
81
  'showcount',
78
82
  'notranslations',
79
83
  ]),
80
- combooption: new Set(['name', 'for', 'inline', 'align']),
81
- }, empty = new Set(), extAttrs = {
84
+ combooption: new Set(['name', 'for', 'inline']),
82
85
  nowiki: empty,
83
86
  indicator: new Set(['name']),
84
87
  langconvert: new Set(['from', 'to']),
@@ -267,11 +270,12 @@ class AttributeToken extends index_2.Token {
267
270
  errors.push(e);
268
271
  }
269
272
  const attrs = extAttrs[tag];
270
- if (attrs && !attrs.has(name)
271
- || (type === 'ext-attr' ? tag in htmlAttrs : !/\{\{[^{]+\}\}/u.test(name))
272
- && !htmlAttrs[tag]?.has(name)
273
- && !/^(?:xmlns:[\w:.-]+|data-(?!ooui|mw|parsoid)[^:]*)$/u.test(name)
274
- && (tag === 'meta' || tag === 'link' || !commonHtmlAttrs.has(name))) {
273
+ if (!attrs?.has(name)
274
+ && (type === 'ext-attr' ? attrs : !/\{\{[^{]+\}\}/u.test(name))
275
+ && (type === 'ext-attr' && !(tag in htmlAttrs)
276
+ || !htmlAttrs[tag]?.has(name)
277
+ && !/^(?:xmlns:[\w:.-]+|data-(?!ooui|mw|parsoid)[^:]*)$/u.test(name)
278
+ && (tag === 'meta' || tag === 'link' || !commonHtmlAttrs.has(name)))) {
275
279
  errors.push((0, lint_1.generateForChild)(firstChild, rect, 'illegal-attr', 'illegal attribute name'));
276
280
  }
277
281
  else if (obsoleteAttrs[tag]?.has(name)) {
@@ -48,7 +48,7 @@ class AttributesToken extends index_2.Token {
48
48
  while (mt) {
49
49
  const { index, 0: full, 1: key, 2: equal, 3: quoteStart, 4: quoted, 5: quoteEnd, 6: unquoted } = mt;
50
50
  out += attr.slice(lastIndex, index);
51
- if (/^(?:[\w:]|\0\d+[t!~{}+-]\x7F)(?:[\w:.-]|\0\d+[t!~{}+-]\x7F)*$/u.test((0, string_1.removeComment)(key).trim())) {
51
+ if (/^(?:[\w:]|\0\d+t\x7F)(?:[\w:.-]|\0\d+t\x7F)*$/u.test((0, string_1.removeComment)(key).trim())) {
52
52
  const value = quoted ?? unquoted, quotes = [quoteStart, quoteEnd],
53
53
  // @ts-expect-error abstract class
54
54
  token = new attribute_1.AttributeToken(toAttributeType(type), name, key, equal, value, quotes, config, accum);
@@ -131,6 +131,12 @@ class TranscludeToken extends index_2.Token {
131
131
  this.setAttribute('modifier', this.buildFromStr(this.modifier, constants_1.BuildMethod.String));
132
132
  }
133
133
  super.afterBuild();
134
+ if (this.isTemplate()) {
135
+ const isTemplate = this.type === 'template';
136
+ if (isTemplate) {
137
+ this.setAttribute('name', this.#getTitle().title);
138
+ }
139
+ }
134
140
  }
135
141
  /** @private */
136
142
  toString(skip) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.12.4",
3
+ "version": "2.12.6",
4
4
  "description": "A Node.js linter for MediaWiki markup",
5
5
  "keywords": [
6
6
  "mediawiki",