wikilint 2.25.1 → 2.26.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.
Files changed (45) hide show
  1. package/README.md +3 -3
  2. package/config/default.json +3 -0
  3. package/config/enwiki.json +3 -0
  4. package/config/jawiki.json +3 -0
  5. package/config/minimum.json +1 -0
  6. package/config/moegirl.json +0 -20
  7. package/config/zhwiki.json +3 -0
  8. package/data/ext/math.json +41 -0
  9. package/dist/base.d.mts +15 -3
  10. package/dist/base.d.ts +15 -3
  11. package/dist/bin/cli.js +2 -0
  12. package/dist/bin/config.js +8 -2
  13. package/dist/index.d.ts +2 -1
  14. package/dist/index.js +2 -3
  15. package/dist/lib/lintConfig.d.ts +18 -7
  16. package/dist/lib/lintConfig.js +55 -12
  17. package/dist/lib/lsp.js +16 -8
  18. package/dist/lib/text.js +35 -33
  19. package/dist/src/arg.js +8 -6
  20. package/dist/src/attribute.js +23 -13
  21. package/dist/src/attributes.js +23 -15
  22. package/dist/src/converterFlags.js +9 -7
  23. package/dist/src/gallery.js +7 -5
  24. package/dist/src/heading.js +35 -25
  25. package/dist/src/html.js +38 -29
  26. package/dist/src/imageParameter.js +9 -5
  27. package/dist/src/imagemap.js +7 -5
  28. package/dist/src/index.js +50 -41
  29. package/dist/src/link/base.js +19 -11
  30. package/dist/src/link/file.js +24 -18
  31. package/dist/src/link/galleryImage.js +4 -2
  32. package/dist/src/link/index.js +4 -2
  33. package/dist/src/link/redirectTarget.js +4 -2
  34. package/dist/src/magicLink.js +13 -10
  35. package/dist/src/nested.js +7 -5
  36. package/dist/src/nowiki/comment.js +4 -2
  37. package/dist/src/nowiki/index.js +4 -2
  38. package/dist/src/nowiki/quote.js +10 -6
  39. package/dist/src/paramTag/index.js +4 -2
  40. package/dist/src/parameter.js +4 -2
  41. package/dist/src/table/td.js +9 -7
  42. package/dist/src/tagPair/ext.js +3 -3
  43. package/dist/src/tagPair/include.js +7 -3
  44. package/dist/src/transclude.js +13 -7
  45. package/package.json +4 -4
@@ -53,7 +53,7 @@ class QuoteToken extends base_1.NowikiBaseToken {
53
53
  /** @private */
54
54
  lint(start = this.getAbsoluteIndex()) {
55
55
  LINT: { // eslint-disable-line no-unused-labels
56
- const { previousSibling, bold, closing } = this, previousData = previousSibling?.type === 'text' ? previousSibling.data : undefined, errors = [], rect = new rect_1.BoundingRect(this, start), rules = ['lonely-apos', 'bold-header'], severities = [undefined, 'word'].map(key => index_1.default.lintConfig.getSeverity(rules[0], key)), s = index_1.default.lintConfig.getSeverity(rules[1]);
56
+ const { previousSibling, bold, closing } = this, previousData = previousSibling?.type === 'text' ? previousSibling.data : undefined, errors = [], rect = new rect_1.BoundingRect(this, start), rules = ['lonely-apos', 'bold-header'], { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, severities = [undefined, 'word'].map(key => lintConfig.getSeverity(rules[0], key)), s = lintConfig.getSeverity(rules[1]);
57
57
  if (previousData?.endsWith(`'`)) {
58
58
  const severity = severities[(closing.bold || closing.italic) && /[a-z\d]'$/iu.test(previousData) ? 1 : 0];
59
59
  if (severity) {
@@ -65,16 +65,20 @@ class QuoteToken extends base_1.NowikiBaseToken {
65
65
  startCol: endCol - length,
66
66
  endCol,
67
67
  };
68
- eNew.suggestions = [
69
- (0, lint_1.fixByEscape)(startIndex, ''', length),
70
- (0, lint_1.fixByRemove)(eNew),
71
- ];
68
+ if (computeEditInfo) {
69
+ eNew.suggestions = [
70
+ (0, lint_1.fixByEscape)(startIndex, ''', length),
71
+ (0, lint_1.fixByRemove)(eNew),
72
+ ];
73
+ }
72
74
  errors.push(eNew);
73
75
  }
74
76
  }
75
77
  if (s && bold && this.closest('heading-title,ext')?.type === 'heading-title') {
76
78
  const e = (0, lint_1.generateForSelf)(this, rect, rules[1], 'bold-in-header', s);
77
- e.suggestions = [(0, lint_1.fixByRemove)(e)];
79
+ if (computeEditInfo) {
80
+ e.suggestions = [(0, lint_1.fixByRemove)(e)];
81
+ }
78
82
  errors.push(e);
79
83
  }
80
84
  return errors;
@@ -82,7 +82,7 @@ let ParamTagToken = (() => {
82
82
  /** @private */
83
83
  lint(start = this.getAbsoluteIndex()) {
84
84
  LINT: { // eslint-disable-line no-unused-labels
85
- const rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, this.name);
85
+ const rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
86
86
  if (!s) {
87
87
  return [];
88
88
  }
@@ -98,7 +98,9 @@ let ParamTagToken = (() => {
98
98
  const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
99
99
  if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
100
100
  const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
101
- e.suggestions = [(0, lint_1.fixByRemove)(e)];
101
+ if (lintConfig.computeEditInfo) {
102
+ e.suggestions = [(0, lint_1.fixByRemove)(e)];
103
+ }
102
104
  errors.push(e);
103
105
  }
104
106
  else {
@@ -67,7 +67,7 @@ class ParameterToken extends index_2.Token {
67
67
  /** @private */
68
68
  lint(start = this.getAbsoluteIndex(), re) {
69
69
  LINT: { // eslint-disable-line no-unused-labels
70
- const errors = super.lint(start, re), rule = 'unescaped', s = index_1.default.lintConfig.getSeverity(rule);
70
+ const errors = super.lint(start, re), rule = 'unescaped', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
71
71
  if (s) {
72
72
  const { firstChild } = this, link = linkRegex.exec(firstChild.text())?.[0];
73
73
  try {
@@ -78,7 +78,9 @@ class ParameterToken extends index_2.Token {
78
78
  e.startCol = e.endCol;
79
79
  e.endIndex++;
80
80
  e.endCol++;
81
- e.fix = (0, lint_1.fixByEscape)(e.startIndex, '{{=}}');
81
+ if (lintConfig.computeEditInfo || lintConfig.fix) {
82
+ e.fix = (0, lint_1.fixByEscape)(e.startIndex, '{{=}}');
83
+ }
82
84
  errors.push(e);
83
85
  }
84
86
  }
@@ -148,7 +148,7 @@ let TdToken = (() => {
148
148
  /** @private */
149
149
  lint(start = this.getAbsoluteIndex(), re) {
150
150
  LINT: { // eslint-disable-line no-unused-labels
151
- const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start + this.getRelativeIndex(this.length - 1)), rule = 'pipe-like', severities = ['td', 'double'].map(key => index_1.default.lintConfig.getSeverity(rule, key));
151
+ const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start + this.getRelativeIndex(this.length - 1)), rule = 'pipe-like', { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, severities = ['td', 'double'].map(key => lintConfig.getSeverity(rule, key));
152
152
  for (const child of this.lastChild.childNodes) {
153
153
  if (child.type === 'text') {
154
154
  const { data } = child;
@@ -156,12 +156,14 @@ let TdToken = (() => {
156
156
  const double = data.includes('||'), s = severities[double ? 1 : 0];
157
157
  if (s) {
158
158
  const e = (0, lint_1.generateForChild)(child, rect, rule, 'pipe-in-table', s);
159
- if (double) {
160
- const syntax = { caption: '|+', td: '|', th: '!' }[this.subtype];
161
- e.fix = (0, lint_1.fixBy)(e, 'newline', data.replace(/\|\|/gu, `\n${syntax}`));
162
- }
163
- else {
164
- e.suggestions = [(0, lint_1.fixByPipe)(e.startIndex, data)];
159
+ if (computeEditInfo || fix) {
160
+ if (double) {
161
+ const syntax = { caption: '|+', td: '|', th: '!' }[this.subtype];
162
+ e.fix = (0, lint_1.fixBy)(e, 'newline', data.replace(/\|\|/gu, `\n${syntax}`));
163
+ }
164
+ else if (computeEditInfo) {
165
+ e.suggestions = [(0, lint_1.fixByPipe)(e.startIndex, data)];
166
+ }
165
167
  }
166
168
  errors.push(e);
167
169
  }
@@ -186,14 +186,14 @@ let ExtToken = (() => {
186
186
  /** @private */
187
187
  lint(start = this.getAbsoluteIndex(), re) {
188
188
  LINT: { // eslint-disable-line no-unused-labels
189
- const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start);
189
+ const errors = super.lint(start, re), { lintConfig } = index_1.default, rect = new rect_1.BoundingRect(this, start);
190
190
  if (this.name !== 'nowiki') {
191
- const s = this.inHtmlAttrs(), rule = 'parsing-order', severity = s && index_1.default.lintConfig.getSeverity(rule, s === 2 ? 'ext' : 'templateInTable');
191
+ const s = this.inHtmlAttrs(), rule = 'parsing-order', severity = s && lintConfig.getSeverity(rule, s === 2 ? 'ext' : 'templateInTable');
192
192
  if (severity) {
193
193
  errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'ext-in-html', severity));
194
194
  }
195
195
  }
196
- const rule = 'var-anchor', s = index_1.default.lintConfig.getSeverity(rule, 'ref');
196
+ const rule = 'var-anchor', s = lintConfig.getSeverity(rule, 'ref');
197
197
  if (s && this.name === 'ref' && this.closest('heading-title')) {
198
198
  errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'variable-anchor', s));
199
199
  }
@@ -83,15 +83,19 @@ let IncludeToken = (() => {
83
83
  /** @private */
84
84
  lint(start = this.getAbsoluteIndex()) {
85
85
  LINT: { // eslint-disable-line no-unused-labels
86
- const errors = [], { firstChild, closed, name } = this, rect = new rect_1.BoundingRect(this, start), rules = ['no-ignored', 'unclosed-comment'], s = rules.map(rule => index_1.default.lintConfig.getSeverity(rule, 'include'));
86
+ const errors = [], { firstChild, closed, name } = this, rect = new rect_1.BoundingRect(this, start), rules = ['no-ignored', 'unclosed-comment'], { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, s = rules.map(rule => lintConfig.getSeverity(rule, 'include'));
87
87
  if (s[0] && firstChild.data.trim()) {
88
88
  const e = (0, lint_1.generateForChild)(firstChild, rect, rules[0], 'useless-attribute', s[0]);
89
- e.suggestions = [(0, lint_1.fixByRemove)(e)];
89
+ if (computeEditInfo) {
90
+ e.suggestions = [(0, lint_1.fixByRemove)(e)];
91
+ }
90
92
  errors.push(e);
91
93
  }
92
94
  if (s[1] && !closed) {
93
95
  const e = (0, lint_1.generateForSelf)(this, rect, rules[1], index_1.default.msg('unclosed', `<${name}>`), s[1]);
94
- e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, `</${name}>`)];
96
+ if (computeEditInfo) {
97
+ e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, `</${name}>`)];
98
+ }
95
99
  errors.push(e);
96
100
  }
97
101
  return errors;
@@ -276,11 +276,11 @@ let TranscludeToken = (() => {
276
276
  if (!this.isTemplate()) {
277
277
  return errors;
278
278
  }
279
- const { type, childNodes, length } = this, rect = new rect_1.BoundingRect(this, start), invoke = type === 'magic-word';
280
- let rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, 'fragment');
279
+ const { type, childNodes, length } = this, rect = new rect_1.BoundingRect(this, start), { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, invoke = type === 'magic-word';
280
+ let rule = 'no-ignored', s = lintConfig.getSeverity(rule, 'fragment');
281
281
  if (invoke && !this.#getTitle().valid) {
282
282
  rule = 'invalid-invoke';
283
- s = index_1.default.lintConfig.getSeverity(rule, 'name');
283
+ s = lintConfig.getSeverity(rule, 'name');
284
284
  if (s) {
285
285
  errors.push((0, lint_1.generateForChild)(childNodes[1], rect, rule, 'illegal-module', s));
286
286
  }
@@ -290,25 +290,31 @@ let TranscludeToken = (() => {
290
290
  .findIndex(c => c.type === 'text' && (0, string_1.decodeHtml)(c.data).includes('#')), textNode = child.childNodes[i];
291
291
  if (textNode) {
292
292
  const e = (0, lint_1.generateForChild)(child, rect, rule, 'useless-fragment', s);
293
- e.suggestions = [(0, lint_1.fixByRemove)(e, child.getRelativeIndex(i) + textNode.data.indexOf('#'))];
293
+ if (computeEditInfo) {
294
+ e.suggestions = [
295
+ (0, lint_1.fixByRemove)(e, child.getRelativeIndex(i) + textNode.data.indexOf('#')),
296
+ ];
297
+ }
294
298
  errors.push(e);
295
299
  }
296
300
  }
297
301
  rule = 'invalid-invoke';
298
- s = index_1.default.lintConfig.getSeverity(rule, 'function');
302
+ s = lintConfig.getSeverity(rule, 'function');
299
303
  if (s && invoke && length === 2) {
300
304
  errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'missing-function', s));
301
305
  return errors;
302
306
  }
303
307
  rule = 'no-duplicate';
304
- s = index_1.default.lintConfig.getSeverity(rule, 'parameter');
308
+ s = lintConfig.getSeverity(rule, 'parameter');
305
309
  if (s) {
306
310
  const duplicatedArgs = this.getDuplicatedArgs()
307
311
  .filter(([, parameter]) => !parameter[0].querySelector('ext')), msg = 'duplicate-parameter';
308
312
  for (const [, args] of duplicatedArgs) {
309
313
  errors.push(...args.map(arg => {
310
314
  const e = (0, lint_1.generateForChild)(arg, rect, rule, msg, s);
311
- e.suggestions = [(0, lint_1.fixByRemove)(e, -1)];
315
+ if (computeEditInfo) {
316
+ e.suggestions = [(0, lint_1.fixByRemove)(e, -1)];
317
+ }
312
318
  return e;
313
319
  }));
314
320
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.25.1",
3
+ "version": "2.26.0",
4
4
  "description": "A Node.js linter for MediaWiki markup",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -79,13 +79,13 @@
79
79
  "entities": "^6.0.0",
80
80
  "mathjax": "^3.2.2",
81
81
  "minimatch": "^10.0.1",
82
- "stylelint": "^16.23.1",
82
+ "stylelint": "^16.24.0",
83
83
  "vscode-css-languageservice": "^6.3.7",
84
84
  "vscode-html-languageservice": "^5.5.1",
85
85
  "vscode-json-languageservice": "^5.6.1"
86
86
  },
87
87
  "devDependencies": {
88
- "@bhsd/code-standard": "^1.0.1",
88
+ "@bhsd/code-standard": "^1.1.0",
89
89
  "@bhsd/test-util": "^0.1.0",
90
90
  "@stylistic/eslint-plugin": "^3.1.0",
91
91
  "@types/color-name": "^2.0.0",
@@ -98,7 +98,7 @@
98
98
  "esbuild": "^0.25.5",
99
99
  "eslint": "^8.57.1",
100
100
  "eslint-plugin-eslint-comments": "^3.2.0",
101
- "eslint-plugin-jsdoc": "^52.0.2",
101
+ "eslint-plugin-jsdoc": "^54.1.1",
102
102
  "eslint-plugin-json-es": "^1.6.0",
103
103
  "eslint-plugin-n": "^17.20.0",
104
104
  "eslint-plugin-promise": "^7.2.1",