textlint-rule-terminology
Advanced tools
Comparing version 5.0.20 to 5.0.21
22
index.js
@@ -15,2 +15,3 @@ // @ts-check | ||
const sentenceStartRegExp = /\w+[.?!]\)? $/; | ||
const punctuation = '[\\.,;:!?\'"’”)]'; | ||
@@ -58,3 +59,3 @@ function reporter(context, opts = {}) { | ||
// Capitalize word in the beginning of a sentense if the original word was capitalized | ||
// Capitalize word in the beginning of a sentence if the original word was capitalized | ||
const textBeforeMatch = text.substring(0, index); | ||
@@ -95,3 +96,4 @@ const isSentenceStart = | ||
const extras = typeof terms === 'string' ? loadJson(terms) : terms; | ||
// Order matters, the first term to match is used. We prioritize user 'extras' before defaults | ||
// Order matters, the first term to match is used. We prioritize user | ||
// 'extras' before defaults | ||
const listTerms = [...(Array.isArray(extras) ? extras : []), ...defaults]; | ||
@@ -139,8 +141,12 @@ | ||
function getExactMatchRegExp(pattern) { | ||
const punctuation = '[\\.,;:!?\'"’”)]'; | ||
return new RegExp( | ||
// 1. Beginning of the string, or any character that isn't "-" or alphanumeric | ||
// 2. Exact match of the pattern | ||
// 3. Space, punctuation + space, punctuation + punctuation, or punctuation at the end of the string, end of the string | ||
`(?<=^|[^-\\w])\\b${pattern}\\b(?= |${punctuation} |${punctuation}${punctuation}|${punctuation}$|$)`, | ||
// 1. Beginning of the string, or any character that isn't "-" | ||
// or alphanumeric | ||
// 2. Not a dot "." (to make it ignore file extensions) | ||
// 3. Word boundary | ||
// 4. Exact match of the pattern | ||
// 5. Word boundary | ||
// 6. Space, punctuation + space, punctuation + punctuation, | ||
// or punctuation at the end of the string, end of the string | ||
`(?<=^|[^-\\w])(?<!\\.)\\b${pattern}\\b(?= |${punctuation} |${punctuation}${punctuation}|${punctuation}$|$)`, | ||
'igm' | ||
@@ -160,3 +166,3 @@ ); | ||
* Match pattern on word boundaries in the middle of the text unless the pattern | ||
* has look behinds | ||
* has look behinds or look aheads | ||
* @param {string} pattern | ||
@@ -163,0 +169,0 @@ */ |
{ | ||
"name": "textlint-rule-terminology", | ||
"version": "5.0.20", | ||
"version": "5.0.21", | ||
"description": "TextLint rule to check correct terms spelling", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
21033
189