From 998e6546b172850a7f51d0e4e1d50017b655a80e Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Mon, 3 Jun 2013 17:11:35 -0700 Subject: Switch to a CommonJS format for rule definitions Rules are now defined as CommonJS modules, using the exports object as the external facing API for the rule. --- exampleData/ruleSets/backgroundCheck.js | 10 ---------- exampleData/ruleSets/colorRules.json | 20 +++++--------------- exampleData/ruleSets/colorRules/backgroundCheck.js | 18 ++++++++++++++++++ exampleData/ruleSets/colorRules/foregroundCheck.js | 16 ++++++++++++++++ exampleData/ruleSets/foregroundCheck.js | 9 --------- 5 files changed, 39 insertions(+), 34 deletions(-) delete mode 100644 exampleData/ruleSets/backgroundCheck.js create mode 100644 exampleData/ruleSets/colorRules/backgroundCheck.js create mode 100644 exampleData/ruleSets/colorRules/foregroundCheck.js delete mode 100644 exampleData/ruleSets/foregroundCheck.js (limited to 'exampleData') diff --git a/exampleData/ruleSets/backgroundCheck.js b/exampleData/ruleSets/backgroundCheck.js deleted file mode 100644 index 7da59aa..0000000 --- a/exampleData/ruleSets/backgroundCheck.js +++ /dev/null @@ -1,10 +0,0 @@ -function() { - var allow = '#00 #FF #3D #F7 #C2 #B4 #4E'.split(' '); - report("broken"); - $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)); - }); -} diff --git a/exampleData/ruleSets/colorRules.json b/exampleData/ruleSets/colorRules.json index 54fb549..bcfce72 100644 --- a/exampleData/ruleSets/colorRules.json +++ b/exampleData/ruleSets/colorRules.json @@ -6,20 +6,10 @@ { "name": "Color Guidelines" , "description": "Foreground/background color guidelines" -, "rules": [ - //---------------------------------------------------------------- - { "name": "Foreground check" - , "description": ["Foreground colors should be in the set: \n", - "#00 #FF #3D #F7 #C2 #B4 #4E #FFCB05 #7B8738"] - , "file": "foregroundCheck.js" - }, - //---------------------------------------------------------------- - { "name": "Background check" - , "description": ["Backgrounds colors should be in the set:", - "#00 #FF #3D #F7 #C2 #B4 #4E"] - , "file": "backgroundCheck.js" - } -] +, "rules": + [ "colorRules/foregroundCheck.js" + , "colorRules/backgroundCheck.js" + ] } //---------------------------------------------------------------- /* { "id": 2141103 @@ -72,4 +62,4 @@ //---------------------------------------------------------------- ] } - */ \ No newline at end of file + */ diff --git a/exampleData/ruleSets/colorRules/backgroundCheck.js b/exampleData/ruleSets/colorRules/backgroundCheck.js new file mode 100644 index 0000000..4ce7043 --- /dev/null +++ b/exampleData/ruleSets/colorRules/backgroundCheck.js @@ -0,0 +1,18 @@ + +exports.name = 'Foreground Check'; + +exports.description = + [ 'Foreground colors should be in the set:' + , '#00 #FF #3D #F7 #C2 #B4 #4E #FFCB05 #7B8738' + ].join('\n'); + +exports.rule = function() { + var allow = '#00 #FF #3D #F7 #C2 #B4 #4E'.split(' '); + report("broken"); + $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)); + }); +}; diff --git a/exampleData/ruleSets/colorRules/foregroundCheck.js b/exampleData/ruleSets/colorRules/foregroundCheck.js new file mode 100644 index 0000000..5b1e04b --- /dev/null +++ b/exampleData/ruleSets/colorRules/foregroundCheck.js @@ -0,0 +1,16 @@ +exports.name = 'Background Check'; + +exports.description = + [ 'Backgrounds colors should be in the set:' + , '#00 #FF #3D #F7 #C2 #B4 #4E' + ].join('\n'); + +exports.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); + }); +}; diff --git a/exampleData/ruleSets/foregroundCheck.js b/exampleData/ruleSets/foregroundCheck.js deleted file mode 100644 index 32a8ee5..0000000 --- a/exampleData/ruleSets/foregroundCheck.js +++ /dev/null @@ -1,9 +0,0 @@ -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); - }); -} -- cgit v1.2.3