wikilint 2.47.0 → 2.48.1

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/README.md CHANGED
@@ -97,6 +97,6 @@ repos:
97
97
  # You can add any CLI options as needed
98
98
  entry: wikilint
99
99
  language: node
100
- additional_dependencies: ['wikilint@2.47.0']
100
+ additional_dependencies: ['wikilint@2.48.1']
101
101
  files: \.(mediawiki|wiki|wikitext)$
102
102
  ```
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "type": "object",
4
4
  "properties": {
5
5
  "ext": {
@@ -1023,6 +1023,7 @@
1023
1023
  "DEFAULTSORT": "defaultsort",
1024
1024
  "DEFAULTSORTKEY": "defaultsort",
1025
1025
  "DEFAULTCATEGORYSORT": "defaultsort",
1026
+ "CATEGORYSORT": "categorysort",
1026
1027
  "分类中页面数": "pagesincategory",
1027
1028
  "カテゴリ内ページ数": "pagesincategory",
1028
1029
  "PAGESINCATEGORY": "pagesincategory",
@@ -456,6 +456,7 @@
456
456
  "DEFAULTSORT": "defaultsort",
457
457
  "DEFAULTSORTKEY": "defaultsort",
458
458
  "DEFAULTCATEGORYSORT": "defaultsort",
459
+ "CATEGORYSORT": "categorysort",
459
460
  "PAGESINCATEGORY": "pagesincategory",
460
461
  "PAGESINCAT": "pagesincategory",
461
462
  "PAGESIZE": "pagesize",
@@ -546,6 +546,7 @@
546
546
  "DEFAULTSORT": "defaultsort",
547
547
  "DEFAULTSORTKEY": "defaultsort",
548
548
  "DEFAULTCATEGORYSORT": "defaultsort",
549
+ "CATEGORYSORT": "categorysort",
549
550
  "カテゴリ内ページ数": "pagesincategory",
550
551
  "PAGESINCATEGORY": "pagesincategory",
551
552
  "PAGESINCAT": "pagesincategory",
@@ -682,6 +682,7 @@
682
682
  "默认排序": "defaultsort",
683
683
  "默认排序关键字": "defaultsort",
684
684
  "默认分类排序": "defaultsort",
685
+ "CATEGORYSORT": "categorysort",
685
686
  "PAGESINCATEGORY": "pagesincategory",
686
687
  "PAGESINCAT": "pagesincategory",
687
688
  "分类中页面数": "pagesincategory",
@@ -2158,6 +2158,26 @@
2158
2158
  ],
2159
2159
  "description": "Used for categorizing pages, sets a default [category sort key](https://www.mediawiki.org/wiki/Help:Categories). It can take a second argument of *noerror* or *noreplace* to suppress error messages when multiple defaultsortkeys are used on one page or to make this `defaultsort` do nothing if a `defaultsort` was already specified earlier in the page."
2160
2160
  },
2161
+ {
2162
+ "aliases": [
2163
+ "categorysort"
2164
+ ],
2165
+ "signatures": [
2166
+ [
2167
+ {
2168
+ "label": "TIMESTAMP",
2169
+ "const": true
2170
+ }
2171
+ ],
2172
+ [
2173
+ {
2174
+ "label": "RTIMESTAMP",
2175
+ "const": true
2176
+ }
2177
+ ]
2178
+ ],
2179
+ "description": "When placed on a category page, the category will be sorted based on timestamp of categorization. `{{CATEGORYSORT:TIMESTAMP}}` lists members by the time they were added to the category, oldest first, and `{{CATEGORYSORT:RTIMESTAMP}}` lists the most recently added members first. Readers can still override this with the `cldsort` URL parameter, and the new `cldorder=desc` URL parameter reverses a `cldsort=timestamp` listing."
2180
+ },
2161
2181
  {
2162
2182
  "aliases": [
2163
2183
  "numberofpages"
package/dist/base.d.mts CHANGED
@@ -2,7 +2,7 @@ import type { Range, Position, ColorInformation, ColorPresentation, CompletionIt
2
2
  export interface Config {
3
3
  ext: string[];
4
4
  readonly html: [string[], string[], string[]];
5
- readonly namespaces: Record<string, string>;
5
+ readonly namespaces: Record<number, string>;
6
6
  readonly nsid: Record<string, number>;
7
7
  readonly parserFunction: [Record<string, string>, Record<string, string>, string[], string[]];
8
8
  readonly doubleUnderscore: [string[], string[], Record<string, string>, Record<string, string>];
@@ -117,6 +117,7 @@ export type CompletionItem = Omit<CompletionItemBase, 'kind'> & {
117
117
  kind?: CompletionItemKind | keyof typeof CompletionItemKind;
118
118
  };
119
119
  export interface LanguageService {
120
+ /** @since v1.17.1 */
120
121
  include: boolean;
121
122
  /**
122
123
  * Destroy the instance
@@ -147,6 +148,14 @@ export interface LanguageService {
147
148
  * @param position position / 位置
148
149
  */
149
150
  provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
151
+ /**
152
+ * Add additional information to a completion item
153
+ *
154
+ * 为自动补全项添加额外信息
155
+ * @param item completion item / 自动补全项
156
+ * @since v1.48.0
157
+ */
158
+ resolveCompletionItem(item: CompletionItem): CompletionItem;
150
159
  /**
151
160
  * Provide grammar check
152
161
  *
@@ -160,6 +169,7 @@ export interface LanguageService {
160
169
  *
161
170
  * 实现修复全部代码的操作
162
171
  * @param action code action / 代码操作
172
+ * @since v1.24.1
163
173
  */
164
174
  resolveCodeAction(action: CodeAction): CodeAction;
165
175
  /**
@@ -182,6 +192,7 @@ export interface LanguageService {
182
192
  * 提供文档高亮
183
193
  * @param text source Wikitext / 源代码
184
194
  * @param position position / 位置
195
+ * @since v1.46.1
185
196
  */
186
197
  provideDocumentHighlights(text: string, position: Position): Promise<DocumentHighlight[] | undefined>;
187
198
  /**
@@ -238,6 +249,7 @@ export interface LanguageService {
238
249
  *
239
250
  * 提供 CodeLens
240
251
  * @param text source Wikitext / 源代码
252
+ * @since v1.16.3
241
253
  */
242
254
  provideInlayHints(text: string): Promise<InlayHint[]>;
243
255
  /**
@@ -246,6 +258,7 @@ export interface LanguageService {
246
258
  * 提供重构操作
247
259
  * @param text source Wikitext / 源代码
248
260
  * @param range range of the refactoring / 重构范围
261
+ * @since v1.24.1
249
262
  */
250
263
  provideRefactoringAction(text: string, range?: Range): Promise<CodeAction[]>;
251
264
  /**
@@ -268,6 +281,7 @@ export interface LanguageService {
268
281
  * 设置目标维基百科
269
282
  * @param wiki Wikipedia URL / 维基百科网址
270
283
  * @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
284
+ * @since v1.18.1
271
285
  */
272
286
  setTargetWikipedia(wiki: string, user: string): Promise<void>;
273
287
  [Symbol.dispose](): void;
@@ -302,6 +316,7 @@ export interface Parser {
302
316
  *
303
317
  * 获取当前的解析设置
304
318
  * @param config unprocessed parser configuration / 未处理的解析设置
319
+ * @throws `RangeError` if the configuration file path or file name is invalid
305
320
  */
306
321
  getConfig(config?: ConfigData): Config;
307
322
  /**
package/dist/base.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { Range, Position, ColorInformation, ColorPresentation, CompletionIt
2
2
  export interface Config {
3
3
  ext: string[];
4
4
  readonly html: [string[], string[], string[]];
5
- readonly namespaces: Record<string, string>;
5
+ readonly namespaces: Record<number, string>;
6
6
  readonly nsid: Record<string, number>;
7
7
  readonly parserFunction: [Record<string, string>, Record<string, string>, string[], string[]];
8
8
  readonly doubleUnderscore: [string[], string[], Record<string, string>, Record<string, string>];
@@ -117,6 +117,7 @@ export type CompletionItem = Omit<CompletionItemBase, 'kind'> & {
117
117
  kind?: CompletionItemKind | keyof typeof CompletionItemKind;
118
118
  };
119
119
  export interface LanguageService {
120
+ /** @since v1.17.1 */
120
121
  include: boolean;
121
122
  /**
122
123
  * Destroy the instance
@@ -147,6 +148,14 @@ export interface LanguageService {
147
148
  * @param position position / 位置
148
149
  */
149
150
  provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
151
+ /**
152
+ * Add additional information to a completion item
153
+ *
154
+ * 为自动补全项添加额外信息
155
+ * @param item completion item / 自动补全项
156
+ * @since v1.48.0
157
+ */
158
+ resolveCompletionItem(item: CompletionItem): CompletionItem;
150
159
  /**
151
160
  * Provide grammar check
152
161
  *
@@ -160,6 +169,7 @@ export interface LanguageService {
160
169
  *
161
170
  * 实现修复全部代码的操作
162
171
  * @param action code action / 代码操作
172
+ * @since v1.24.1
163
173
  */
164
174
  resolveCodeAction(action: CodeAction): CodeAction;
165
175
  /**
@@ -182,6 +192,7 @@ export interface LanguageService {
182
192
  * 提供文档高亮
183
193
  * @param text source Wikitext / 源代码
184
194
  * @param position position / 位置
195
+ * @since v1.46.1
185
196
  */
186
197
  provideDocumentHighlights(text: string, position: Position): Promise<DocumentHighlight[] | undefined>;
187
198
  /**
@@ -238,6 +249,7 @@ export interface LanguageService {
238
249
  *
239
250
  * 提供 CodeLens
240
251
  * @param text source Wikitext / 源代码
252
+ * @since v1.16.3
241
253
  */
242
254
  provideInlayHints(text: string): Promise<InlayHint[]>;
243
255
  /**
@@ -246,6 +258,7 @@ export interface LanguageService {
246
258
  * 提供重构操作
247
259
  * @param text source Wikitext / 源代码
248
260
  * @param range range of the refactoring / 重构范围
261
+ * @since v1.24.1
249
262
  */
250
263
  provideRefactoringAction(text: string, range?: Range): Promise<CodeAction[]>;
251
264
  /**
@@ -268,6 +281,7 @@ export interface LanguageService {
268
281
  * 设置目标维基百科
269
282
  * @param wiki Wikipedia URL / 维基百科网址
270
283
  * @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
284
+ * @since v1.18.1
271
285
  */
272
286
  setTargetWikipedia(wiki: string, user: string): Promise<void>;
273
287
  [Symbol.dispose](): void;
@@ -302,6 +316,7 @@ export interface Parser {
302
316
  *
303
317
  * 获取当前的解析设置
304
318
  * @param config unprocessed parser configuration / 未处理的解析设置
319
+ * @throws `RangeError` if the configuration file path or file name is invalid
305
320
  */
306
321
  getConfig(config?: ConfigData): Config;
307
322
  /**
package/dist/bin/cli.js CHANGED
@@ -285,11 +285,10 @@ if (recursive) {
285
285
  if (!fs_1.default.existsSync(file)) {
286
286
  return [];
287
287
  }
288
- if (fs_1.default.statSync(file).isFile()) {
289
- return file;
290
- }
291
- return fs_1.default.readdirSync(file, { recursive: true, withFileTypes: true }).filter(dir => dir.isFile())
292
- .map(dir => path_1.default.join(dir.parentPath, dir.name));
288
+ return fs_1.default.statSync(file).isFile()
289
+ ? file
290
+ : fs_1.default.readdirSync(file, { recursive: true, withFileTypes: true }).filter(dir => dir.isFile())
291
+ .map(dir => path_1.default.join(dir.parentPath, dir.name));
293
292
  });
294
293
  }
295
294
  if (exts.length > 0) {
@@ -405,9 +404,9 @@ const { mtimeMs } = fs_1.default.statSync(config), obj = cache?.[include ? 'incl
405
404
  exiting ||= Boolean(nLocalErr || strict && nLocalWarn);
406
405
  }
407
406
  if (nErr || nWarn) {
408
- console.error(styleText(['red', 'bold'], '%s'), `\n✖ ${plural(nErr + nWarn, 'problem')} (${plural(nErr, 'error')}, ${plural(nWarn, 'warning')})`);
407
+ console.error(styleText(['red', 'bold'], '\n✖ %s (%s, %s)'), plural(nErr + nWarn, 'problem'), plural(nErr, 'error'), plural(nWarn, 'warning'));
409
408
  if (nFixableErr || nFixableWarn) {
410
- console.error(styleText(['red', 'bold'], '%s'), ` ${plural(nFixableErr, 'error')} and ${plural(nFixableWarn, 'warning')} potentially fixable with the \`--fix\` option.`);
409
+ console.error(styleText(['red', 'bold'], ' %s and %s potentially fixable with the `--fix` option.'), plural(nFixableErr, 'error'), plural(nFixableWarn, 'warning'));
411
410
  }
412
411
  console.error();
413
412
  }
@@ -41,7 +41,7 @@ const filterGadget = (id) => {
41
41
  const n = Number(id);
42
42
  return n < 2300 || n > 2303; // Gadget, Gadget talk, Gadget definition, Gadget definition talk
43
43
  };
44
- const pkg = 'wikilint', version = '2.47.0';
44
+ const pkg = 'wikilint', version = '2.48.1';
45
45
  /**
46
46
  * Get the parser configuration for a Wikimedia Foundation project.
47
47
  * @param site site nickname
@@ -49,6 +49,7 @@ const pkg = 'wikilint', version = '2.47.0';
49
49
  * @param user URI for wiki userpage or email address of the user
50
50
  * @param force whether to overwrite the existing configuration
51
51
  * @param internal for internal use
52
+ * @throws `RangeError` if the site nickname or script path is missing, or Extension:CodeMirror is not installed
52
53
  */
53
54
  exports.default = async (site, url, user, force, internal) => {
54
55
  // wrong calls
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { TitleOptions } from './lib/title';
5
5
  import type { LanguageService, QuickFixData } from './lib/lsp';
6
6
  import type { Token } from './internal';
7
7
  declare interface Parser extends ParserBase {
8
- default: Parser;
8
+ default: this;
9
9
  /** @since v1.5.1 */
10
10
  readonly rules: readonly LintError.Rule[];
11
11
  configPaths: string[];
@@ -33,6 +33,7 @@ declare interface Parser extends ParserBase {
33
33
  *
34
34
  * 获取一个WMF网站的名称
35
35
  * @param url script path
36
+ * @throws `RangeError` if the URL is not a recognizable WMF site
36
37
  * @since v1.22.0
37
38
  */
38
39
  getWMFSite(url: string): [string, string];
@@ -43,6 +44,7 @@ declare interface Parser extends ParserBase {
43
44
  * @param site site nickname / 网站别名
44
45
  * @param url script path / 脚本路径
45
46
  * @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
47
+ * @throws `RangeError` if Extension:CodeMirror is not installed
46
48
  * @since v1.18.4
47
49
  */
48
50
  fetchConfig(site: string, url: string, user?: string): Promise<Config>;
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ const re = new RegExp(String.raw `^https?:\/\/([^./]+)\.(${common_1.wmf})\.org`,
20
20
  /**
21
21
  * require一个JSON文件
22
22
  * @param file 文件名
23
- * @throws {RangeError} 仅支持JSON文件
23
+ * @throws `RangeError` 仅支持JSON文件
24
24
  */
25
25
  const jsonRequire = (file) => {
26
26
  const fullPath = require.resolve(file);
@@ -159,7 +159,7 @@ const Parser = {
159
159
  for (const key of keys) {
160
160
  const str = t[key];
161
161
  if (str?.includes('\0')) {
162
- const s = root.buildFromStr(str, constants_1.BuildMethod.Text);
162
+ const s = root.buildFromStr(str, 1 /* BuildMethod.Text */);
163
163
  if (key === 'main') {
164
164
  t.main = s;
165
165
  }
@@ -1,8 +1,8 @@
1
1
  import type { Position } from 'vscode-languageserver-types';
2
2
  import type { TextDocument, Range } from 'vscode-languageserver-textdocument';
3
- import type { JSONDocument, LanguageService as JSONLanguageService } from 'vscode-json-languageservice';
4
- import type { Stylesheet, LanguageService as CSSLanguageService } from 'vscode-css-languageservice';
5
- import type { IHTMLDataProvider } from 'vscode-html-languageservice';
3
+ import type * as JsonLanguageService from 'vscode-json-languageservice';
4
+ import type * as CssLanguageService from 'vscode-css-languageservice';
5
+ import type * as HtmlLanguageService from 'vscode-html-languageservice';
6
6
  import type { PublicApi } from 'stylelint';
7
7
  import type { Token } from '../internal';
8
8
  export interface TexvcLocation {
@@ -32,9 +32,9 @@ declare interface Texvcjs {
32
32
  }): TexvcReport;
33
33
  }
34
34
  export declare const loadTexvcjs: () => Texvcjs | null;
35
- export declare const loadJsonLSP: () => JSONLanguageService | null;
36
- export declare const loadCssLSP: () => CSSLanguageService | null;
37
- export declare const loadHtmlData: () => IHTMLDataProvider | null;
35
+ export declare const loadJsonLSP: () => JsonLanguageService.LanguageService | null;
36
+ export declare const loadCssLSP: () => CssLanguageService.LanguageService | null;
37
+ export declare const loadHtmlData: () => HtmlLanguageService.IHTMLDataProvider | null;
38
38
  export declare const loadStylelint: () => PublicApi | null;
39
39
  /** embedded document */
40
40
  declare abstract class EmbeddedDocument implements TextDocument {
@@ -65,7 +65,7 @@ declare abstract class EmbeddedDocument implements TextDocument {
65
65
  }
66
66
  /** embedded JSON document */
67
67
  export declare class EmbeddedJSONDocument extends EmbeddedDocument {
68
- jsonDoc: JSONDocument;
68
+ jsonDoc: JsonLanguageService.JSONDocument;
69
69
  abstract getLineRange(): Range;
70
70
  abstract getEOLCharacters(): string;
71
71
  /**
@@ -76,7 +76,7 @@ export declare class EmbeddedJSONDocument extends EmbeddedDocument {
76
76
  }
77
77
  /** embedded CSS document */
78
78
  export declare class EmbeddedCSSDocument extends EmbeddedDocument {
79
- styleSheet: Stylesheet;
79
+ styleSheet: CssLanguageService.Stylesheet;
80
80
  abstract getLineRange(): Range;
81
81
  abstract getEOLCharacters(): string;
82
82
  /**
@@ -27,8 +27,7 @@ let jsonLSP;
27
27
  const loadJsonLSP = () => {
28
28
  if (jsonLSP === undefined) {
29
29
  try {
30
- jsonLSP = require('vscode-json-languageservice')
31
- .getLanguageService({
30
+ jsonLSP = require('vscode-json-languageservice').getLanguageService({
32
31
  /* c8 ignore start */
33
32
  /** @implements */
34
33
  async schemaRequestService(uri) {
@@ -67,8 +66,7 @@ let cssLSP;
67
66
  const loadCssLSP = () => {
68
67
  if (cssLSP === undefined) {
69
68
  try {
70
- cssLSP = require('vscode-css-languageservice')
71
- .getCSSLanguageService();
69
+ cssLSP = require('vscode-css-languageservice').getCSSLanguageService();
72
70
  }
73
71
  catch /* c8 ignore start */ {
74
72
  cssLSP = null;
package/dist/lib/lsp.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import Parser from '../index';
2
2
  import { Token } from '../src/index';
3
- import type { Range, Position, ColorInformation, ColorPresentation, FoldingRange, DocumentLink, Location, DocumentHighlight, WorkspaceEdit, Diagnostic as DiagnosticBase, TextEdit, Hover, SignatureHelp, InlayHint, CodeAction, DocumentSymbol } from 'vscode-languageserver-types';
3
+ import type { Range, Position, ColorInformation, ColorPresentation, CompletionItem as CompletionItemBase, FoldingRange, DocumentLink, Location, DocumentHighlight, WorkspaceEdit, Diagnostic as DiagnosticBase, TextEdit, Hover, SignatureHelp, InlayHint, CodeAction, DocumentSymbol } from 'vscode-languageserver-types';
4
4
  import type { Config, LanguageService as LanguageServiceBase, CompletionItem, SignatureData } from '../base';
5
5
  import type { AttributeToken } from '../internal';
6
6
  import type { TokenTypeMap, SelectedTokenTypes } from '../map';
@@ -41,6 +41,14 @@ export declare class LanguageService implements LanguageServiceBase {
41
41
  * @param position position / 位置
42
42
  */
43
43
  provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
44
+ /**
45
+ * Add additional information to a completion item
46
+ *
47
+ * 为自动补全项添加额外信息
48
+ * @param item completion item / 自动补全项
49
+ * @since v1.48.0
50
+ */
51
+ resolveCompletionItem<T extends CompletionItem | CompletionItemBase>(item: T): T;
44
52
  /**
45
53
  * Provide grammar check
46
54
  *