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 +1 -1
- package/config/.schema.json +1 -1
- package/config/default.json +1 -0
- package/config/enwiki.json +1 -0
- package/config/jawiki.json +1 -0
- package/config/zhwiki.json +1 -0
- package/data/signatures.json +20 -0
- package/dist/base.d.mts +16 -1
- package/dist/base.d.ts +16 -1
- package/dist/bin/cli.js +6 -7
- package/dist/bin/config.js +2 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -2
- package/dist/lib/document.d.ts +8 -8
- package/dist/lib/document.js +2 -4
- package/dist/lib/lsp.d.ts +9 -1
- package/dist/lib/lsp.js +106 -100
- package/dist/lib/node.js +1 -1
- package/dist/lib/text.d.ts +2 -3
- package/dist/lib/text.js +4 -5
- package/dist/parser/braces.js +3 -4
- package/dist/src/attribute.js +13 -13
- package/dist/src/converterFlags.js +14 -13
- package/dist/src/converterRule.js +1 -1
- package/dist/src/extLink.js +1 -0
- package/dist/src/index.js +3 -2
- package/dist/src/link/base.js +3 -3
- package/dist/src/link/categorytree.js +3 -4
- package/dist/src/link/file.js +8 -7
- package/dist/src/multiLine/gallery.js +1 -1
- package/dist/src/table/index.d.ts +1 -1
- package/dist/src/table/td.js +2 -2
- package/dist/src/transclude.d.ts +2 -1
- package/dist/src/transclude.js +11 -7
- package/dist/util/ajv.js +26 -0
- package/dist/util/constants.js +1 -6
- package/dist/util/string.js +1 -0
- package/package.json +18 -18
package/dist/src/transclude.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ParameterToken } from './parameter';
|
|
|
3
3
|
import { AtomToken } from './atom';
|
|
4
4
|
import { SyntaxToken } from './syntax';
|
|
5
5
|
import type { Config, LintError } from '../base';
|
|
6
|
+
export declare const invalidTemplateMsg = "Invalid template name";
|
|
6
7
|
/**
|
|
7
8
|
* template or magic word
|
|
8
9
|
*
|
|
@@ -78,7 +79,7 @@ export declare abstract class TranscludeToken extends Token {
|
|
|
78
79
|
* Get possible values of some magic words
|
|
79
80
|
*
|
|
80
81
|
* 对特定魔术字获取可能的取值
|
|
81
|
-
* @throws `Error`
|
|
82
|
+
* @throws `Error` if not a supported magic word
|
|
82
83
|
*/
|
|
83
84
|
getPossibleValues(): Token[];
|
|
84
85
|
}
|
package/dist/src/transclude.js
CHANGED
|
@@ -37,11 +37,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.TranscludeToken = void 0;
|
|
40
|
+
exports.TranscludeToken = exports.invalidTemplateMsg = void 0;
|
|
41
41
|
const string_1 = require("../util/string");
|
|
42
42
|
const lint_1 = require("../util/lint");
|
|
43
43
|
const debug_1 = require("../util/debug");
|
|
44
|
-
const constants_1 = require("../util/constants");
|
|
45
44
|
const rect_1 = require("../lib/rect");
|
|
46
45
|
const gapped_1 = require("../mixin/gapped");
|
|
47
46
|
const noEscape_1 = require("../mixin/noEscape");
|
|
@@ -50,6 +49,8 @@ const index_2 = require("./index");
|
|
|
50
49
|
const parameter_1 = require("./parameter");
|
|
51
50
|
const atom_1 = require("./atom");
|
|
52
51
|
const syntax_1 = require("./syntax");
|
|
52
|
+
exports.invalidTemplateMsg = 'Invalid template name';
|
|
53
|
+
const sortArgs = /** @ignore */ ({ childNodes }, args) => [...args].sort((a, b) => childNodes.indexOf(a) - childNodes.indexOf(b));
|
|
53
54
|
/**
|
|
54
55
|
* template or magic word
|
|
55
56
|
*
|
|
@@ -159,7 +160,7 @@ let TranscludeToken = (() => {
|
|
|
159
160
|
const name = (0, string_1.removeComment)(title).trim();
|
|
160
161
|
if (!this.normalizeTitle(name, 10, { halfParsed: true, temporary: true }).valid) {
|
|
161
162
|
accum.pop();
|
|
162
|
-
throw new SyntaxError(
|
|
163
|
+
throw new SyntaxError(exports.invalidTemplateMsg);
|
|
163
164
|
}
|
|
164
165
|
const token = new atom_1.AtomToken(title, 'template-name', config, accum, {});
|
|
165
166
|
super.insertAt(token);
|
|
@@ -226,7 +227,7 @@ let TranscludeToken = (() => {
|
|
|
226
227
|
/** @private */
|
|
227
228
|
afterBuild() {
|
|
228
229
|
if (this.modifier.includes('\0')) {
|
|
229
|
-
this.setAttribute('modifier', this.buildFromStr(this.modifier,
|
|
230
|
+
this.setAttribute('modifier', this.buildFromStr(this.modifier, 0 /* BuildMethod.String */));
|
|
230
231
|
}
|
|
231
232
|
super.afterBuild();
|
|
232
233
|
if (this.isTemplate()) {
|
|
@@ -332,7 +333,7 @@ let TranscludeToken = (() => {
|
|
|
332
333
|
this.#anonCount +=
|
|
333
334
|
1;
|
|
334
335
|
let i;
|
|
335
|
-
// eslint-disable-next-line prefer-const
|
|
336
|
+
// eslint-disable-next-line prefer-const, unicorn/no-immediate-mutation
|
|
336
337
|
i = this.#anonCount - 1;
|
|
337
338
|
const token = addedToken, newName = String(i + 1);
|
|
338
339
|
token.setAttribute('name', newName);
|
|
@@ -371,6 +372,9 @@ let TranscludeToken = (() => {
|
|
|
371
372
|
args = new Set();
|
|
372
373
|
this.#args.set(keyStr, args);
|
|
373
374
|
}
|
|
375
|
+
if (copy) {
|
|
376
|
+
args = new Set(sortArgs(this, args));
|
|
377
|
+
}
|
|
374
378
|
return args;
|
|
375
379
|
}
|
|
376
380
|
/**
|
|
@@ -382,7 +386,7 @@ let TranscludeToken = (() => {
|
|
|
382
386
|
LINT: {
|
|
383
387
|
const isTemplate = this.isTemplate();
|
|
384
388
|
const duplicatedArgs = [...this.#args].filter(([, { size }]) => size > 1)
|
|
385
|
-
.map(([key, args]) => [key,
|
|
389
|
+
.map(([key, args]) => [key, sortArgs(this, args)]);
|
|
386
390
|
return isTemplate
|
|
387
391
|
? duplicatedArgs
|
|
388
392
|
: duplicatedArgs
|
|
@@ -394,7 +398,7 @@ let TranscludeToken = (() => {
|
|
|
394
398
|
* Get possible values of some magic words
|
|
395
399
|
*
|
|
396
400
|
* 对特定魔术字获取可能的取值
|
|
397
|
-
* @throws `Error`
|
|
401
|
+
* @throws `Error` if not a supported magic word
|
|
398
402
|
*/
|
|
399
403
|
getPossibleValues() {
|
|
400
404
|
const { type, name, childNodes, length: l } = this;
|
package/dist/util/ajv.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
/**
|
|
8
|
+
* 验证JSON数据并返回错误信息
|
|
9
|
+
* @param schemaPath JSON Schema文件路径
|
|
10
|
+
* @param dataVar 错误信息前缀
|
|
11
|
+
*/
|
|
12
|
+
exports.default = (schemaPath, dataVar = '#') => {
|
|
13
|
+
const schema = JSON.parse(fs_1.default.readFileSync(schemaPath, 'utf8'));
|
|
14
|
+
const Ajv = require(schema.$schema?.includes('draft-07') ? 'ajv' : 'ajv/dist/2020'), ajvErrors = require('ajv-errors');
|
|
15
|
+
const ajv = new Ajv({ allErrors: true });
|
|
16
|
+
ajvErrors(ajv, { singleError: true });
|
|
17
|
+
ajv.addKeyword('markdownDescription');
|
|
18
|
+
const v = ajv.compile(schema);
|
|
19
|
+
return data => {
|
|
20
|
+
if (v(data)) {
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
const errors = v.errors, { instancePath } = errors[0], related = errors.filter(error => error.instancePath === instancePath);
|
|
24
|
+
return ajv.errorsText([related.find(({ keyword }) => keyword === 'errorMessage') || related[0]], { dataVar });
|
|
25
|
+
};
|
|
26
|
+
};
|
package/dist/util/constants.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mathTags = exports.jsonTags = exports.extensions = exports.galleryParams = exports.enMsg = exports.
|
|
3
|
+
exports.mathTags = exports.jsonTags = exports.extensions = exports.galleryParams = exports.enMsg = exports.MAX_STAGE = void 0;
|
|
4
4
|
exports.MAX_STAGE = 11;
|
|
5
|
-
var BuildMethod;
|
|
6
|
-
(function (BuildMethod) {
|
|
7
|
-
BuildMethod[BuildMethod["String"] = 0] = "String";
|
|
8
|
-
BuildMethod[BuildMethod["Text"] = 1] = "Text";
|
|
9
|
-
})(BuildMethod || (exports.BuildMethod = BuildMethod = {}));
|
|
10
5
|
exports.enMsg = (() => {
|
|
11
6
|
LSP: return require(
|
|
12
7
|
// eslint-disable-next-line n/no-missing-require
|
package/dist/util/string.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toLowerCase = exports.decodeNumber = exports.decodeHtml = exports.decodeHtmlBasic = exports.text = exports.removeCommentLine = exports.removeComment = exports.tidy = exports.trimLc = exports.extUrlChar = exports.extUrlCharFirst = exports.zs = void 0;
|
|
4
4
|
exports.restore = restore;
|
|
5
|
+
/* NOT FOR BROWSER ONLY END */
|
|
5
6
|
exports.zs = String.raw ` \xA0\u1680\u2000-\u200A\u202F\u205F\u3000`;
|
|
6
7
|
const commonExtUrlChar = String.raw `[^[\]<>"\0-\x1F\x7F${exports.zs}\uFFFD]`;
|
|
7
8
|
exports.extUrlCharFirst = String.raw `(?:\[[\da-f:.]+\]|${commonExtUrlChar})`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikilint",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.48.1",
|
|
4
4
|
"description": "A Node.js linter for MediaWiki markup",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mediawiki",
|
|
@@ -39,23 +39,23 @@
|
|
|
39
39
|
"url": "git+https://github.com/bhsd-harry/wikiparser-node.git"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
-
"ls": "npm i --package-lock-only && npm ls --package-lock-only
|
|
42
|
+
"ls": "npm i --package-lock-only && npm ls --package-lock-only -a --include=peer --omit=dev",
|
|
43
43
|
"prepublishOnly": "npm run build:core",
|
|
44
44
|
"build:core": "bash build.sh",
|
|
45
45
|
"build:define": "bash sed.sh -i \"s/pkg = \\$PKG/pkg = '$(npm pkg get name)'/; s/version = \\$VERSION/version = '$(npm pkg get version)'/\" dist/bin/config.js",
|
|
46
46
|
"build": "npm run build:core",
|
|
47
47
|
"diff": "bash diff.sh",
|
|
48
48
|
"diff:stat": "f() { git diff --stat -w --color=always $1 $2 -- . | grep '\\.ts'; }; f",
|
|
49
|
-
"lint:ts": "tsc --noEmit && eslint --cache .",
|
|
50
|
-
"lint:
|
|
51
|
-
"lint
|
|
52
|
-
"lint": "npm run lint:ts && npm run lint:json && npm run lint:md",
|
|
49
|
+
"lint:ts": "[ ! -f dist/bin/config.js ] && npm run build:core; tsc --noEmit && eslint --cache .",
|
|
50
|
+
"lint:md": "myMarkdownlint",
|
|
51
|
+
"lint": "npm run lint:ts && npm run lint:md",
|
|
53
52
|
"prof": "node dist/test/prof.js",
|
|
54
|
-
"coverage": "tsc
|
|
53
|
+
"coverage": "tsc -d false -t es2024 && npm run build:define && c8 npm run test:ci && node dist/script/coverage.js && open coverage/index.html",
|
|
55
54
|
"test:unit": "testUtil dist/test/test.js",
|
|
55
|
+
"test:json": "testUtil dist/test/json.js",
|
|
56
56
|
"test:parser": "LC_ALL=en.UTF-8 testUtil dist/test/parserTests.js",
|
|
57
57
|
"test:perf": "testUtil --test-reporter=spec dist/test/perf.js",
|
|
58
|
-
"test": "npm run test:unit && npm run test:parser",
|
|
58
|
+
"test": "npm run test:unit && npm run test:parser && npm run test:json",
|
|
59
59
|
"test:parseronly": "LSP=0 npm run test:parser",
|
|
60
60
|
"test:ci": "LSP=0 npm test",
|
|
61
61
|
"test:end": "pkill -x http-server",
|
|
@@ -98,30 +98,30 @@
|
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
|
-
"@bhsd/cm-util": "^2.4.
|
|
101
|
+
"@bhsd/cm-util": "^2.4.2",
|
|
102
102
|
"@bhsd/common": "^4.1.0",
|
|
103
103
|
"@bhsd/stylelint-util": "^1.1.0",
|
|
104
104
|
"culori": "^4.0.2",
|
|
105
|
-
"entities": "^8.
|
|
106
|
-
"vscode-languageserver-types": "^3.18.
|
|
105
|
+
"entities": "^8.1.0",
|
|
106
|
+
"vscode-languageserver-types": "^3.18.4"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@bhsd/code-standard": "^
|
|
109
|
+
"@bhsd/code-standard": "^5.0.0",
|
|
110
110
|
"@bhsd/nodejs": "^1.2.1",
|
|
111
|
-
"@bhsd/test-util": "^3.
|
|
111
|
+
"@bhsd/test-util": "^3.3.0",
|
|
112
|
+
"ajv": "^8.20.0",
|
|
113
|
+
"ajv-errors": "^3.0.0",
|
|
112
114
|
"c8": "^12.0.0",
|
|
113
115
|
"diff2html-cli": "^5.2.15",
|
|
114
116
|
"esbuild": "^0.28.2",
|
|
115
|
-
"eslint": "^10.
|
|
116
|
-
"markdownlint-cli2": "^0.23.2",
|
|
117
|
+
"eslint": "^10.13.0",
|
|
117
118
|
"mathoid-texvcjs": "^0.6.0",
|
|
118
|
-
"stylelint": "^17.
|
|
119
|
+
"stylelint": "^17.16.0",
|
|
119
120
|
"typescript": "^6.0.3",
|
|
120
|
-
"v8r": "^6.1.0",
|
|
121
121
|
"vscode-css-languageservice": "^6.3.10",
|
|
122
122
|
"vscode-html-languageservice": "^5.6.2",
|
|
123
123
|
"vscode-json-languageservice": "^5.7.2",
|
|
124
|
-
"vscode-languageserver-textdocument": "^1.0.
|
|
124
|
+
"vscode-languageserver-textdocument": "^1.0.15"
|
|
125
125
|
},
|
|
126
126
|
"engines": {
|
|
127
127
|
"node": "^20.19.0 || ^22.13.0 || >=24.11.0"
|