retext-repeated-words
Advanced tools
Comparing version 4.0.0 to 4.1.0
/** | ||
* A retext plugin to check for ~for~ repeated words. | ||
* A retext plugin to check for for repeated words. | ||
* | ||
@@ -9,6 +9,13 @@ * * Doesn’t warn for some words which *do* occur twice (`the best exhibition | ||
* | ||
* @type {import('unified').Plugin<[]>} | ||
* @type {import('unified').Plugin<[], Root>} | ||
*/ | ||
export default function retextRepeatedWords(): | ||
| void | ||
| import('unified').Transformer | ||
| import('unified').Transformer<import('nlcst').Root, import('nlcst').Root> | ||
export type Root = import('nlcst').Root | ||
export type SentenceContent = import('nlcst').SentenceContent | ||
export type Info = { | ||
value: string | ||
child: SentenceContent | ||
index: number | ||
} |
24
index.js
@@ -0,3 +1,8 @@ | ||
/** | ||
* @typedef {import('nlcst').Root} Root | ||
* @typedef {import('nlcst').SentenceContent} SentenceContent | ||
* @typedef {{value: string, child: SentenceContent, index: number}} Info | ||
*/ | ||
import {toString} from 'nlcst-to-string' | ||
import {convert} from 'unist-util-is' | ||
import {visit, SKIP} from 'unist-util-visit' | ||
@@ -8,5 +13,2 @@ import {pointStart, pointEnd} from 'unist-util-position' | ||
const word = convert('WordNode') | ||
const whiteSpace = convert('WhiteSpaceNode') | ||
// List of words that can legally occur twice. | ||
@@ -33,13 +35,7 @@ const list = new Set([ | ||
* | ||
* @type {import('unified').Plugin<[]>} | ||
* @type {import('unified').Plugin<[], Root>} | ||
*/ | ||
export default function retextRepeatedWords() { | ||
/** | ||
* @typedef {import('unist').Node} Node | ||
* @typedef {import('unist').Parent} Parent | ||
* @typedef {{value: string, child: Node, index: number}} Info | ||
*/ | ||
return (tree, file) => { | ||
visit(tree, 'SentenceNode', (/** @type {Parent} */ parent) => { | ||
visit(tree, 'SentenceNode', (parent) => { | ||
let index = -1 | ||
@@ -54,3 +50,3 @@ /** @type {Info|undefined} */ | ||
if (word(child)) { | ||
if (child.type === 'WordNode') { | ||
const value = toString(child) | ||
@@ -79,3 +75,3 @@ | ||
} | ||
} else if (whiteSpace(child)) { | ||
} else if (child.type === 'WhiteSpaceNode') { | ||
previous = current | ||
@@ -82,0 +78,0 @@ current = undefined |
{ | ||
"name": "retext-repeated-words", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "retext plugin to check for for repeated words", | ||
@@ -36,7 +36,7 @@ "license": "MIT", | ||
"dependencies": { | ||
"@types/nlcst": "^1.0.0", | ||
"nlcst-to-string": "^3.0.0", | ||
"unified": "^10.0.0", | ||
"unist-util-is": "^5.0.0", | ||
"unist-util-position": "^4.0.0", | ||
"unist-util-visit": "^3.0.0" | ||
"unist-util-visit": "^4.0.0" | ||
}, | ||
@@ -48,4 +48,4 @@ "devDependencies": { | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^9.0.0", | ||
"remark-preset-wooorm": "^8.0.0", | ||
"remark-cli": "^10.0.0", | ||
"remark-preset-wooorm": "^9.0.0", | ||
"retext": "^8.0.0", | ||
@@ -56,3 +56,3 @@ "rimraf": "^3.0.0", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.39.0" | ||
"xo": "^0.44.0" | ||
}, | ||
@@ -59,0 +59,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11229
120
0
+ Added@types/nlcst@^1.0.0
+ Addedunist-util-visit@4.1.2(transitive)
+ Addedunist-util-visit-parents@5.1.3(transitive)
- Removedunist-util-is@^5.0.0
- Removedunist-util-visit@3.1.0(transitive)
- Removedunist-util-visit-parents@4.1.1(transitive)
Updatedunist-util-visit@^4.0.0