Skip to content

Commit 80819fc

Browse files
committed
feat(rule): "無い"にも対応
1 parent 8097322 commit 80819fc

File tree

7 files changed

+44
-23
lines changed

7 files changed

+44
-23
lines changed

src/matchTokenStream.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
function matchToken(token, expectShape) {
44
return Object.keys(expectShape).every(key => {
55
const actualValue = token[key];
6-
const expectedValue = expectShape[key];
7-
return actualValue === expectedValue;
6+
// 値は複数の場合もある
7+
const expectedValues = Array.isArray(expectShape[key]) ? expectShape[key] : [expectShape[key]];
8+
return expectedValues.some(expectedValue => {
9+
return actualValue === expectedValue;
10+
});
811
})
912
}
1013
export default function expectTokenStream(tokenStream) {

src/rules/ないことは-ない.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function (context) {
99
const {RuleError} = context;
1010
const matchPatternないことはない = matchTokenStream([
1111
{
12-
"basic_form": "ない"
12+
"basic_form": ["ない", "無い"]
1313
},
1414
{
1515
"reading": "コト",// 漢字に対応するため
@@ -20,13 +20,13 @@ export default function (context) {
2020
"pos": "助詞"
2121
},
2222
{
23-
"basic_form": "ない"
23+
"basic_form": ["ない", "無い"]
2424
//"pos": "形容詞" || "助動詞"
2525
}
2626
]);
2727
const matchPatternないこともない = matchTokenStream([
2828
{
29-
"basic_form": "ない"
29+
"basic_form": ["ない", "無い"]
3030
},
3131
{
3232
"reading": "コト",// 漢字に対応するため
@@ -37,7 +37,7 @@ export default function (context) {
3737
"pos": "助詞"
3838
},
3939
{
40-
"basic_form": "ない",
40+
"basic_form": ["ない", "無い"],
4141
"pos": "形容詞"
4242
}
4343
]);

src/rules/ないでも-ない.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function (context) {
1111

1212
const monaiTokens = [
1313
{
14-
"basic_form": "ない"
14+
"basic_form": ["ない", "無い"]
1515
},
1616
{
1717
"surface_form": "で",
@@ -23,14 +23,14 @@ export default function (context) {
2323
"pos": "助詞"
2424
},
2525
{
26-
"basic_form": "ない",
26+
"basic_form": ["ない", "無い"],
2727
"pos": "形容詞"
2828
}
2929
];
3030

3131
const nakuhaTokens = [
3232
{
33-
"basic_form": "ない"
33+
"basic_form": ["ない", "無い"]
3434
},
3535
{
3636
"surface_form": "で",
@@ -42,7 +42,7 @@ export default function (context) {
4242
"pos": "助詞"
4343
},
4444
{
45-
"basic_form": "ない",
45+
"basic_form": ["ない", "無い"],
4646
"pos": "形容詞"
4747
}
4848
];

src/rules/ないものでは-ない.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function (context) {
99
const {RuleError} = context;
1010
const matchPatternないものでもない = matchTokenStream([
1111
{
12-
"basic_form": "ない"
12+
"basic_form": ["ない", "無い"]
1313
},
1414
{
1515
"reading": "モノ",// 漢字に対応するため
@@ -24,13 +24,13 @@ export default function (context) {
2424
"pos": "助詞"
2525
},
2626
{
27-
"basic_form": "ない",
27+
"basic_form": ["ない", "無い"],
2828
"pos": "形容詞"
2929
}
3030
]);
3131
const matchPatternないものではない = matchTokenStream([
3232
{
33-
"basic_form": "ない"
33+
"basic_form": ["ない", "無い"]
3434
},
3535
{
3636
"reading": "モノ",// 漢字に対応するため
@@ -45,7 +45,7 @@ export default function (context) {
4545
"pos": "助詞"
4646
},
4747
{
48-
"basic_form": "ない",
48+
"basic_form": ["ない", "無い"],
4949
"pos": "形容詞"
5050
}
5151
]);

src/rules/ないわけでは-ない.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function (context) {
88
const {RuleError} = context;
99
const matchPatternないわけでもない = matchTokenStream([
1010
{
11-
"basic_form": "ない"
11+
"basic_form": ["ない", "無い"]
1212
},
1313
{
1414
"reading": "ワケ",// 漢字に対応するため
@@ -23,13 +23,13 @@ export default function (context) {
2323
"pos": "助詞"
2424
},
2525
{
26-
"basic_form": "ない",
26+
"basic_form": ["ない", "無い"],
2727
"pos": "形容詞"
2828
}
2929
]);
3030
const matchPatternないわけではない = matchTokenStream([
3131
{
32-
"basic_form": "ない"
32+
"basic_form": ["ない", "無い"]
3333
},
3434
{
3535
"reading": "ワケ",// 漢字に対応するため
@@ -44,7 +44,7 @@ export default function (context) {
4444
"pos": "助詞"
4545
},
4646
{
47-
"basic_form": "ない"
47+
"basic_form": ["ない", "無い"]
4848
}
4949
]);
5050
return (token) => {

src/rules/なくは-ない.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ export default function (context) {
1111
const {RuleError} = context;
1212
const matchPatternなくもない = matchTokenStream([
1313
{
14-
"basic_form": "ない"
14+
"basic_form": ["ない", "無い"]
1515
},
1616
{
1717
"surface_form": "も",
1818
"pos": "助詞"
1919
},
2020
{
21-
"basic_form": "ない",
21+
"basic_form": ["ない", "無い"],
2222
"pos": "形容詞"
2323
}
2424
]);
2525
const matchPatternなくはない = matchTokenStream([
2626
{
27-
"basic_form": "ない"
27+
"basic_form": ["ない", "無い"]
2828
},
2929
{
3030
"surface_form": "は",
3131
"pos": "助詞"
3232
},
3333
{
34-
"basic_form": "ない",
34+
"basic_form": ["ない", "無い"],
3535
"pos": "形容詞"
3636
}
3737
]);

test/no-doubled-negative-ja-test.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ tester.run("no-doubled-negative", rule, {
1414
}
1515
]
1616
},
17+
{// 漢字
18+
text: "だが、それが事件の発端だったといえ無くも無い。",
19+
errors: [
20+
{
21+
message: "二重否定: 〜なくもない",
22+
column: 21
23+
}
24+
]
25+
},
1726
{
1827
text: "いや、本音を言えば、それよりこちらの方が大事ではないかという思いもなくはなかった。",
1928
errors: [
@@ -52,6 +61,15 @@ tester.run("no-doubled-negative", rule, {
5261
}
5362
]
5463
},
64+
{// 漢字
65+
text: "どんな窃視的行為に出ないものでも無い。",
66+
errors: [
67+
{
68+
message: "二重否定: 〜ないものでもない",
69+
column: 17
70+
}
71+
]
72+
},
5573
{
5674
text: "これらの投与が決して避けられないものではなかったことが、不条理な無念さで患者たち、そして死者たちを眠らせない。",
5775
errors: [
@@ -135,7 +153,7 @@ tester.run("no-doubled-negative", rule, {
135153
}
136154
]
137155
},
138-
{
156+
{// 漢字
139157
text: "ない訳ではないですが",
140158
errors: [
141159
{

0 commit comments

Comments
 (0)