Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking Change: 文体が統一されていてもpreferIn設定に違反する場合エラーとなるように変更 #40

Merged
merged 4 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/azu/textlint-rule-no-mix-dearu-desumasu/issues"
},
"version": "5.0.0",
"version": "6.0.0",
azu marked this conversation as resolved.
Show resolved Hide resolved
"description": "textlint rule that no mixed である and ですます.",
"main": "lib/no-mix-dearu-desumasu.js",
"files": [
Expand Down
6 changes: 5 additions & 1 deletion src/MixedChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ export default class MixedChecker {
}

isOver() {
return this.dearuCount !== 0 && this.desumasuCount !== 0;
return (
(this.options.preferDesumasu && this.dearuCount !== 0) ||
(this.options.preferDearu && this.desumasuCount !== 0) ||
(this.dearuCount !== 0 && this.desumasuCount !== 0)
);
azu marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
147 changes: 147 additions & 0 deletions test/no-mix-dearu-desumasu-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ Total:
}
]
},

// 箇条書き間での混在
{
text: `
Expand Down Expand Up @@ -502,6 +503,152 @@ Total:
column: 12
}
]
},

// 混在はしていないがpreferInの設定と一致していない場合
{
text: `今日はいい天気である。
明日はいい天気である。`,
options: {
preferInBody: "ですます"
},
errors: [
// preferInで"ですます"が設定されているため、"である"に統一された文章でも、"ですます"を優先する
{
message: `本文: "である"調 と "ですます"調 が混在
=> "ですます"調 の文体に、次の "である"調 の箇所があります: "である。"
Total:
である : 2
ですます: 0
`,
line: 1,
column: 8
},
{
message: `本文: "である"調 と "ですます"調 が混在
=> "ですます"調 の文体に、次の "である"調 の箇所があります: "である。"
Total:
である : 2
ですます: 0
`,
line: 2,
column: 8
}
]
},
{
text: `今日はいい天気ですね。
明日はいい天気ですね。`,
options: {
preferInBody: "である"
},
errors: [
// preferInで"である"が設定されているため、"ですます"に統一された文章でも、"である"を優先する
{
message: `本文: "である"調 と "ですます"調 が混在
=> "である"調 の文体に、次の "ですます"調 の箇所があります: "ですね。"
Total:
である : 0
ですます: 2
`,
line: 1,
column: 8
},
{
message: `本文: "である"調 と "ですます"調 が混在
=> "である"調 の文体に、次の "ですます"調 の箇所があります: "ですね。"
Total:
である : 0
ですます: 2
`,
line: 2,
column: 8
}
]
},
{
text: `
# 今日はいい天気である
`,
options: {
preferInHeader: "ですます"
},
errors: [
// preferInで"ですます"が設定されているため、"である"に統一された文章でも、"ですます"を優先する
{
message: `見出し: "である"調 と "ですます"調 が混在
=> "ですます"調 の文体に、次の "である"調 の箇所があります: "である"
Total:
である : 1
ですます: 0
`,
line: 2,
column: 10
}
]
},
{
text: `
# 今日はいい天気になりますね
`,
options: {
preferInHeader: "である"
},
errors: [
// preferInで"である"が設定されているため、"ですます"に統一された文章でも、"である"を優先する
{
message: `見出し: "である"調 と "ですます"調 が混在
=> "である"調 の文体に、次の "ですます"調 の箇所があります: "ますね"
Total:
である : 0
ですます: 1
`,
line: 2,
column: 13
}
]
},
{
text: `
- 今日はいい天気である
`,
options: {
preferInList: "ですます"
},
errors: [
// preferInで"ですます"が設定されているため、"である"に統一された文章でも、"ですます"を優先する
{
message: `箇条書き: "である"調 と "ですます"調 が混在
=> "ですます"調 の文体に、次の "である"調 の箇所があります: "である"
Total:
である : 1
ですます: 0
`,
line: 2,
column: 10
}
]
},
{
text: `
- 今日はいい天気になりますね
`,
options: {
preferInList: "である"
},
errors: [
// preferInで"である"が設定されているため、"ですます"に統一された文章でも、"である"を優先する
{
message: `箇条書き: "である"調 と "ですます"調 が混在
=> "である"調 の文体に、次の "ですます"調 の箇所があります: "ますね"
Total:
である : 0
ですます: 1
`,
line: 2,
column: 13
}
]
}
]
});
Loading