@qualweb/cui-checks 0.1.1 → 0.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.
Files changed (43) hide show
  1. package/dist/CuiChecksModule.d.ts +10 -0
  2. package/dist/CuiChecksModule.d.ts.map +1 -0
  3. package/dist/CuiChecksModule.js +19 -0
  4. package/dist/CuiChecksRunner.d.ts +9 -0
  5. package/dist/CuiChecksRunner.d.ts.map +1 -0
  6. package/dist/CuiChecksRunner.js +18 -0
  7. package/dist/__webpack/cui.bundle.js +1 -0
  8. package/dist/checks/QW-CUI-C1.d.ts +7 -0
  9. package/dist/checks/QW-CUI-C1.d.ts.map +1 -0
  10. package/dist/checks/QW-CUI-C1.js +32 -0
  11. package/dist/checks/index.d.ts +2 -0
  12. package/dist/checks/index.d.ts.map +1 -0
  13. package/dist/checks/index.js +17 -0
  14. package/dist/index.d.ts +3 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +7 -0
  17. package/dist/lib/CUIChecksTester.object.d.ts +9 -0
  18. package/dist/lib/CUIChecksTester.object.d.ts.map +1 -0
  19. package/dist/lib/CUIChecksTester.object.js +71 -0
  20. package/dist/lib/Check.object.d.ts +21 -0
  21. package/dist/lib/Check.object.d.ts.map +1 -0
  22. package/dist/lib/Check.object.js +76 -0
  23. package/dist/lib/checks.json +25 -0
  24. package/dist/lib/mapping.d.ts +5 -0
  25. package/dist/lib/mapping.d.ts.map +1 -0
  26. package/dist/lib/mapping.js +5 -0
  27. package/package.json +24 -20
  28. package/.mocharc.js +0 -3
  29. package/CHANGELOG.md +0 -11
  30. package/compile-rules.js +0 -23
  31. package/cui-checks.schema.json +0 -115
  32. package/dist/cui.bundle.js +0 -1
  33. package/src/index.ts +0 -121
  34. package/src/lib/Check.object.ts +0 -105
  35. package/src/lib/Test.object.ts +0 -40
  36. package/src/lib/decorator.ts +0 -463
  37. package/src/lib/rules.json +0 -25
  38. package/src/lib/rules.ts +0 -5
  39. package/src/rules/QW-CUI-C1.ts +0 -46
  40. package/tsconfig.json +0 -43
  41. package/tsconfig.prod.json +0 -20
  42. package/validate-rules.js +0 -42
  43. package/webpack.config.js +0 -30
@@ -1,463 +0,0 @@
1
- import { CUICheck, CUICheckResult } from '@qualweb/cui-checks';
2
- import { Translate } from '@qualweb/locale';
3
- import rules from './rules.json';
4
-
5
- function CUICheckDecorator<T extends { new (...args: any[]): {} }>(constructor: T) {
6
- const newConstructor: any = function () {
7
- const locales = <Translate>arguments[0];
8
-
9
- //@ts-ignore
10
- const rule = <CUICheck>rules[constructor.name];
11
-
12
- rule.metadata.passed = 0;
13
- rule.metadata.warning = 0;
14
- rule.metadata.failed = 0;
15
- rule.metadata.inapplicable = 0;
16
- rule.metadata.outcome = 'inapplicable';
17
- try {
18
- rule.name = <string>(
19
- (locales.translate['act-rules']?.[rule.code]?.name ?? locales.fallback['act-rules']?.[rule.code]?.name)
20
- );
21
- rule.description = <string>(
22
- (locales.translate['act-rules']?.[rule.code]?.description ??
23
- locales.fallback['act-rules']?.[rule.code]?.description)
24
- );
25
- rule.metadata.description = <string>(
26
- (locales.translate['act-rules']?.[rule.code]?.results?.I1 ??
27
- locales.fallback['act-rules']?.[rule.code].results?.I1)
28
- );
29
- } catch (err) {
30
- console.error(err);
31
- }
32
- rule.results = new Array<CUICheckResult>();
33
-
34
- const func: any = function () {
35
- return new constructor(rule, locales);
36
- };
37
- func.prototype = constructor.prototype;
38
- return new func();
39
- };
40
- newConstructor.prototype = constructor.prototype;
41
- return newConstructor;
42
- }
43
-
44
- function ElementExists(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
45
- const method = descriptor.value;
46
- descriptor.value = function () {
47
- if (<typeof window.qwElement>arguments[0]) {
48
- return method.apply(this, arguments);
49
- }
50
- };
51
- }
52
-
53
- function ElementIsHTMLElement(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
54
- const method = descriptor.value;
55
- descriptor.value = function () {
56
- const element = <typeof window.qwElement>arguments[0];
57
- if (element.isElementHTMLElement()) {
58
- return method.apply(this, arguments);
59
- }
60
- };
61
- }
62
-
63
- function ElementHasAttributes(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
64
- const method = descriptor.value;
65
- descriptor.value = function () {
66
- const hasAttributes = (<typeof window.qwElement>arguments[0]).elementHasAttributes();
67
- if (hasAttributes) {
68
- return method.apply(this, arguments);
69
- }
70
- };
71
- }
72
-
73
- function ElementHasAttribute(attribute: string) {
74
- return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
75
- const method = descriptor.value;
76
- descriptor.value = function () {
77
- const attr = (<typeof window.qwElement>arguments[0]).elementHasAttribute(attribute);
78
- if (attr) {
79
- return method.apply(this, arguments);
80
- }
81
- };
82
- };
83
- }
84
-
85
- function ElementHasNonEmptyAttribute(attribute: string) {
86
- return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
87
- const method = descriptor.value;
88
- descriptor.value = function () {
89
- const attr = (<typeof window.qwElement>arguments[0]).getElementAttribute(attribute);
90
- if (attr && attr.trim()) {
91
- return method.apply(this, arguments);
92
- }
93
- };
94
- };
95
- }
96
-
97
- function ElementHasAttributeRole(role: string) {
98
- return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
99
- const method = descriptor.value;
100
- descriptor.value = function () {
101
- const _role = window.AccessibilityUtils.getElementRole(<typeof window.qwElement>arguments[0]);
102
- if (!_role || _role === role) {
103
- return method.apply(this, arguments);
104
- }
105
- };
106
- };
107
- }
108
-
109
- function ElementHasAttributeValue(attribute: string, value: string) {
110
- return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
111
- const method = descriptor.value;
112
- descriptor.value = function () {
113
- const attr = (<typeof window.qwElement>arguments[0]).getElementAttribute(attribute);
114
- if (attr && attr === value) {
115
- return method.apply(this, arguments);
116
- }
117
- };
118
- };
119
- }
120
-
121
- function IfElementHasTagNameMustHaveAttributeRole(tagName: string, role: string) {
122
- return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
123
- const method = descriptor.value;
124
- descriptor.value = function () {
125
- const _tagName = (<typeof window.qwElement>arguments[0]).getElementTagName();
126
- if (_tagName === tagName) {
127
- const _role = (<typeof window.qwElement>arguments[0]).getElementAttribute('role'); // window.AccessibilityUtils.getElementRole(arguments[0], arguments[1]);
128
- if (!_role || _role === role) {
129
- return method.apply(this, arguments);
130
- }
131
- } else {
132
- return method.apply(this, arguments);
133
- }
134
- };
135
- };
136
- }
137
-
138
- function ElementHasText(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
139
- const method = descriptor.value;
140
- descriptor.value = function () {
141
- const element = <typeof window.qwElement>arguments[0];
142
- if (window.DomUtils.getTrimmedText(element) !== '') {
143
- return method.apply(this, arguments);
144
- }
145
- };
146
- }
147
-
148
- function ElementHasTextNode(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
149
- const method = descriptor.value;
150
- descriptor.value = function () {
151
- const element = <typeof window.qwElement>arguments[0];
152
- if (element.elementHasTextNode()) {
153
- return method.apply(this, arguments);
154
- }
155
- };
156
- }
157
-
158
- function ElementIsInAccessibilityTree(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
159
- const method = descriptor.value;
160
- descriptor.value = function () {
161
- const isInAT = window.AccessibilityUtils.isElementInAT(<typeof window.qwElement>arguments[0]);
162
- if (isInAT) {
163
- return method.apply(this, arguments);
164
- }
165
- };
166
- }
167
-
168
- function ElementHasNegativeTabIndex(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
169
- const method = descriptor.value;
170
- descriptor.value = function () {
171
- const tabindex = (<typeof window.qwElement>arguments[0]).getElementAttribute('tabindex');
172
- if (tabindex && parseInt(tabindex) <= -1) {
173
- return method.apply(this, arguments);
174
- }
175
- };
176
- }
177
-
178
- function ElementIsNotInert(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
179
- const method = descriptor.value;
180
- descriptor.value = function () {
181
- let notInert: boolean = true;
182
- const hasInert = (<typeof window.qwElement>arguments[0]).elementHasAttribute('inert');
183
- if (hasInert) {
184
- const inert = (<typeof window.qwElement>arguments[0]).getElementAttribute('inert');
185
- if (inert !== 'false') {
186
- notInert = false;
187
- }
188
- if (!notInert) {
189
- return;
190
- }
191
- }
192
- let noParentInert: boolean = true;
193
- let parent = (<typeof window.qwElement>arguments[0]).getElementParent();
194
- while (parent) {
195
- const inert = parent.getElementAttribute('inert');
196
- if (inert && inert === 'true') {
197
- noParentInert = false;
198
- }
199
- parent = parent.getElementParent();
200
- }
201
- if (!noParentInert) {
202
- return;
203
- }
204
- if (window.qwPage.pageHasOpenDialog()) {
205
- return;
206
- }
207
- return method.apply(this, arguments);
208
- };
209
- }
210
-
211
- function ElementIsVisibleOrInAccessibilityTree(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
212
- const method = descriptor.value;
213
- descriptor.value = function () {
214
- const page = <typeof window.qwPage>window.qwPage;
215
- const elements = page.getElements('*').filter((element: typeof window.qwElement) => {
216
- return (
217
- element.hasTextNode() &&
218
- (window.DomUtils.isElementVisible(element) || window.AccessibilityUtils.isElementInAT(element))
219
- );
220
- });
221
- if (elements.length > 0) {
222
- return method.apply(this, arguments);
223
- }
224
- };
225
- }
226
-
227
- function ElementIsNotHidden(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
228
- const method = descriptor.value;
229
- descriptor.value = function () {
230
- const notHidden = !window.DomUtils.isElementHidden(<typeof window.qwElement>arguments[0]);
231
- if (notHidden) {
232
- return method.apply(this, arguments);
233
- }
234
- };
235
- }
236
-
237
- function ElementSrcAttributeFilenameEqualsAccessibleName(
238
- _target: any,
239
- _propertyKey: string,
240
- descriptor: PropertyDescriptor
241
- ) {
242
- const method = descriptor.value;
243
- descriptor.value = function () {
244
- const src = (<typeof window.qwElement>arguments[0]).getElementAttribute('src');
245
- const srcSet = (<typeof window.qwElement>arguments[0]).getElementAttribute('srcset');
246
- const parent = (<typeof window.qwElement>arguments[0]).getElementParent();
247
- let filenameWithExtension = new Array<string>();
248
- if (src) {
249
- const filePath = src.split('/');
250
- filenameWithExtension = [filePath[filePath.length - 1].trim().toLowerCase()];
251
- }
252
- if (srcSet) {
253
- const srcSetElements = srcSet.split(',');
254
- for (const srcsetElement of srcSetElements || []) {
255
- const srcValue = srcsetElement.split(' ')[0];
256
- const fileSrc = srcValue.split('/');
257
- filenameWithExtension.push(fileSrc[fileSrc.length - 1].trim().toLowerCase());
258
- }
259
- }
260
- if (parent) {
261
- const parentTag = parent.getElementTagName();
262
- if (parentTag === 'picture') {
263
- const sourceElements = parent.getElements('source');
264
- for (const sourceElement of sourceElements) {
265
- const src = sourceElement.getElementAttribute('srcset');
266
- if (src) {
267
- const filePath = src.split('/');
268
- filenameWithExtension.push(filePath[filePath.length - 1].trim().toLowerCase());
269
- }
270
- }
271
- }
272
- }
273
-
274
- const accessibleName = window.AccessibilityUtils.getAccessibleName(<typeof window.qwElement>arguments[0]);
275
-
276
- if (accessibleName && filenameWithExtension && filenameWithExtension.includes(accessibleName.toLowerCase())) {
277
- return method.apply(this, arguments);
278
- }
279
- };
280
- }
281
-
282
- function isInMainContext(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
283
- const method = descriptor.value;
284
- descriptor.value = function () {
285
- const differentContext = (<typeof window.qwElement>arguments[0]).getElementAttribute('_documentSelector');
286
- if (!differentContext || !differentContext.includes('>')) {
287
- return method.apply(this, arguments);
288
- }
289
- };
290
- }
291
-
292
- function ElementIsVisible(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
293
- const method = descriptor.value;
294
- descriptor.value = function () {
295
- const isVisible = window.DomUtils.isElementVisible(<typeof window.qwElement>arguments[0]);
296
- if (isVisible) {
297
- return method.apply(this, arguments);
298
- }
299
- };
300
- }
301
-
302
- function ElementIsNot(names: string[]) {
303
- return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
304
- const method = descriptor.value;
305
- descriptor.value = function () {
306
- const name = (<typeof window.qwElement>arguments[0]).getElementTagName();
307
- if (name && !names.includes(name)) {
308
- return method.apply(this, arguments);
309
- }
310
- };
311
- };
312
- }
313
-
314
- function ElementHasOneOfTheFollowingRoles(roles: string[]) {
315
- return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
316
- const method = descriptor.value;
317
- descriptor.value = function () {
318
- const role = window.AccessibilityUtils.getElementRole(<typeof window.qwElement>arguments[0]);
319
- if (!!role && roles.includes(role)) {
320
- return method.apply(this, arguments);
321
- }
322
- };
323
- };
324
- }
325
-
326
- function ElementIsWidget(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
327
- const method = descriptor.value;
328
- descriptor.value = function () {
329
- const isWidget = window.AccessibilityUtils.isElementWidget(<typeof window.qwElement>arguments[0]);
330
- if (isWidget) {
331
- return method.apply(this, arguments);
332
- }
333
- };
334
- }
335
-
336
- function ElementIsNotWidget(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
337
- const method = descriptor.value;
338
- descriptor.value = function () {
339
- const isWidget = window.AccessibilityUtils.isElementWidget(<typeof window.qwElement>arguments[0]);
340
- if (!isWidget) {
341
- return method.apply(this, arguments);
342
- }
343
- };
344
- }
345
-
346
- function ElementAllowsNameFromContent(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
347
- const method = descriptor.value;
348
- descriptor.value = function () {
349
- const supportsNameFromContent = window.AccessibilityUtils.allowsNameFromContent(
350
- <typeof window.qwElement>arguments[0]
351
- );
352
- if (supportsNameFromContent) {
353
- return method.apply(this, arguments);
354
- }
355
- };
356
- }
357
-
358
- function IsHTMLDocument(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
359
- const method = descriptor.value;
360
- descriptor.value = function () {
361
- let IsNonHTMLDocument = false;
362
- const htmlElement = window.qwPage.getElement('html');
363
- if (htmlElement) IsNonHTMLDocument = htmlElement.getElementAttribute('nonHTMLPage') === 'true';
364
- if (!IsNonHTMLDocument) {
365
- return method.apply(this, arguments);
366
- }
367
- };
368
- }
369
-
370
- function ElementHasCSSRules(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
371
- const method = descriptor.value;
372
- descriptor.value = function () {
373
- const element = <typeof window.qwElement>arguments[0];
374
- if (element.getCSSRules()) {
375
- return method.apply(this, arguments);
376
- }
377
- };
378
- }
379
-
380
- function IsLangSubTagValid(attribute: string) {
381
- return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
382
- const method = descriptor.value;
383
- descriptor.value = function () {
384
- const attr = (<typeof window.qwElement>arguments[0]).getElementAttribute(attribute);
385
- if (attr && isSubTagValid(attr.split('-')[0])) {
386
- return method.apply(this, arguments);
387
- }
388
- };
389
- };
390
- }
391
-
392
- function isSubTagValid(subTag: string): boolean {
393
- const languages = window.AccessibilityUtils.languages;
394
- return languages.hasOwnProperty(subTag.toLowerCase());
395
- }
396
-
397
- function ElementIsImage(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
398
- const method = descriptor.value;
399
- descriptor.value = function () {
400
- const element = <typeof window.qwElement>arguments[0];
401
- const role = window.AccessibilityUtils.getElementRole(element);
402
- if (element.getElementTagName() === 'img' || role === 'img') {
403
- return method.apply(this, arguments);
404
- }
405
- };
406
- }
407
-
408
- function ElementIsNonText(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
409
- const method = descriptor.value;
410
- descriptor.value = function () {
411
- const element = <typeof window.qwElement>arguments[0];
412
- const isNonText = window.DomUtils.objectElementIsNonText(element);
413
- if (isNonText) {
414
- return method.apply(this, arguments);
415
- }
416
- };
417
- }
418
-
419
- const semanticLinkRoles = ['link', 'doc-backlink', 'doc-biblioref', 'doc-glossref', 'doc-noteref'];
420
-
421
- function ElementIsSemanticLink(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
422
- const method = descriptor.value;
423
- descriptor.value = function () {
424
- const element = <typeof window.qwElement>arguments[0];
425
- const role = window.AccessibilityUtils.getElementRole(element);
426
- if (!!role && semanticLinkRoles.includes(role)) {
427
- return method.apply(this, arguments);
428
- }
429
- };
430
- }
431
-
432
- export {
433
- CUICheckDecorator,
434
- ElementExists,
435
- ElementIsHTMLElement,
436
- ElementHasAttributes,
437
- ElementHasAttribute,
438
- ElementHasAttributeRole,
439
- ElementHasAttributeValue,
440
- IfElementHasTagNameMustHaveAttributeRole,
441
- ElementHasNonEmptyAttribute,
442
- ElementHasText,
443
- ElementHasTextNode,
444
- ElementIsInAccessibilityTree,
445
- ElementSrcAttributeFilenameEqualsAccessibleName,
446
- ElementIsVisible,
447
- ElementIsNot,
448
- ElementHasOneOfTheFollowingRoles,
449
- ElementIsWidget,
450
- ElementIsNotWidget,
451
- ElementAllowsNameFromContent,
452
- IsHTMLDocument,
453
- IsLangSubTagValid,
454
- isInMainContext,
455
- ElementIsNotHidden,
456
- ElementIsVisibleOrInAccessibilityTree,
457
- ElementHasNegativeTabIndex,
458
- ElementHasCSSRules,
459
- ElementIsImage,
460
- ElementIsNonText,
461
- ElementIsSemanticLink,
462
- ElementIsNotInert
463
- };
@@ -1,25 +0,0 @@
1
- {
2
- "QW_CUI_C1": {
3
- "name": "Testing check",
4
- "code": "QW-CUI-C1",
5
- "description": "This is a test.",
6
- "metadata": {
7
- "target": {
8
- "element": "title"
9
- },
10
- "success-criteria": [
11
- {
12
- "name": "2.4.2",
13
- "level": "A",
14
- "principle": "Operable",
15
- "url": "https://www.w3.org/WAI/WCAG21/Understanding/page-titled",
16
- "url_tr": "https://www.w3.org/TR/WCAG21/#page-titled"
17
- }
18
- ],
19
- "related": ["G88", "H25"],
20
- "url": "https://www.w3.org/WAI/standards-guidelines/act/rules/2779a5/",
21
- "type": ["ACTRule", "TestCase"],
22
- "a11yReq": ["WCAG21:title"]
23
- }
24
- }
25
- }
package/src/lib/rules.ts DELETED
@@ -1,5 +0,0 @@
1
- import QW_CUI_C1 from '../rules/QW-CUI-C1';
2
-
3
- export {
4
- QW_CUI_C1,
5
- };
@@ -1,46 +0,0 @@
1
- import { CUICheck } from '@qualweb/cui-checks';
2
- import { Translate } from '@qualweb/locale';
3
- import { CUICheckDecorator, IsHTMLDocument } from '../lib/decorator';
4
- import Test from '../lib/Test.object';
5
- import Check from '../lib/Check.object';
6
-
7
- @CUICheckDecorator
8
- class QW_CUI_C1 extends Check {
9
- constructor(rule: CUICheck, locale: Translate) {
10
- super(rule, locale);
11
- }
12
-
13
- @IsHTMLDocument
14
- execute(element: typeof window.qwElement | undefined): void {
15
- //the first title element was already tested
16
- if (super.getNumberOfPassedResults() + super.getNumberOfFailedResults() === 0) {
17
- const test = new Test();
18
- // the first title element was not tested yet
19
- if (!element) {
20
- //the title element does not exit
21
- test.verdict = 'failed';
22
- test.resultCode = 'F1';
23
- }
24
- //the title element is empty
25
- else if (!element.getElementText() || element.getElementText().trim() === '') {
26
- test.verdict = 'failed';
27
- test.resultCode = 'F2';
28
- } else if (element.getElementAttribute('_documentSelector')) {
29
- test.verdict = 'failed';
30
- test.resultCode = 'F3';
31
- } else {
32
- //the title element exists and it's not empty
33
- test.verdict = 'passed';
34
- test.resultCode = 'P1';
35
- }
36
-
37
- if (element) {
38
- test.addElement(element);
39
- }
40
-
41
- super.addTestResult(test);
42
- }
43
- }
44
- }
45
-
46
- export = QW_CUI_C1;
package/tsconfig.json DELETED
@@ -1,43 +0,0 @@
1
- {
2
- "extends": "@tsconfig/recommended/tsconfig.json",
3
- "compilerOptions": {
4
- /* Basic Options */
5
- "resolveJsonModule": true,
6
- "outDir": "./prebuild" /* Redirect output structure to the directory. */,
7
- "rootDir": "." /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
8
- "removeComments": true /* Do not emit comments to output. */,
9
-
10
- /* Strict Type-Checking Options */
11
- "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
12
- "strictNullChecks": true /* Enable strict null checks. */,
13
- "strictFunctionTypes": true /* Enable strict checking of function types. */,
14
- "strictBindCallApply": true /* Enable strict 'bind', 'call', and 'apply' methods on functions. */,
15
- "strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */,
16
- "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
17
- "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
18
-
19
- /* Additional Checks */
20
- "noUnusedLocals": true /* Report errors on unused locals. */,
21
- "noUnusedParameters": true /* Report errors on unused parameters. */,
22
- "noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
23
- "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
24
-
25
- /* Module Resolution Options */
26
- "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
27
-
28
- "types": [
29
- "@qualweb/types",
30
- "node",
31
- "mocha",
32
- ] /* Type declaration files to be included in compilation. */,
33
- "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
34
-
35
- /* Experimental Options */
36
- "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
37
- "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */
38
- },
39
- "include": [
40
- "src/**/*.ts",
41
- "test/**/*.ts",
42
- ],
43
- }
@@ -1,20 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
5
-
6
- /* Additional Checks */
7
- "noUnusedLocals": true /* Report errors on unused locals. */,
8
- "noUnusedParameters": true /* Report errors on unused parameters. */,
9
- "noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
10
- "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
11
-
12
- "types": [
13
- "@qualweb/types",
14
- "node",
15
- ] /* Type declaration files to be included in compilation. */,
16
- },
17
- "include": [
18
- "src",
19
- ],
20
- }
package/validate-rules.js DELETED
@@ -1,42 +0,0 @@
1
- /**
2
- * Validation script.
3
- * Uses the schema defined in: cui-checks.schema.json
4
- * For the cui checks in: src/lib/rules.json
5
- */
6
-
7
- const Ajv = require('ajv');
8
- const fsSync = require('fs');
9
- const path = require('path');
10
-
11
- const schemaPath = path.join(__dirname, 'cui-checks.schema.json');
12
- const cuichecksPath = path.join(__dirname, 'src', 'lib', 'rules.json');
13
-
14
- const ajv = new Ajv({
15
- allErrors: true
16
- });
17
-
18
- console.info(`Using schema at ${schemaPath}`);
19
- console.info(`Using ACT rules defined in ${cuichecksPath}`);
20
-
21
- const schemaString = fsSync.readFileSync(schemaPath, 'utf-8');
22
- // const schemaString = await fs.readFile(schemaPath, 'utf-8');
23
-
24
- const schemaObject = JSON.parse(schemaString);
25
-
26
- const cuichecks = JSON.parse(fsSync.readFileSync(cuichecksPath, 'utf-8'));
27
- // const actrules = JSON.parse(await fs.readFile(actrulesPath, 'utf-8'));
28
-
29
- const validateFunction = ajv.compile(schemaObject);
30
- // const validateFunction = await ajv.compileAsync(schemaObject);
31
-
32
- console.info('Starting validation');
33
-
34
- const isValid = validateFunction(cuichecks);
35
-
36
- if (isValid === false && validateFunction.errors) {
37
- for (const error of validateFunction.errors) {
38
- console.error(error);
39
- }
40
- } else {
41
- console.info('Validation found no errors.');
42
- }
package/webpack.config.js DELETED
@@ -1,30 +0,0 @@
1
- const path = require('path');
2
- const TerserPlugin = require('terser-webpack-plugin');
3
-
4
- module.exports = {
5
- mode: 'production',
6
- entry: './prebuild/index.js',
7
- output: {
8
- filename: 'cui.bundle.js',
9
- path: path.resolve(__dirname, 'dist'),
10
- library: {
11
- type: 'this'
12
- }
13
- },
14
- optimization: {
15
- minimize: true,
16
- minimizer: [
17
- new TerserPlugin({
18
- terserOptions: {
19
- compress: {
20
- keep_classnames: true
21
- },
22
- mangle: {
23
- keep_classnames: true
24
- }
25
- }
26
- })
27
- ]
28
- },
29
- target: 'web'
30
- }