-
Notifications
You must be signed in to change notification settings - Fork 181
chore: Update lint:text command for incoming document #454
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
Closed
Closed
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
78f8300
chore: Update lint:text command forincoming document
no-yan d5d7844
ignore .textlintcache
no-yan 30126be
enable lint subdirectory of content/home
no-yan e636360
Revert "enable lint subdirectory of content/home"
no-yan 9555d83
copy textlint config from root
no-yan bb4ca5d
add lint-staged
no-yan 2505a28
Remove excess space
no-yan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
.idea | ||
node_modules | ||
/public | ||
yarn-error.log | ||
yarn-error.log | ||
.textlintcache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,6 @@ yarn-error.log* | |
|
||
# vercel | ||
.vercel | ||
|
||
# textlint | ||
.textlintcache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"rules": { | ||
"preset-jtf-style": { | ||
"1.1.3.箇条書き": false, | ||
"1.2.1.句点(。)と読点(、)": false, | ||
"1.2.2.ピリオド(.)とカンマ(,)": false, | ||
"3.1.1.全角文字と半角文字の間": false, | ||
"4.2.1.感嘆符(!)": false, | ||
"4.2.2.疑問符(?)": false | ||
}, | ||
"@textlint-rule/no-invalid-control-character": { | ||
"checkCode": true | ||
}, | ||
"prh": { | ||
"severity" : "warning", | ||
"rulePaths" :["./prh.yml"] | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# prh version | ||
version: 1 | ||
rules: | ||
|
||
- expected: ください | ||
pattern: 下さい | ||
prh: 補助動詞はかな書きにします | ||
|
||
- expected: てみる | ||
pattern: て見る | ||
prh: 補助動詞はかな書きにします | ||
|
||
- expected: てくる | ||
pattern: て来る | ||
prh: 補助動詞はかな書きにします | ||
|
||
- expected: てしまう | ||
pattern: /て(仕舞|終|蔵|了)う/ | ||
prh: 補助動詞はかな書きにします | ||
|
||
- expected: ついに | ||
pattern: /(遂|終)に/ | ||
prh: 語彙化した副詞はなるべくかな書きにします | ||
|
||
- expected: まれに | ||
pattern: /(希|稀)に/ | ||
prh: 語彙化した副詞はなるべくかな書きにします | ||
|
||
- expected: $1とき | ||
pattern: /(な|の)時(?!点|代|々|間|計)/ | ||
prh: 語彙化した副詞はなるべくかな書きにします | ||
specs: | ||
- from: その時 | ||
to: そのとき | ||
- from: その時点 | ||
to: その時点 | ||
- from: その時代 | ||
to: その時代 | ||
- from: それまでの時間 | ||
to: それまでの時間 | ||
- from: 同時 | ||
to: 同時 | ||
- from: 実行時 | ||
to: 実行時 | ||
- from: 利用時 | ||
to: 利用時 | ||
- from: 開発時 | ||
to: 開発時 | ||
- from: 時点 | ||
to: 時点 | ||
- from: 時代 | ||
to: 時代 | ||
- from: 時間 | ||
to: 時間 | ||
- from: 時計 | ||
to: 時計 | ||
|
||
- expected: ようやく | ||
pattern: 漸く | ||
prh: 語彙化した副詞はかな書きにします | ||
|
||
- expected: おそらく | ||
pattern: 恐らく | ||
prh: 語彙化した副詞はかな書きにします | ||
|
||
- expected: ユーザ | ||
pattern: ユーザー | ||
prh: 3音以上の語の最後の長音府は原則として省略します | ||
|
||
- expected: リスナ | ||
pattern: リスナー | ||
prh: 3音以上の語の最後の長音府は原則として省略します | ||
|
||
- expected: ハンドラ | ||
pattern: ハンドラー | ||
prh: 3音以上の語の最後の長音府は原則として省略します |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
const toString = require('mdast-util-to-string'); | ||
|
||
module.exports = context => { | ||
return { | ||
// [context.Syntax.Header]: node => {}, | ||
|
||
[context.Syntax.Paragraph]: node => { | ||
// Checks against paragraph-based rules. | ||
|
||
// Convert a paragraph to plain text, stripping any markups | ||
const text = toString(node); | ||
|
||
enforceSpaceAfterQuestionOrExclamation(node, text, context); | ||
noHanPunctSpace(node, text, context); | ||
enforceZenHanSpace(node, text, context); | ||
noLineEndSpace(node, text, context); | ||
noConflictMarker(node, text, context); | ||
}, | ||
|
||
[context.Syntax.Str]: node => { | ||
const text = toString(node); | ||
const index = text.indexOf(' '); | ||
if (index >= 0) { | ||
context.report( | ||
node, | ||
new context.RuleError( | ||
'いかなる場合も全角スペースは使用しないでください。', | ||
{index}, | ||
), | ||
); | ||
} | ||
}, | ||
}; | ||
}; | ||
|
||
const enforceSpaceAfterQuestionOrExclamation = (node, text, context) => { | ||
const markReg = /[!?](\u3000|[A-Za-z0-9]|[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]|[ぁ-んァ-ヶ])/; | ||
if (markReg.exec(text)) { | ||
context.report( | ||
node, | ||
new context.RuleError( | ||
'全角の「!」「?」と次の文の間には半角スペースを挿入してください。', | ||
), | ||
); | ||
} | ||
}; | ||
|
||
const noHanPunctSpace = (node, text, context) => { | ||
const match = /(.{0,3})[、。]( |\u3000)/.exec(text); | ||
if (match) { | ||
context.report( | ||
node, | ||
new context.RuleError( | ||
`全角の句読点の直後にスペースを入れてはいけません("${match[0]}")。`, | ||
), | ||
); | ||
} | ||
}; | ||
|
||
const enforceZenHanSpace = (node, text, context) => { | ||
const hanZen = /[A-Za-z0-9](?:[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]|[ぁ-んァ-ヶ])/; | ||
const zenHan = /(?:[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]|[ぁ-んァ-ヶ])[A-Za-z0-9]/; | ||
|
||
const hanZenMatch = hanZen.exec(text); | ||
const zenHanMatch = zenHan.exec(text); | ||
|
||
if (hanZenMatch || zenHanMatch) { | ||
const matched = hanZenMatch ? hanZenMatch[0] : zenHanMatch[0]; | ||
context.report( | ||
node, | ||
new context.RuleError( | ||
`全角文字と半角英数字とが隣接しています("${matched}")。` + | ||
`半角スペースを挿入してください。`, | ||
), | ||
); | ||
} | ||
}; | ||
|
||
const noLineEndSpace = (node, text, context) => { | ||
// This detects a line-end space *only when* the line contains Japanese characters. | ||
const reg = /(?:[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]|[ぁ-んァ-ヶ]).?(\s|\u3000)$/; | ||
|
||
if (reg.exec(text)) { | ||
context.report( | ||
node, | ||
new context.RuleError('行末にスペース文字を入れないでください。'), | ||
); | ||
} | ||
}; | ||
|
||
const noConflictMarker = (node, text, context) => { | ||
const reg = /<<<<<<< HEAD/; | ||
|
||
if (reg.exec(text)) { | ||
context.report( | ||
node, | ||
new context.RuleError( | ||
'コンフリクトマーカーが残っています。コンフリクトを解消してください。', | ||
), | ||
); | ||
} | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.