aboutsummaryrefslogtreecommitdiff
path: root/exampleData/ruleSets/combinedRules.json
diff options
context:
space:
mode:
Diffstat (limited to 'exampleData/ruleSets/combinedRules.json')
-rw-r--r--exampleData/ruleSets/combinedRules.json464
1 files changed, 285 insertions, 179 deletions
diff --git a/exampleData/ruleSets/combinedRules.json b/exampleData/ruleSets/combinedRules.json
index 385a3dd..0bf54ca 100644
--- a/exampleData/ruleSets/combinedRules.json
+++ b/exampleData/ruleSets/combinedRules.json
@@ -1,212 +1,309 @@
{ 'name': "Combined color, font, image, and text rules"
, 'description': "Site colors, fonts, images, and text should conform to these general guidelines"
, 'rules': [
- //----------------------------------------------------------------
- { 'name': "Foreground check"
- , 'description': "Foreground colors should be in the set:"+
- "#00 #FF #3D #F7 #C2 #B4 #4E #FFCB05 #7B8738"
+// --- included from file: alwaysErrThreeTimes.json --- //
+
+ { 'id': 112201
+ , 'name': 'Reports three times'
+ , 'description': 'Test guideline that reports three errors'
+ , 'rule':
+ function() {
+ report('Problem 1 (g1)', null);
+ report('Problem 3 (g1)', null);
+ report('Problem 2 (g1)', null);
+ }
+ },
+
+ { 'id': 1122202
+ , 'name': 'Reports two times'
+ , 'description': 'Test guideline that reports two errors.'
+ , 'rule':
+ function() {
+ report('Problem 1 (g2)', null);
+ report('Problem 2 (g2)', null);
+ }
+ },
+// --- included from file: basicUIRules.json --- //
+
+ { 'id': 1001801
+ , 'name': 'All input fields have exactly one label.'
+ , 'description': '<p>Screen readers rely on HTML attributes to identify the purpose '
+ + "of form widgets on-screen. These tools use label tags with 'for' "
+ + 'attributes that specify the id of the form element they pertain to. '
+ + 'Some of the components of this web page do not have those labels.</p>'
+ , 'rule':
+ function() {
+ fiveui.query(':input').each(
+ function(i, elt) {
+ if (elt.id) {
+ var $label = fiveui.query("label[for='" + elt.id + "']");
+
+ if (1 < $label.size()) {
+ report('Form element has too many labels', elt);
+ }
+
+ if (0 == $label.size()) {
+ report('Form element has no label', elt);
+ }
+ }
+ });
+ }
+ },
+
+ { 'id': 1001802
+ , 'name': "Don't use empty headings."
+ , 'description': 'Empty headings confuse layout.'
+ , 'rule':
+ function() {
+ fiveui.query(':header').each(
+ function(i, elt) {
+ if ($(elt).text() == '') {
+ report('Heading is empty', elt);
+ }
+ });
+ }
+ },
+// --- included from file: colorRules.json --- //
+
+ { 'id': 2141101
+ , 'name': 'Foreground check'
+ , 'description': 'Foreground colors should be in the set:'+
+ '#00 #FF #3D #F7 #C2 #B4 #4E #FFCB05 #7B8738'
, 'rule':
- function () {
- var allow = "#00 #FF #3D #F7 #C2 #B4 #4E #FFCB05 #7B8738".split(" ");
- $5(":visible")
- .cssIsNot("color", allow, fiveui.color.colorToHex)
- .each(function (i, elt) {
- var color = fiveui.color.colorToHex($(elt).css("color"));
- report("foreground color: " + color, elt);
+ function() {
+ var allow = '#00 #FF #3D #F7 #C2 #B4 #4E #FFCB05 #7B8738'.split(' ');
+ $5(':visible')
+ .cssIsNot('color', allow, fiveui.color.colorToHex)
+ .each(function(i, elt) {
+ var color = fiveui.color.colorToHex($(elt).css('color'));
+ report('foreground color: ' + color, elt);
});
}
},
- //----------------------------------------------------------------
- { 'name': "Background check"
- , 'description': "Backgrounds colors should be in the set:" +
- "#00 #FF #3D #F7 #C2 #B4 #4E"
+
+ { 'id': 2141102
+ , 'name': 'Background check'
+ , 'description': 'Backgrounds colors should be in the set:' +
+ '#00 #FF #3D #F7 #C2 #B4 #4E'
, 'rule':
- function () {
- var allow = "#00 #FF #3D #F7 #C2 #B4 #4E".split(" ");
- $5(":visible")
- .cssIsNot("background-color", allow, fiveui.color.colorToHex)
- .each(function (i, elt) {
- var color = fiveui.color.colorToHex($(elt).css("background-color"));
- report("non-standard background color: " + color, elt);
+ function() {
+ var allow = '#00 #FF #3D #F7 #C2 #B4 #4E'.split(' ');
+ $5(':visible')
+ .cssIsNot('background-color', allow, fiveui.color.colorToHex)
+ .each(function(i, elt) {
+ var color = fiveui.color.colorToHex($(elt).css('background-color'));
+ report('non-standard background color: ' + color, $(elt));
});
}
},
- //----------------------------------------------------------------
- { 'name': "Content area color"
- , 'description': "Background color should be: " +
- "#F7"
+
+ { 'id': 2141103
+ , 'name': 'Content area color'
+ , 'description': 'Background color should be: ' +
+ '#F7'
, 'rule':
- function () {
- var allow = "#F7";
- $5("#content")
- .cssIsNot("background-color", allow, fiveui.color.colorToHex)
- .each(function (i, elt) {
- var color = fiveui.color.colorToHex($(elt).css("background-color"));
- report("non-standard content background color: " + color, elt);
+ function() {
+ var allow = '#F7';
+ $5('#content')
+ .cssIsNot('background-color', allow, fiveui.color.colorToHex)
+ .each(function(i, elt) {
+ var color = fiveui.color.colorToHex($(elt).css('background-color'));
+ report('non-standard content background color: ' + color, elt);
});
}
},
- //----------------------------------------------------------------
- { 'name': "Left navigation color"
- , 'description': "Left navigation color should be: " +
- "#C2"
+
+ { 'id': 2141104
+ , 'name': 'Left navigation color'
+ , 'description': 'Left navigation color should be: ' +
+ '#C2'
, 'rule':
- function () {
- var allow = "#C2";
- $5("#leftNav")
- .cssIsNot("color", allow, fiveui.color.colorToHex)
- .each(function (i, elt) {
- var color = fiveui.color.colorToHex($(elt).css("color"));
- report("non-standard left navigation color: " + color, elt);
+ function() {
+ var allow = '#C2';
+ $5('#leftNav')
+ .cssIsNot('color', allow, fiveui.color.colorToHex)
+ .each(function(i, elt) {
+ var color = fiveui.color.colorToHex($(elt).css('color'));
+ report('non-standard left navigation color: ' + color, elt);
});
}
},
- //----------------------------------------------------------------
- { 'name': "Header color check"
- , 'description': "Header color should be: " +
- "#3D"
+
+ { 'id': 2141105
+ , 'name': 'Header color check'
+ , 'description': 'Header color should be: ' +
+ '#3D'
, 'rule':
- function () {
- var allow = "#3D";
- $5(":header")
- .cssIsNot("color", allow, fiveui.color.colorToHex)
- .each(function (i, elt) {
- var color = fiveui.color.colorToHex($(elt).css("color"));
- report("non-standard header color: " + color, elt);
+ function() {
+ var allow = '#3D';
+ $5(':header')
+ .cssIsNot('color', allow, fiveui.color.colorToHex)
+ .each(function(i, elt) {
+ var color = fiveui.color.colorToHex($(elt).css('color'));
+ report('non-standard header color: ' + color, elt);
});
}
},
- //---------------------------------------------------------
- { 'name': "Font properties check"
- , 'description': "Verify that fonts (family, size, weight) are \"standard\""
+// --- included from file: emptyHeadings.json --- //
+
+ { 'id': 4121501
+ , 'name': 'Disallow Empty Headers'
+ , 'description': 'Heading elements should contain text.'
+ , 'rule': function() {
+ fiveui.query(':header').each(function(ix, elt) {
+ if ($(elt).text() == '') {
+ report('Heading does not contain text', elt);
+ }
+ });
+ }
+ },
+// --- included from file: fontRules.json --- //
+
+ { 'id': 5141301
+ , 'name': 'Font properties check'
+ , 'description': 'Verify that fonts (family, size, weight) are \"standard\"'
, 'rule':
function() {
var allow = {
- "Verdana": { "bold": [25, 22, 12, 10]
- , "normal": [12, 11, 10] }};
+ 'Verdana': { 'bold': [25, 22, 12, 10]
+ , 'normal': [12, 11, 10] }};
fiveui.query('body p,:header').each(
function(i, elt) {
var font = fiveui.font.getFont($(elt));
if (!fiveui.font.validate(allow, font)) {
report('non-standard font: ' +
- font.family + ", " +
- font.size + ", " +
- font.weight, $(elt));
+ font.family + ', ' +
+ font.size + ', ' +
+ font.weight, elt);
}
});
}
},
- //----------------------------------------------------------------
- { 'name': "Banner check"
- , 'description': "Banner image banner.gif must appear and link to somewhere"
+// --- included from file: headingGuidelines.json --- //
+
+ { 'id': 7040001
+ , 'name': 'Headings are capitalized'
+ , 'description': 'Check to see if all headings use leading capital letters'
+ , 'rule':
+ function() {
+ var badHeadings =
+ fiveui.query(':header').filter(
+ function(idx) {
+ var ch = $(this).text()[0];
+ if (ch) {
+ return (ch == ch.toLowerCase());
+ } else {
+ return false;
+ }
+ });
+ $(badHeadings).map(function(idx, elt) {
+ report('Heading does not start with a capital letter', elt);
+ });
+
+ }
+ },
+
+ { 'id': 7040002
+ , 'name': 'Disallow Empty Headers'
+ , 'description': 'Heading elements should contain text'
+ , 'rule': function() {
+ fiveui.query(':header').each(
+ function(ix, elt) {
+ if ($(elt).text() == '') {
+ report('Heading does not contain text', elt);
+ }
+ });
+ }
+ },
+// --- included from file: imageRules.json --- //
+
+ { 'id': 8120001
+ , 'name': 'Banner check'
+ , 'description': 'Banner image banner.gif must appear and link to somewhere'
, 'severity': 1
, 'rule':
function() {
- var elt = $5("div[id=header]"); // get the div with id=header
- var b = elt.css("background"); // get its background CSS property
- var l = $5("a[href]", elt).prop("href"); // get the <a href=...> string inside the div
+ var elt = $5('div[id=header]');
+ var b = $5(elt).css('background');
+ var l = $5('a[href]', elt).prop('href');
if (/banner\.gif/.test(b)) {
- report("banner.gif missing", elt);
+ report('banner.gif missing', elt);
}
- if (l.length == 0) { // this list will be empty if there is no link
- report("banner.gif link is missing", elt);
+ if (l === null || l.length == 0) {
+ report('banner.gif link is missing', elt);
}
}
},
- //----------------------------------------------------------------
- { 'name': "Image Size check"
- , 'description': "All site images should have height and width in a given set of choices"
+
+ { 'id': 8120002
+ , 'name': 'Image Size check'
+ , 'description': 'All site images should have height and width in a given set of choices'
, 'severity': 2
, 'rule':
function() {
- var allowedDimensions = { 446: { 300: {}} // allow any image with these height:width pairs
+ var allowedDimensions = { 446: { 300: {}}
, 342: { 228: {}}
, 150: { 100: {}} };
- var specialWidths = { 640: {} // allow any image with these special widths
+ var specialWidths = { 640: {}
, 100: {} };
- $5("img").not("div.filmstrip *") // skip filmstrip images
- .each(function (i, elt) {
- var borderStr = /^[0-9]+/.exec($(elt).css("border")); // compensate for image border
+ $5('img').not('div.filmstrip *')
+ .each(function(i, elt) {
+ var borderStr = /^[0-9]+/.exec($(elt).css('border'));
var border = borderStr ? parseInt(borderStr[0]) : 0;
- var w = $(elt).width() + 2*border;
- var h = $(elt).height() + 2*border;
+ var w = $(elt).width() + 2 * border;
+ var h = $(elt).height() + 2 * border;
if (!((w in specialWidths) ||
(h in allowedDimensions && w in allowedDimensions[h]))) {
- report("non-standard dimensions "+h+"x"+w, elt);
+ report('non-standard dimensions ' + h + 'x' + w, elt);
}
});
}
},
- //----------------------------------------------------------------
- { 'name': "Image Border check"
- , 'description': "All site images should have 1px solid #3D border"
+
+ { 'id': 8120003
+ , 'name': 'Image Border check'
+ , 'description': 'All site images should have 1px solid #3D border'
, 'severity': 1
, 'rule':
function() {
- var norm = function (s) { return /^\w+\s+\w+/.exec(s)[0]; } // select out first two words of the input
- var imgs = $5("img").not("div.filmstrip *"); // select images not in the filmstrip
- imgs.cssIsNot("border", "1px solid", norm)
- .each(function (i, elt) {
- report("non-standard border style", elt);
+
+ var norm = function(s) {
+ if (/^\w+\s+\w+/.exec(s))
+ return /^\w+\s+\w+/.exec(s)[0];
+ else
+ return 'null null';
+ };
+ var imgs = $5('img').not('div.filmstrip *');
+ imgs.cssIsNot('border', '1px solid', norm)
+ .each(function(i, elt) {
+ report('non-standard border style', elt);
});
- imgs.cssIsNot("border-color", "#3D3D3D", fiveui.color.colorToHex)
- .each(function (i, elt) {
- report("non-standard border color", elt);
+ imgs.cssIsNot('border-color', '#3D3D3D', fiveui.color.colorToHex)
+ .each(function(i, elt) {
+ report('non-standard border color', elt);
});
}
},
-//------------
- { "id": 1
- , "name": "Headings are capitalized"
- , "description": "Check to see if all headings use leading capital letters"
- , "rule":
- function() {
- var badHeadings =
- fiveui.query(':header').filter(
- function(idx) {
- var ch = $(this).text()[0];
- if (ch) {
- return (ch == ch.toLowerCase() );
- } else {
- return false;
- }
- });
- $(badHeadings).map(function(idx, elt){
- report('Heading does not start with a capital letter', elt);
- });
-
- }
- },
-//------------
- { "id": 2
- , "name": "Disallow Empty Headers"
- , "description": "Heading elements should contain text"
- , "rule": function() {
- fiveui.query(':header').each(
- function(ix, elt) {
- if($(elt).text() == '') {
- report('Heading does not contain text', elt);
- }
- });
- }
- },
- //---------------------------------------------------------
- { 'name': "Footer check"
- , 'description': "Footer should appear on the page"
+// --- included from file: miscRules.json --- //
+
+ { 'id': 12081801
+ , 'name': 'Footer check'
+ , 'description': 'Footer should appear on the page'
, 'rule':
function() {
- if ($5("div.footer").length === 0) {
+ if ($5('div.footer').length === 0) {
report('Footer does not appear', elt);
}
}
},
- //---------------------------------------------------------
- { 'name': "Main content width check"
- , 'description': "Main content div should be between 520px and 1200px wide"
+
+ { 'id': 12081802
+ , 'name': 'Main content width check'
+ , 'description': 'Main content div should be between 520px and 1200px wide'
, 'rule':
function() {
var width;
- var elt = $5("#content");
+ var elt = $5('#content');
if (elt) {
width = elt.width();
if (width > 1200) {
@@ -217,11 +314,35 @@
}
}
},
- //---------------------------------------------------------------
- { "id": 13
- , "name": "Sentence case"
- , "description": "Titles should be written in sentence case"
- , "rule":
+// --- included from file: reportOnSampleText.json --- //
+
+ { 'id': 17041501
+ , 'name': 'Test rule'
+ , 'description': 'An empty test rule'
+ , 'rule': function() {
+ fiveui.query('p').each(
+ function(idx, elt) {
+ if ($(elt).text().indexOf('Sample text') != -1) {
+ report('test error', elt);
+ }
+ });
+ }
+ },
+// --- included from file: simpleRuleSet1.json --- //
+// --- included from file: template.json --- //
+
+ { 'id': 123456789
+ , 'name': 'RULE NAME'
+ , 'description': 'RULE DESC'
+ , 'rule':
+ function() {}
+ },
+// --- included from file: textRules.json --- //
+
+ { 'id': 19042301
+ , 'name': 'Sentence case'
+ , 'description': 'Titles should be written in sentence case'
+ , 'rule':
function() {
var posLength = function(ar) {
return 1 <= ar.length;
@@ -233,60 +354,45 @@
var assertSentenceCase = function(inStr, elt) {
var str = fiveui.string.trim(inStr);
- if ( !fiveui.word.capitalized(str[0]) ) {
- report('The heading: "'+str+'" is not in sentence case.', elt);
+ if (!fiveui.word.capitalized(str[0])) {
+ report('The heading: [' + str + '] is not in sentence case.', elt);
return;
}
var tokens = str.split(' ').filter(posLength);
- for (var i=1; i < tokens.length; ++i) {
+ for (var i = 1; i < tokens.length; ++i) {
if (fiveui.word.capitalized(tokens[i])) {
- report('The heading: "'+str+'" is not in sentence case.', elt);
+ report('The heading: [' + str + '] is not in sentence case.', elt);
return;
}
}
};
fiveui.query(':header').each(function(idx, elt) {
- assertSentenceCase($(elt).text(), elt);
- });
+ assertSentenceCase($(elt).text(), elt);
+ });
}
},
- //---------------------------------------------------------------
- { "id":12
- , "name": "Capitalization check"
- , "description": "Capitalize \"Galois\" and \"Galwegian\" when referring to the company"
- , "rule":
+
+ { 'id': 19042302
+ , 'name': 'Capitalization check'
+ , 'description': 'Capitalize \"Galois\" and \"Galwegian\" when referring to the company'
+ , 'rule':
function() {
- fiveui.query('*').hasText('galois').each(function (i, elt) {
- report('"Galois" should be capitalized', elt);
- })
+ fiveui.query('*').hasText('galois').each(function(i, elt) {
+ report('\"Galois\" should be capitalized', elt);
+ });
- fiveui.query('*').hasText('galwegian').each(function (i, elt) {
- report('"Galwegian" should be capitalized', elt);
- })
+ fiveui.query('*').hasText('galwegian').each(function(i, elt) {
+ report('\"Galwegian\" should be capitalized', elt);
+ });
}
},
-//---------------------------------
- { "id":13
- , "name": "Reports three times"
- , "description": "Test guideline that reports three errors"
- , "rule":
- function() {
- report('Problem 1 (g1)', null);
- report('Problem 3 (g1)', null);
- report('Problem 2 (g1)', null);
- }
- },
-//---------------------------------
- { "id":14
- , "name": "Reports two times"
- , "description": "Test guideline that reports two errors."
- , "rule":
- function() {
- report('Problem 1 (g2)', null);
- report('Problem 2 (g2)', null);
- }
+// --- included from file: trivialReport.json --- //
+
+ { 'id': 191708, 'name': 'Test rule',
+ 'description': 'An empty test rule',
+ 'rule': function() { report('test error'); }
}
]}