Skip to content

Commit

Permalink
feat(src): support "filter" field
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Jun 8, 2016
1 parent a086e60 commit c4f8105
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/textlintrc-to-pacakge-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 3 additions & 0 deletions test/fixtures/.textlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"plugins": [
"jtf-style"
],
"filters": {
"comments": true
},
"rules": {
"max-ten": {
"max": 3
Expand Down
1 change: 1 addition & 0 deletions test/textlintrc-to-pacakge-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c4f8105

Please sign in to comment.