Skip to content

Commit

Permalink
Simplify schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
btmills committed Apr 7, 2015
1 parent 01f7048 commit 8c3008d
Show file tree
Hide file tree
Showing 24 changed files with 246 additions and 325 deletions.
30 changes: 13 additions & 17 deletions lib/rules/brace-style.js
Expand Up @@ -203,21 +203,17 @@ module.exports = function(context) {

};

module.exports.schema = {
"items": [
{
"type": "string",
"enum": ["1tbs", "stroustrup"]
module.exports.schema = [
{
"enum": ["1tbs", "stroustrup"]
},
{
"type": "object",
"properties": {
"allowSingleLine": {
"type": "boolean"
}
},
{
"type": "object",
"properties": {
"allowSingleLine": {
"type": "boolean"
}
},
"additionalProperties": false
}
],
"maxItems": 2
};
"additionalProperties": false
}
];
24 changes: 10 additions & 14 deletions lib/rules/camelcase.js
Expand Up @@ -98,18 +98,14 @@ module.exports = function(context) {

};

module.exports.schema = {
"items": [
{
"type": "object",
module.exports.schema = [
{
"type": "object",
"properties": {
"properties": {
"properties": {
"type": "string",
"enum": ["always", "never"]
}
},
"additionalProperties": false
}
],
"maxItems": 1
};
"enum": ["always", "never"]
}
},
"additionalProperties": false
}
];
14 changes: 5 additions & 9 deletions lib/rules/comma-dangle.js
Expand Up @@ -57,12 +57,8 @@ module.exports = function (context) {
};
};

module.exports.schema = {
"items": [
{
"type": "string",
"enum": ["always", "always-multiline", "never"]
}
],
"maxItems": 1
};
module.exports.schema = [
{
"enum": ["always", "always-multiline", "never"]
}
];
29 changes: 13 additions & 16 deletions lib/rules/comma-spacing.js
Expand Up @@ -158,20 +158,17 @@ module.exports = function(context) {

};

module.exports.schema = {
"items": [
{
"type": "object",
"properties": {
"before": {
"type": "boolean"
},
"after": {
"type": "boolean"
}
module.exports.schema = [
{
"type": "object",
"properties": {
"before": {
"type": "boolean"
},
"additionalProperties": false
}
],
"maxItems": 1
};
"after": {
"type": "boolean"
}
},
"additionalProperties": false
}
];
14 changes: 5 additions & 9 deletions lib/rules/curly.js
Expand Up @@ -102,12 +102,8 @@ module.exports = function(context) {

};

module.exports.schema = {
"items": [
{
"type": "string",
"enum": ["all", "multi", "multi-line"]
}
],
"maxItems": 1
};
module.exports.schema = [
{
"enum": ["all", "multi", "multi-line"]
}
];
29 changes: 13 additions & 16 deletions lib/rules/dot-notation.js
Expand Up @@ -103,20 +103,17 @@ module.exports = function(context) {
};
};

module.exports.schema = {
"items": [
{
"type": "object",
"properties": {
"allowKeywords": {
"type": "boolean"
},
"allowPattern": {
"type": "string"
}
module.exports.schema = [
{
"type": "object",
"properties": {
"allowKeywords": {
"type": "boolean"
},
"additionalProperties": false
}
],
"maxItems": 1
};
"allowPattern": {
"type": "string"
}
},
"additionalProperties": false
}
];
14 changes: 5 additions & 9 deletions lib/rules/eqeqeq.js
Expand Up @@ -89,12 +89,8 @@ module.exports = function(context) {

};

module.exports.schema = {
"items": [
{
"type": "string",
"enum": ["smart", "allow-null"]
}
],
"maxItems": 1
};
module.exports.schema = [
{
"enum": ["smart", "allow-null"]
}
];
36 changes: 16 additions & 20 deletions lib/rules/key-spacing.js
Expand Up @@ -306,24 +306,20 @@ module.exports = function(context) {

};

module.exports.schema = {
"items": [
{
"type": "object",
"properties": {
"align": {
"type": "string",
"enum": ["colon", "value"]
},
"beforeColon": {
"type": "boolean"
},
"afterColon": {
"type": "boolean"
}
module.exports.schema = [
{
"type": "object",
"properties": {
"align": {
"enum": ["colon", "value"]
},
"additionalProperties": false
}
],
"maxItems": 1
};
"beforeColon": {
"type": "boolean"
},
"afterColon": {
"type": "boolean"
}
},
"additionalProperties": false
}
];
28 changes: 12 additions & 16 deletions lib/rules/max-len.js
Expand Up @@ -32,9 +32,9 @@ module.exports = function(context) {
return result;
}

var tabWidth = context.options[1];
var tabWidth = context.options[1] || 4; // TODO: Add tests for default

var maxLength = context.options[0],
var maxLength = context.options[0] || 80,
tabString = stringRepeat(" ", tabWidth);

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -64,17 +64,13 @@ module.exports = function(context) {

};

module.exports.schema = {
"items": [
{
"type": "integer",
"minimum": 0
},
{
"type": "integer",
"minimum": 0
}
],
"minItems": 2,
"maxItems": 2
};
module.exports.schema = [
{
"type": "integer",
"minimum": 0
},
{
"type": "integer",
"minimum": 0
}
];
51 changes: 24 additions & 27 deletions lib/rules/new-cap.js
Expand Up @@ -196,32 +196,29 @@ module.exports = function(context) {
return listeners;
};

module.exports.schema = {
"items": [
{
"type": "object",
"properties": {
"newIsCap": {
"type": "boolean"
},
"capIsNew": {
"type": "boolean"
},
"newIsCapExceptions": {
"type": "array",
"items": {
"type": "string"
}
},
"capIsNewExceptions": {
"type": "array",
"items": {
"type": "string"
}
module.exports.schema = [
{
"type": "object",
"properties": {
"newIsCap": {
"type": "boolean"
},
"capIsNew": {
"type": "boolean"
},
"newIsCapExceptions": {
"type": "array",
"items": {
"type": "string"
}
},
"additionalProperties": false
}
],
"maxItems": 1
};
"capIsNewExceptions": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
}
];
14 changes: 5 additions & 9 deletions lib/rules/no-cond-assign.js
Expand Up @@ -116,12 +116,8 @@ module.exports = function(context) {

};

module.exports.schema = {
"items": [
{
"type": "string",
"enum": ["except-parens", "always"]
}
],
"maxItems": 1
};
module.exports.schema = [
{
"enum": ["except-parens", "always"]
}
];
14 changes: 5 additions & 9 deletions lib/rules/no-inner-declarations.js
Expand Up @@ -71,12 +71,8 @@ module.exports = function(context) {

};

module.exports.schema = {
"items": [
{
"type": "string",
"enum": ["functions", "both"]
}
],
"maxItems": 1
};
module.exports.schema = [
{
"enum": ["functions", "both"]
}
];
13 changes: 5 additions & 8 deletions lib/rules/no-mixed-spaces-and-tabs.js
Expand Up @@ -67,11 +67,8 @@ module.exports = function(context) {

};

module.exports.schema = {
"items": [
{
"enum": ["smart-tabs", true, false]
}
],
"maxItems": 1
};
module.exports.schema = [
{
"enum": ["smart-tabs", true, false]
}
];

0 comments on commit 8c3008d

Please sign in to comment.