Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/no-dropping-the-ra.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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("ら抜き言葉を使用しています。", {
Expand All @@ -37,4 +50,4 @@ module.exports = function(context) {
});
}
}
};
};
25 changes: 23 additions & 2 deletions test/no-double-joshi-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ tester.run("no-dropping-the-ra", rule, {
valid: [
"お刺身を食べられない。",
"見られる",
"出られる"
"出られる",
"来られる"
],
invalid: [
{
Expand All @@ -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
}
]
}
]
});
});