diff --git a/src/no-dropping-the-ra.js b/src/no-dropping-the-ra.js index 4adb887..2955c7a 100644 --- a/src/no-dropping-the-ra.js +++ b/src/no-dropping-the-ra.js @@ -16,6 +16,11 @@ function isRaWord(token) { token.basic_form == 'れる' } +function isKoreru(token) { + return token.pos == '動詞' && + token.basic_form == '来れる' +} + module.exports = function(context) { const helper = new RuleHelper(context); let {Syntax, report, getSource, RuleError} = context; @@ -26,6 +31,14 @@ module.exports = function(context) { } let text = getSource(node); return kuromojin(text).then(tokens => { + tokens.forEach((token) => { + if (isKoreru(token)) { + report(node, new RuleError("ら抜き言葉を使用しています。", { + index: (token.word_position) + })); + }; + }); + tokens.reduce((prev, current) => { if (isTargetVerb(prev) && isRaWord(current)) { report(node, new RuleError("ら抜き言葉を使用しています。", { @@ -37,4 +50,4 @@ module.exports = function(context) { }); } } -}; \ No newline at end of file +}; diff --git a/test/no-double-joshi-test.js b/test/no-double-joshi-test.js index c3a8508..bf72d9e 100644 --- a/test/no-double-joshi-test.js +++ b/test/no-double-joshi-test.js @@ -6,7 +6,8 @@ tester.run("no-dropping-the-ra", rule, { valid: [ "お刺身を食べられない。", "見られる", - "出られる" + "出られる", + "来られる" ], invalid: [ { @@ -28,6 +29,26 @@ tester.run("no-dropping-the-ra", rule, { column: 6 } ] + }, + { + text: "来れる", + errors: [ + { + message: "ら抜き言葉を使用しています。", + line: 1, + column: 2 + } + ] + }, + { + text: "女の子が来れないんです", + errors: [ + { + message: "ら抜き言葉を使用しています。", + line: 1, + column: 6 + } + ] } ] -}); \ No newline at end of file +});