@markuplint/config-presets 3.0.0-alpha.2 → 3.0.0-alpha.3

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
@@ -28,31 +28,32 @@ Ruleset|Description|`recommended`|`recommended-vue`|`recommended-svelte`|`recomm
28
28
  ---|---|---|---|---|---|---|---|---|---|---|---|---|
29
29
  [Disallow `<hgroup>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hgroup)|The hgroup element should not be used because no assistive technology supports it.|✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
30
30
  [Must not duplicate **ID**](https://www.w3.org/WAI/WCAG21/Techniques/html/H93.html)|Be able to avoid problems in assistive technologies from the viewpoint of machine readability.|✅|✅|✅|✅|✅|✅|❌|✅|❌|❌|❌|
31
- [Disallow `autofocus` attr](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus#accessibility_considerations)||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
32
- [`tabindex` attr only `-1` or `0`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex#accessibility_concerns)||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
33
- [Use **landmark**](https://www.w3.org/TR/wai-aria-practices/examples/landmarks/)||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
34
- No refer to no existent **ID**||✅|✅|✅|✅|✅|✅|❌|✅|❌|❌|❌|
35
- Require **accessible name**||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
36
- Require `<h1>`||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
37
- Use `<ul>`||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
38
- Conform to **WAI-ARIA**||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
39
- Require `<html lang>`||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
40
- Require `<abbr title>`||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
41
- Require `<track>`||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
42
- Require `<video muted>`||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
43
- No merge cells||✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
31
+ [Disallow `autofocus` attr](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus#accessibility_considerations)| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
32
+ [`tabindex` attr only `-1` or `0`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex#accessibility_concerns)| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
33
+ [Use **landmark**](https://www.w3.org/TR/wai-aria-practices/examples/landmarks/)| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
34
+ No refer to no existent **ID**| |✅|✅|✅|✅|✅|✅|❌|✅|❌|❌|❌|
35
+ Require **accessible name**| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
36
+ Require `<h1>`| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
37
+ Use `<ul>`| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
38
+ Conform to **WAI-ARIA**| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
39
+ Require `<html lang>`| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
40
+ Require `<abbr title>`| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
41
+ Require `<track>`| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
42
+ Require `<video muted>`| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
43
+ No merge cells| |✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
44
+ [`<summary>` no contains interactive contents](https://github.com/whatwg/html/issues/2272#issuecomment-1242415594)|There is a case where an assistive technology can't access contents, or contents don't propagate a mouse event to `<summary>`.|✅|✅|✅|✅|✅|✅|❌|❌|❌|❌|❌|
44
45
  [No duplicate attr](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-duplicate-attribute)|The parser ignores all such duplicate occurrences of the attribute.|✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
45
- Use **character reference**||✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
46
+ Use **character reference**| |✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
46
47
  No use depreacted attr|You should not use deprecated attributes from the viewpoint of compatibility.|✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
47
48
  No use depreacted element|You should not use deprecated elements from the viewpoint of compatibility.|✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
48
49
  [Require `doctype`](https://html.spec.whatwg.org/multipage/syntax.html#syntax-doctype)|It has the effect of avoiding quirks mode.|✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
49
- No use ineffective attr||✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
50
- Allow only **permitted contents**||✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
51
- Specify required attr||✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
52
- [Specify `charset=UTF-8`](https://html.spec.whatwg.org/multipage/semantics.html#charset)||✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
50
+ No use ineffective attr| |✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
51
+ Allow only **permitted contents**| |✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
52
+ Specify required attr| |✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
53
+ [Specify `charset=UTF-8`](https://html.spec.whatwg.org/multipage/semantics.html#charset)| |✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
53
54
  [No use `<small>` as **subheadings**](https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-small-element)|Should not use it in `<h1>`, `<h2>`, `<h3>`, `<h4>`, `<h5>`, and `<h6>`.|✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
54
55
  [No use `<caption>` within `<figure>`](https://html.spec.whatwg.org/multipage/tables.html#the-caption-element)|When `<table>` is the only content in `<figure>` other than `<figcaption>`, `<caption>` should be omitted in favor of `<figcaption>`.|✅|✅|✅|✅|✅|❌|❌|✅|❌|❌|❌|
55
- [Require `charset=UTF-8`](https://html.spec.whatwg.org/multipage/semantics.html#charset)||✅|✅|✅|✅|✅|❌|❌|❌|✅|❌|❌|
56
+ [Require `charset=UTF-8`](https://html.spec.whatwg.org/multipage/semantics.html#charset)| |✅|✅|✅|✅|✅|❌|❌|❌|✅|❌|❌|
56
57
  Require `defer` attr|Should load and parse scripts lazily to avoid render-blocking.|✅|✅|✅|✅|✅|❌|❌|❌|✅|❌|❌|
57
58
  Require **aspect-ratio**|Require `width` and `height` attr with `<img>` to avoid **Cumulative Layout Shift**|✅|✅|✅|✅|✅|❌|❌|❌|✅|❌|❌|
58
59
  Require async decoding image|Require `decoding=async` with `<img>` to avoid render-blocking.|✅|✅|✅|✅|✅|❌|❌|❌|✅|❌|❌|
package/build.mjs CHANGED
@@ -38,16 +38,11 @@ for (const file of files) {
38
38
  onComment(offset, length) {
39
39
  const comment = code.substring(offset, offset + length);
40
40
  const line = comment.split('\n');
41
- const text = line
42
- .map(line =>
43
- line
44
- .trim()
45
- .replace(/^\/\*\*|^\*\/|^\*\s*/g, '')
46
- .trim(),
47
- )
48
- .filter(s => s);
49
- const heading = text.shift();
50
- const desc = text.filter(t => !/^@see\s/i.test(t));
41
+ const [heading = '', desc = ''] = comment
42
+ .split(/\n\s*\*\s*\n/g)
43
+ .map(section => cleanComment(section))
44
+ .filter(s => !/^@see\s/.test(s));
45
+ const text = line.map(line => cleanComment(line)).filter(s => s);
51
46
  const url = (text.find(t => /^@see\s/i.test(t)) || '').replace(/^@see\s/i, '');
52
47
 
53
48
  if (!heading) {
@@ -89,11 +84,24 @@ const renderMd = mustache.render(md, {
89
84
  const has = configs.some(config => context.config?.includes(config));
90
85
  return has ? '✅' : '❌';
91
86
  });
92
- line.push(`${title}|${context.desc.join(' ')}|${checks.join('|')}|`);
87
+ line.push(`${title}|${context.desc || ' '}|${checks.join('|')}|`);
93
88
  });
94
89
 
95
90
  return line.join('\n');
96
91
  },
97
92
  });
98
93
 
94
+ /**
95
+ *
96
+ * @param {string} text
97
+ * @returns
98
+ */
99
+ function cleanComment(text) {
100
+ const t1 = text.trim();
101
+ const t2 = t1.replace(/^\/\*\*(?:[\n\s]*\*[\n\s]*)?|^\*\/|^\*|^\*[\s\n]*|[\s\n]*\*\/$/g, '');
102
+ const t3 = t2.replace(/\s*\n\s*(?:\*\s*)?/g, ' ');
103
+ const t4 = t3.trim();
104
+ return t4;
105
+ }
106
+
99
107
  await writeFile('README.md', renderMd, { encoding: 'utf-8' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/config-presets",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.3",
4
4
  "description": "markuplint config presets",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -17,5 +17,5 @@
17
17
  "jsonc-parser": "^3.2.0",
18
18
  "mustache": "^4.2.0"
19
19
  },
20
- "gitHead": "830bf8187b81bf5ca2f5f09b6f85a98395a58bdb"
20
+ "gitHead": "884b1a6a7385e86cca7796b0b927a886ee90140e"
21
21
  }
package/preset.a11y.json CHANGED
@@ -1 +1 @@
1
- {"rules":{"disallowed-element":["hgroup"],"id-duplication":true,"invalid-attr":{"option":{"attrs":{"autofocus":{"disallowed":true},"accesskey":{"disallowed":true},"tabindex":{"enum":["-1","0"]}}}},"landmark-roles":true,"no-refer-to-non-existent-id":true,"require-accessible-name":true,"required-h1":true,"use-list":true,"wai-aria":true},"nodeRules":[{"selector":":where(html)","rules":{"required-attr":["lang"]}},{"selector":":where(abbr)","rules":{"required-attr":["title"]}},{"selector":":where(video, audio)","rules":{"required-element":["track"]}},{"selector":":where(video[autoplay])","rules":{"required-attr":["muted"]}},{"selector":":where(th, td)","rules":{"invalid-attr":{"option":{"attrs":{"colspan":{"disallowed":true},"rowspan":{"disallowed":true}}}}}}]}
1
+ {"rules":{"disallowed-element":["hgroup"],"id-duplication":true,"invalid-attr":{"option":{"attrs":{"autofocus":{"disallowed":true},"accesskey":{"disallowed":true},"tabindex":{"enum":["-1","0"]}}}},"landmark-roles":true,"no-refer-to-non-existent-id":true,"require-accessible-name":true,"required-h1":true,"use-list":true,"wai-aria":true},"nodeRules":[{"selector":":where(html)","rules":{"required-attr":["lang"]}},{"selector":":where(abbr)","rules":{"required-attr":["title"]}},{"selector":":where(video, audio)","rules":{"required-element":["track"]}},{"selector":":where(video[autoplay])","rules":{"required-attr":["muted"]}},{"selector":":where(th, td)","rules":{"invalid-attr":{"option":{"attrs":{"colspan":{"disallowed":true},"rowspan":{"disallowed":true}}}}}},{"selector":":where(summary)","rules":{"disallowed-element":[":model(interactive)"]}}]}
@@ -148,6 +148,25 @@
148
148
  }
149
149
  }
150
150
  }
151
+ },
152
+ {
153
+ "selector": ":where(summary)",
154
+ "rules": {
155
+ /**
156
+ * `<summary>` no contains interactive contents
157
+ *
158
+ * There is a case where an assistive technology can't access contents, or contents don't propagate a mouse event to `<summary>`.
159
+ *
160
+ * > The link is not discoverable at all to JAWS when navigating with its virtual cursor.
161
+ * > If navigating to the summary element via the Tab key,
162
+ * > JAWS announces "example text, button" as the name and role of the element.
163
+ * > If hitting Tab key again, JAWS again announces "example text,
164
+ * > button" even though keyboard focus is on the link.
165
+ *
166
+ * @see https://github.com/whatwg/html/issues/2272#issuecomment-1242415594
167
+ */
168
+ "disallowed-element": [":model(interactive)"]
169
+ }
151
170
  }
152
171
  ]
153
172
  }