UNPKG

2.76 kBJavaScriptView Raw
1var lodash = require('lodash');
2
3var errors = {
4 E000: 'not a valid error code',
5 E001: 'the "<%= attribute %>" attribute is banned',
6 E002: 'attribute names must match the format: <%= format %>',
7 E003: 'duplicate attribute: <%= attribute %>',
8 E004: 'attribute values must not include unsafe characters',
9 E005: 'the "<%= attribute %>" attribute is not <%= format %>',
10 E006: 'attribute values cannot be empty',
11 E007: '<!DOCTYPE> should be the first element seen',
12 E008: 'the doctype must conform to the HTML5 standard.',
13 E009: 'use only <%= format %> links',
14 E010: 'ids and classes may not use the word "ad"',
15 E011: 'ids and classes must match the format: <%= format %>',
16 E012: 'the id "<%= id %>" is already in use',
17 E013: 'the `alt` property must be set for image tags.',
18 E014: 'a source must be given for each `img` tag',
19 E015: 'line ending does not match format: <%= format %>',
20 E016: 'the <%= tag %> tag is banned',
21 E017: 'tag names must be lowercase',
22 E018: 'void element should close itself',
23 E019: 'all labels should have a `for` attribute',
24 E020: 'label does not have a "for" attribute or a labeable child',
25 E021: 'an element with the id "<%= id %>" does not exist (should match "for" attribute)',
26 E022: 'the linked element is not labeable (id: <%= id %>)',
27 E023: '<%= part %> contains improperly escaped characters: <%= chars %>',
28 E024: '<%= type %> not allowed',
29 E025: 'html element should specify the language of the page',
30 E026: '<%= op %> (all focusable elements on a page must either have a positive tabindex or none at all)',
31 E027: 'the <head> tag must contain a title',
32 E028: 'the <head> tag can only contain one title; <%= num %> given',
33 E029: 'title "<%= title %>" exceeds maximum length of <%= maxlength %>',
34 E030: 'tag start and end must match',
35 E031: 'table must have a caption for accessibility',
36 E032: 'figure must have a figcaption, figcaption must be in a figure (for accessibility)',
37 E033: 'input with id: <%= idValue %> (or if type is text, name: <%= nameValue %>) is not associated with a label for accessibility.',
38 E034: 'radio input must have an associated name.',
39 E035: 'table must have a header for accessibility',
40 E036: 'indenting spaces must be used in groups of <%= width %>'
41};
42
43module.exports.errors = {};
44
45lodash.forOwn(errors, function (format, code) {
46 module.exports.errors[code] = {
47 format: format,
48 code: code
49 };
50});
51
52module.exports.renderMsg = function (code, data) {
53 var format = errors[code];
54
55 return lodash.template(format, data);
56};
57
58module.exports.renderIssue = function (issue) {
59 return this.renderMsg(issue.code, issue.data);
60};