Skip to content

Commit e7319cd

Browse files
committed
feat(rule): add ないものでは〜ない
1 parent 3a0d415 commit e7319cd

File tree

4 files changed

+88
-3
lines changed

4 files changed

+88
-3
lines changed

src/no-doubled-negative-ja.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import {getTokenizer} from "kuromojin";
55
import NakumonaiRule from "./rules/なくは-ない";
66
import NidemoNaiRule from "./rules/ないでも-ない";
7+
import NimonodehaRule from "./rules/ないものでは-ない";
78
export default function (context) {
89
const {Syntax,getSource, report,RuleError} = context;
910
const ruleなくもない = NakumonaiRule(context);
1011
const ruleないでもない = NidemoNaiRule(context);
12+
const ruleないものではない = NimonodehaRule(context);
1113
return {
1214
[Syntax.Str](node){
1315
const text = getSource(node);
@@ -23,6 +25,7 @@ export default function (context) {
2325
tokens.forEach(token => {
2426
pushError(ruleなくもない(token));
2527
pushError(ruleないでもない(token));
28+
pushError(ruleないものではない(token));
2629
});
2730
}).then(()=> {
2831
results.forEach(error => {
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// LICENSE : MIT
2+
"use strict";
3+
/*
4+
(c)「~ないものでは / もない」
5+
~ない(否定助動詞 / 否定形容詞の連体形) + 形式名詞「もの」+ 判定詞「だ」の連用形「で」+ とりたて助詞「は / も」+補助形容詞「ない」
6+
*/
7+
import matchTokenStream from "./../matchTokenStream";
8+
export default function (context) {
9+
const {RuleError} = context;
10+
const matchPatternないものでもない = matchTokenStream([
11+
{
12+
"basic_form": "ない"
13+
},
14+
{
15+
"surface_form": "もの",
16+
"pos": "名詞"
17+
},
18+
{
19+
"conjugated_form": "連用形",
20+
"basic_form": "だ"
21+
},
22+
{
23+
"surface_form": "も",
24+
"pos": "助詞"
25+
},
26+
{
27+
"basic_form": "ない",
28+
"pos": "形容詞"
29+
}
30+
]);
31+
const matchPatternないものではない = matchTokenStream([
32+
{
33+
"basic_form": "ない"
34+
},
35+
{
36+
"surface_form": "もの",
37+
"pos": "名詞"
38+
},
39+
{
40+
"conjugated_form": "連用形",
41+
"basic_form": "だ"
42+
},
43+
{
44+
"surface_form": "は",
45+
"pos": "助詞"
46+
},
47+
{
48+
"basic_form": "ない",
49+
"pos": "形容詞"
50+
}
51+
]);
52+
return (token) => {
53+
if (matchPatternないものでもない(token)) {
54+
return new RuleError("二重否定: 〜ないものでもない", {
55+
column: token.word_position - 1
56+
});
57+
}
58+
if (matchPatternないものではない(token)) {
59+
return new RuleError("二重否定: 〜ないものではない", {
60+
column: token.word_position - 1
61+
});
62+
}
63+
};
64+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
も: いや、本音を言えば、それよりこちらの方が大事ではないかという思いもなくはなかった。
88
*/
99
import matchTokenStream from "./../matchTokenStream";
10-
export default function nakumonai(context) {
10+
export default function (context) {
1111
const {RuleError} = context;
1212
const monaiTokens = [
1313
{

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var tester = new TextLintTester();
44
tester.run("no-doubled-negative", rule, {
55
valid: [],
66
invalid: [
7+
// a
78
{
89
text: "だが、それが事件の発端だったといえなくもない。",
910
errors: [
@@ -40,8 +41,25 @@ tester.run("no-doubled-negative", rule, {
4041
column: 20
4142
}
4243
]
44+
},
45+
// c
46+
{
47+
text: "どんな窃視的行為に出ないものでもない。",
48+
errors: [
49+
{
50+
message: "二重否定: 〜ないものでもない",
51+
column: 17
52+
}
53+
]
54+
},
55+
{
56+
text: "これらの投与が決して避けられないものではなかったことが、不条理な無念さで患者たち、そして死者たちを眠らせない。",
57+
errors: [
58+
{
59+
message: "二重否定: 〜ないものではない",
60+
column: 21
61+
}
62+
]
4363
}
44-
45-
4664
]
4765
});

0 commit comments

Comments
 (0)