@riebeckite/plugin-quality 0.0.13 → 0.0.15

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 CHANGED
@@ -66,4 +66,5 @@ misattribute findings in unusual markup.
66
66
 
67
67
  ## See also
68
68
 
69
- - [Plugin guide](../../../docs/en/reference/plugin-api.md)
69
+ - [Plugin guide](../../../docs/en/docs/reference/plugin-api.md)
70
+
package/README_ja.md CHANGED
@@ -37,7 +37,7 @@ export default defineConfig({
37
37
  | `quality:img-alt-missing` | warning | `alt` のない `<img>`。装飾画像の `alt=""` は対象外です。 |
38
38
  | `quality:duplicate-id` | error | 同じ `id` が同一文書内で複数回使われています。 |
39
39
  | `quality:broken-internal-anchor` | warning | `href="#foo"` に対応する `id="foo"` が文書内にありません。 |
40
- | `quality:heading-order` | warning | 見出しレベルの飛び(`h1` → `h3` など)、または `h1` が1つもない状態。 |
40
+ | `quality:heading-order` | warning | 見出しレベルの飛び(`h1` → `h3` など)、または `h1` が 1 つもない状態。 |
41
41
  | `quality:empty-link-text` | warning | テキストが空で、`aria-label`・`title`・alt 付き `img` もない `<a href>`。 |
42
42
  | `quality:html-lang-missing` | warning | 空でない `lang` を持たない `<html>`(完全な文書のみ)。 |
43
43
  | `quality:table-no-header` | warning | データセルはあるが `<th>`・`scope`・`headers` がない `<table>`。 |
@@ -56,4 +56,5 @@ export default defineConfig({
56
56
 
57
57
  ## 関連
58
58
 
59
- - [プラグインガイド](../../../docs/ja/reference/plugin-api.md)
59
+ - [プラグインガイド](../../../docs/ja/docs/reference/plugin-api.md)
60
+
package/dist/index.js CHANGED
@@ -215,8 +215,10 @@ function brokenInternalAnchor({ elements }) {
215
215
  return diagnostics;
216
216
  }
217
217
  function headingOrder({ elements }) {
218
+ const graphics = graphicRanges(elements);
218
219
  const levels = [];
219
220
  for (const element of elements) {
221
+ if (isInsideGraphic(element, graphics)) continue;
220
222
  const level = headingLevel(element.tag);
221
223
  if (level !== null) levels.push(level);
222
224
  }
@@ -332,6 +334,19 @@ function headingLevel(tag) {
332
334
  const level = Number.parseInt(tag[1] ?? "", 10);
333
335
  return level >= 1 && level <= 6 ? level : null;
334
336
  }
337
+ function graphicRanges(elements) {
338
+ const ranges = [];
339
+ for (const element of elements) {
340
+ if (element.tag !== "svg" && element.tag !== "foreignobject") continue;
341
+ ranges.push([element.start, element.end + element.content.length]);
342
+ }
343
+ return ranges;
344
+ }
345
+ function isInsideGraphic(element, ranges) {
346
+ return ranges.some(
347
+ ([start, end]) => element.start >= start && element.start < end
348
+ );
349
+ }
335
350
  function createDiagnostic(code, severity, message, extra = {}) {
336
351
  return {
337
352
  code,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-quality",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -14,7 +14,7 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@riebeckite/core": "0.0.13"
17
+ "@riebeckite/core": "0.0.15"
18
18
  },
19
19
  "devDependencies": {
20
20
  "tsx": "^4.22.4"