From c4f81056861039afdfd8b02be241b2a5c52f13b1 Mon Sep 17 00:00:00 2001 From: azu Date: Wed, 8 Jun 2016 23:07:47 +0900 Subject: [PATCH] feat(src): support "filter" field --- src/textlintrc-to-pacakge-list.js | 6 +++++- test/fixtures/.textlintrc.json | 3 +++ test/textlintrc-to-pacakge-list-test.js | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/textlintrc-to-pacakge-list.js b/src/textlintrc-to-pacakge-list.js index b1f2548..0f21248 100644 --- a/src/textlintrc-to-pacakge-list.js +++ b/src/textlintrc-to-pacakge-list.js @@ -9,11 +9,15 @@ function validRulePackageKey(key) { export default function listPackageName(configJSON) { const plugins = Array.isArray(configJSON["plugins"]) ? configJSON["plugins"] : []; const rules = configJSON["rules"] || {}; + const filterRules = configJSON["filters"] || {}; const pluginsNameList = plugins.map(key => { return `textlint-plugin-${key}`; }); const ruleNameList = Object.keys(rules).filter(validRulePackageKey).map(key => { return `textlint-rule-${key}`; }); - return [].concat(pluginsNameList, ruleNameList); + const filterRuleNameList = Object.keys(filterRules).filter(validRulePackageKey).map(key => { + return `textlint-filter-rule-${key}`; + }); + return [].concat(pluginsNameList, filterRuleNameList, ruleNameList); } \ No newline at end of file diff --git a/test/fixtures/.textlintrc.json b/test/fixtures/.textlintrc.json index e2d6a12..0a027b7 100644 --- a/test/fixtures/.textlintrc.json +++ b/test/fixtures/.textlintrc.json @@ -2,6 +2,9 @@ "plugins": [ "jtf-style" ], + "filters": { + "comments": true + }, "rules": { "max-ten": { "max": 3 diff --git a/test/textlintrc-to-pacakge-list-test.js b/test/textlintrc-to-pacakge-list-test.js index b4de70d..081dba1 100644 --- a/test/textlintrc-to-pacakge-list-test.js +++ b/test/textlintrc-to-pacakge-list-test.js @@ -9,6 +9,7 @@ describe("textlintrc-to-pacakge-list", function () { var names = listPackageNames(config); assert.deepEqual(names, [ "textlint-plugin-jtf-style", + "textlint-filter-rule-comments", "textlint-rule-max-ten", "textlint-rule-no-doubled-joshi", "textlint-rule-sentence-length",