textlint rule for no pair
This rule checks whether the disallowed brackets are present in the sentences.
For example, if full-width parenthesis and lenticular brackets are not allowed, the following are NG and OK:
They are coming to our house after work(around six o'clock).
【重要】これは(秘密)です。
They are coming to our house after work (around six o'clock).
[重要] これは(秘密)です。
Install with npm:
npm install textlint-rule-no-pair
.textlintrcIt’s recommended that this rule is used in .textlintrc.js.
undefinedThis rule allows all pair by default. So you need to put to disallowPairs option which pairs you do not allow.
Below is an example of using full-width parenthesis and lenticular brackets:
const { FullWidthParenthesis, LenticularBrackets } =
require('textlint-rule-no-pair').pairs
module.exports = {
rules: {
'no-pair': {
disallowPairs: [FullWidthParenthesis, LenticularBrackets]
}
}
}
If you would like to use other pairs, you can put the pairs scheme.
You must define the pair scheme, which is an object with following the properties:
name: the name of the bracketstart: the opening pair characterend: the closing pair characterthese interface is defined in here
module.exports = {
rules: {
'no-pair': {
disallowPairs: [
{
name: 'Double Angle Quotation Mark',
start: '«',
end: '»'
}
]
}
}
}
( and )[ and ]{ and }( and )[ and ]{ and }「 and 」『 and 』< and >【 and 】〖 and 〗〚 and 〛These built-in pairs is defined in here
If you would like to use these built-in pairs and custom pairs, you can use spread syntax (...) as follows:
const { defaultPairs } = require('textlint-rule-no-pair')
module.exports = {
rules: {
'no-pair': {
disallowPairs: [
{
name: 'Double Angle Quotation Mark',
start: '«',
end: '»'
},
...defaultPairs
]
}
}
}
If you are interested in contributing to textlint-rule-no-pair, I highly recommend checking out the contributing guidelines here. You’ll find all the relevant information such as how to make a PR, how to setup development) etc., there.
MIT ©️ 2024 kazupon
We use cookies
We use cookies to analyze traffic and improve your experience. You can accept or reject analytics cookies.