wikilint 2.26.0 → 2.28.0

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.
Files changed (86) hide show
  1. package/coverage/badge.svg +1 -1
  2. package/data/.schema.json +2 -1
  3. package/data/signatures.json +82 -16
  4. package/dist/base.d.mts +3 -3
  5. package/dist/base.d.ts +3 -3
  6. package/dist/bin/config.js +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +2 -3
  9. package/dist/internal.d.ts +5 -5
  10. package/dist/lib/document.js +6 -0
  11. package/dist/lib/lintConfig.js +19 -12
  12. package/dist/lib/lsp.d.ts +1 -1
  13. package/dist/lib/lsp.js +1 -1
  14. package/dist/lib/node.js +44 -33
  15. package/dist/lib/text.js +3 -3
  16. package/dist/mixin/attributesParent.js +16 -14
  17. package/dist/mixin/elementLike.js +45 -43
  18. package/dist/mixin/hidden.js +0 -1
  19. package/dist/mixin/nodeLike.js +2 -2
  20. package/dist/mixin/padded.js +9 -7
  21. package/dist/parser/commentAndExt.js +1 -1
  22. package/dist/parser/html.js +1 -1
  23. package/dist/src/arg.js +1 -1
  24. package/dist/src/atom.d.ts +1 -1
  25. package/dist/src/atom.js +0 -1
  26. package/dist/src/attribute.d.ts +2 -4
  27. package/dist/src/attribute.js +16 -12
  28. package/dist/src/attributes.d.ts +3 -4
  29. package/dist/src/attributes.js +5 -3
  30. package/dist/src/commented.d.ts +3 -3
  31. package/dist/src/imageParameter.js +11 -6
  32. package/dist/src/index.js +2 -2
  33. package/dist/src/link/file.js +13 -7
  34. package/dist/src/link/index.js +1 -1
  35. package/dist/src/multiLine/gallery.d.ts +20 -0
  36. package/dist/src/multiLine/gallery.js +95 -0
  37. package/dist/src/multiLine/imagemap.d.ts +21 -0
  38. package/dist/src/multiLine/imagemap.js +111 -0
  39. package/dist/src/multiLine/index.d.ts +14 -0
  40. package/dist/src/multiLine/index.js +27 -0
  41. package/dist/src/{paramTag → multiLine}/inputbox.d.ts +1 -1
  42. package/dist/src/{paramTag → multiLine}/inputbox.js +2 -2
  43. package/dist/src/multiLine/paramTag.d.ts +16 -0
  44. package/dist/src/multiLine/paramTag.js +67 -0
  45. package/dist/src/nowiki/base.d.ts +1 -1
  46. package/dist/src/nowiki/comment.js +2 -1
  47. package/dist/src/nowiki/commentLine.d.ts +10 -0
  48. package/dist/src/nowiki/commentLine.js +12 -0
  49. package/dist/src/nowiki/quote.js +1 -1
  50. package/dist/src/paramLine.d.ts +13 -0
  51. package/dist/src/paramLine.js +15 -0
  52. package/dist/src/parameter.d.ts +0 -1
  53. package/dist/src/parameter.js +1 -0
  54. package/dist/src/pre.d.ts +3 -5
  55. package/dist/src/pre.js +2 -2
  56. package/dist/src/syntax.d.ts +1 -1
  57. package/dist/src/table/base.d.ts +6 -1
  58. package/dist/src/table/base.js +73 -23
  59. package/dist/src/table/index.js +44 -40
  60. package/dist/src/table/td.d.ts +1 -1
  61. package/dist/src/table/td.js +6 -4
  62. package/dist/src/table/tr.d.ts +1 -1
  63. package/dist/src/table/trBase.js +3 -1
  64. package/dist/src/{html.d.ts → tag/html.d.ts} +5 -13
  65. package/dist/src/{html.js → tag/html.js} +11 -71
  66. package/dist/src/tag/index.d.ts +31 -0
  67. package/dist/src/tag/index.js +110 -0
  68. package/dist/src/tag/tvar.d.ts +20 -0
  69. package/dist/src/tag/tvar.js +75 -0
  70. package/dist/src/tagPair/ext.js +4 -4
  71. package/dist/src/tagPair/index.d.ts +1 -1
  72. package/dist/src/tagPair/translate.js +9 -9
  73. package/dist/src/transclude.d.ts +3 -5
  74. package/dist/src/transclude.js +3 -1
  75. package/i18n/en.json +14 -13
  76. package/i18n/zh-hans.json +19 -18
  77. package/i18n/zh-hant.json +31 -30
  78. package/package.json +2 -2
  79. package/dist/mixin/multiLine.d.ts +0 -4
  80. package/dist/mixin/multiLine.js +0 -26
  81. package/dist/src/gallery.d.ts +0 -26
  82. package/dist/src/gallery.js +0 -149
  83. package/dist/src/imagemap.d.ts +0 -27
  84. package/dist/src/imagemap.js +0 -164
  85. package/dist/src/paramTag/index.d.ts +0 -21
  86. package/dist/src/paramTag/index.js +0 -121
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="98" height="20" role="img" aria-label="Coverage: 89%"><title>Coverage: 89%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="98" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="35" height="20" fill="#4c1"/><rect width="98" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="795" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">89%</text><text x="795" y="140" transform="scale(.1)" fill="#fff" textLength="250">89%</text></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="98" height="20" role="img" aria-label="Coverage: 90%"><title>Coverage: 90%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="98" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="35" height="20" fill="#4c1"/><rect width="98" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="795" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">90%</text><text x="795" y="140" transform="scale(.1)" fill="#fff" textLength="250">90%</text></g></svg>
package/data/.schema.json CHANGED
@@ -10,7 +10,8 @@
10
10
  "description": "An array of aliases for the magic word",
11
11
  "type": "array",
12
12
  "items": {
13
- "type": "string"
13
+ "type": "string",
14
+ "pattern": "^[^A-Z]+$"
14
15
  },
15
16
  "minItems": 1,
16
17
  "uniqueItems": true
@@ -390,9 +390,18 @@
390
390
  "label": "NOSEP",
391
391
  "const": true
392
392
  }
393
+ ],
394
+ [
395
+ {
396
+ "label": "unformatted number"
397
+ },
398
+ {
399
+ "label": "LOSSLESS",
400
+ "const": true
401
+ }
393
402
  ]
394
403
  ],
395
- "description": "Takes an unformatted number (Arabic, no group separators and `.` as decimal separator) and outputs it in the localized digit script and formatted with decimal and decimal group separators, according to the page language.\n\nThe `|R` parameter can be used to reverse the behavior, for use in mathematical situations: it's reliable and should be used only to deformat numbers which are known to be formatted exactly as formatnum formats them with the wiki's locale.\n\nThe `NOSEP` (\"no separators\") parameter means that no group / decimal separators are changed; formatnum will only transform the digits themselves in languages which don't use the [Hindu–Arabic numeral system](https://en.wikipedia.org/wiki/Hindu%E2%80%93Arabic_numeral_system). `NOSEP` can also prevent non-standard digit groupings you wouldn't expect."
404
+ "description": "Takes an unformatted number (Arabic, no group separators and `.` as decimal separator) and outputs it in the localized digit script and formatted with decimal and decimal group separators, according to the page language.\n\nThe `|R` parameter can be used to reverse the behavior, for use in mathematical situations: it's reliable and should be used only to deformat numbers which are known to be formatted exactly as formatnum formats them with the wiki's locale.\n\nThe `NOSEP` (\"no separators\") parameter means that no group / decimal separators are changed; formatnum will only transform the digits themselves in languages which don't use the [Hindu–Arabic numeral system](https://en.wikipedia.org/wiki/Hindu%E2%80%93Arabic_numeral_system). `NOSEP` can also prevent non-standard digit groupings you wouldn't expect.\n\nBy default, the formatted number may be slightly imprecise. The `LOSSLESS` parameter can be added to instead use the unformatted (exact) number in this case."
396
405
  },
397
406
  {
398
407
  "aliases": [
@@ -611,7 +620,7 @@
611
620
  }
612
621
  ]
613
622
  ],
614
- "description": "Outputs a plural form appropriate for the given language. For English, the singular form (second parameter) is used if the absolute value of the first parameter is an expression equalling one; and the the plural form (third parameter) is used otherwise. See further documentation [on translatewiki.net](https://translatewiki.net/wiki/Plural#Plural_in_MediaWiki)."
623
+ "description": "Outputs a plural form appropriate for the given language. For English, the singular form (second parameter) is used if the absolute value of the first parameter is an expression equalling one; and the plural form (third parameter) is used otherwise. See further documentation [on translatewiki.net](https://translatewiki.net/wiki/Plural#Plural_in_MediaWiki)."
615
624
  },
616
625
  {
617
626
  "aliases": [
@@ -639,7 +648,21 @@
639
648
  "label": "username"
640
649
  },
641
650
  {
642
- "label": "text for every gender"
651
+ "label": "gender-neutral text"
652
+ }
653
+ ],
654
+ [
655
+ {
656
+ "label": "username"
657
+ },
658
+ {
659
+ "label": "male text"
660
+ },
661
+ {
662
+ "label": "female text"
663
+ },
664
+ {
665
+ "label": "text for unspecified gender"
643
666
  }
644
667
  ],
645
668
  [
@@ -654,7 +677,7 @@
654
677
  "label": "female text"
655
678
  },
656
679
  {
657
- "label": "text for unspecified"
680
+ "label": "text for unspecified gender"
658
681
  }
659
682
  ],
660
683
  [
@@ -669,11 +692,27 @@
669
692
  "label": "female text"
670
693
  },
671
694
  {
672
- "label": "text for unspecified"
695
+ "label": "text for unspecified gender"
696
+ }
697
+ ]
698
+ ],
699
+ "description": "A switch for the gender set by the user in Special:Preferences.\n\nIf only two parameters are used (for male and female text) but the 3rd parameter is omitted, and user hasn't defined their gender, then the first parameter (`male text`) is returned as a default.\n\nA blank username field (`{{GENDER:|`) means the current user, but can be used only in interface messages (MediaWiki namespace).\n\nUsing a dot (`.`) in the username field produces the output corresponding to the default user gender on this wiki."
700
+ },
701
+ {
702
+ "aliases": [
703
+ "#formal"
704
+ ],
705
+ "signatures": [
706
+ [
707
+ {
708
+ "label": "informal text"
709
+ },
710
+ {
711
+ "label": "formal text"
673
712
  }
674
713
  ]
675
714
  ],
676
- "description": "A switch for the gender set in Special:Preferences.\n\n**Note:** If 3rd parameter is omitted and user hasn't defined their gender, then `male text` is returned.\n\nA blank username field (`{{GENDER:|`) means the current user, but can be used only in interface messages (MediaWiki namespace).\n\nA dot username (`.`) means the default user gender on this wiki."
715
+ "description": "A switch for the formality index set by the configuration for certain languages. The default formality index is 0 (informal), but some language codes have the formality index 1 (formal). For these languages, what is displayed for the end user depends on whether their interface language is set to the formal or informal language code."
677
716
  },
678
717
  {
679
718
  "aliases": [
@@ -1848,7 +1887,7 @@
1848
1887
  }
1849
1888
  ]
1850
1889
  ],
1851
- "description": "Outputs the protection level (e.g. \"autoconfirmed\", \"sysop\") for a given action (e.g. \"edit\", \"move\") on the current page. Returns an empty string if not protected.\n\n**[Expensive]** Outputs the protection level on the specified page."
1890
+ "description": "Outputs the protection level (e.g. `autoconfirmed`, `sysop`) for a given action (e.g. `edit`, `move`) on the current page. Returns an empty string if not protected.\n\n**[Expensive]** Outputs the protection level on the specified page."
1852
1891
  },
1853
1892
  {
1854
1893
  "aliases": [
@@ -1885,6 +1924,33 @@
1885
1924
  ],
1886
1925
  "description": "**[Expensive]** Returns the sources of any cascading protection acting on the current page or the specified page. Pages will not return their own title unless they transclude themselves."
1887
1926
  },
1927
+ {
1928
+ "aliases": [
1929
+ "#contentmodel"
1930
+ ],
1931
+ "signatures": [
1932
+ [],
1933
+ [
1934
+ {
1935
+ "label": "canonical",
1936
+ "const": true
1937
+ },
1938
+ {
1939
+ "label": "page name"
1940
+ }
1941
+ ],
1942
+ [
1943
+ {
1944
+ "label": "local",
1945
+ "const": true
1946
+ },
1947
+ {
1948
+ "label": "page name"
1949
+ }
1950
+ ]
1951
+ ],
1952
+ "description": "The canonical or localized name of the content model of the specified page."
1953
+ },
1888
1954
  {
1889
1955
  "aliases": [
1890
1956
  "revisionid"
@@ -1897,7 +1963,7 @@
1897
1963
  }
1898
1964
  ]
1899
1965
  ],
1900
- "description": "Unique revision ID. It is always empty in preview, thus one can show an error message only in preview. May be disabled in [miser mode (all WMF wikis)](https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:$wgMiserMode) returning `-` instead when not in preview.\n\n**[Expensive]** Unique revision ID of the last revision on the specified page."
1966
+ "description": "Unique revision ID.\n\nIt is always empty in preview, thus one can show an error message only in preview. May be disabled in [miser mode (all WMF wikis)](https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:$wgMiserMode) returning `-` instead when not in preview.\n\n**Warning**: This variable **cannot** be [substituted](https://www.mediawiki.org/wiki/Help:Substitution).\n\n**[Expensive]** Unique revision ID of the last revision on the specified page."
1901
1967
  },
1902
1968
  {
1903
1969
  "aliases": [
@@ -2257,7 +2323,7 @@
2257
2323
  }
2258
2324
  ]
2259
2325
  ],
2260
- "description": "Namespace and full page title (including all subpage levels)."
2326
+ "description": "Namespace and full page name (including all subpage levels)."
2261
2327
  },
2262
2328
  {
2263
2329
  "aliases": [
@@ -2271,7 +2337,7 @@
2271
2337
  }
2272
2338
  ]
2273
2339
  ],
2274
- "description": "URL encoded namespace and full page title (including all subpage levels)."
2340
+ "description": "URL encoded namespace and full page name (including all subpage levels)."
2275
2341
  },
2276
2342
  {
2277
2343
  "aliases": [
@@ -2285,7 +2351,7 @@
2285
2351
  }
2286
2352
  ]
2287
2353
  ],
2288
- "description": "Full page title (including all subpage levels) without the namespace."
2354
+ "description": "The page name, including all subpage levels, but without the namespace."
2289
2355
  },
2290
2356
  {
2291
2357
  "aliases": [
@@ -2299,7 +2365,7 @@
2299
2365
  }
2300
2366
  ]
2301
2367
  ],
2302
- "description": "URL encoded full page title (including all subpage levels) without the namespace."
2368
+ "description": "URL encoded page name, including all subpage levels, but without the namespace."
2303
2369
  },
2304
2370
  {
2305
2371
  "aliases": [
@@ -2313,7 +2379,7 @@
2313
2379
  }
2314
2380
  ]
2315
2381
  ],
2316
- "description": "Page title of the page in the immediately superior [subpage](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Subpages) level without the namespace."
2382
+ "description": "Page name of the page in the immediately superior [subpage](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Subpages) level without the namespace."
2317
2383
  },
2318
2384
  {
2319
2385
  "aliases": [
@@ -2327,7 +2393,7 @@
2327
2393
  }
2328
2394
  ]
2329
2395
  ],
2330
- "description": "URL encoded page title of the page in the immediately superior [subpage](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Subpages) level without the namespace."
2396
+ "description": "URL encoded page name of the page in the immediately superior [subpage](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Subpages) level without the namespace."
2331
2397
  },
2332
2398
  {
2333
2399
  "aliases": [
@@ -2369,7 +2435,7 @@
2369
2435
  }
2370
2436
  ]
2371
2437
  ],
2372
- "description": "The [subpage](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Subpages) title. If no subpage exists the value of `{{PAGENAME}}` is returned."
2438
+ "description": "The [subpage](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Subpages) title. If no subpage exists, the value of `{{PAGENAME}}` is returned."
2373
2439
  },
2374
2440
  {
2375
2441
  "aliases": [
@@ -2383,7 +2449,7 @@
2383
2449
  }
2384
2450
  ]
2385
2451
  ],
2386
- "description": "The URL encoded [subpage](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Subpages) title. If no subpage exists the value of `{{PAGENAME}}` is returned."
2452
+ "description": "The URL encoded [subpage](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Subpages) title. If no subpage exists, the value of `{{PAGENAME}}` is returned."
2387
2453
  },
2388
2454
  {
2389
2455
  "aliases": [
package/dist/base.d.mts CHANGED
@@ -16,7 +16,7 @@ export interface Config {
16
16
  readonly articlePath?: string;
17
17
  }
18
18
  export type ConfigData = Omit<Config, 'excludes'>;
19
- export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
19
+ export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
20
20
  export declare const stages: {
21
21
  redirect: number;
22
22
  onlyinclude: number;
@@ -266,8 +266,8 @@ export interface LanguageService {
266
266
  */
267
267
  setTargetWikipedia(wiki: string, user: string): Promise<void>;
268
268
  }
269
- export type SeverityLevel = 0 | 1 | 2;
270
- export type LintConfigValue = SeverityLevel | [SeverityLevel, Record<string, SeverityLevel>];
269
+ export type SeverityLevel = 0 | 1 | 2 | false | 'off' | 'warning' | 'error';
270
+ export type LintConfigValue = SeverityLevel | [SeverityLevel, Record<string, SeverityLevel>?];
271
271
  export type LintRuleConfig = Partial<Record<LintError.Rule, LintConfigValue>>;
272
272
  export interface FullLintConfig {
273
273
  rules: LintRuleConfig;
package/dist/base.d.ts CHANGED
@@ -16,7 +16,7 @@ export interface Config {
16
16
  readonly articlePath?: string;
17
17
  }
18
18
  export type ConfigData = Omit<Config, 'excludes'>;
19
- export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
19
+ export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
20
20
  export declare const stages: {
21
21
  redirect: number;
22
22
  onlyinclude: number;
@@ -266,8 +266,8 @@ export interface LanguageService {
266
266
  */
267
267
  setTargetWikipedia(wiki: string, user: string): Promise<void>;
268
268
  }
269
- export type SeverityLevel = 0 | 1 | 2;
270
- export type LintConfigValue = SeverityLevel | [SeverityLevel, Record<string, SeverityLevel>];
269
+ export type SeverityLevel = 0 | 1 | 2 | false | 'off' | 'warning' | 'error';
270
+ export type LintConfigValue = SeverityLevel | [SeverityLevel, Record<string, SeverityLevel>?];
271
271
  export type LintRuleConfig = Partial<Record<LintError.Rule, LintConfigValue>>;
272
272
  export interface FullLintConfig {
273
273
  rules: LintRuleConfig;
@@ -77,7 +77,7 @@ const mw = {
77
77
  },
78
78
  },
79
79
  };
80
- const pkg = "wikilint", version = "2.26.0";
80
+ const pkg = "wikilint", version = "2.28.0";
81
81
  let mwConfig;
82
82
  /**
83
83
  * Get the parser configuration for a Wikimedia Foundation project.
package/dist/index.d.ts CHANGED
@@ -49,6 +49,6 @@ declare const Parser: Parser;
49
49
  // @ts-expect-error mixed export styles
50
50
  export = Parser;
51
51
  export default Parser;
52
- export type { Config, ConfigData, LintConfig, LintError, TokenTypes, LanguageService, QuickFixData, };
52
+ export type { Config, ConfigData, LintConfig, LintError, TokenTypes, LanguageService, QuickFixData, Title, };
53
53
  export type * from './internal';
54
54
  declare global { type WikiParserAcceptable = Record<string, any>; }
package/dist/index.js CHANGED
@@ -117,9 +117,8 @@ const Parser = {
117
117
  },
118
118
  /** @implements */
119
119
  msg(msg, arg = '') {
120
- LINT: { // eslint-disable-line no-unused-labels
121
- return msg && (this.i18n[msg] ?? msg).replace('$1', this.msg(arg));
122
- }
120
+ LINT: return msg // eslint-disable-line no-unused-labels
121
+ && (this.i18n[msg] ?? msg).replace('$1', this.msg(arg));
123
122
  },
124
123
  /** @implements */
125
124
  normalizeTitle(title, defaultNs = 0, include, config = Parser.getConfig(), opt) {
@@ -17,7 +17,7 @@ export type { SyntaxToken } from './src/syntax';
17
17
  export type { ParameterToken } from './src/parameter';
18
18
  export type { TranscludeToken } from './src/transclude';
19
19
  export type { HeadingToken } from './src/heading';
20
- export type { HtmlToken } from './src/html';
20
+ export type { HtmlToken } from './src/tag/html';
21
21
  export type { TdToken } from './src/table/td';
22
22
  export type { TrToken } from './src/table/tr';
23
23
  export type { TableToken } from './src/table/index';
@@ -38,11 +38,11 @@ export type { ConverterRuleToken } from './src/converterRule';
38
38
  export type { ConverterToken } from './src/converter';
39
39
  export type { NowikiToken } from './src/nowiki/index';
40
40
  export type { PreToken } from './src/pre';
41
- export type { ParamTagToken } from './src/paramTag/index';
42
- export type { InputboxToken } from './src/paramTag/inputbox';
41
+ export type { ParamTagToken } from './src/multiLine/paramTag';
42
+ export type { InputboxToken } from './src/multiLine/inputbox';
43
43
  export type { NestedToken } from './src/nested';
44
- export type { GalleryToken } from './src/gallery';
44
+ export type { GalleryToken } from './src/multiLine/gallery';
45
45
  export type { ImagemapLinkToken } from './src/imagemapLink';
46
- export type { ImagemapToken } from './src/imagemap';
46
+ export type { ImagemapToken } from './src/multiLine/imagemap';
47
47
  export type { CommentedToken } from './src/commented';
48
48
  export type { TranslateToken } from './src/tagPair/translate';
@@ -30,6 +30,7 @@ const loadMathJax = (id = 'mathjax') => {
30
30
  return MathJax;
31
31
  }
32
32
  catch {
33
+ /* istanbul ignore next */
33
34
  return undefined;
34
35
  }
35
36
  };
@@ -56,6 +57,7 @@ exports.jsonLSP = (() => {
56
57
  };
57
58
  }
58
59
  catch {
60
+ /* istanbul ignore next */
59
61
  return false;
60
62
  }
61
63
  }).filter(Boolean),
@@ -63,6 +65,7 @@ exports.jsonLSP = (() => {
63
65
  return lsp;
64
66
  }
65
67
  catch {
68
+ /* istanbul ignore next */
66
69
  return undefined;
67
70
  }
68
71
  })();
@@ -72,6 +75,7 @@ exports.cssLSP = (() => {
72
75
  .getCSSLanguageService();
73
76
  }
74
77
  catch {
78
+ /* istanbul ignore next */
75
79
  return undefined;
76
80
  }
77
81
  })();
@@ -81,6 +85,7 @@ exports.htmlData = (() => {
81
85
  .getDefaultHTMLDataProvider();
82
86
  }
83
87
  catch {
88
+ /* istanbul ignore next */
84
89
  return undefined;
85
90
  }
86
91
  })();
@@ -89,6 +94,7 @@ exports.stylelint = (async () => {
89
94
  return (await import('stylelint')).default;
90
95
  }
91
96
  catch {
97
+ /* istanbul ignore next */
92
98
  return undefined;
93
99
  }
94
100
  })();
@@ -2,10 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LintConfiguration = void 0;
4
4
  const base_1 = require("../base");
5
- const severities = new Set([0, 1, 2]), dict = new Map([
5
+ const dict = new Map([
6
6
  [0, false],
7
7
  [1, 'warning'],
8
8
  [2, 'error'],
9
+ [false, false],
10
+ ['off', false],
11
+ ['warning', 'warning'],
12
+ ['error', 'error'],
9
13
  ]);
10
14
  const defaultLintRuleConfig = {
11
15
  'bold-header': [
@@ -45,6 +49,7 @@ const defaultLintRuleConfig = {
45
49
  'invalid-gallery': [
46
50
  2,
47
51
  {
52
+ // extension: 2,
48
53
  // image: 2,
49
54
  parameter: 1,
50
55
  },
@@ -167,11 +172,11 @@ const defaultLintRuleConfig = {
167
172
  'unmatched-tag': [
168
173
  1,
169
174
  {
170
- // both: 1,
171
- // closing: 1,
172
- // conditional: 1,
173
- // opening: 1,
174
- // selfClosing: 1,
175
+ both: 2,
176
+ // closing: 1,
177
+ // conditional: 1,
178
+ // opening: 1,
179
+ selfClosing: 2,
175
180
  },
176
181
  ],
177
182
  'unterminated-url': [
@@ -223,14 +228,13 @@ Object.freeze(defaultLintConfig);
223
228
  * 验证错误级别是否符合规范
224
229
  * @param severity 错误级别
225
230
  */
226
- const validateSeverity = (severity) => typeof severity === 'number' && severities.has(severity);
231
+ const validateSeverity = (severity) => dict.has(severity);
227
232
  /**
228
233
  * 验证设置值是否符合规范
229
234
  * @param value 设置值
230
235
  */
231
236
  const validateConfigValue = (value) => validateSeverity(value)
232
- || Array.isArray(value) && value.length === 2
233
- && validateSeverity(value[0]) && value[1] && typeof value[1] === 'object';
237
+ || Array.isArray(value) && validateSeverity(value[0]) && (value.length === 1 || typeof value[1] === 'object');
234
238
  /**
235
239
  * 设置语法检查规则
236
240
  * @param obj 语法检查设置对象
@@ -239,16 +243,18 @@ const validateConfigValue = (value) => validateSeverity(value)
239
243
  * @throws `RangeError` 未知的规则或无效的值
240
244
  */
241
245
  const set = (obj, key, value) => {
246
+ /* istanbul ignore if */
242
247
  if (!base_1.rules.includes(key)) {
243
248
  throw new RangeError(`Unknown lint rule: ${key}`);
244
249
  }
245
- else if (value === undefined) {
250
+ else /* istanbul ignore if */ if (value === undefined) {
246
251
  return false;
247
252
  }
248
253
  else if (validateConfigValue(value)) {
249
254
  obj[key] = value;
250
255
  return true;
251
256
  }
257
+ /* istanbul ignore next */
252
258
  throw new RangeError(`Invalid lint config for ${key}: ${JSON.stringify(value)}`);
253
259
  };
254
260
  /** 语法规则设置 */
@@ -266,10 +272,10 @@ class LintRuleConfiguration {
266
272
  /** @implements */
267
273
  getSeverity(rule, key) {
268
274
  const value = this[rule];
269
- if (typeof value === 'number') {
275
+ if (typeof value !== 'object') {
270
276
  return dict.get(value);
271
277
  }
272
- return key ? dict.get(value[1][key]) ?? dict.get(value[0]) : dict.get(value[0]);
278
+ return key ? dict.get(value[1]?.[key]) ?? dict.get(value[0]) : dict.get(value[0]);
273
279
  }
274
280
  }
275
281
  /** 语法检查设置 */
@@ -284,6 +290,7 @@ class LintConfiguration {
284
290
  set,
285
291
  /** @ignore */
286
292
  deleteProperty() {
293
+ /* istanbul ignore next */
287
294
  return false;
288
295
  },
289
296
  });
package/dist/lib/lsp.d.ts CHANGED
@@ -167,8 +167,8 @@ export declare class LanguageService implements LanguageServiceBase {
167
167
  * 设置目标维基百科
168
168
  * @param wiki Wikipedia URL / 维基百科网址
169
169
  * @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
170
- * @throws `RangeError` 不是有效的维基百科网址
171
170
  * @since v1.18.1
171
+ * @throws `RangeError` 不是有效的维基百科网址
172
172
  */
173
173
  setTargetWikipedia(wiki: string, user: string): Promise<void>;
174
174
  }
package/dist/lib/lsp.js CHANGED
@@ -1526,8 +1526,8 @@ class LanguageService {
1526
1526
  * 设置目标维基百科
1527
1527
  * @param wiki Wikipedia URL / 维基百科网址
1528
1528
  * @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
1529
- * @throws `RangeError` 不是有效的维基百科网址
1530
1529
  * @since v1.18.1
1530
+ * @throws `RangeError` 不是有效的维基百科网址
1531
1531
  */
1532
1532
  async setTargetWikipedia(wiki, user) {
1533
1533
  const [site, host] = index_1.default.getWMFSite(wiki);
package/dist/lib/node.js CHANGED
@@ -108,7 +108,9 @@ let AstNode = (() => {
108
108
  this.#previousSibling = value;
109
109
  break;
110
110
  case 'aIndex':
111
- this.#aIndex = [debug_1.Shadow.rev, value];
111
+ LINT: { // eslint-disable-line no-unused-labels
112
+ this.#aIndex = [debug_1.Shadow.rev, value];
113
+ }
112
114
  break;
113
115
  default:
114
116
  this[key] = value; // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -154,18 +156,22 @@ let AstNode = (() => {
154
156
  * @param index character index / 字符位置
155
157
  */
156
158
  posFromIndex(index) {
157
- const { length } = String(this);
158
- index += index < 0 ? length : 0;
159
- if (index >= 0 && index <= length) {
160
- const lines = this.getLines(), top = lines.findIndex(([, , end]) => index <= end);
161
- return { top, left: index - lines[top][1] };
159
+ LINT: { // eslint-disable-line no-unused-labels
160
+ const { length } = String(this);
161
+ index += index < 0 ? length : 0;
162
+ if (index >= 0 && index <= length) {
163
+ const lines = this.getLines(), top = lines.findIndex(([, , end]) => index <= end);
164
+ return { top, left: index - lines[top][1] };
165
+ }
166
+ return undefined;
162
167
  }
163
- return undefined;
164
168
  }
165
169
  /** @private */
166
170
  getDimension() {
167
- const lines = this.getLines(), last = lines[lines.length - 1];
168
- return { height: lines.length, width: last[2] - last[1] };
171
+ LINT: { // eslint-disable-line no-unused-labels
172
+ const lines = this.getLines(), last = lines[lines.length - 1];
173
+ return { height: lines.length, width: last[2] - last[1] };
174
+ }
169
175
  }
170
176
  /** @private */
171
177
  getGaps(_) {
@@ -178,23 +184,25 @@ let AstNode = (() => {
178
184
  * @param j rank of the child node / 子节点序号
179
185
  */
180
186
  getRelativeIndex(j) {
181
- if (j === undefined) {
182
- const { parentNode } = this;
183
- return parentNode
184
- ? parentNode.getRelativeIndex(parentNode.childNodes.indexOf(this))
185
- : 0;
186
- }
187
- return (0, lint_1.cache)(this.#rIndex[j], () => {
188
- const { childNodes } = this, n = j + (j < 0 ? childNodes.length : 0);
189
- let acc = this.getAttribute('padding');
190
- for (let i = 0; i < n; i++) {
191
- this.#rIndex[i] = [debug_1.Shadow.rev, acc];
192
- acc += childNodes[i].toString().length + this.getGaps(i);
187
+ LINT: { // eslint-disable-line no-unused-labels
188
+ if (j === undefined) {
189
+ const { parentNode } = this;
190
+ return parentNode
191
+ ? parentNode.getRelativeIndex(parentNode.childNodes.indexOf(this))
192
+ : 0;
193
193
  }
194
- return acc;
195
- }, value => {
196
- this.#rIndex[j] = value;
197
- });
194
+ return (0, lint_1.cache)(this.#rIndex[j], () => {
195
+ const { childNodes } = this, n = j + (j < 0 ? childNodes.length : 0);
196
+ let acc = this.getAttribute('padding');
197
+ for (let i = 0; i < n; i++) {
198
+ this.#rIndex[i] = [debug_1.Shadow.rev, acc];
199
+ acc += childNodes[i].toString().length + this.getGaps(i);
200
+ }
201
+ return acc;
202
+ }, value => {
203
+ this.#rIndex[j] = value;
204
+ });
205
+ }
198
206
  }
199
207
  /**
200
208
  * Get the absolute character index of the current node
@@ -202,7 +210,8 @@ let AstNode = (() => {
202
210
  * 获取当前节点的绝对位置
203
211
  */
204
212
  getAbsoluteIndex() {
205
- return (0, lint_1.cache)(this.#aIndex, () => {
213
+ LINT: return (0, lint_1.cache)(// eslint-disable-line no-unused-labels
214
+ this.#aIndex, () => {
206
215
  const { parentNode } = this;
207
216
  return parentNode ? parentNode.getAbsoluteIndex() + this.getRelativeIndex() : 0;
208
217
  }, value => {
@@ -238,14 +247,16 @@ let AstNode = (() => {
238
247
  * @since v1.16.3
239
248
  */
240
249
  getLines() {
241
- const results = [];
242
- let start = 0;
243
- for (const line of String(this).split('\n')) {
244
- const end = start + line.length;
245
- results.push([line, start, end]);
246
- start = end + 1;
250
+ LINT: { // eslint-disable-line no-unused-labels
251
+ const results = [];
252
+ let start = 0;
253
+ for (const line of String(this).split('\n')) {
254
+ const end = start + line.length;
255
+ results.push([line, start, end]);
256
+ start = end + 1;
257
+ }
258
+ return results;
247
259
  }
248
- return results;
249
260
  }
250
261
  };
251
262
  return AstNode = _classThis;
package/dist/lib/text.js CHANGED
@@ -106,9 +106,9 @@ class AstText extends node_1.AstNode {
106
106
  return [];
107
107
  }
108
108
  errorRegex.lastIndex = 0;
109
- const errors = [], nextType = nextSibling?.type, nextName = nextSibling?.name, previousType = previousSibling?.type, root = this.getRootNode(), rootStr = root.toString(), { ext, html, variants } = root.getAttribute('config'), { top, left } = root.posFromIndex(start), { lintConfig } = index_1.default, tagLike = lintConfig.rules['tag-like'], specified = typeof tagLike === 'number'
110
- ? new Set()
111
- : new Set(Object.keys(tagLike[1]).filter(tag => tag !== 'invalid' && tag !== 'disallowed')), tags = new Set([
109
+ const errors = [], nextType = nextSibling?.type, nextName = nextSibling?.name, previousType = previousSibling?.type, root = this.getRootNode(), rootStr = root.toString(), { ext, html, variants } = root.getAttribute('config'), { top, left } = root.posFromIndex(start), { lintConfig } = index_1.default, tagLike = lintConfig.rules['tag-like'], specified = typeof tagLike === 'object' && tagLike[1]
110
+ ? new Set(Object.keys(tagLike[1]).filter(tag => tag !== 'invalid' && tag !== 'disallowed'))
111
+ : new Set(), tags = new Set([
112
112
  'onlyinclude',
113
113
  'noinclude',
114
114
  'includeonly',