@markuplint/rules 3.12.0 → 3.13.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.
- package/lib/create-message.d.ts +1 -1
- package/lib/create-message.js +5 -1
- package/lib/permitted-contents/choice.js +14 -4
- package/lib/permitted-contents/count-pattern.js +1 -1
- package/package.json +10 -10
- package/test/invalid-attr/index.spec.js +2 -12
- package/test/permitted-contents/index.spec.js +4 -4
package/lib/create-message.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import type { AttributeType } from '@markuplint/ml-spec';
|
|
|
3
3
|
import type { UnmatchedResult } from '@markuplint/types';
|
|
4
4
|
import type { ReadonlyDeep } from 'type-fest';
|
|
5
5
|
export declare function createMessageValueExpected(t: Translator, baseTarget: string, type: ReadonlyDeep<AttributeType>, matches: UnmatchedResult): string;
|
|
6
|
-
export declare function __createMessageValueExpected(t: Translator, baseTarget: string, expected: string | null, matches: Pick<UnmatchedResult, 'partName' | 'reason' | 'raw' | 'candidate' | 'ref' | 'extra'>): string;
|
|
6
|
+
export declare function __createMessageValueExpected(t: Translator, baseTarget: string, expected: string | null, matches: Pick<UnmatchedResult, 'partName' | 'reason' | 'raw' | 'candidate' | 'ref' | 'extra' | 'fallbackTo'>): string;
|
package/lib/create-message.js
CHANGED
|
@@ -28,6 +28,7 @@ function __createMessageValueExpected(t, baseTarget, expected, matches) {
|
|
|
28
28
|
let expectPart;
|
|
29
29
|
let unnecessaryPart;
|
|
30
30
|
let candidatePart;
|
|
31
|
+
let fallbackToPart;
|
|
31
32
|
let expectOrNeed = 'expects';
|
|
32
33
|
if (matches.partName) {
|
|
33
34
|
if (matches.partName === 'the content of the list') {
|
|
@@ -192,7 +193,10 @@ function __createMessageValueExpected(t, baseTarget, expected, matches) {
|
|
|
192
193
|
if (matches.candidate) {
|
|
193
194
|
candidatePart = t('Did you mean "{0*}"?', matches.candidate);
|
|
194
195
|
}
|
|
195
|
-
|
|
196
|
+
if (matches.fallbackTo) {
|
|
197
|
+
fallbackToPart = t('The user agent will automatically use "{0*}" instead', matches.fallbackTo);
|
|
198
|
+
}
|
|
199
|
+
let message = [reasonPart, unnecessaryPart, expectPart, candidatePart, fallbackToPart].filter(s => s).join(t('. '));
|
|
196
200
|
if (matches.ref) {
|
|
197
201
|
message += ` (${matches.ref})`;
|
|
198
202
|
}
|
|
@@ -15,24 +15,34 @@ elements, specs, options, depth) {
|
|
|
15
15
|
for (const some of pattern.choice) {
|
|
16
16
|
choiceLog('Patterns[%s]: %s', i, (0, utils_1.modelLog)(some, ''));
|
|
17
17
|
const result = (0, order_1.order)(some, collection.unmatched, specs, options, depth + 1);
|
|
18
|
-
if (result.type === '
|
|
18
|
+
if (result.type === 'MATCHED' ||
|
|
19
|
+
result.type === 'MATCHED_ZERO' ||
|
|
20
|
+
(result.type === 'UNEXPECTED_EXTRA_NODE' && result.matched.length >= 1)) {
|
|
19
21
|
choiceLog('Results[%s]: %s', i, choiceLogString(pattern.choice, i));
|
|
20
|
-
collection.addMatched(result.matched);
|
|
21
22
|
return {
|
|
22
23
|
type: result.type,
|
|
23
|
-
matched:
|
|
24
|
-
unmatched:
|
|
24
|
+
matched: result.matched,
|
|
25
|
+
unmatched: result.unmatched,
|
|
25
26
|
zeroMatch: result.zeroMatch,
|
|
26
27
|
query: result.query,
|
|
27
28
|
hint: result.hint,
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
unmatchedResults.push(result);
|
|
32
|
+
collection.addMatched(result.matched);
|
|
31
33
|
indexes.set(result, i);
|
|
32
34
|
i++;
|
|
33
35
|
}
|
|
34
36
|
const barelyMatchedResult = unmatchedResults.sort((a, b) => {
|
|
35
37
|
var _c, _d, _e, _f;
|
|
38
|
+
if (a.type !== b.type) {
|
|
39
|
+
if (a.type === 'UNEXPECTED_EXTRA_NODE') {
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
if (b.type === 'UNEXPECTED_EXTRA_NODE') {
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
36
46
|
const computed1 = b.matched.length - a.matched.length;
|
|
37
47
|
if (computed1 !== 0) {
|
|
38
48
|
return computed1;
|
|
@@ -4,6 +4,7 @@ exports.countPattern = void 0;
|
|
|
4
4
|
const debug_1 = require("./debug");
|
|
5
5
|
const recursive_branch_1 = require("./recursive-branch");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
|
+
const cLog = debug_1.cmLog.extend('countCompereResult');
|
|
7
8
|
/**
|
|
8
9
|
* Check count
|
|
9
10
|
*
|
|
@@ -143,7 +144,6 @@ elements, specs, options, depth) {
|
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
exports.countPattern = countPattern;
|
|
146
|
-
const cLog = debug_1.cmLog.extend('countCompereResult');
|
|
147
147
|
function compereResult(
|
|
148
148
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
149
149
|
a,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/rules",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
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>",
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"./lib/permitted-contents/debug.js": "./lib/permitted-contents/debug.browser.js"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@markuplint/html-spec": "3.
|
|
24
|
-
"@markuplint/ml-core": "3.
|
|
25
|
-
"@markuplint/ml-spec": "3.
|
|
26
|
-
"@markuplint/selector": "3.
|
|
23
|
+
"@markuplint/html-spec": "3.12.0",
|
|
24
|
+
"@markuplint/ml-core": "3.13.0",
|
|
25
|
+
"@markuplint/ml-spec": "3.12.0",
|
|
26
|
+
"@markuplint/selector": "3.12.0",
|
|
27
27
|
"@markuplint/shared": "3.8.0",
|
|
28
|
-
"@markuplint/types": "3.
|
|
28
|
+
"@markuplint/types": "3.10.0",
|
|
29
29
|
"@types/debug": "^4.1.8",
|
|
30
30
|
"@ungap/structured-clone": "^1.2.0",
|
|
31
31
|
"ansi-colors": "^4.1.3",
|
|
32
|
-
"chrono-node": "^2.6.
|
|
32
|
+
"chrono-node": "^2.6.6",
|
|
33
33
|
"debug": "^4.3.4",
|
|
34
|
-
"tslib": "^2.6.
|
|
35
|
-
"type-fest": "^3.
|
|
34
|
+
"tslib": "^2.6.2",
|
|
35
|
+
"type-fest": "^4.3.1"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "ef31aef8f2fff319d0f692feead332ec5fc5c7cf"
|
|
38
38
|
}
|
|
@@ -93,18 +93,8 @@ test('the input element type case-insensitive', async () => {
|
|
|
93
93
|
expect(violations2.length).toBe(0);
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
test('ancestor condition', async () => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
expect((await mlRuleTest(rule, '<audio><source media="print"></audio>')).violations).toStrictEqual([
|
|
100
|
-
{
|
|
101
|
-
severity: 'error',
|
|
102
|
-
line: 1,
|
|
103
|
-
col: 16,
|
|
104
|
-
message: 'The "media" attribute is disallowed',
|
|
105
|
-
raw: 'media',
|
|
106
|
-
},
|
|
107
|
-
]);
|
|
96
|
+
test.skip('ancestor condition', async () => {
|
|
97
|
+
// TODO: Find instead of test
|
|
108
98
|
});
|
|
109
99
|
|
|
110
100
|
test('Add allow attr', async () => {
|
|
@@ -169,10 +169,10 @@ describe('verify', () => {
|
|
|
169
169
|
expect(violations2).toStrictEqual([
|
|
170
170
|
{
|
|
171
171
|
severity: 'error',
|
|
172
|
-
col:
|
|
173
|
-
line:
|
|
174
|
-
message: '
|
|
175
|
-
raw: '<
|
|
172
|
+
col: 5,
|
|
173
|
+
line: 2,
|
|
174
|
+
message: 'The "dt" element is not allowed in the "dl" element in this context',
|
|
175
|
+
raw: '<dt>',
|
|
176
176
|
},
|
|
177
177
|
{
|
|
178
178
|
severity: 'error',
|