Skip to content

Commit 06c7d5f

Browse files
committed
feat(rule): no 値を返却する
1 parent 100e49f commit 06c7d5f

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
},
4343
"dependencies": {
4444
"kuromojin": "^1.3.1",
45-
"morpheme-match": "^1.0.1"
45+
"morpheme-match": "^1.0.1",
46+
"textlint-rule-prh": "^3.1.1"
4647
}
47-
}
48+
}

src/no-restitution-value.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 1
2+
rules:
3+
- expected: 値を返却する
4+
patterns: 値を返す
5+
- expected: $1の返り値
6+
patterns: /(メソッド|関数)の返却値/
7+
specs:
8+
- from: これはメソッドの返却値
9+
to: これはメソッドの返り値
10+
- from: 関数の返却値
11+
to: 関数の返り値

src/textlint-rule-ja-no-abusage.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// LICENSE : MIT
22
"use strict";
33
const tokenize = require("kuromojin").tokenize;
4+
const fs = require("fs");
5+
const path = require("path");
6+
const prh = require("textlint-rule-prh");
47
const dictionaryList = require("./no-confusing-adjust-and-apply");
58
const createTokenMatcher = require("morpheme-match");
69
const reporter = (context) => {
@@ -12,9 +15,16 @@ const reporter = (context) => {
1215
expected: dict["expected"]
1316
};
1417
});
18+
const prhLinter = prh.linter;
19+
const prhStr = prhLinter(context, {
20+
ruleContents:[
21+
fs.readFileSync(path.join(__dirname, "no-restitution-value.yml"))
22+
]
23+
});
1524
return {
1625
[Syntax.Str](node){
1726
const text = getSource(node);
27+
prhStr[Syntax.Str](node);
1828
return tokenize(text).then(currentTokens => {
1929
currentTokens.forEach(token => {
2030
matcherList.forEach(({matcher, message, expected}) => {

0 commit comments

Comments
 (0)