testaro 61.0.0 → 61.2.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/README.md +1 -1
- package/package.json +1 -1
- package/procs/standardize.js +44 -43
- package/tests/nuVal.js +5 -0
- package/tests/nuVnu.js +5 -0
package/README.md
CHANGED
|
@@ -731,7 +731,7 @@ This instance says that a `button` element violates a rule named `rule01`.
|
|
|
731
731
|
|
|
732
732
|
The element has no `id` attribute to distinguish it from other `button` elements, but the tool describes its location. This tool uses an XPath to do that. Tools use various methods for location description, namely:
|
|
733
733
|
|
|
734
|
-
- `
|
|
734
|
+
- `code` (line, starting column, and ending column): Nu Html Checker (API and installed)
|
|
735
735
|
- `selector` (CSS selector): Axe, QualWeb, WAVE
|
|
736
736
|
- `xpath`: Alfa, ASLint, Equal Access
|
|
737
737
|
- `box` (coordinates, width, and height of the element box): Editoria11y, Testaro
|
package/package.json
CHANGED
package/procs/standardize.js
CHANGED
|
@@ -30,31 +30,24 @@ const cap = rawString => {
|
|
|
30
30
|
};
|
|
31
31
|
// Returns whether an id attribute value is valid without character escaping.
|
|
32
32
|
const isBadID = id => /[^-\w]|^\d|^--|^-\d/.test(id);
|
|
33
|
-
// Returns
|
|
33
|
+
// Returns a tag name and the value of an id attribute from a substring of HTML code.
|
|
34
34
|
const getIdentifiers = code => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
// If the id value is invalid without character escaping:
|
|
51
|
-
if (isBadID(id)) {
|
|
52
|
-
// Remove it.
|
|
53
|
-
id = '';
|
|
54
|
-
}
|
|
55
|
-
}
|
|
35
|
+
// Normalize the code.
|
|
36
|
+
code = code.replace(/\s+/g, ' ').replace(/\\"/g, '"');
|
|
37
|
+
// Get the first start tag of an element, if any.
|
|
38
|
+
const startTagData = code.match(/^.*?< ?([^>]*)/);
|
|
39
|
+
// If there is any:
|
|
40
|
+
if (startTagData) {
|
|
41
|
+
// Get the tag name.
|
|
42
|
+
const tagNameData = startTagData[1].match(/^[A-Za-z0-9]+/);
|
|
43
|
+
const tagName = tagNameData ? tagNameData[0].toUpperCase() : '';
|
|
44
|
+
// Get the value of the id attribute, if any.
|
|
45
|
+
const idData = startTagData[1].match(/ id="([^"]+)"/);
|
|
46
|
+
const id = idData ? idData[1] : '';
|
|
47
|
+
// Return the tag name and the value of the id attribute, if any.
|
|
48
|
+
return [tagName, id];
|
|
56
49
|
}
|
|
57
|
-
return [
|
|
50
|
+
return ['', ''];
|
|
58
51
|
};
|
|
59
52
|
/*
|
|
60
53
|
Differentiates some rule IDs of aslint.
|
|
@@ -221,30 +214,34 @@ const doNuVal = (result, standardResult, docType) => {
|
|
|
221
214
|
const items = result[docType] && result[docType].messages;
|
|
222
215
|
if (items && items.length) {
|
|
223
216
|
items.forEach(item => {
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
217
|
+
const {extract, firstColumn, lastColumn, lastLine, message, subType, type} = item;
|
|
218
|
+
const identifiers = getIdentifiers(extract);
|
|
219
|
+
if (! identifiers[0] && message) {
|
|
220
|
+
const tagNameLCArray = message.match(
|
|
227
221
|
/^Element ([^ ]+)|^An (img) element| (meta|script) element| element (script)| tag (script)/
|
|
228
222
|
);
|
|
229
223
|
if (tagNameLCArray && tagNameLCArray[1]) {
|
|
230
224
|
identifiers[0] = tagNameLCArray[1].toUpperCase();
|
|
231
225
|
}
|
|
232
226
|
}
|
|
233
|
-
|
|
227
|
+
let spec = '';
|
|
228
|
+
const locationSegments = [lastLine, firstColumn, lastColumn];
|
|
229
|
+
if (locationSegments.every(segment => typeof segment === 'number')) {
|
|
230
|
+
spec = locationSegments.join(':');
|
|
231
|
+
}
|
|
234
232
|
const instance = {
|
|
235
|
-
ruleID:
|
|
236
|
-
what:
|
|
233
|
+
ruleID: message,
|
|
234
|
+
what: message,
|
|
237
235
|
ordinalSeverity: -1,
|
|
238
236
|
tagName: identifiers[0],
|
|
239
237
|
id: identifiers[1],
|
|
240
238
|
location: {
|
|
241
239
|
doc: docType === 'pageContent' ? 'dom' : 'source',
|
|
242
|
-
type: '
|
|
243
|
-
spec
|
|
240
|
+
type: 'code',
|
|
241
|
+
spec
|
|
244
242
|
},
|
|
245
|
-
excerpt: cap(
|
|
243
|
+
excerpt: cap(extract)
|
|
246
244
|
};
|
|
247
|
-
const {type, subType} = item;
|
|
248
245
|
if (type === 'info' && subType === 'warning') {
|
|
249
246
|
instance.ordinalSeverity = 0;
|
|
250
247
|
}
|
|
@@ -260,30 +257,34 @@ const doNuVnu = (result, standardResult, docType) => {
|
|
|
260
257
|
const items = result[docType] && result[docType].messages;
|
|
261
258
|
if (items && items.length) {
|
|
262
259
|
items.forEach(item => {
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
260
|
+
const {extract, firstColumn, lastColumn, lastLine, message, subType, type} = item;
|
|
261
|
+
const identifiers = getIdentifiers(extract);
|
|
262
|
+
if (! identifiers[0] && message) {
|
|
263
|
+
const tagNameLCArray = message.match(
|
|
266
264
|
/^Element ([^ ]+)|^An (img) element| (meta|script) element| element (script)| tag (script)/
|
|
267
265
|
);
|
|
268
266
|
if (tagNameLCArray && tagNameLCArray[1]) {
|
|
269
267
|
identifiers[0] = tagNameLCArray[1].toUpperCase();
|
|
270
268
|
}
|
|
271
269
|
}
|
|
272
|
-
|
|
270
|
+
let spec = '';
|
|
271
|
+
const locationSegments = [lastLine, firstColumn, lastColumn];
|
|
272
|
+
if (locationSegments.every(segment => typeof segment === 'number')) {
|
|
273
|
+
spec = locationSegments.join(':');
|
|
274
|
+
}
|
|
273
275
|
const instance = {
|
|
274
|
-
ruleID:
|
|
275
|
-
what:
|
|
276
|
+
ruleID: message,
|
|
277
|
+
what: message,
|
|
276
278
|
ordinalSeverity: -1,
|
|
277
279
|
tagName: identifiers[0],
|
|
278
280
|
id: identifiers[1],
|
|
279
281
|
location: {
|
|
280
282
|
doc: docType === 'pageContent' ? 'dom' : 'source',
|
|
281
|
-
type: '
|
|
282
|
-
spec
|
|
283
|
+
type: 'code',
|
|
284
|
+
spec
|
|
283
285
|
},
|
|
284
|
-
excerpt: cap(
|
|
286
|
+
excerpt: cap(extract)
|
|
285
287
|
};
|
|
286
|
-
const {type, subType} = item;
|
|
287
288
|
if (type === 'info' && subType === 'warning') {
|
|
288
289
|
instance.ordinalSeverity = 0;
|
|
289
290
|
}
|
package/tests/nuVal.js
CHANGED
|
@@ -97,6 +97,11 @@ exports.reporter = async (page, report, actIndex) => {
|
|
|
97
97
|
}
|
|
98
98
|
}));
|
|
99
99
|
}
|
|
100
|
+
// Remove messages reporting duplicate blank IDs.
|
|
101
|
+
const badMessages = new Set(['Duplicate ID .', 'The first occurrence of ID was here.']);
|
|
102
|
+
result[page[0]].messages = result[page[0]].messages.filter(
|
|
103
|
+
message => ! badMessages.has(message.message)
|
|
104
|
+
);
|
|
100
105
|
}
|
|
101
106
|
// If an error occurred:
|
|
102
107
|
catch (error) {
|
package/tests/nuVnu.js
CHANGED
|
@@ -115,6 +115,11 @@ exports.reporter = async (page, report, actIndex) => {
|
|
|
115
115
|
}
|
|
116
116
|
}));
|
|
117
117
|
}
|
|
118
|
+
// Remove messages reporting duplicate blank IDs.
|
|
119
|
+
const badMessages = new Set(['Duplicate ID .', 'The first occurrence of ID was here.']);
|
|
120
|
+
result[page[0]].messages = result[page[0]].messages.filter(
|
|
121
|
+
message => ! badMessages.has(message.message)
|
|
122
|
+
);
|
|
118
123
|
}
|
|
119
124
|
}
|
|
120
125
|
// If both page types prevented testing:
|