Skip to content

Commit

Permalink
feat(rule): no 値を返却する
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Jun 19, 2016
1 parent 100e49f commit 06c7d5f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
},
"dependencies": {
"kuromojin": "^1.3.1",
"morpheme-match": "^1.0.1"
"morpheme-match": "^1.0.1",
"textlint-rule-prh": "^3.1.1"
}
}
}
11 changes: 11 additions & 0 deletions src/no-restitution-value.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 1
rules:
- expected: 値を返却する
patterns: 値を返す
- expected: $1の返り値
patterns: /(メソッド|関数)の返却値/
specs:
- from: これはメソッドの返却値
to: これはメソッドの返り値
- from: 関数の返却値
to: 関数の返り値
10 changes: 10 additions & 0 deletions src/textlint-rule-ja-no-abusage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// LICENSE : MIT
"use strict";
const tokenize = require("kuromojin").tokenize;
const fs = require("fs");
const path = require("path");
const prh = require("textlint-rule-prh");
const dictionaryList = require("./no-confusing-adjust-and-apply");
const createTokenMatcher = require("morpheme-match");
const reporter = (context) => {
Expand All @@ -12,9 +15,16 @@ const reporter = (context) => {
expected: dict["expected"]
};
});
const prhLinter = prh.linter;
const prhStr = prhLinter(context, {
ruleContents:[
fs.readFileSync(path.join(__dirname, "no-restitution-value.yml"))
]
});
return {
[Syntax.Str](node){
const text = getSource(node);
prhStr[Syntax.Str](node);
return tokenize(text).then(currentTokens => {
currentTokens.forEach(token => {
matcherList.forEach(({matcher, message, expected}) => {
Expand Down

0 comments on commit 06c7d5f

Please sign in to comment.