From 5d9b32e8dce446116655c1aacb9c1aabcbb045e7 Mon Sep 17 00:00:00 2001 From: David Anson Date: Mon, 2 Mar 2015 22:45:43 -0800 Subject: [PATCH] Add "default" rule to config, use to simplify JSON styles. --- lib/markdownlint.js | 6 ++-- styles/all.json | 33 +--------------------- test/incorrect_bullet_style_asterisk.json | 34 ++--------------------- test/incorrect_bullet_style_dash.json | 34 ++--------------------- test/incorrect_bullet_style_plus.json | 34 ++--------------------- test/incorrect_header_atx.json | 34 ++--------------------- test/incorrect_header_atx_closed.json | 34 ++--------------------- test/incorrect_header_setext.json | 34 ++--------------------- test/lists_without_blank_lines.json | 34 ++--------------------- 9 files changed, 19 insertions(+), 258 deletions(-) diff --git a/lib/markdownlint.js b/lib/markdownlint.js index 756ca0d5..e6c8731c 100644 --- a/lib/markdownlint.js +++ b/lib/markdownlint.js @@ -22,9 +22,11 @@ function lintFile(file, config, callback) { "lines": contents.split(/\r\n|\r|\n/g) }; var result = {}; + var configDefault = config.default; + var defaultRule = (configDefault !== undefined) && !!configDefault; rules.forEach(function forRule(rule) { var ruleConfig = config[rule.name]; - if ((ruleConfig === undefined) || ruleConfig) { + if (ruleConfig || (defaultRule && (ruleConfig === undefined))) { params.options = (ruleConfig instanceof Object) ? ruleConfig : {}; var errors = []; rule.func(params, errors); @@ -42,7 +44,7 @@ function lintFile(file, config, callback) { module.exports = function markdownlint(options, callback) { options = options || {}; var files = options.files || []; - var config = options.config || {}; + var config = options.config || { "default": true }; var results = {}; function lintFiles() { var file = files.shift(); diff --git a/styles/all.json b/styles/all.json index f6dd6df4..e55dc9f8 100644 --- a/styles/all.json +++ b/styles/all.json @@ -1,34 +1,3 @@ { - "MD001": true, - "MD002": true, - "MD003": true, - "MD004": true, - "MD005": true, - "MD006": true, - "MD007": true, - "MD008": true, - "MD009": true, - "MD010": true, - "MD011": true, - "MD012": true, - "MD013": true, - "MD014": true, - "MD015": true, - "MD016": true, - "MD017": true, - "MD018": true, - "MD019": true, - "MD020": true, - "MD021": true, - "MD022": true, - "MD023": true, - "MD024": true, - "MD025": true, - "MD026": true, - "MD027": true, - "MD028": true, - "MD029": true, - "MD030": true, - "MD031": true, - "MD032": true + "default": true } diff --git a/test/incorrect_bullet_style_asterisk.json b/test/incorrect_bullet_style_asterisk.json index a9e7899d..acd390bd 100644 --- a/test/incorrect_bullet_style_asterisk.json +++ b/test/incorrect_bullet_style_asterisk.json @@ -1,36 +1,6 @@ { - "MD001": true, - "MD002": true, - "MD003": true, + "default": true, "MD004": { "style": "asterisk" - }, - "MD005": true, - "MD006": true, - "MD007": true, - "MD008": true, - "MD009": true, - "MD010": true, - "MD011": true, - "MD012": true, - "MD013": true, - "MD014": true, - "MD015": true, - "MD016": true, - "MD017": true, - "MD018": true, - "MD019": true, - "MD020": true, - "MD021": true, - "MD022": true, - "MD023": true, - "MD024": true, - "MD025": true, - "MD026": true, - "MD027": true, - "MD028": true, - "MD029": true, - "MD030": true, - "MD031": true, - "MD032": true + } } diff --git a/test/incorrect_bullet_style_dash.json b/test/incorrect_bullet_style_dash.json index ca37b04f..c77c94bf 100644 --- a/test/incorrect_bullet_style_dash.json +++ b/test/incorrect_bullet_style_dash.json @@ -1,36 +1,6 @@ { - "MD001": true, - "MD002": true, - "MD003": true, + "default": true, "MD004": { "style": "dash" - }, - "MD005": true, - "MD006": true, - "MD007": true, - "MD008": true, - "MD009": true, - "MD010": true, - "MD011": true, - "MD012": true, - "MD013": true, - "MD014": true, - "MD015": true, - "MD016": true, - "MD017": true, - "MD018": true, - "MD019": true, - "MD020": true, - "MD021": true, - "MD022": true, - "MD023": true, - "MD024": true, - "MD025": true, - "MD026": true, - "MD027": true, - "MD028": true, - "MD029": true, - "MD030": true, - "MD031": true, - "MD032": true + } } diff --git a/test/incorrect_bullet_style_plus.json b/test/incorrect_bullet_style_plus.json index ca394a6d..435f296c 100644 --- a/test/incorrect_bullet_style_plus.json +++ b/test/incorrect_bullet_style_plus.json @@ -1,36 +1,6 @@ { - "MD001": true, - "MD002": true, - "MD003": true, + "default": true, "MD004": { "style": "plus" - }, - "MD005": true, - "MD006": true, - "MD007": true, - "MD008": true, - "MD009": true, - "MD010": true, - "MD011": true, - "MD012": true, - "MD013": true, - "MD014": true, - "MD015": true, - "MD016": true, - "MD017": true, - "MD018": true, - "MD019": true, - "MD020": true, - "MD021": true, - "MD022": true, - "MD023": true, - "MD024": true, - "MD025": true, - "MD026": true, - "MD027": true, - "MD028": true, - "MD029": true, - "MD030": true, - "MD031": true, - "MD032": true + } } diff --git a/test/incorrect_header_atx.json b/test/incorrect_header_atx.json index ef5558cf..aa2692a1 100644 --- a/test/incorrect_header_atx.json +++ b/test/incorrect_header_atx.json @@ -1,36 +1,6 @@ { - "MD001": true, - "MD002": true, + "default": true, "MD003": { "style": "atx" - }, - "MD004": true, - "MD005": true, - "MD006": true, - "MD007": true, - "MD008": true, - "MD009": true, - "MD010": true, - "MD011": true, - "MD012": true, - "MD013": true, - "MD014": true, - "MD015": true, - "MD016": true, - "MD017": true, - "MD018": true, - "MD019": true, - "MD020": true, - "MD021": true, - "MD022": true, - "MD023": true, - "MD024": true, - "MD025": true, - "MD026": true, - "MD027": true, - "MD028": true, - "MD029": true, - "MD030": true, - "MD031": true, - "MD032": true + } } diff --git a/test/incorrect_header_atx_closed.json b/test/incorrect_header_atx_closed.json index 2932411b..a7764db7 100644 --- a/test/incorrect_header_atx_closed.json +++ b/test/incorrect_header_atx_closed.json @@ -1,36 +1,6 @@ { - "MD001": true, - "MD002": true, + "default": true, "MD003": { "style": "atx_closed" - }, - "MD004": true, - "MD005": true, - "MD006": true, - "MD007": true, - "MD008": true, - "MD009": true, - "MD010": true, - "MD011": true, - "MD012": true, - "MD013": true, - "MD014": true, - "MD015": true, - "MD016": true, - "MD017": true, - "MD018": true, - "MD019": true, - "MD020": true, - "MD021": true, - "MD022": true, - "MD023": true, - "MD024": true, - "MD025": true, - "MD026": true, - "MD027": true, - "MD028": true, - "MD029": true, - "MD030": true, - "MD031": true, - "MD032": true + } } diff --git a/test/incorrect_header_setext.json b/test/incorrect_header_setext.json index 0bea61ce..0a9cf563 100644 --- a/test/incorrect_header_setext.json +++ b/test/incorrect_header_setext.json @@ -1,36 +1,6 @@ { - "MD001": true, - "MD002": true, + "default": true, "MD003": { "style": "setext" - }, - "MD004": true, - "MD005": true, - "MD006": true, - "MD007": true, - "MD008": true, - "MD009": true, - "MD010": true, - "MD011": true, - "MD012": true, - "MD013": true, - "MD014": true, - "MD015": true, - "MD016": true, - "MD017": true, - "MD018": true, - "MD019": true, - "MD020": true, - "MD021": true, - "MD022": true, - "MD023": true, - "MD024": true, - "MD025": true, - "MD026": true, - "MD027": true, - "MD028": true, - "MD029": true, - "MD030": true, - "MD031": true, - "MD032": true + } } diff --git a/test/lists_without_blank_lines.json b/test/lists_without_blank_lines.json index 5c61583e..d74a3913 100644 --- a/test/lists_without_blank_lines.json +++ b/test/lists_without_blank_lines.json @@ -1,34 +1,4 @@ { - "MD001": true, - "MD002": true, - "MD003": true, - "MD004": false, - "MD005": true, - "MD006": true, - "MD007": true, - "MD008": true, - "MD009": true, - "MD010": true, - "MD011": true, - "MD012": true, - "MD013": true, - "MD014": true, - "MD015": true, - "MD016": true, - "MD017": true, - "MD018": true, - "MD019": true, - "MD020": true, - "MD021": true, - "MD022": true, - "MD023": true, - "MD024": true, - "MD025": true, - "MD026": true, - "MD027": true, - "MD028": true, - "MD029": true, - "MD030": true, - "MD031": true, - "MD032": true + "default": true, + "MD004": false }