wikilint 2.48.0 → 3.0.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 +1 -1
- package/config/.schema.json +1 -1
- package/data/signatures.json +2 -2
- package/dist/base.d.mts +4 -3
- package/dist/base.d.ts +4 -3
- package/dist/base.js +1 -0
- package/dist/base.mjs +2 -1
- package/dist/bin/cli.js +2 -2
- package/dist/bin/config.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +17 -11
- package/dist/internal.d.ts +1 -0
- package/dist/lib/document.d.ts +12 -12
- package/dist/lib/document.js +2 -4
- package/dist/lib/lintConfig.js +1 -0
- package/dist/lib/lsp.js +7 -4
- package/dist/lib/node.d.ts +0 -4
- package/dist/lib/node.js +9 -1
- package/dist/lib/text.js +1 -1
- package/dist/map.d.ts +2 -1
- package/dist/parser/commentAndExt.js +1 -2
- package/dist/parser/hrAndDoubleUnderscore.js +3 -2
- package/dist/parser/table.js +2 -1
- package/dist/src/arg.d.ts +1 -1
- package/dist/src/arg.js +1 -1
- package/dist/src/attribute.js +12 -12
- package/dist/src/attributes.d.ts +4 -3
- package/dist/src/converter.d.ts +1 -1
- package/dist/src/converter.js +1 -1
- package/dist/src/converterRule.d.ts +1 -1
- package/dist/src/converterRule.js +2 -2
- package/dist/src/extLink.d.ts +1 -1
- package/dist/src/extLink.js +1 -1
- package/dist/src/index.js +55 -14
- package/dist/src/link/base.js +2 -2
- package/dist/src/link/category.d.ts +1 -1
- package/dist/src/link/category.js +1 -1
- package/dist/src/link/index.d.ts +1 -1
- package/dist/src/link/index.js +1 -1
- package/dist/src/link/redirectTarget.d.ts +1 -1
- package/dist/src/link/redirectTarget.js +1 -1
- package/dist/src/magicLink.d.ts +4 -3
- package/dist/src/magicLink.js +1 -1
- package/dist/src/multiLine/gallery.d.ts +4 -4
- package/dist/src/multiLine/gallery.js +1 -1
- package/dist/src/multiLine/imagemap.d.ts +5 -3
- package/dist/src/multiLine/imagemap.js +1 -1
- package/dist/src/nested.d.ts +1 -1
- package/dist/src/nested.js +1 -1
- package/dist/src/nowiki/list.js +6 -3
- package/dist/src/nowiki/listBase.d.ts +24 -0
- package/dist/src/nowiki/listBase.js +104 -0
- package/dist/src/paramLine.d.ts +1 -1
- package/dist/src/paramLine.js +1 -1
- package/dist/src/pre.d.ts +5 -3
- package/dist/src/redirect.d.ts +1 -1
- package/dist/src/redirect.js +1 -1
- package/dist/src/singleLine/charinsertLine.d.ts +1 -1
- package/dist/src/singleLine/charinsertLine.js +1 -1
- package/dist/src/table/index.d.ts +2 -2
- package/dist/src/table/index.js +1 -1
- package/dist/src/table/tr.d.ts +1 -1
- package/dist/src/table/tr.js +1 -1
- package/dist/src/tag/index.d.ts +7 -5
- package/dist/src/tag/index.js +9 -4
- package/dist/src/tagPair/ext.js +1 -1
- package/dist/src/transclude.d.ts +1 -1
- package/dist/src/transclude.js +2 -2
- package/dist/util/ajv.js +26 -0
- package/dist/util/debug.js +7 -1
- package/dist/util/string.js +1 -0
- package/i18n/en.json +1 -0
- package/i18n/zh-hans.json +1 -0
- package/i18n/zh-hant.json +1 -0
- package/package.json +16 -16
package/dist/src/tag/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const index_1 = require("../index");
|
|
|
8
8
|
* HTML tag
|
|
9
9
|
*
|
|
10
10
|
* HTML标签
|
|
11
|
-
* @classdesc `{childNodes: [AttributesToken]}`
|
|
11
|
+
* @classdesc `{childNodes: [AttributesToken|SyntaxToken]}`
|
|
12
12
|
*/
|
|
13
13
|
class TagToken extends index_1.Token {
|
|
14
14
|
#closing;
|
|
@@ -47,7 +47,6 @@ class TagToken extends index_1.Token {
|
|
|
47
47
|
findMatchingTag() {
|
|
48
48
|
LINT: return (0, lint_1.cache)(this.#match, () => {
|
|
49
49
|
const { type, name, closing, selfClosing, } = this;
|
|
50
|
-
// eslint-disable-next-line prefer-const
|
|
51
50
|
let { parentNode } = this, isVoid = false, isFlexible = false;
|
|
52
51
|
if (type === 'html') {
|
|
53
52
|
const [, flexibleTags, voidTags] = this.getAttribute('config').html;
|
|
@@ -63,9 +62,15 @@ class TagToken extends index_1.Token {
|
|
|
63
62
|
}
|
|
64
63
|
const { childNodes } = parentNode, i = childNodes.indexOf(this), siblings = closing ? childNodes.slice(0, i) : childNodes.slice(i + 1).reverse(), stack = [this], { rev } = debug_1.Shadow;
|
|
65
64
|
let cur = siblings.pop(), until;
|
|
66
|
-
while (cur) {
|
|
67
|
-
// eslint-disable-next-line no-empty, @typescript-eslint/no-unnecessary-condition
|
|
65
|
+
while (cur || parentNode.is('list-range') && parentNode.parentNode) {
|
|
68
66
|
if (!cur) {
|
|
67
|
+
const parent = parentNode.parentNode, ch = parent.childNodes, j = ch.indexOf(parentNode);
|
|
68
|
+
Array.prototype.push.apply(siblings, closing ? ch.slice(0, j) : ch.slice(j + 1).reverse());
|
|
69
|
+
parentNode = parent;
|
|
70
|
+
}
|
|
71
|
+
else if (cur.is('list-range')) {
|
|
72
|
+
const ch = cur.childNodes;
|
|
73
|
+
Array.prototype.push.apply(siblings, closing ? ch : [...ch].reverse());
|
|
69
74
|
}
|
|
70
75
|
else if (until) {
|
|
71
76
|
if (cur === until) {
|
package/dist/src/tagPair/ext.js
CHANGED
|
@@ -223,7 +223,7 @@ let ExtToken = (() => {
|
|
|
223
223
|
LINT: {
|
|
224
224
|
const refName = this.getAttr('name'), text = this.innerText?.trim();
|
|
225
225
|
let msg = '';
|
|
226
|
-
if (this.closest('ext#references')) {
|
|
226
|
+
if (this.closest('ext-inner#references')) {
|
|
227
227
|
if (!refName) {
|
|
228
228
|
msg = 'no-named-in-references';
|
|
229
229
|
}
|
package/dist/src/transclude.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const invalidTemplateMsg = "Invalid template name";
|
|
|
8
8
|
* template or magic word
|
|
9
9
|
*
|
|
10
10
|
* 模板或魔术字
|
|
11
|
-
* @classdesc `{childNodes: [AtomToken|SyntaxToken, ...
|
|
11
|
+
* @classdesc `{childNodes: [AtomToken|SyntaxToken, ...ParameterToken[]]}`
|
|
12
12
|
*/
|
|
13
13
|
export declare abstract class TranscludeToken extends Token {
|
|
14
14
|
#private;
|
package/dist/src/transclude.js
CHANGED
|
@@ -55,7 +55,7 @@ const sortArgs = /** @ignore */ ({ childNodes }, args) => [...args].sort((a, b)
|
|
|
55
55
|
* template or magic word
|
|
56
56
|
*
|
|
57
57
|
* 模板或魔术字
|
|
58
|
-
* @classdesc `{childNodes: [AtomToken|SyntaxToken, ...
|
|
58
|
+
* @classdesc `{childNodes: [AtomToken|SyntaxToken, ...ParameterToken[]]}`
|
|
59
59
|
*/
|
|
60
60
|
let TranscludeToken = (() => {
|
|
61
61
|
let _classDecorators = [noEscape_1.noEscape, (0, gapped_1.gapped)()];
|
|
@@ -333,7 +333,7 @@ let TranscludeToken = (() => {
|
|
|
333
333
|
this.#anonCount +=
|
|
334
334
|
1;
|
|
335
335
|
let i;
|
|
336
|
-
// eslint-disable-next-line prefer-const
|
|
336
|
+
// eslint-disable-next-line prefer-const, unicorn/no-immediate-mutation
|
|
337
337
|
i = this.#anonCount - 1;
|
|
338
338
|
const token = addedToken, newName = String(i + 1);
|
|
339
339
|
token.setAttribute('name', newName);
|
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/debug.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mixin = exports.emptyArray = exports.getMagicWordInfo = exports.setChildNodes = exports.isLink = exports.isRowEnd = exports.Shadow = void 0;
|
|
3
|
+
exports.mixin = exports.emptyArray = exports.getMagicWordInfo = exports.setChildNodes = exports.isLink = exports.isRowEnd = exports.isIsolated = exports.Shadow = void 0;
|
|
4
4
|
exports.isToken = isToken;
|
|
5
5
|
exports.Shadow = {
|
|
6
6
|
running: false,
|
|
@@ -37,6 +37,12 @@ exports.Shadow = {
|
|
|
37
37
|
function isToken(type) {
|
|
38
38
|
return (node) => node.type === type;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* 扩展节点是否提供独立解析环境
|
|
42
|
+
* @param name 扩展节点名称
|
|
43
|
+
*/
|
|
44
|
+
const isIsolated = (name) => name === 'poem' || name === 'indicator';
|
|
45
|
+
exports.isIsolated = isIsolated;
|
|
40
46
|
/**
|
|
41
47
|
* 是否是行尾
|
|
42
48
|
* @param token 节点
|
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/i18n/en.json
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"duplicate-ext-parameter": "duplicate parameter of <$1>",
|
|
18
18
|
"duplicate-id": "duplicate HTML id",
|
|
19
19
|
"duplicate-image-parameter": "duplicate image $1 parameter",
|
|
20
|
+
"duplicate-name": "duplicate name of <indicator>",
|
|
20
21
|
"duplicate-parameter": "duplicate template parameter",
|
|
21
22
|
"encode": null,
|
|
22
23
|
"escape": null,
|
package/i18n/zh-hans.json
CHANGED
package/i18n/zh-hant.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikilint",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A Node.js linter for MediaWiki markup",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mediawiki",
|
|
@@ -39,7 +39,7 @@
|
|
|
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",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"diff": "bash diff.sh",
|
|
48
48
|
"diff:stat": "f() { git diff --stat -w --color=always $1 $2 -- . | grep '\\.ts'; }; f",
|
|
49
49
|
"lint:ts": "[ ! -f dist/bin/config.js ] && npm run build:core; tsc --noEmit && eslint --cache .",
|
|
50
|
-
"lint:
|
|
51
|
-
"lint
|
|
52
|
-
"lint": "npm run lint:ts && npm run lint:json && npm run lint:md",
|
|
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,32 +98,32 @@
|
|
|
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
105
|
"entities": "^8.1.0",
|
|
106
|
-
"vscode-languageserver-types": "^3.18.
|
|
106
|
+
"vscode-languageserver-types": "^3.18.5"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@bhsd/code-standard": "^
|
|
109
|
+
"@bhsd/code-standard": "^5.1.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.3",
|
|
117
|
+
"eslint": "^10.14.0",
|
|
117
118
|
"mathoid-texvcjs": "^0.6.0",
|
|
118
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.16"
|
|
125
125
|
},
|
|
126
126
|
"engines": {
|
|
127
|
-
"node": "^
|
|
127
|
+
"node": "^22.13.0 || >=24.11.0"
|
|
128
128
|
}
|
|
129
129
|
}
|