@markuplint/rules 4.10.12 → 4.11.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/CHANGELOG.md +21 -0
- package/lib/index.d.ts +1 -1
- package/lib/require-datetime/utils.js +3 -1
- package/lib/required-attr/index.js +10 -2
- package/lib/table-row-column-alignment/index.js +17 -1
- package/package.json +12 -13
- package/lib/__foo/index.d.ts +0 -2
- package/lib/__foo/index.js +0 -31
- package/lib/__foo/meta.d.ts +0 -4
- package/lib/__foo/meta.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.11.1](https://github.com/markuplint/markuplint/compare/@markuplint/rules@4.11.0...@markuplint/rules@4.11.1) (2025-08-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **rules:** handle rowspan/colspan combinations correctly in table-row-column-alignment ([5579c98](https://github.com/markuplint/markuplint/commit/5579c98995fbad02086e2c9a5470cfcee5ef9ef0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [4.11.0](https://github.com/markuplint/markuplint/compare/@markuplint/rules@4.10.12...@markuplint/rules@4.11.0) (2025-08-13)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- ensure that each `clean` command correctly removes build files ([110b78e](https://github.com/markuplint/markuplint/commit/110b78e85379d29a84ca68325127344a87a570b6))
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
- **rules:** improve error message for multiple required attributes ([4aa4e4f](https://github.com/markuplint/markuplint/commit/4aa4e4fe54efc05edf7e9166a7fd769127b75769))
|
|
26
|
+
|
|
6
27
|
## [4.10.12](https://github.com/markuplint/markuplint/compare/@markuplint/rules@4.10.11...@markuplint/rules@4.10.12) (2025-04-13)
|
|
7
28
|
|
|
8
29
|
**Note:** Version bump only for package @markuplint/rules
|
package/lib/index.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ declare const rules: {
|
|
|
62
62
|
}>>;
|
|
63
63
|
readonly 'label-has-control': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
64
64
|
readonly 'landmark-roles': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
65
|
-
ignoreRoles: (("banner" | "main" | "complementary" | "contentinfo") | "
|
|
65
|
+
ignoreRoles: ("form" | ("banner" | "main" | "complementary" | "contentinfo") | "navigation" | "region")[];
|
|
66
66
|
labelEachArea: boolean;
|
|
67
67
|
}>>;
|
|
68
68
|
readonly 'neighbor-popovers': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
@@ -92,7 +92,9 @@ function toDatetimeString(date) {
|
|
|
92
92
|
}
|
|
93
93
|
function parseTryMultipleLangs(content, langs, base) {
|
|
94
94
|
for (const lang of langs) {
|
|
95
|
-
const results =
|
|
95
|
+
const results =
|
|
96
|
+
// eslint-disable-next-line import-x/namespace
|
|
97
|
+
chrono[lang].casual.parse(content, base);
|
|
96
98
|
// Is not multiple datetime contents
|
|
97
99
|
if (results.length === 0) {
|
|
98
100
|
continue;
|
|
@@ -45,9 +45,10 @@ export default createRule({
|
|
|
45
45
|
}
|
|
46
46
|
for (const spec of Object.values(attributeSpecs)) {
|
|
47
47
|
const didntHave = !el.hasAttribute(spec.name);
|
|
48
|
+
const candidate = [spec.name];
|
|
48
49
|
let invalid = false;
|
|
49
50
|
if (spec.requiredEither) {
|
|
50
|
-
|
|
51
|
+
candidate.push(...spec.requiredEither);
|
|
51
52
|
invalid = !candidate.some(attrName => el.hasAttribute(attrName));
|
|
52
53
|
}
|
|
53
54
|
else if (spec.required === true) {
|
|
@@ -57,8 +58,15 @@ export default createRule({
|
|
|
57
58
|
const selector = typeof spec.required === 'string' ? spec.required : spec.required.join(',');
|
|
58
59
|
invalid = el.matches(selector) && didntHave;
|
|
59
60
|
}
|
|
61
|
+
candidate.sort();
|
|
60
62
|
if (invalid) {
|
|
61
|
-
const
|
|
63
|
+
const expects = candidate.length === 1
|
|
64
|
+
? t('the "{0*}" {1}', spec.name, 'attribute')
|
|
65
|
+
: t('{0} {1}', candidate
|
|
66
|
+
.map(attrName => t('the "{0*}"', attrName))
|
|
67
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
68
|
+
.reduce((a, b) => t('{0} or {1}', a, b)), t('attribute'));
|
|
69
|
+
const message = t('{0} expects {1}', t('the "{0*}" {1}', el.localName, 'element'), expects);
|
|
62
70
|
report({
|
|
63
71
|
scope: el,
|
|
64
72
|
message,
|
|
@@ -37,6 +37,22 @@ export default createRule({
|
|
|
37
37
|
if (!rowEl) {
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
|
+
// Skip validation for rows that have expected column count differences due to rowspan/colspan
|
|
41
|
+
const cells = findChildren(rowEl, 'th, td');
|
|
42
|
+
let actualCellCount = 0;
|
|
43
|
+
for (const cell of cells) {
|
|
44
|
+
const colspan = Number.parseInt(cell.getAttribute('colspan') ?? '1');
|
|
45
|
+
actualCellCount += colspan;
|
|
46
|
+
}
|
|
47
|
+
// Check for rowspan cells occupying spaces in this row
|
|
48
|
+
const rowspanOccupiedCount = row.filter(cell => cell === '↓').length;
|
|
49
|
+
const expectedColumnCount = actualCellCount + rowspanOccupiedCount;
|
|
50
|
+
// Skip validation if the structure is valid accounting for spans
|
|
51
|
+
if (expectedColumnCount === baseColLength || actualCellCount + rowspanOccupiedCount === baseColLength) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
// Debug log
|
|
55
|
+
// console.log(`Row ${rowNum}: baseColLength=${baseColLength}, colLength=${colLength}, actualCellCount=${actualCellCount}, rowspanOccupiedCount=${rowspanOccupiedCount}, expectedColumnCount=${expectedColumnCount}`);
|
|
40
56
|
const indexes = getIndexes(row);
|
|
41
57
|
if (colLength > baseColLength) {
|
|
42
58
|
const index = indexes.slice(baseColLength)[0];
|
|
@@ -60,7 +76,7 @@ export default createRule({
|
|
|
60
76
|
message: t('{0} extra {1} in {2}', t(`${diff}`), t(diff === 1 ? 'column' : 'columns'), t('a {0}', t('row'))),
|
|
61
77
|
});
|
|
62
78
|
}
|
|
63
|
-
if (colLength < baseColLength) {
|
|
79
|
+
if (colLength < baseColLength && expectedColumnCount < baseColLength) {
|
|
64
80
|
const diff = baseColLength - colLength;
|
|
65
81
|
report({
|
|
66
82
|
scope: rowEl,
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/rules",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.1",
|
|
4
4
|
"description": "Built-in rules of markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"private": false,
|
|
9
8
|
"type": "module",
|
|
10
9
|
"exports": {
|
|
11
10
|
".": {
|
|
@@ -19,24 +18,24 @@
|
|
|
19
18
|
"scripts": {
|
|
20
19
|
"build": "tsc --project tsconfig.build.json",
|
|
21
20
|
"dev": "tsc --watch --project tsconfig.build.json",
|
|
22
|
-
"clean": "tsc --build --clean"
|
|
21
|
+
"clean": "tsc --build --clean tsconfig.build.json"
|
|
23
22
|
},
|
|
24
23
|
"browser": {
|
|
25
24
|
"./lib/permitted-contents/debug.js": "./lib/permitted-contents/debug.browser.js"
|
|
26
25
|
},
|
|
27
26
|
"dependencies": {
|
|
28
|
-
"@markuplint/html-spec": "4.
|
|
29
|
-
"@markuplint/ml-core": "4.
|
|
30
|
-
"@markuplint/ml-spec": "4.
|
|
31
|
-
"@markuplint/selector": "4.7.
|
|
32
|
-
"@markuplint/shared": "4.4.
|
|
33
|
-
"@markuplint/types": "4.
|
|
27
|
+
"@markuplint/html-spec": "4.16.0",
|
|
28
|
+
"@markuplint/ml-core": "4.13.1",
|
|
29
|
+
"@markuplint/ml-spec": "4.10.0",
|
|
30
|
+
"@markuplint/selector": "4.7.6",
|
|
31
|
+
"@markuplint/shared": "4.4.12",
|
|
32
|
+
"@markuplint/types": "4.8.0",
|
|
34
33
|
"@types/debug": "4.1.12",
|
|
35
34
|
"@ungap/structured-clone": "1.3.0",
|
|
36
35
|
"ansi-colors": "4.1.3",
|
|
37
|
-
"chrono-node": "2.8.
|
|
38
|
-
"debug": "4.4.
|
|
39
|
-
"type-fest": "4.
|
|
36
|
+
"chrono-node": "2.8.4",
|
|
37
|
+
"debug": "4.4.1",
|
|
38
|
+
"type-fest": "4.41.0"
|
|
40
39
|
},
|
|
41
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "ae97eb2d31ecedf4f0800fbbf18588aad4ebca04"
|
|
42
41
|
}
|
package/lib/__foo/index.d.ts
DELETED
package/lib/__foo/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { createRule } from "@markuplint/ml-core";
|
|
2
|
-
import meta from "./meta.js";
|
|
3
|
-
export default createRule({
|
|
4
|
-
meta: meta,
|
|
5
|
-
defaultValue: true,
|
|
6
|
-
defaultOptions: null,
|
|
7
|
-
async verify({ document, report, t }) {
|
|
8
|
-
// Element
|
|
9
|
-
await document.walkOn("Element", (el) => {
|
|
10
|
-
const raw = el.raw.trim();
|
|
11
|
-
if (/./.test(raw)) {
|
|
12
|
-
report({
|
|
13
|
-
scope: el,
|
|
14
|
-
message: t("It is {0}", "issue"),
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
// Attribute
|
|
19
|
-
await document.walkOn("Attr", (attr) => {
|
|
20
|
-
if (/./.test(attr.name)) {
|
|
21
|
-
report({
|
|
22
|
-
scope: attr,
|
|
23
|
-
line: attr.nameNode?.startLine,
|
|
24
|
-
col: attr.nameNode?.startCol,
|
|
25
|
-
raw: attr.nameNode?.raw,
|
|
26
|
-
message: t("It is {0}", "issue"),
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
});
|
package/lib/__foo/meta.d.ts
DELETED
package/lib/__foo/meta.js
DELETED