wikilint 2.15.0 → 2.16.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.
- package/README.md +2 -1
- package/config/.schema.json +14 -1
- package/config/llwiki.json +1 -0
- package/config/minimum.json +2 -0
- package/config/moegirl.json +1 -0
- package/config/zhwiki.json +24 -23
- package/coverage/badge.svg +1 -0
- package/dist/base.d.mts +164 -0
- package/dist/base.d.ts +68 -0
- package/dist/base.js +70 -63
- package/dist/base.mjs +74 -0
- package/dist/bin/coverage.js +19 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +13 -3
- package/dist/internal.d.ts +41 -41
- package/dist/lib/lsp.d.ts +68 -0
- package/dist/lib/lsp.js +610 -0
- package/dist/lib/node.js +2 -2
- package/dist/lib/rect.d.ts +3 -5
- package/dist/lib/rect.js +13 -10
- package/dist/lib/text.js +6 -7
- package/dist/parser/braces.js +2 -0
- package/dist/parser/commentAndExt.js +1 -0
- package/dist/parser/converter.js +1 -0
- package/dist/parser/externalLinks.js +2 -1
- package/dist/parser/hrAndDoubleUnderscore.js +2 -1
- package/dist/parser/html.js +1 -0
- package/dist/parser/links.js +1 -0
- package/dist/parser/list.js +1 -0
- package/dist/parser/magicLinks.js +2 -1
- package/dist/parser/quotes.js +1 -0
- package/dist/parser/redirect.js +1 -0
- package/dist/parser/table.js +1 -0
- package/dist/src/attribute.d.ts +4 -2
- package/dist/src/attribute.js +3 -4
- package/dist/src/attributes.js +1 -1
- package/dist/src/heading.js +3 -1
- package/dist/src/html.js +3 -4
- package/dist/src/link/redirectTarget.d.ts +2 -3
- package/dist/src/link/redirectTarget.js +1 -2
- package/dist/src/magicLink.js +1 -1
- package/dist/src/nowiki/comment.d.ts +1 -1
- package/dist/src/nowiki/comment.js +1 -1
- package/dist/src/nowiki/quote.js +8 -12
- package/dist/util/debug.js +14 -2
- package/dist/util/diff.js +5 -0
- package/dist/util/html.js +3 -1
- package/dist/util/lint.js +16 -4
- package/dist/util/sharable.js +5 -4
- package/dist/util/sharable.mjs +4 -4
- package/dist/util/string.js +12 -1
- package/package.json +39 -21
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const diff_1 = require("./util/diff");
|
|
|
12
12
|
* @param file 文件名
|
|
13
13
|
* @param dir 子路径
|
|
14
14
|
*/
|
|
15
|
-
const rootRequire = (file, dir) => require(path.isAbsolute(file) ? file : path.join('..', file.includes('/') ? '' : dir, file));
|
|
15
|
+
const rootRequire = (file, dir) => require(path.isAbsolute(file) ? /* istanbul ignore next */ file : path.join('..', file.includes('/') ? '' : dir, file));
|
|
16
16
|
const Parser = {
|
|
17
17
|
config: 'default',
|
|
18
18
|
i18n: undefined,
|
|
@@ -21,6 +21,7 @@ const Parser = {
|
|
|
21
21
|
getConfig() {
|
|
22
22
|
if (typeof this.config === 'string') {
|
|
23
23
|
this.config = rootRequire(this.config, 'config');
|
|
24
|
+
/* istanbul ignore if */
|
|
24
25
|
if (this.config.doubleUnderscore.length < 3 || Array.isArray(this.config.parserFunction[1])) {
|
|
25
26
|
(0, diff_1.error)(`The schema (${path.resolve(__dirname, '..', 'config', '.schema.json')}) of parser configuration is updated.`);
|
|
26
27
|
}
|
|
@@ -90,11 +91,11 @@ const Parser = {
|
|
|
90
91
|
try {
|
|
91
92
|
return token.parse(maxStage, include);
|
|
92
93
|
}
|
|
93
|
-
catch (e) {
|
|
94
|
+
catch (e) /* istanbul ignore next */ {
|
|
94
95
|
if (e instanceof Error) {
|
|
95
96
|
const file = path.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage');
|
|
96
97
|
for (const k in config) {
|
|
97
|
-
if (k.startsWith('regex')) {
|
|
98
|
+
if (k.startsWith('regex') || config[k] instanceof Set) {
|
|
98
99
|
delete config[k];
|
|
99
100
|
}
|
|
100
101
|
}
|
|
@@ -107,12 +108,21 @@ const Parser = {
|
|
|
107
108
|
});
|
|
108
109
|
return root;
|
|
109
110
|
},
|
|
111
|
+
/** @implements */
|
|
112
|
+
createLanguageService(uri) {
|
|
113
|
+
let mod;
|
|
114
|
+
// eslint-disable-next-line no-unused-labels
|
|
115
|
+
LSP: mod = require('./lib/lsp');
|
|
116
|
+
const { LanguageService, tasks } = mod;
|
|
117
|
+
return tasks.get(uri) ?? new LanguageService(uri);
|
|
118
|
+
},
|
|
110
119
|
};
|
|
111
120
|
const def = {
|
|
112
121
|
default: { value: Parser },
|
|
113
122
|
}, enumerable = new Set([
|
|
114
123
|
'normalizeTitle',
|
|
115
124
|
'parse',
|
|
125
|
+
'createLanguageService',
|
|
116
126
|
]);
|
|
117
127
|
for (const key in Parser) {
|
|
118
128
|
if (!enumerable.has(key)) {
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
export type { AstNodes
|
|
2
|
-
export type
|
|
1
|
+
export type { AstNodes } from './lib/node';
|
|
2
|
+
export type { AstText } from './lib/text';
|
|
3
3
|
export type { Token } from './src/index';
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
export type
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
9
|
-
export type
|
|
10
|
-
export type
|
|
4
|
+
export type { RedirectToken } from './src/redirect';
|
|
5
|
+
export type { RedirectTargetToken } from './src/link/redirectTarget';
|
|
6
|
+
export type { OnlyincludeToken } from './src/onlyinclude';
|
|
7
|
+
export type { NoincludeToken } from './src/nowiki/noinclude';
|
|
8
|
+
export type { IncludeToken } from './src/tagPair/include';
|
|
9
|
+
export type { CommentToken } from './src/nowiki/comment';
|
|
10
|
+
export type { AtomToken } from './src/atom';
|
|
11
11
|
export type { AttributeToken } from './src/attribute';
|
|
12
|
-
export type
|
|
13
|
-
export type
|
|
14
|
-
export type
|
|
15
|
-
export type
|
|
16
|
-
export type
|
|
17
|
-
export type
|
|
18
|
-
export type
|
|
19
|
-
export type
|
|
20
|
-
export type
|
|
12
|
+
export type { AttributesToken } from './src/attributes';
|
|
13
|
+
export type { ExtToken } from './src/tagPair/ext';
|
|
14
|
+
export type { HiddenToken } from './src/hidden';
|
|
15
|
+
export type { ArgToken } from './src/arg';
|
|
16
|
+
export type { SyntaxToken } from './src/syntax';
|
|
17
|
+
export type { ParameterToken } from './src/parameter';
|
|
18
|
+
export type { TranscludeToken } from './src/transclude';
|
|
19
|
+
export type { HeadingToken } from './src/heading';
|
|
20
|
+
export type { HtmlToken } from './src/html';
|
|
21
21
|
export type { TdToken } from './src/table/td';
|
|
22
|
-
export type
|
|
22
|
+
export type { TrToken } from './src/table/tr';
|
|
23
23
|
export type { TableToken } from './src/table/index';
|
|
24
|
-
export type
|
|
25
|
-
export type
|
|
26
|
-
export type
|
|
27
|
-
export type
|
|
24
|
+
export type { HrToken } from './src/nowiki/hr';
|
|
25
|
+
export type { DoubleUnderscoreToken } from './src/nowiki/doubleUnderscore';
|
|
26
|
+
export type { LinkToken } from './src/link/index';
|
|
27
|
+
export type { CategoryToken } from './src/link/category';
|
|
28
28
|
export type { ImageParameterToken } from './src/imageParameter';
|
|
29
|
-
export type
|
|
30
|
-
export type
|
|
31
|
-
export type
|
|
32
|
-
export type
|
|
33
|
-
export type
|
|
34
|
-
export type
|
|
35
|
-
export type
|
|
36
|
-
export type
|
|
37
|
-
export type
|
|
38
|
-
export type
|
|
39
|
-
export type
|
|
40
|
-
export type
|
|
41
|
-
export type
|
|
42
|
-
export type
|
|
43
|
-
export type
|
|
44
|
-
export type
|
|
45
|
-
export type
|
|
46
|
-
export type
|
|
29
|
+
export type { FileToken } from './src/link/file';
|
|
30
|
+
export type { GalleryImageToken } from './src/link/galleryImage';
|
|
31
|
+
export type { QuoteToken } from './src/nowiki/quote';
|
|
32
|
+
export type { MagicLinkToken } from './src/magicLink';
|
|
33
|
+
export type { ExtLinkToken } from './src/extLink';
|
|
34
|
+
export type { DdToken } from './src/nowiki/dd';
|
|
35
|
+
export type { ListToken } from './src/nowiki/list';
|
|
36
|
+
export type { ConverterFlagsToken } from './src/converterFlags';
|
|
37
|
+
export type { ConverterRuleToken } from './src/converterRule';
|
|
38
|
+
export type { ConverterToken } from './src/converter';
|
|
39
|
+
export type { NowikiToken } from './src/nowiki/index';
|
|
40
|
+
export type { PreToken } from './src/pre';
|
|
41
|
+
export type { ParamTagToken } from './src/paramTag/index';
|
|
42
|
+
export type { InputboxToken } from './src/paramTag/inputbox';
|
|
43
|
+
export type { NestedToken } from './src/nested';
|
|
44
|
+
export type { GalleryToken } from './src/gallery';
|
|
45
|
+
export type { ImagemapLinkToken } from './src/imagemapLink';
|
|
46
|
+
export type { ImagemapToken } from './src/imagemap';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Range, Position, ColorInformation, ColorPresentation, CompletionItem, FoldingRange, DocumentSymbol, DocumentLink, Location, WorkspaceEdit } from 'vscode-languageserver-types';
|
|
2
|
+
import type { LanguageService as LanguageServiceBase } from '../base';
|
|
3
|
+
export declare const tasks: WeakMap<object, LanguageService>;
|
|
4
|
+
/** VSCode-style language service */
|
|
5
|
+
export declare class LanguageService implements LanguageServiceBase {
|
|
6
|
+
#private;
|
|
7
|
+
/** @param uri 任务标识 */
|
|
8
|
+
constructor(uri: object);
|
|
9
|
+
/**
|
|
10
|
+
* 提供颜色指示
|
|
11
|
+
* @param rgba 颜色解析函数
|
|
12
|
+
* @param text 源代码
|
|
13
|
+
* @param hsl 是否允许HSL颜色
|
|
14
|
+
*/
|
|
15
|
+
provideDocumentColors(rgba: (s: string) => [number, number, number, number] | [], text: string, hsl?: boolean): Promise<ColorInformation[]>;
|
|
16
|
+
/**
|
|
17
|
+
* 颜色选择器
|
|
18
|
+
* @ignore
|
|
19
|
+
*/
|
|
20
|
+
provideColorPresentations(// eslint-disable-line @typescript-eslint/class-methods-use-this
|
|
21
|
+
{ color: { red, green, blue, alpha }, range }: ColorInformation): ColorPresentation[];
|
|
22
|
+
/**
|
|
23
|
+
* 提供自动补全
|
|
24
|
+
* @param text 源代码
|
|
25
|
+
* @param position 位置
|
|
26
|
+
*/
|
|
27
|
+
provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* 提供折叠范围
|
|
30
|
+
* @param text 源代码
|
|
31
|
+
*/
|
|
32
|
+
provideFoldingRanges(text: string): Promise<FoldingRange[]>;
|
|
33
|
+
/**
|
|
34
|
+
* 提供章节
|
|
35
|
+
* @param text 源代码
|
|
36
|
+
*/
|
|
37
|
+
provideDocumentSymbols(text: string): Promise<DocumentSymbol[]>;
|
|
38
|
+
/**
|
|
39
|
+
* 提供链接
|
|
40
|
+
* @param text 源代码
|
|
41
|
+
*/
|
|
42
|
+
provideLinks(text: string): Promise<DocumentLink[]>;
|
|
43
|
+
/**
|
|
44
|
+
* 提供引用
|
|
45
|
+
* @param text 源代码
|
|
46
|
+
* @param position 位置
|
|
47
|
+
*/
|
|
48
|
+
provideReferences(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* 提供定义
|
|
51
|
+
* @param text 源代码
|
|
52
|
+
* @param position 位置
|
|
53
|
+
*/
|
|
54
|
+
provideDefinition(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
|
|
55
|
+
/**
|
|
56
|
+
* 提供变量更名准备
|
|
57
|
+
* @param text 源代码
|
|
58
|
+
* @param position 位置
|
|
59
|
+
*/
|
|
60
|
+
resolveRenameLocation(text: string, position: Position): Promise<Range | undefined>;
|
|
61
|
+
/**
|
|
62
|
+
* 变量更名
|
|
63
|
+
* @param text 源代码
|
|
64
|
+
* @param position 位置
|
|
65
|
+
* @param newName 新名称
|
|
66
|
+
*/
|
|
67
|
+
provideRenameEdits(text: string, position: Position, newName: string): Promise<WorkspaceEdit | undefined>;
|
|
68
|
+
}
|