Skip to content

Commit

Permalink
chore(Options): Add option
Browse files Browse the repository at this point in the history
- It's set to  by default
- The JSDoc documentation for it has also been added
  • Loading branch information
danielgolden committed Jul 26, 2022
1 parent 2f65236 commit 5003a00
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* Whether to ignore literal words.
* @property {boolean} [ignoreDigits=true]
* Whether to ignore “words” that contain only digits, such as `123456`.
* @property {boolean} [ignoreAnyDigits=false]
* Whether to ignore “words” that contain *any* digits, such as `2:41pm` or `A11y`.
* @property {boolean} [normalizeApostrophes=true]
* Deal with apostrophes.
* Whether to swap smart apostrophes (`’`) with straight apostrophes (`'`)
Expand All @@ -32,6 +34,7 @@
* @property {Array<string>} ignore
* @property {boolean} ignoreLiteral
* @property {boolean} ignoreDigits
* @property {boolean} ignoreAnyDigits
* @property {boolean} normalizeApostrophes
* @property {any} checker
* @property {Record<string, Array<string>>} cache
Expand Down Expand Up @@ -69,6 +72,7 @@ export default function retextSpell(options = {}) {
max,
ignoreLiteral,
ignoreDigits,
ignoreAnyDigits,
normalizeApostrophes,
personal
} = options
Expand All @@ -89,6 +93,10 @@ export default function retextSpell(options = {}) {
: ignoreLiteral,
ignoreDigits:
ignoreDigits === null || ignoreDigits === undefined ? true : ignoreDigits,
ignoreAnyDigits:
ignoreAnyDigits === null || ignoreAnyDigits === undefined
? false
: ignoreAnyDigits,
normalizeApostrophes:
normalizeApostrophes === null || normalizeApostrophes === undefined
? true
Expand Down Expand Up @@ -162,6 +170,7 @@ function all(tree, file, config) {
ignore,
ignoreLiteral,
ignoreDigits,
ignoreAnyDigits,
normalizeApostrophes,
// To do: nspell.
// type-coverage:ignore-next-line
Expand Down Expand Up @@ -286,6 +295,10 @@ function all(tree, file, config) {
* @returns {boolean}
*/
function irrelevant(word) {
return ignore.includes(word) || (ignoreDigits && /^\d+$/.test(word))
return (
ignore.includes(word) ||
(ignoreDigits && /^\d+$/.test(word)) ||
(ignoreAnyDigits && /\d/.test(word))
)
}
}

0 comments on commit 5003a00

Please sign in to comment.