testaro 27.0.0 → 28.0.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/CONTRIBUTING.md +3 -1
- package/README.md +14 -3
- package/package.json +2 -1
- package/procs/aslint.js +83 -0
- package/procs/nav.js +56 -14
- package/procs/standardize.js +36 -0
- package/run.js +35 -22
- package/tests/aslint.js +83 -0
- package/tests/axe.js +4 -0
- package/tests/qualWeb.js +6 -0
- package/aslint/LICENSE +0 -362
- package/aslint/README.md +0 -260
- package/aslint/app/rules/abstract-rule.ts +0 -83
- package/aslint/app/rules/aslint/incorrect-technique-for-hiding-content/incorrect-technique-for-hiding-content.documentation.md +0 -36
- package/aslint/app/rules/aslint/incorrect-technique-for-hiding-content/incorrect-technique-for-hiding-content.test.ts +0 -113
- package/aslint/app/rules/aslint/incorrect-technique-for-hiding-content/incorrect-technique-for-hiding-content.ts +0 -103
- package/aslint/app/rules/aslint/invalid-attribute-dir-value/invalid-attribute-dir-value.documentation.md +0 -34
- package/aslint/app/rules/aslint/invalid-attribute-dir-value/invalid-attribute-dir-value.test.ts +0 -82
- package/aslint/app/rules/aslint/invalid-attribute-dir-value/invalid-attribute-dir-value.ts +0 -44
- package/aslint/app/rules/aslint/label-duplicated-content-title/label-duplicated-content-title.documentation.md +0 -40
- package/aslint/app/rules/aslint/label-duplicated-content-title/label-duplicated-content-title.test.ts +0 -48
- package/aslint/app/rules/aslint/label-duplicated-content-title/label-duplicated-content-title.ts +0 -37
- package/aslint/app/rules/aslint/links-language-destination/links-language-destination.test.ts +0 -50
- package/aslint/app/rules/aslint/links-language-destination/links-language-destination.ts +0 -70
- package/aslint/app/rules/aslint/main-element-only-one/main-element-only-one.test.ts +0 -55
- package/aslint/app/rules/aslint/main-element-only-one/main-element-only-one.ts +0 -83
- package/aslint/app/rules/aslint/main-landmark-must-be-top-level/main-landmark-must-be-top-level.test.ts +0 -12
- package/aslint/app/rules/aslint/main-landmark-must-be-top-level/main-landmark-must-be-top-level.ts +0 -73
- package/aslint/app/rules/aslint/minimum-font-size/minimum-font-size.test.ts +0 -12
- package/aslint/app/rules/aslint/minimum-font-size/minimum-font-size.ts +0 -87
- package/aslint/app/rules/aslint/missing-href-on-a/missing-href-on-a.test.ts +0 -48
- package/aslint/app/rules/aslint/missing-href-on-a/missing-href-on-a.ts +0 -40
- package/aslint/app/rules/aslint/misused-aria-on-focusable-element/misused-aria-on-focusable-element.test.ts +0 -12
- package/aslint/app/rules/aslint/misused-aria-on-focusable-element/misused-aria-on-focusable-element.ts +0 -66
- package/aslint/app/rules/aslint/misused-input-attribute/misused-input-attribute.test.ts +0 -12
- package/aslint/app/rules/aslint/misused-input-attribute/misused-input-attribute.ts +0 -134
- package/aslint/app/rules/aslint/misused-required-attribute/misused-required-attribute.test.ts +0 -12
- package/aslint/app/rules/aslint/misused-required-attribute/misused-required-attribute.ts +0 -90
- package/aslint/app/rules/aslint/navigation-landmark-restrictions/navigation-landmark-restrictions.test.ts +0 -12
- package/aslint/app/rules/aslint/navigation-landmark-restrictions/navigation-landmark-restrictions.ts +0 -48
- package/aslint/app/rules/aslint/obsolete-html-attributes/obsolete-html-attributes.test.ts +0 -12
- package/aslint/app/rules/aslint/obsolete-html-attributes/obsolete-html-attributes.ts +0 -148
- package/aslint/app/rules/aslint/obsolete-html-elements/obsolete-html-elements.test.ts +0 -12
- package/aslint/app/rules/aslint/obsolete-html-elements/obsolete-html-elements.ts +0 -66
- package/aslint/app/rules/aslint/outline-zero/outline-zero.test.ts +0 -12
- package/aslint/app/rules/aslint/outline-zero/outline-zero.ts +0 -85
- package/aslint/app/rules/aslint/overlay/overlay.test.ts +0 -122
- package/aslint/app/rules/aslint/overlay/overlay.ts +0 -141
- package/aslint/app/rules/aslint/redundant/aria-role-dialog/aria-role-dialog.documentation.md +0 -49
- package/aslint/app/rules/aslint/redundant/aria-role-dialog/aria-role-dialog.test.ts +0 -91
- package/aslint/app/rules/aslint/redundant/aria-role-dialog/aria-role-dialog.ts +0 -62
- package/aslint/app/rules/aslint/redundant/capital-letters-words/capital-letters-words.documentation.md +0 -44
- package/aslint/app/rules/aslint/redundant/capital-letters-words/capital-letters-words.test.ts +0 -111
- package/aslint/app/rules/aslint/redundant/capital-letters-words/capital-letters-words.ts +0 -120
- package/aslint/app/rules/aslint/redundant/contentinfo-landmark-only-one/contentinfo-landmark-only-one.documentation.md +0 -45
- package/aslint/app/rules/aslint/redundant/contentinfo-landmark-only-one/contentinfo-landmark-only-one.test.ts +0 -63
- package/aslint/app/rules/aslint/redundant/contentinfo-landmark-only-one/contentinfo-landmark-only-one.ts +0 -44
- package/aslint/app/rules/aslint/redundant/empty-title-attribute/empty-title-attribute.documentation.md +0 -55
- package/aslint/app/rules/aslint/redundant/empty-title-attribute/empty-title-attribute.test.ts +0 -80
- package/aslint/app/rules/aslint/redundant/empty-title-attribute/empty-title-attribute.ts +0 -58
- package/aslint/app/rules/aslint/redundant/flash-content/flash-content.documentation.md +0 -48
- package/aslint/app/rules/aslint/redundant/flash-content/flash-content.test.ts +0 -52
- package/aslint/app/rules/aslint/redundant/flash-content/flash-content.ts +0 -32
- package/aslint/app/rules/aslint/redundant/font-style-italic/font-style-italic.documentation.md +0 -44
- package/aslint/app/rules/aslint/redundant/font-style-italic/font-style-italic.test.ts +0 -12
- package/aslint/app/rules/aslint/redundant/font-style-italic/font-style-italic.ts +0 -83
- package/aslint/app/rules/aslint/redundant/h1-must-be/h1-must-be.documentation.md +0 -46
- package/aslint/app/rules/aslint/redundant/h1-must-be/h1-must-be.test.ts +0 -46
- package/aslint/app/rules/aslint/redundant/h1-must-be/h1-must-be.ts +0 -36
- package/aslint/app/rules/aslint/role-application/role-application.test.ts +0 -48
- package/aslint/app/rules/aslint/role-application/role-application.ts +0 -38
- package/aslint/app/rules/aslint/rtl-content/rtl-content.test.ts +0 -12
- package/aslint/app/rules/aslint/rtl-content/rtl-content.ts +0 -75
- package/aslint/app/rules/aslint/unclear-uri-on-a/unclear-anchor-uri.test.ts +0 -12
- package/aslint/app/rules/aslint/unclear-uri-on-a/unclear-anchor-uri.ts +0 -48
- package/aslint/app/rules/aslint/unimportant/aria-hidden-false/aria-hidden-false.test.ts +0 -73
- package/aslint/app/rules/aslint/unimportant/aria-hidden-false/aria-hidden-false.ts +0 -34
- package/aslint/app/rules/aslint/unimportant/aria-hidden-false/aria-hidden.documentation.md +0 -32
- package/aslint/app/rules/aslint/unimportant/content-editable-missing-attributes/content-editable-missing-attributes.docmentation.md +0 -48
- package/aslint/app/rules/aslint/unimportant/content-editable-missing-attributes/content-editable-missing-attributes.test.ts +0 -67
- package/aslint/app/rules/aslint/unimportant/content-editable-missing-attributes/content-editable-missing-attributes.ts +0 -63
- package/aslint/app/rules/aslint/unsupported-role-on-element/unsupported-role-on-element.test.ts +0 -12
- package/aslint/app/rules/aslint/unsupported-role-on-element/unsupported-role-on-element.ts +0 -63
- package/aslint/app/rules/aslint/used/elements-not-allowed-in-head/elements-not-allowed-in-head.documentation.md +0 -65
- package/aslint/app/rules/aslint/used/elements-not-allowed-in-head/elements-not-allowed-in-head.test.ts +0 -53
- package/aslint/app/rules/aslint/used/elements-not-allowed-in-head/elements-not-allowed-in-head.ts +0 -47
- package/aslint/app/rules/aslint/used/headings-sibling-unique/headings-sibling-unique.documentation.md +0 -57
- package/aslint/app/rules/aslint/used/headings-sibling-unique/headings-sibling-unique.test.ts +0 -52
- package/aslint/app/rules/aslint/used/headings-sibling-unique/headings-sibling-unique.ts +0 -63
- package/aslint/app/rules/aslint/used/horizontal-rule/horizontal-rule.documentation.md +0 -39
- package/aslint/app/rules/aslint/used/horizontal-rule/horizontal-rule.test.ts +0 -66
- package/aslint/app/rules/aslint/used/horizontal-rule/horizontal-rule.ts +0 -37
- package/aslint/utils/aria.test.ts +0 -12
- package/aslint/utils/aria.ts +0 -120
- package/aslint/utils/async.test.ts +0 -25
- package/aslint/utils/async.ts +0 -22
- package/aslint/utils/common.test.ts +0 -239
- package/aslint/utils/common.ts +0 -168
- package/aslint/utils/console.test.ts +0 -85
- package/aslint/utils/console.ts +0 -89
- package/aslint/utils/css.test.ts +0 -153
- package/aslint/utils/css.ts +0 -191
- package/aslint/utils/dom.test.ts +0 -627
- package/aslint/utils/dom.ts +0 -1051
- package/aslint/utils/env.test.ts +0 -14
- package/aslint/utils/env.ts +0 -8
- package/aslint/utils/func.test.ts +0 -160
- package/aslint/utils/func.ts +0 -70
- package/aslint/utils/global.test.ts +0 -12
- package/aslint/utils/global.ts +0 -25
- package/aslint/utils/object.test.ts +0 -524
- package/aslint/utils/object.ts +0 -278
- package/aslint/utils/report.test.ts +0 -56
- package/aslint/utils/report.ts +0 -36
- package/aslint/utils/text.test.ts +0 -270
- package/aslint/utils/text.ts +0 -165
- package/aslint/utils/time.test.ts +0 -43
- package/aslint/utils/time.ts +0 -33
package/aslint/utils/text.ts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { ObjectUtility } from './object';
|
|
2
|
-
|
|
3
|
-
// Note: safeTrim related constants
|
|
4
|
-
|
|
5
|
-
const SP: string = ' ';
|
|
6
|
-
const TAB: string = '\t';
|
|
7
|
-
const CR: string = '\r';
|
|
8
|
-
const LF: string = '\n';
|
|
9
|
-
const CR_LF = '\r\n';
|
|
10
|
-
const FF: string = '\f';
|
|
11
|
-
const ZERO_WIDTH_SPACE: string = '\v' + // \x0B VT 垂直制表符
|
|
12
|
-
'\f' + // \x0C FF 换页符
|
|
13
|
-
'\u200B\u200C\u200D\u200E\u200F\u000b\u2028\u2029\uFEFF\u202D';
|
|
14
|
-
const OTHER_SPACE: string = '\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000';
|
|
15
|
-
|
|
16
|
-
const ALL_SPACES: string = SP + TAB + CR + LF + CR_LF + ZERO_WIDTH_SPACE + OTHER_SPACE;
|
|
17
|
-
|
|
18
|
-
const leftReg: RegExp = new RegExp(`^[${ALL_SPACES}]+`);
|
|
19
|
-
const rightReg: RegExp = new RegExp(`[${ALL_SPACES}]+$`);
|
|
20
|
-
const zeroReg: RegExp = new RegExp(`[${ZERO_WIDTH_SPACE}]+`, 'g');
|
|
21
|
-
const otherReg: RegExp = new RegExp(`[${OTHER_SPACE}]+`, 'g');
|
|
22
|
-
const space: RegExp = new RegExp(`^[${SP+TAB+LF+FF+CR}]+$`);
|
|
23
|
-
const allWhiteSpaces: RegExp = new RegExp(`[${TAB + CR + LF + CR_LF + ZERO_WIDTH_SPACE + OTHER_SPACE}]`, 'g');
|
|
24
|
-
|
|
25
|
-
export class TextUtility {
|
|
26
|
-
private static isNativeTrimAvailable: boolean = String.prototype.trim && ObjectUtility.isNativeMethod(String.prototype.trim);
|
|
27
|
-
private static escapeEntityMap: { [key: string]: string } = {
|
|
28
|
-
'"': '"',
|
|
29
|
-
'&': '&',
|
|
30
|
-
'\'': ''',
|
|
31
|
-
'/': '/',
|
|
32
|
-
'<': '<',
|
|
33
|
-
'=': '=',
|
|
34
|
-
'>': '>',
|
|
35
|
-
'`': '`'
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
private static unescapeEntityMap: { [key: string]: string } = {
|
|
39
|
-
''': '\'',
|
|
40
|
-
'/': '/',
|
|
41
|
-
'=': '=',
|
|
42
|
-
'`': '`',
|
|
43
|
-
'&': '&',
|
|
44
|
-
'>': '>',
|
|
45
|
-
'<': '<',
|
|
46
|
-
'"': '"'
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
public static trim(text: string): string {
|
|
50
|
-
if (TextUtility.isNativeTrimAvailable) {
|
|
51
|
-
return text.trim();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return text.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public static truncateWords(str: string, numberOfChars?: number): string {
|
|
58
|
-
const amount: number = numberOfChars ? numberOfChars : 50;
|
|
59
|
-
const cut: number = str.indexOf(' ', amount);
|
|
60
|
-
|
|
61
|
-
if (cut === -1) {
|
|
62
|
-
return str;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return `${str.substring(0, cut)} [...]`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public static truncate(str: string, numberOfChars?: number): string {
|
|
69
|
-
const amount: number = numberOfChars ? numberOfChars : 50;
|
|
70
|
-
|
|
71
|
-
return `${str.substring(0, amount)} [...]`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public static truncateInTheMiddle(text: string, startChars?: number, endChars?: number, maxLength?: number): string {
|
|
75
|
-
let start: any;
|
|
76
|
-
let end: any;
|
|
77
|
-
const charsAtTheBeginning: number = startChars || 70;
|
|
78
|
-
const charsAtTheEnd: number = endChars || 70;
|
|
79
|
-
const maximumLength: number = maxLength || 120;
|
|
80
|
-
const content: string = text.trim();
|
|
81
|
-
|
|
82
|
-
if (content.length > maximumLength) {
|
|
83
|
-
start = content.substring(0, charsAtTheBeginning);
|
|
84
|
-
end = content.substring(content.length - charsAtTheEnd, content.length);
|
|
85
|
-
|
|
86
|
-
return `${start} [...] ${end}`;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return text;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public static isUpperCase(str: string): boolean {
|
|
93
|
-
if ((/[^\w]/).test(str)) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (isNaN(Number(str)) && str.length > 1) {
|
|
98
|
-
return str === str.toUpperCase();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public static containsOnlyWhiteSpaces(str: string): boolean {
|
|
105
|
-
return (/^\s*$/).test(str);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Note: following by https://www.w3.org/TR/2010/WD-html-markup-20100624/terminology.html#space
|
|
109
|
-
public static containsSpaceCharacter(str: string): boolean {
|
|
110
|
-
return space.test(str);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public static safeTrim(string: string): string {
|
|
114
|
-
return string
|
|
115
|
-
.replace(leftReg, '')
|
|
116
|
-
.replace(rightReg, '')
|
|
117
|
-
.replace(new RegExp(TAB, 'g'), '')
|
|
118
|
-
.replace(new RegExp(CR_LF, 'g'), LF)
|
|
119
|
-
.replace(new RegExp(CR, 'g'), LF)
|
|
120
|
-
.replace(zeroReg, '')
|
|
121
|
-
.replace(otherReg, '')
|
|
122
|
-
.trim();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
public static normalizeWhitespaces(string: string): string {
|
|
126
|
-
return string
|
|
127
|
-
.replace(allWhiteSpaces, ' ').replace(/\s+/g, ' ');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
public static escape(str: string): string {
|
|
131
|
-
const fromEntityMap: any = (s: any): string => {
|
|
132
|
-
return this.escapeEntityMap[s];
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
return String(str).replace(/[&<>"'`=/]/g, fromEntityMap);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public static unescape(str: string): string {
|
|
139
|
-
const fromEntityMap: any = (s: any): string => {
|
|
140
|
-
return this.unescapeEntityMap[s];
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
return String(str).replace(/&([^;]+);/g, fromEntityMap);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
public static convertUnderscoresToDashes(text: string): string {
|
|
147
|
-
return text.replace(/_/g, '-');
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
public static convertDashesToUnderscores(text: string): string {
|
|
151
|
-
return text.replace(/-/g, '_');
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
public static replacePlaceholder(text: string, words: string[], placeholder: string = '%'): string {
|
|
155
|
-
const replaceValue = (result: string, value: string, i: number): string => {
|
|
156
|
-
return result.replace(`${placeholder}${i}`, String(value));
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
return words.reduce(replaceValue, text);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
public static areStringsTheSame(str1: string, str2: string): boolean {
|
|
163
|
-
return str1.toLocaleUpperCase() === str2.toLocaleUpperCase();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Time } from './time';
|
|
2
|
-
|
|
3
|
-
describe('Utils', () => {
|
|
4
|
-
|
|
5
|
-
describe('Time', () => {
|
|
6
|
-
|
|
7
|
-
describe('#format', () => {
|
|
8
|
-
|
|
9
|
-
it('should return "< 1 ms" when value is 0.1 ms', () => {
|
|
10
|
-
expect(Time.format(0.1)).toBe('< 1 ms');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('should return seconds and miliseconds formatted when value is 1.0499999999992724 ms', () => {
|
|
14
|
-
expect(Time.format(1.0499999999992724)).toBe('1ms');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should return seconds and miliseconds formatted when value is 1300 ms', () => {
|
|
18
|
-
expect(Time.format(1300)).toBe('1s 300ms');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should return minutes, seconds and miliseconds formatted when value is 61003 ms', () => {
|
|
22
|
-
expect(Time.format(61003)).toBe('1m 1s 3ms');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should return minutes and miliseconds formatted when value is 60300 ms', () => {
|
|
26
|
-
expect(Time.format(60300)).toBe('1m 300ms');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should return minutes, seconds and miliseconds formatted when value is 62300 ms', () => {
|
|
30
|
-
expect(Time.format(62300)).toBe('1m 2s 300ms');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should return miliseconds formatted when value is 50 ms', () => {
|
|
34
|
-
expect(Time.format(50)).toBe('50ms');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should return formatted and rounded milliseconds long number', () => {
|
|
38
|
-
expect(Time.format(21.1234500000013)).toBe('21ms');
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
});
|
package/aslint/utils/time.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export class Time {
|
|
2
|
-
|
|
3
|
-
public static format(duration: any): any {
|
|
4
|
-
const milliseconds: any = Math.floor(duration % 1000);
|
|
5
|
-
const seconds: any = Math.floor(duration / 1000 % 60);
|
|
6
|
-
const minutes: any = Math.floor(duration / (60 * 1000) % 60);
|
|
7
|
-
const hours: any = Math.floor(duration / (60 * 60 * 1000) % 60);
|
|
8
|
-
let time: any = '';
|
|
9
|
-
|
|
10
|
-
if (duration < 1) {
|
|
11
|
-
return '< 1 ms';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (hours > 0) {
|
|
15
|
-
time += `${hours}h `;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (minutes > 0) {
|
|
19
|
-
time += `${minutes}m `;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (seconds > 0) {
|
|
23
|
-
time += `${seconds}s `;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (milliseconds > 0) {
|
|
27
|
-
time += `${milliseconds}ms`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return time;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
}
|