wikilint 2.22.0 → 2.22.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/config/default.json +2 -0
- package/config/minimum.json +1 -0
- package/config/moegirl.json +2 -0
- package/dist/lib/document.js +1 -1
- package/dist/lib/element.js +3 -3
- package/dist/lib/lsp.js +25 -8
- package/dist/parser/selector.js +6 -3
- package/package.json +2 -2
package/config/default.json
CHANGED
|
@@ -567,6 +567,7 @@
|
|
|
567
567
|
"translation",
|
|
568
568
|
"chart",
|
|
569
569
|
"avatar",
|
|
570
|
+
"img",
|
|
570
571
|
"mentor"
|
|
571
572
|
],
|
|
572
573
|
"variable": [
|
|
@@ -936,6 +937,7 @@
|
|
|
936
937
|
"#头像": "avatar",
|
|
937
938
|
"#頭像": "avatar",
|
|
938
939
|
"#avatar": "avatar",
|
|
940
|
+
"#img": "img",
|
|
939
941
|
"wb報表名稱": "wbreponame",
|
|
940
942
|
"wb报告名": "wbreponame",
|
|
941
943
|
"wbreponame": "wbreponame"
|
package/config/minimum.json
CHANGED
package/config/moegirl.json
CHANGED
|
@@ -396,6 +396,7 @@
|
|
|
396
396
|
"vardefine",
|
|
397
397
|
"vardefineecho",
|
|
398
398
|
"invoke",
|
|
399
|
+
"img",
|
|
399
400
|
"related"
|
|
400
401
|
],
|
|
401
402
|
"variable": [
|
|
@@ -629,6 +630,7 @@
|
|
|
629
630
|
"样式路径": "stylepath",
|
|
630
631
|
"stylepath": "stylepath",
|
|
631
632
|
"msgnw": "msgnw",
|
|
633
|
+
"#img": "img",
|
|
632
634
|
"#related": "related"
|
|
633
635
|
},
|
|
634
636
|
{
|
package/dist/lib/document.js
CHANGED
|
@@ -111,7 +111,7 @@ class EmbeddedDocument {
|
|
|
111
111
|
this.languageId = id;
|
|
112
112
|
this.lineCount = root.getLines().length;
|
|
113
113
|
this.#root = root;
|
|
114
|
-
this.#content =
|
|
114
|
+
this.#content = token.toString();
|
|
115
115
|
this.#offset = token.getAbsoluteIndex();
|
|
116
116
|
this.pre = pre;
|
|
117
117
|
this.#post = post;
|
package/dist/lib/element.js
CHANGED
|
@@ -115,9 +115,9 @@ class AstElement extends node_1.AstNode {
|
|
|
115
115
|
/**
|
|
116
116
|
* 符合条件的所有后代节点
|
|
117
117
|
* @param condition 条件
|
|
118
|
+
* @param descendants 已经找到的后代节点
|
|
118
119
|
*/
|
|
119
|
-
#getElementsBy(condition) {
|
|
120
|
-
let descendants = [];
|
|
120
|
+
#getElementsBy(condition, descendants = []) {
|
|
121
121
|
for (const child of this.childNodes) {
|
|
122
122
|
if (child.type === 'text') {
|
|
123
123
|
continue;
|
|
@@ -125,7 +125,7 @@ class AstElement extends node_1.AstNode {
|
|
|
125
125
|
else if (condition(child)) {
|
|
126
126
|
descendants.push(child);
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
child.#getElementsBy(condition, descendants);
|
|
129
129
|
}
|
|
130
130
|
return descendants;
|
|
131
131
|
}
|
package/dist/lib/lsp.js
CHANGED
|
@@ -223,14 +223,16 @@ const adjustPos = (height, width, line, column) => {
|
|
|
223
223
|
* Get the position of a Stylelint error.
|
|
224
224
|
* @param rect bounding client rect of the token
|
|
225
225
|
* @param bottom bottom of the style block
|
|
226
|
-
* @param
|
|
227
|
-
* @param
|
|
226
|
+
* @param lineOrCode line number or code string
|
|
227
|
+
* @param columnOrOffset column number or offset in the code string
|
|
228
228
|
*/
|
|
229
|
-
const getStylelintPos = (rect, bottom,
|
|
229
|
+
const getStylelintPos = (rect, bottom, lineOrCode, columnOrOffset) => {
|
|
230
230
|
const { top, left, height, width } = rect, start = bottom - height - 1;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
if (typeof lineOrCode === 'number') {
|
|
232
|
+
return (0, lint_1.getEndPos)(top, left, ...adjustPos(height, width, lineOrCode - start, columnOrOffset));
|
|
233
|
+
}
|
|
234
|
+
const lines = lineOrCode.slice(0, columnOrOffset).split(/\r?\n/u);
|
|
235
|
+
return getStylelintPos(rect, bottom, lines.length, lines.at(-1).length);
|
|
234
236
|
};
|
|
235
237
|
/**
|
|
236
238
|
* Convert LilyPond errors to VSCode diagnostics.
|
|
@@ -756,7 +758,7 @@ class LanguageService {
|
|
|
756
758
|
if (tokens.length === 0) {
|
|
757
759
|
return [];
|
|
758
760
|
}
|
|
759
|
-
const
|
|
761
|
+
const code = tokens.map(({ type, tag, lastChild }, i) => `${type === 'ext-attr' ? 'div' : tag}#${i}{\n${(0, common_1.sanitizeInlineStyle)(lastChild.toString())}\n}`).join('\n'), cssErrors = await (0, stylelint_util_1.styleLint)((await document_1.stylelint), code, cssRules);
|
|
760
762
|
if (cssErrors.length === 0) {
|
|
761
763
|
return [];
|
|
762
764
|
}
|
|
@@ -766,7 +768,7 @@ class LanguageService {
|
|
|
766
768
|
acc += height + 2;
|
|
767
769
|
return acc;
|
|
768
770
|
});
|
|
769
|
-
return cssErrors.map(({ rule, text: msg, severity, line, column, endLine = line, endColumn = column, }) => {
|
|
771
|
+
return cssErrors.map(({ rule, text: msg, severity, line, column, endLine = line, endColumn = column, fix, }) => {
|
|
770
772
|
const i = bottoms.findIndex(bottom => bottom >= line);
|
|
771
773
|
return {
|
|
772
774
|
range: {
|
|
@@ -777,6 +779,21 @@ class LanguageService {
|
|
|
777
779
|
source: 'Stylelint',
|
|
778
780
|
code: rule,
|
|
779
781
|
message: msg.slice(0, msg.lastIndexOf('(') - 1),
|
|
782
|
+
...fix
|
|
783
|
+
? {
|
|
784
|
+
data: [
|
|
785
|
+
{
|
|
786
|
+
range: {
|
|
787
|
+
start: getStylelintPos(rects[i], bottoms[i], code, fix.range[0]),
|
|
788
|
+
end: getStylelintPos(rects[i], bottoms[i], code, fix.range[1]),
|
|
789
|
+
},
|
|
790
|
+
newText: fix.text,
|
|
791
|
+
title: `Fix: ${rule}`,
|
|
792
|
+
fix: true,
|
|
793
|
+
},
|
|
794
|
+
],
|
|
795
|
+
}
|
|
796
|
+
: {},
|
|
780
797
|
};
|
|
781
798
|
});
|
|
782
799
|
})() :
|
package/dist/parser/selector.js
CHANGED
|
@@ -9,8 +9,8 @@ exports.getCondition = void 0;
|
|
|
9
9
|
*/
|
|
10
10
|
const basic = (selector, type, name) => {
|
|
11
11
|
if (selector.includes('#')) {
|
|
12
|
-
const
|
|
13
|
-
return (
|
|
12
|
+
const i = selector.indexOf('#');
|
|
13
|
+
return (i === 0 || selector.slice(0, i) === type) && selector.slice(i + 1) === name;
|
|
14
14
|
}
|
|
15
15
|
return !selector || selector === type;
|
|
16
16
|
};
|
|
@@ -20,5 +20,8 @@ const basic = (selector, type, name) => {
|
|
|
20
20
|
* @param scope 作用对象
|
|
21
21
|
* @param has `:has()`伪选择器
|
|
22
22
|
*/
|
|
23
|
-
const getCondition = (selector, scope, has) =>
|
|
23
|
+
const getCondition = (selector, scope, has) => {
|
|
24
|
+
const parts = selector.split(',');
|
|
25
|
+
return (({ type, name }) => parts.some(str => basic(str.trim(), type, name)));
|
|
26
|
+
};
|
|
24
27
|
exports.getCondition = getCondition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikilint",
|
|
3
|
-
"version": "2.22.
|
|
3
|
+
"version": "2.22.1",
|
|
4
4
|
"description": "A Node.js linter for MediaWiki markup",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mediawiki",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"entities": "^6.0.0",
|
|
81
81
|
"mathjax": "^3.2.2",
|
|
82
82
|
"minimatch": "^10.0.1",
|
|
83
|
-
"stylelint": "^16.
|
|
83
|
+
"stylelint": "^16.22.0",
|
|
84
84
|
"vscode-css-languageservice": "^6.3.7",
|
|
85
85
|
"vscode-html-languageservice": "^5.5.1",
|
|
86
86
|
"vscode-json-languageservice": "^5.6.1"
|