Skip to content

Commit 4e5b502

Browse files
authored
feat: Detect 見れる as special invalid case. (#4)
BREAKING CHANGE: detect "見れる" and "来れる"
2 parents 8332d64 + d39ef17 commit 4e5b502

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/no-dropping-the-ra.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ function isRaWord(token) {
1616
return token.pos == "動詞" && token.pos_detail_1 == "接尾" && token.basic_form == "れる";
1717
}
1818

19-
function isKoreru(token) {
20-
return token.pos == "動詞" && token.basic_form == "来れる";
19+
function isSpecialCases(token) {
20+
// Due to kuromoji.js's behavior, some dropping-ra words will be tokenized as one.
21+
// See also https://github.com/takuyaa/kuromoji.js/issues/28
22+
return token.pos == "動詞" && (token.basic_form == "来れる" || token.basic_form == "見れる");
2123
}
2224

2325
module.exports = function (context) {
@@ -31,7 +33,7 @@ module.exports = function (context) {
3133
const text = getSource(node);
3234
return tokenize(text).then(tokens => {
3335
tokens.forEach(token => {
34-
if (isKoreru(token)) {
36+
if (isSpecialCases(token)) {
3537
report(
3638
node,
3739
new RuleError("ら抜き言葉を使用しています。", {

test/no-double-joshi-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ tester.run("no-dropping-the-ra", rule, {
3131
}
3232
]
3333
},
34+
{
35+
text: "この距離からでも見れる。",
36+
errors: [
37+
{
38+
message: "ら抜き言葉を使用しています。",
39+
line: 1,
40+
column: 10
41+
}
42+
]
43+
},
3444
{
3545
text: "来れる",
3646
errors: [

0 commit comments

Comments
 (0)